diff --git a/lib/noosfero/plugin/macro.rb b/lib/noosfero/plugin/macro.rb index 1fdeb09..a9a0d0d 100644 --- a/lib/noosfero/plugin/macro.rb +++ b/lib/noosfero/plugin/macro.rb @@ -33,9 +33,9 @@ class Noosfero::Plugin::Macro end def attributes(macro) - macro.attributes.to_hash. + macro.attributes. select {|key, value| key[0..10] == 'data-macro-'}. - inject({}){|result, a| result.merge({a[0][11..-1] => a[1]})}. + inject({}){|result, a| result.merge({a[0][11..-1] => a[1].value})}. with_indifferent_access end diff --git a/test/unit/macro_test.rb b/test/unit/macro_test.rb new file mode 100644 index 0000000..bc709b2 --- /dev/null +++ b/test/unit/macro_test.rb @@ -0,0 +1,37 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class MacroTest < ActiveSupport::TestCase + + class Plugin1 < Noosfero::Plugin + end + + class Plugin1::Macro < Noosfero::Plugin::Macro + def parse(params, inner_html, source) + "Testing: #{inner_html}" + end + end + + MACRO = "