diff --git a/lib/redmine/wiki_formatting/macros.rb b/lib/redmine/wiki_formatting/macros.rb index 64b7814b9..5bafd269b 100644 --- a/lib/redmine/wiki_formatting/macros.rb +++ b/lib/redmine/wiki_formatting/macros.rb @@ -147,10 +147,10 @@ module Redmine unless block_given? raise "Can not create a macro without a block!" end - name = name.to_sym if name.is_a?(String) + name = name.to_s.downcase.to_sym available_macros[name] = {:desc => @@desc || ''}.merge(options) @@desc = nil - Definitions.send :define_method, "macro_#{name}".downcase, &block + Definitions.send :define_method, "macro_#{name}", &block end # Sets description for the next macro to be defined diff --git a/test/unit/lib/redmine/wiki_formatting/macros_test.rb b/test/unit/lib/redmine/wiki_formatting/macros_test.rb index cd3ac7a48..d014aa5e6 100644 --- a/test/unit/lib/redmine/wiki_formatting/macros_test.rb +++ b/test/unit/lib/redmine/wiki_formatting/macros_test.rb @@ -78,6 +78,12 @@ class Redmine::WikiFormatting::MacrosTest < ActionView::TestCase assert_equal "
Baz: (arg1,arg2) (String) (line1\nline2)
", textilizable("{{baz(arg1, arg2)\nline1\nline2\n}}") end + def test_macro_name_with_upper_case + Redmine::WikiFormatting::Macros.macro(:UpperCase) {|obj, args| "Upper"} + + assert_equal "Upper
", textilizable("{{UpperCase}}") + end + def test_multiple_macros_on_the_same_line Redmine::WikiFormatting::Macros.macro :foo do |obj, args| args.any? ? "args: #{args.join(',')}" : "no args"