diff --git a/lib/redmine/wiki_formatting.rb b/lib/redmine/wiki_formatting.rb index c62a3ef01..dcce0fc44 100644 --- a/lib/redmine/wiki_formatting.rb +++ b/lib/redmine/wiki_formatting.rb @@ -25,17 +25,17 @@ module Redmine 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 diff --git a/test/unit/lib/redmine/wiki_formatting.rb b/test/unit/lib/redmine/wiki_formatting.rb index f52c84e0e..deedebae1 100644 --- a/test/unit/lib/redmine/wiki_formatting.rb +++ b/test/unit/lib/redmine/wiki_formatting.rb @@ -19,6 +19,16 @@ require File.dirname(__FILE__) + '/../../../test_helper' 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