Fixed that macros with uppercase letters can not be called (#12744).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11126 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2013-01-05 23:11:35 +00:00
parent 45c93340b7
commit 582dcf4b36
2 changed files with 8 additions and 2 deletions

View File

@ -147,10 +147,10 @@ module Redmine
unless block_given? unless block_given?
raise "Can not create a macro without a block!" raise "Can not create a macro without a block!"
end end
name = name.to_sym if name.is_a?(String) name = name.to_s.downcase.to_sym
available_macros[name] = {:desc => @@desc || ''}.merge(options) available_macros[name] = {:desc => @@desc || ''}.merge(options)
@@desc = nil @@desc = nil
Definitions.send :define_method, "macro_#{name}".downcase, &block Definitions.send :define_method, "macro_#{name}", &block
end end
# Sets description for the next macro to be defined # Sets description for the next macro to be defined

View File

@ -78,6 +78,12 @@ class Redmine::WikiFormatting::MacrosTest < ActionView::TestCase
assert_equal "<p>Baz: (arg1,arg2) (String) (line1\nline2)</p>", textilizable("{{baz(arg1, arg2)\nline1\nline2\n}}") assert_equal "<p>Baz: (arg1,arg2) (String) (line1\nline2)</p>", textilizable("{{baz(arg1, arg2)\nline1\nline2\n}}")
end end
def test_macro_name_with_upper_case
Redmine::WikiFormatting::Macros.macro(:UpperCase) {|obj, args| "Upper"}
assert_equal "<p>Upper</p>", textilizable("{{UpperCase}}")
end
def test_multiple_macros_on_the_same_line def test_multiple_macros_on_the_same_line
Redmine::WikiFormatting::Macros.macro :foo do |obj, args| Redmine::WikiFormatting::Macros.macro :foo do |obj, args|
args.any? ? "args: #{args.join(',')}" : "no args" args.any? ? "args: #{args.join(',')}" : "no args"