Commit 46fd248067ac1c5b754eab871c27299dfd2d8916
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branch 'AI3074-community_dashboard' of gitlab.com:participa/noosfero into …
…AI3074-community_dashboard
Showing
3 changed files
with
192 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,7 @@ |
1 | +require File.dirname(__FILE__) + '/../../../test/test_helper' | |
2 | + | |
3 | +def create_hub(name, community, user) | |
4 | + hub = CommunityHubPlugin::Hub.new(:abstract => 'abstract', :body => 'body', :name => name, :profile => community, :last_changed_by_id => user.id ) | |
5 | + hub.save! | |
6 | + hub | |
7 | +end | ... | ... |
plugins/community_hub/test/unit/community_hub_plugin/hub_test.rb
0 → 100644
... | ... | @@ -0,0 +1,136 @@ |
1 | +require File.dirname(__FILE__) + '/../../test_helper' | |
2 | + | |
3 | +class HubTest < ActiveSupport::TestCase | |
4 | + | |
5 | + def setup | |
6 | + @env = fast_create(Environment) | |
7 | + @user = create_user('testuser', :environment => @env).person | |
8 | + @comm = fast_create(Community, :environment_id => @env.id) | |
9 | + @hub = create_hub('hub', @comm, @user) | |
10 | + end | |
11 | + | |
12 | + should 'has setting twitter_enable' do | |
13 | + assert_respond_to @hub, :twitter_enabled | |
14 | + end | |
15 | + | |
16 | + should 'default value of setting twitter_enabled is false' do | |
17 | + assert_equal @hub.twitter_enabled, false | |
18 | + end | |
19 | + | |
20 | + should 'has setting twitter_hashtags' do | |
21 | + assert_respond_to @hub, :twitter_hashtags | |
22 | + end | |
23 | + | |
24 | + should 'default value of setting twitter_hashtags is blank' do | |
25 | + assert_equal @hub.twitter_hashtags, "" | |
26 | + end | |
27 | + | |
28 | + should 'has setting twitter_consumer_key' do | |
29 | + assert_respond_to @hub, :twitter_consumer_key | |
30 | + end | |
31 | + | |
32 | + should 'default value of setting twitter_consumer is blank' do | |
33 | + assert_equal @hub.twitter_consumer_key, "" | |
34 | + end | |
35 | + | |
36 | + should 'has setting twitter_consumer_secret' do | |
37 | + assert_respond_to @hub, :twitter_consumer_secret | |
38 | + end | |
39 | + | |
40 | + should 'default value of setting twitter_consumer_secret is blank' do | |
41 | + assert_equal @hub.twitter_consumer_secret, "" | |
42 | + end | |
43 | + | |
44 | + should 'has setting twitter_access_token' do | |
45 | + assert_respond_to @hub, :twitter_access_token | |
46 | + end | |
47 | + | |
48 | + should 'default value of setting twitter_access_token is blank' do | |
49 | + assert_equal @hub.twitter_access_token, "" | |
50 | + end | |
51 | + | |
52 | + should 'has setting twitter_access_token_secret' do | |
53 | + assert_respond_to @hub, :twitter_access_token_secret | |
54 | + end | |
55 | + | |
56 | + should 'default value of setting twitter_access_token_secret' do | |
57 | + assert_equal @hub.twitter_access_token_secret, "" | |
58 | + end | |
59 | + | |
60 | + should 'has setting facebook_enabled' do | |
61 | + assert_respond_to @hub, :facebook_enabled | |
62 | + end | |
63 | + | |
64 | + should 'default value of setting facebook_enabled is false' do | |
65 | + assert_equal @hub.facebook_enabled, false | |
66 | + end | |
67 | + | |
68 | + should 'has setting facebook_page_id' do | |
69 | + assert_respond_to @hub, :facebook_page_id | |
70 | + end | |
71 | + | |
72 | + should 'default value of setting facebook_page_id' do | |
73 | + assert_equal @hub.facebook_page_id, "" | |
74 | + end | |
75 | + | |
76 | + should 'has setting facebook_pooling_time' do | |
77 | + assert_respond_to @hub, :facebook_pooling_time | |
78 | + end | |
79 | + | |
80 | + should 'default value of setting facebook_pooling_time id five (5)' do | |
81 | + assert_equal @hub.facebook_pooling_time, 5 | |
82 | + end | |
83 | + | |
84 | + should 'has setting facebook_access_token' do | |
85 | + assert_respond_to @hub, :facebook_access_token | |
86 | + end | |
87 | + | |
88 | + should 'default value of setting facebook_access_token is blank' do | |
89 | + assert_equal @hub.facebook_access_token, "" | |
90 | + end | |
91 | + | |
92 | + should 'has pinned_messages' do | |
93 | + assert_respond_to @hub, :pinned_messages | |
94 | + end | |
95 | + | |
96 | + should 'default value of pinned_messags' do | |
97 | + assert_equal @hub.pinned_messages, [] | |
98 | + end | |
99 | + | |
100 | + should 'has pinned_mediations' do | |
101 | + assert_respond_to @hub, :pinned_mediations | |
102 | + end | |
103 | + | |
104 | + should 'default value of pinned_mediations' do | |
105 | + assert_equal @hub.pinned_mediations, [] | |
106 | + end | |
107 | + | |
108 | + should 'has mediators' do | |
109 | + assert_respond_to @hub, :mediators | |
110 | + end | |
111 | + | |
112 | + should 'hub creator is mediator by default' do | |
113 | + assert @hub.mediators.include?(@user.id) | |
114 | + end | |
115 | + | |
116 | + should 'describe yourself' do | |
117 | + assert CommunityHubPlugin::Hub.description | |
118 | + end | |
119 | + | |
120 | + should 'has a short descriptionf' do | |
121 | + assert CommunityHubPlugin::Hub.short_description | |
122 | + end | |
123 | + | |
124 | + should 'accept comments by default' do | |
125 | + assert @hub.accept_comments? | |
126 | + end | |
127 | + | |
128 | + should 'do not notify comments by default' do | |
129 | + assert !@hub.notify_comments | |
130 | + end | |
131 | + | |
132 | + should 'has a view page' do | |
133 | + assert @hub.view_page | |
134 | + end | |
135 | + | |
136 | +end | ... | ... |
plugins/community_hub/test/unit/community_hub_plugin_test.rb
0 → 100644
... | ... | @@ -0,0 +1,49 @@ |
1 | +require File.dirname(__FILE__) + '/../test_helper' | |
2 | + | |
3 | +class CommunityHubPluginTest < ActiveSupport::TestCase | |
4 | + | |
5 | + def setup | |
6 | + @plugin = CommunityHubPlugin.new | |
7 | + @profile = fast_create(Community) | |
8 | + @params = {} | |
9 | + @plugin.stubs(:context).returns(self) | |
10 | + end | |
11 | + | |
12 | + attr_reader :profile, :params | |
13 | + | |
14 | + should 'has name' do | |
15 | + assert CommunityHubPlugin.plugin_name | |
16 | + end | |
17 | + | |
18 | + should 'describe yourself' do | |
19 | + assert CommunityHubPlugin.plugin_description | |
20 | + end | |
21 | + | |
22 | + should 'has stylesheet' do | |
23 | + assert @plugin.stylesheet? | |
24 | + end | |
25 | + | |
26 | + should 'return Hub as a content type if profile is a community' do | |
27 | + assert_includes @plugin.content_types, CommunityHubPlugin::Hub | |
28 | + end | |
29 | + | |
30 | + should 'do not return Hub as a content type if profile is not a community' do | |
31 | + @profile = Organization.new | |
32 | + assert_not_includes @plugin.content_types, CommunityHubPlugin::Hub | |
33 | + end | |
34 | + | |
35 | + should 'do not return Hub as a content type if there is a parent' do | |
36 | + parent = fast_create(Blog, :profile_id => @profile.id) | |
37 | + @params[:parent_id] = parent.id | |
38 | + assert_not_includes @plugin.content_types, CommunityHubPlugin::Hub | |
39 | + end | |
40 | + | |
41 | + should 'return true at content_remove_new if page is a Hub' do | |
42 | + assert @plugin.content_remove_new(CommunityHubPlugin::Hub.new) | |
43 | + end | |
44 | + | |
45 | + should 'return false at content_remove_new if page is not a Hub' do | |
46 | + assert !@plugin.content_remove_new(Article.new) | |
47 | + end | |
48 | + | |
49 | +end | ... | ... |