From 85511b3b8c1be92a4c4889de6ef9f8ed1d9cbb77 Mon Sep 17 00:00:00 2001 From: Francisco Marcelo de Araújo Lima Júnior Date: Tue, 13 May 2014 16:09:22 -0300 Subject: [PATCH] #community dashboard - add unit test --- test/test_helper.rb | 8 ++++++++ test/unit/community_hub_plugin_test.rb | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 0 deletions(-) create mode 100644 test/test_helper.rb create mode 100644 test/unit/community_hub_plugin_test.rb diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..8e64f83 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,8 @@ +require File.dirname(__FILE__) + '/../../../test/test_helper' + +def create_track(name, profile) + track = CommunityTrackPlugin::Track.new(:abstract => 'abstract', :body => 'body', :name => name, :profile => profile) + track.add_category(fast_create(Category)) + track.save! + track +end diff --git a/test/unit/community_hub_plugin_test.rb b/test/unit/community_hub_plugin_test.rb new file mode 100644 index 0000000..25d2d1f --- /dev/null +++ b/test/unit/community_hub_plugin_test.rb @@ -0,0 +1,49 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class CommunityHubPluginTest < ActiveSupport::TestCase + + def setup + @plugin = CommunityHubPlugin.new + @profile = fast_create(Community) + @params = {} + @plugin.stubs(:context).returns(self) + end + + attr_reader :profile, :params + + should 'has name' do + assert CommunityHubPlugin.plugin_name + end + + should 'describe yourself' do + assert CommunityHubPlugin.plugin_description + end + + should 'has stylesheet' do + assert @plugin.stylesheet? + end + + should 'return Hub as a content type if profile is a community' do + assert_includes @plugin.content_types, CommunityHubPlugin::Hub + end + + should 'do not return Hub as a content type if profile is not a community' do + @profile = Organization.new + assert_not_includes @plugin.content_types, CommunityHubPlugin::Hub + end + + should 'do not return Hub as a content type if there is a parent' do + parent = fast_create(Blog, :profile_id => @profile.id) + @params[:parent_id] = parent.id + assert_not_includes @plugin.content_types, CommunityHubPlugin::Hub + end + + should 'return true at content_remove_new if page is a Hub' do + assert @plugin.content_remove_new(CommunityHubPlugin::Hub.new) + end + + should 'return false at content_remove_new if page is not a Hub' do + assert !@plugin.content_remove_new(Article.new) + end + +end -- libgit2 0.21.2