diff --git a/plugins/community_hub/test/test_helper.rb b/plugins/community_hub/test/test_helper.rb new file mode 100644 index 0000000..8e64f83 --- /dev/null +++ b/plugins/community_hub/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/plugins/community_hub/test/unit/community_hub_plugin_test.rb b/plugins/community_hub/test/unit/community_hub_plugin_test.rb new file mode 100644 index 0000000..25d2d1f --- /dev/null +++ b/plugins/community_hub/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