Project

General

Profile

Defect #12744 ยป 0001-Preserve-case-of-macro-names-shown-by-macro_list.patch

Takeshi Yaegashi, 2013-01-06 19:22

View differences:

lib/redmine/wiki_formatting/macros.rb
147 147
          unless block_given?
148 148
            raise "Can not create a macro without a block!"
149 149
          end
150
          name = name.to_s.downcase.to_sym
151
          available_macros[name] = {:desc => @@desc || ''}.merge(options)
150
          name_s = name.to_s
151
          name_sym = name_s.downcase.to_sym
152
          available_macros[name_sym] = {
153
            :name => name_s,
154
            :desc => @@desc || ''
155
          }.merge(options)
152 156
          @@desc = nil
153
          Definitions.send :define_method, "macro_#{name}", &block
157
          Definitions.send :define_method, "macro_#{name_sym}", &block
154 158
        end
155 159

  
156 160
        # Sets description for the next macro to be defined
......
172 176
      macro :macro_list do |obj, args|
173 177
        out = ''.html_safe
174 178
        @@available_macros.each do |macro, options|
175
          out << content_tag('dt', content_tag('code', macro.to_s))
179
          out << content_tag('dt', content_tag('code', options[:name]))
176 180
          out << content_tag('dd', textilizable(options[:desc]))
177 181
        end
178 182
        content_tag('dl', out)
test/unit/lib/redmine/wiki_formatting/macros_test.rb
82 82
    Redmine::WikiFormatting::Macros.macro(:UpperCase) {|obj, args| "Upper"}
83 83

  
84 84
    assert_equal "<p>Upper</p>", textilizable("{{UpperCase}}")
85
    assert_match %r{<dt><code>UpperCase</code></dt><dd></dd>}, textilizable("{{macro_list}}")
85 86
  end
86 87

  
87 88
  def test_multiple_macros_on_the_same_line
    (1-1/1)