email_article_plugin_test.rb
3.58 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
require_relative '../test_helper'
class EmailArticlePluginTest < ActiveSupport::TestCase
def setup
@environment = Environment.default
@user = create_user('testuser').person
@profile = fast_create(Organization)
context = mock()
context.stubs(:current_person).returns(@user)
context.stubs(:profile).returns(@profile)
@plugin = EmailArticlePlugin.new(context)
end
attr_accessor :plugin, :profile, :user, :environment
should 'be a noosfero plugin' do
assert_kind_of Noosfero::Plugin, @plugin
end
should 'have name' do
assert_equal 'Email Article to Community Members Plugin', EmailArticlePlugin.plugin_name
end
should 'have description' do
assert_equal _("A plugin that emails an article to the members of the community"), EmailArticlePlugin.plugin_description
end
should 'display button to send email for all members of a community if the user is a community admin' do
profile.add_admin(user)
article = fast_create(TextArticle, :profile_id => profile.id)
assert_not_equal [], plugin.article_extra_toolbar_buttons(article)
end
should 'display button to send email for all members of a community if the user is an environment administrator' do
environment.add_admin(user)
article = fast_create(TextArticle, :profile_id => profile.id)
assert_not_equal [], plugin.article_extra_toolbar_buttons(article)
end
should 'the title be Send article to members' do
profile.add_admin(user)
article = fast_create(TextArticle, :profile_id => profile.id)
assert_equal 'Send article to members', plugin.article_extra_toolbar_buttons(article)[:title]
end
should 'the icon be icon-menu-mail' do
profile.add_admin(user)
article = fast_create(TextArticle, :profile_id => profile.id)
assert_equal 'icon-menu-mail', plugin.article_extra_toolbar_buttons(article)[:icon]
end
should 'not display button to send email for members if the user is not a community admin' do
article = fast_create(TextArticle, :profile_id => profile.id)
assert_equal [], plugin.article_extra_toolbar_buttons(article)
end
should 'not display button to send email for members if the article is a Blog' do
profile.add_admin(user)
article = fast_create(Blog, :profile_id => profile.id)
assert_equal [], plugin.article_extra_toolbar_buttons(article)
end
should 'not display button to send email for members if the article is a Folder' do
profile.add_admin(user)
article = fast_create(Folder, :profile_id => profile.id)
assert_equal [], plugin.article_extra_toolbar_buttons(article)
end
should 'not display button to send email for members if the article is a UploadedFile' do
profile.add_admin(user)
article = fast_create(UploadedFile, :profile_id => profile.id)
assert_equal [], plugin.article_extra_toolbar_buttons(article)
end
should 'display button to send email for members if the article is a TextArticle' do
profile.add_admin(user)
article = fast_create(TextArticle, :profile_id => profile.id)
assert_not_equal [], plugin.article_extra_toolbar_buttons(article)
end
should 'display button to send email for members if the article is a TextileArticle' do
profile.add_admin(user)
article = fast_create(TextileArticle, :profile_id => profile.id)
assert_not_equal [], plugin.article_extra_toolbar_buttons(article)
end
should 'display button to send email for members if the article is a TinyMceArticle' do
profile.add_admin(user)
article = fast_create(TinyMceArticle, :profile_id => profile.id)
assert_not_equal [], plugin.article_extra_toolbar_buttons(article)
end
end