Commit ca5e7eb87497fb8a19781672e00bcbe5c2d0a4c7

Authored by Rodrigo Souto
1 parent adc4f4fd

Revert "macro: fix attributes after nokogiri change and write some tests"

This reverts commit 25018e09d903cb9a6cb064ea447888fe2e1c1d39.

Reverting substitution of hpricot for nokogiri on macros infra due to
segfault problem with nokogiri 1.4.0.
lib/noosfero/plugin/macro.rb
... ... @@ -33,9 +33,9 @@ class Noosfero::Plugin::Macro
33 33 end
34 34  
35 35 def attributes(macro)
36   - macro.attributes.
  36 + macro.attributes.to_hash.
37 37 select {|key, value| key[0..10] == 'data-macro-'}.
38   - inject({}){|result, a| result.merge({a[0][11..-1] => a[1].value})}.
  38 + inject({}){|result, a| result.merge({a[0][11..-1] => a[1]})}.
39 39 with_indifferent_access
40 40 end
41 41  
... ...
test/unit/macro_test.rb
... ... @@ -1,37 +0,0 @@
1   -require File.dirname(__FILE__) + '/../test_helper'
2   -
3   -class MacroTest < ActiveSupport::TestCase
4   -
5   - class Plugin1 < Noosfero::Plugin
6   - end
7   -
8   - class Plugin1::Macro < Noosfero::Plugin::Macro
9   - def parse(params, inner_html, source)
10   - "Testing: #{inner_html}"
11   - end
12   - end
13   -
14   - MACRO = "<div class='macro nonEdit' data-macro='#{Plugin1::Macro.identifier}' data-macro-attr1='1' data-macro-attr2='2' data-macro-attr3='3'>It works!</div>"
15   -
16   - def setup
17   - @macro = Plugin1::Macro.new
18   - @macro_element = Nokogiri::HTML(MACRO).css('.macro').first
19   - end
20   -
21   - attr_reader :macro, :macro_element
22   -
23   - should 'access plugin' do
24   - assert_equal Plugin1, Plugin1::Macro.plugin
25   - end
26   -
27   - should 'parse attributes' do
28   - attributes = macro.attributes(macro_element)
29   - assert_equal '1', attributes['attr1']
30   - assert_equal '2', attributes['attr2']
31   - assert_equal '3', attributes['attr3']
32   - end
33   -
34   - should 'convert macro' do
35   - assert_equal 'Testing: It works!', macro.convert(macro_element, nil)
36   - end
37   -end