diff --git a/test/unit/cms_helper_test.rb b/test/unit/cms_helper_test.rb index 0a19498..016c331 100644 --- a/test/unit/cms_helper_test.rb +++ b/test/unit/cms_helper_test.rb @@ -5,6 +5,7 @@ class CmsHelperTest < ActiveSupport::TestCase include CmsHelper include BlogHelper include ApplicationHelper + include ActionView::Helpers::UrlHelper should 'show default options for article' do CmsHelperTest.any_instance.stubs(:controller).returns(ActionController::Base.new) @@ -47,14 +48,18 @@ class CmsHelperTest < ActiveSupport::TestCase end should 'display spread button when profile is a person' do + @controller = ApplicationController.new + @plugins.stubs(:dispatch).returns([]) profile = fast_create(Person) article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id) - expects(:button_without_text).with(:spread, 'Spread this', :action => 'publish', :id => article.id) + expects(:link_to).with('Spread this', {:action => 'publish', :id => article.id}, :class => 'button with-text icon-spread', :title => nil) result = display_spread_button(profile, article) end should 'display spread button when profile is a community and env has portal_community' do + @controller = ApplicationController.new + @plugins.stubs(:dispatch).returns([]) env = fast_create(Environment) env.expects(:portal_community).returns(true) profile = fast_create(Community, :environment_id => env.id) @@ -62,12 +67,14 @@ class CmsHelperTest < ActiveSupport::TestCase article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id) - expects(:button_without_text).with(:spread, 'Spread this', :action => 'publish_on_portal_community', :id => article.id) + expects(:link_to).with('Spread this', {:action => 'publish_on_portal_community', :id => article.id}, :class => 'button with-text icon-spread', :title => nil) result = display_spread_button(profile, article) end should 'not display spread button when profile is a community and env has not portal_community' do + @controller = ApplicationController.new + @plugins.stubs(:dispatch).returns([]) env = fast_create(Environment) env.expects(:portal_community).returns(nil) profile = fast_create(Community, :environment_id => env.id) @@ -75,31 +82,37 @@ class CmsHelperTest < ActiveSupport::TestCase article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id) - expects(:button_without_text).with(:spread, 'Spread this', :action => 'publish_on_portal_community', :id => article.id).never + expects(:link_to).with('Spread this', {:action => 'publish_on_portal_community', :id => article.id}, :class => 'button with-text icon-spread', :title => nil).never result = display_spread_button(profile, article) end should 'display delete_button to folder' do + @controller = ApplicationController.new + @plugins.stubs(:dispatch).returns([]) profile = fast_create(Profile) name = 'My folder' folder = fast_create(Folder, :name => name, :profile_id => profile.id) confirm_message = "Are you sure that you want to remove the folder \"#{name}\"? Note that all the items inside it will also be removed!" - expects(:button_without_text).with(:delete, 'Delete', {:action => 'destroy', :id => folder.id}, :method => :post, :confirm => confirm_message) + expects(:link_to).with('Delete', {:action => 'destroy', :id => folder.id}, :method => :post, :confirm => confirm_message, :class => 'button with-text icon-delete', :title => nil) result = display_delete_button(folder) end should 'display delete_button to article' do + @controller = ApplicationController.new + @plugins.stubs(:dispatch).returns([]) profile = fast_create(Profile) name = 'My article' article = fast_create(TinyMceArticle, :name => name, :profile_id => profile.id) confirm_message = "Are you sure that you want to remove the item \"#{name}\"?" - expects(:button_without_text).with(:delete, 'Delete', {:action => 'destroy', :id => article.id}, :method => :post, :confirm => confirm_message) + expects(:link_to).with('Delete', {:action => 'destroy', :id => article.id}, :method => :post, :confirm => confirm_message, :class => 'button with-text icon-delete', :title => nil) result = display_delete_button(article) end + def link_to(text, *args); puts text; puts args.inspect; text; end + end module RssFeedHelper -- libgit2 0.21.2