Commit 32ae69114be93891a6ced653a05d157c4079611c
1 parent
24eb6750
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
#community dashboard - add unit test
Showing
2 changed files
with
57 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,8 @@ | @@ -0,0 +1,8 @@ | ||
1 | +require File.dirname(__FILE__) + '/../../../test/test_helper' | ||
2 | + | ||
3 | +def create_track(name, profile) | ||
4 | + track = CommunityTrackPlugin::Track.new(:abstract => 'abstract', :body => 'body', :name => name, :profile => profile) | ||
5 | + track.add_category(fast_create(Category)) | ||
6 | + track.save! | ||
7 | + track | ||
8 | +end |
plugins/community_hub/test/unit/community_hub_plugin_test.rb
0 → 100644
@@ -0,0 +1,49 @@ | @@ -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 |