proposals_discussion_plugin_test.rb
2.73 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
require File.dirname(__FILE__) + '/../test_helper'
class ProposalsDiscussionPluginTest < ActiveSupport::TestCase
def setup
@plugin = ProposalsDiscussionPlugin.new
@profile = fast_create(Community)
@params = {}
@plugin.stubs(:context).returns(self)
end
attr_reader :plugin, :profile, :params
should 'has stylesheet' do
assert @plugin.stylesheet?
end
should 'return Discussion as a content type' do
@params[:parent_id] = nil
assert_includes plugin.content_types, ProposalsDiscussionPlugin::Discussion
end
should 'do not return Discussion as a content type if it has a parent' do
parent = fast_create(Folder, :profile_id => @profile.id)
@params[:parent_id] = parent.id
assert_not_includes plugin.content_types, ProposalsDiscussionPlugin::Discussion
end
should 'return Topic as a content type if parent is a Discussion' do
parent = fast_create(ProposalsDiscussionPlugin::Discussion, :profile_id => @profile.id)
@params[:parent_id] = parent.id
assert_includes plugin.content_types, ProposalsDiscussionPlugin::Topic
end
should 'return Proposal as a content type if parent is a Topic' do
parent = fast_create(ProposalsDiscussionPlugin::Topic, :profile_id => @profile.id)
@params[:parent_id] = parent.id
assert_includes plugin.content_types, ProposalsDiscussionPlugin::Proposal
end
should 'do not return Proposal as a content type if parent is nil' do
@params[:parent_id] = nil
assert_not_includes plugin.content_types, ProposalsDiscussionPlugin::Proposal
end
should 'remove new button from content page for a discussion' do
page = fast_create(ProposalsDiscussionPlugin::Discussion, :profile_id => @profile.id)
assert plugin.content_remove_new(page)
end
should 'remove upload button from content page for a discussion' do
page = fast_create(ProposalsDiscussionPlugin::Discussion, :profile_id => @profile.id)
assert plugin.content_remove_upload(page)
end
should 'remove new button from content page for a proposal' do
page = fast_create(ProposalsDiscussionPlugin::Proposal, :profile_id => @profile.id)
assert plugin.content_remove_new(page)
end
should 'remove upload button from content page for a proposal' do
page = fast_create(ProposalsDiscussionPlugin::Proposal, :profile_id => @profile.id)
assert plugin.content_remove_upload(page)
end
should 'do not remove new button from content page for others article types' do
page = fast_create(Article, :profile_id => @profile.id)
assert !plugin.content_remove_new(page)
end
should 'do not remove upload button from content page for others article types' do
page = fast_create(Article, :profile_id => @profile.id)
assert !plugin.content_remove_upload(page)
end
end