end
def register(name, formatter, helper)
- raise ArgumentError, "format name '#{name}' is already taken" if @@formatters[name.to_sym]
- @@formatters[name.to_sym] = {:formatter => formatter, :helper => helper}
+ raise ArgumentError, "format name '#{name}' is already taken" if @@formatters[name.to_s]
+ @@formatters[name.to_s] = {:formatter => formatter, :helper => helper}
end
def formatter_for(name)
- entry = @@formatters[name.to_sym]
+ entry = @@formatters[name.to_s]
(entry && entry[:formatter]) || Redmine::WikiFormatting::NullFormatter::Formatter
end
def helper_for(name)
- entry = @@formatters[name.to_sym]
+ entry = @@formatters[name.to_s]
(entry && entry[:helper]) || Redmine::WikiFormatting::NullFormatter::Helper
end
class Redmine::WikiFormattingTest < ActiveSupport::TestCase
+ def test_textile_formatter
+ assert_equal Redmine::WikiFormatting::Textile::Formatter, Redmine::WikiFormatting.formatter_for('textile')
+ assert_equal Redmine::WikiFormatting::Textile::Helper, Redmine::WikiFormatting.helper_for('textile')
+ end
+
+ def test_null_formatter
+ assert_equal Redmine::WikiFormatting::NullFormatter::Formatter, Redmine::WikiFormatting.formatter_for('')
+ assert_equal Redmine::WikiFormatting::NullFormatter::Helper, Redmine::WikiFormatting.helper_for('')
+ end
+
def test_should_link_urls_and_email_addresses
raw = <<-DIFF
This is a sample *text* with a link: http://www.redmine.org