Commit 575e39eae9bacb6173f1b0090b6ae99fb8edaf20

Authored by Rodrigo Souto
1 parent b90b8b84

[macro-support-review] Fixing send_email plugin

plugins/send_email/lib/send_email_plugin.rb
... ... @@ -12,14 +12,13 @@ class SendEmailPlugin < Noosfero::Plugin
12 12 true
13 13 end
14 14  
15   - def parse_content(args)
16   - raw_content = args[:html]
  15 + def parse_content(html, source)
17 16 if context.profile
18   - raw_content.gsub(/\{sendemail\}/, "/profile/#{context.profile.identifier}/plugin/send_email/deliver")
  17 + html.gsub!(/\{sendemail\}/, "/profile/#{context.profile.identifier}/plugin/send_email/deliver")
19 18 else
20   - raw_content.gsub(/\{sendemail\}/, '/plugin/send_email/deliver')
  19 + html.gsub!(/\{sendemail\}/, '/plugin/send_email/deliver')
21 20 end
22   - args.clone.merge({:html => raw_content})
  21 + [html, source]
23 22 end
24 23  
25 24 end
... ...
plugins/send_email/test/unit/send_email_plugin_test.rb
... ... @@ -18,12 +18,12 @@ class SendEmailPluginTest < ActiveSupport::TestCase
18 18  
19 19 should 'expand macro in parse_content event' do
20 20 @plugin.context.stubs(:profile).returns(nil)
21   - assert_match /plugin\/send_email\/deliver/, @plugin.parse_content("expand this macro {sendemail}")
  21 + assert_match /plugin\/send_email\/deliver/, @plugin.parse_content("expand this macro {sendemail}", nil).first
22 22 end
23 23  
24 24 should 'expand macro in parse_content event on profile context' do
25 25 @plugin.context.stubs(:profile).returns(fast_create(Community))
26   - assert_match /profile\/#{@plugin.context.profile.identifier}\/plugin\/send_email\/deliver/, @plugin.parse_content("expand this macro {sendemail}")
  26 + assert_match /profile\/#{@plugin.context.profile.identifier}\/plugin\/send_email\/deliver/, @plugin.parse_content("expand this macro {sendemail}", nil).first
27 27 end
28 28  
29 29 end
... ...