From ca5e7eb87497fb8a19781672e00bcbe5c2d0a4c7 Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Thu, 13 Feb 2014 20:29:44 -0300 Subject: [PATCH] Revert "macro: fix attributes after nokogiri change and write some tests" --- lib/noosfero/plugin/macro.rb | 4 ++-- test/unit/macro_test.rb | 37 ------------------------------------- 2 files changed, 2 insertions(+), 39 deletions(-) delete mode 100644 test/unit/macro_test.rb diff --git a/lib/noosfero/plugin/macro.rb b/lib/noosfero/plugin/macro.rb index a9a0d0d..1fdeb09 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. + macro.attributes.to_hash. select {|key, value| key[0..10] == 'data-macro-'}. - inject({}){|result, a| result.merge({a[0][11..-1] => a[1].value})}. + inject({}){|result, a| result.merge({a[0][11..-1] => a[1]})}. with_indifferent_access end diff --git a/test/unit/macro_test.rb b/test/unit/macro_test.rb deleted file mode 100644 index bc709b2..0000000 --- a/test/unit/macro_test.rb +++ /dev/null @@ -1,37 +0,0 @@ -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 = "
It works!
" - - def setup - @macro = Plugin1::Macro.new - @macro_element = Nokogiri::HTML(MACRO).css('.macro').first - end - - attr_reader :macro, :macro_element - - should 'access plugin' do - assert_equal Plugin1, Plugin1::Macro.plugin - end - - should 'parse attributes' do - attributes = macro.attributes(macro_element) - assert_equal '1', attributes['attr1'] - assert_equal '2', attributes['attr2'] - assert_equal '3', attributes['attr3'] - end - - should 'convert macro' do - assert_equal 'Testing: It works!', macro.convert(macro_element, nil) - end -end -- libgit2 0.21.2