send_email_plugin_test.rb
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require File.dirname(__FILE__) + '/../../../../test/test_helper'
class SendEmailPluginTest < ActiveSupport::TestCase
def setup
@plugin = SendEmailPlugin.new
@context = mock()
@plugin.context = @context
end
should 'return true to stylesheet?' do
assert @plugin.stylesheet?
end
should 'have admin controller' do
assert SendEmailPlugin.has_admin_url?
end
should 'expand macro in parse_content event' do
@plugin.context.stubs(:profile).returns(nil)
assert_match /plugin\/send_email\/deliver/, @plugin.parse_content("expand this macro {sendemail}", nil).first
end
should 'expand macro in parse_content event on profile context' do
@plugin.context.stubs(:profile).returns(fast_create(Community))
assert_match /profile\/#{@plugin.context.profile.identifier}\/plugin\/send_email\/deliver/, @plugin.parse_content("expand this macro {sendemail}", nil).first
end
should 'expand macro used on form on profile context' do
profile = fast_create(Community)
@plugin.context.stubs(:profile).returns(profile)
article = RawHTMLArticle.create!(:name => 'Raw HTML', :body => "<form action='{sendemail}'></form>", :profile => profile)
assert_match /profile\/#{profile.identifier}\/plugin\/send_email\/deliver/, @plugin.parse_content(article.to_html, nil).first
end
end