Fixed: Deselecting textile text formatting causes interning empty string errors (#4867).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3446 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2010-02-17 20:47:50 +00:00
parent 74e85953f0
commit 0fcc436f22
2 changed files with 14 additions and 4 deletions

View File

@ -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

View File

@ -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