Commit 85b0bd4dde944b206433190f4a50a31ce3622778

Authored by Rodrigo Souto
1 parent 8df53b7e

[tolerance-time] Fixing cms helper test

Showing 1 changed file with 18 additions and 5 deletions   Show diff stats
test/unit/cms_helper_test.rb
@@ -5,6 +5,7 @@ class CmsHelperTest < ActiveSupport::TestCase @@ -5,6 +5,7 @@ class CmsHelperTest < ActiveSupport::TestCase
5 include CmsHelper 5 include CmsHelper
6 include BlogHelper 6 include BlogHelper
7 include ApplicationHelper 7 include ApplicationHelper
  8 + include ActionView::Helpers::UrlHelper
8 9
9 should 'show default options for article' do 10 should 'show default options for article' do
10 CmsHelperTest.any_instance.stubs(:controller).returns(ActionController::Base.new) 11 CmsHelperTest.any_instance.stubs(:controller).returns(ActionController::Base.new)
@@ -47,14 +48,18 @@ class CmsHelperTest < ActiveSupport::TestCase @@ -47,14 +48,18 @@ class CmsHelperTest < ActiveSupport::TestCase
47 end 48 end
48 49
49 should 'display spread button when profile is a person' do 50 should 'display spread button when profile is a person' do
  51 + @controller = ApplicationController.new
  52 + @plugins.stubs(:dispatch).returns([])
50 profile = fast_create(Person) 53 profile = fast_create(Person)
51 article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id) 54 article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id)
52 - expects(:button_without_text).with(:spread, 'Spread this', :action => 'publish', :id => article.id) 55 + expects(:link_to).with('Spread this', {:action => 'publish', :id => article.id}, :class => 'button with-text icon-spread', :title => nil)
53 56
54 result = display_spread_button(profile, article) 57 result = display_spread_button(profile, article)
55 end 58 end
56 59
57 should 'display spread button when profile is a community and env has portal_community' do 60 should 'display spread button when profile is a community and env has portal_community' do
  61 + @controller = ApplicationController.new
  62 + @plugins.stubs(:dispatch).returns([])
58 env = fast_create(Environment) 63 env = fast_create(Environment)
59 env.expects(:portal_community).returns(true) 64 env.expects(:portal_community).returns(true)
60 profile = fast_create(Community, :environment_id => env.id) 65 profile = fast_create(Community, :environment_id => env.id)
@@ -62,12 +67,14 @@ class CmsHelperTest < ActiveSupport::TestCase @@ -62,12 +67,14 @@ class CmsHelperTest < ActiveSupport::TestCase
62 67
63 article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id) 68 article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id)
64 69
65 - expects(:button_without_text).with(:spread, 'Spread this', :action => 'publish_on_portal_community', :id => article.id) 70 + expects(:link_to).with('Spread this', {:action => 'publish_on_portal_community', :id => article.id}, :class => 'button with-text icon-spread', :title => nil)
66 71
67 result = display_spread_button(profile, article) 72 result = display_spread_button(profile, article)
68 end 73 end
69 74
70 should 'not display spread button when profile is a community and env has not portal_community' do 75 should 'not display spread button when profile is a community and env has not portal_community' do
  76 + @controller = ApplicationController.new
  77 + @plugins.stubs(:dispatch).returns([])
71 env = fast_create(Environment) 78 env = fast_create(Environment)
72 env.expects(:portal_community).returns(nil) 79 env.expects(:portal_community).returns(nil)
73 profile = fast_create(Community, :environment_id => env.id) 80 profile = fast_create(Community, :environment_id => env.id)
@@ -75,31 +82,37 @@ class CmsHelperTest < ActiveSupport::TestCase @@ -75,31 +82,37 @@ class CmsHelperTest < ActiveSupport::TestCase
75 82
76 article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id) 83 article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id)
77 84
78 - expects(:button_without_text).with(:spread, 'Spread this', :action => 'publish_on_portal_community', :id => article.id).never 85 + expects(:link_to).with('Spread this', {:action => 'publish_on_portal_community', :id => article.id}, :class => 'button with-text icon-spread', :title => nil).never
79 86
80 result = display_spread_button(profile, article) 87 result = display_spread_button(profile, article)
81 end 88 end
82 89
83 should 'display delete_button to folder' do 90 should 'display delete_button to folder' do
  91 + @controller = ApplicationController.new
  92 + @plugins.stubs(:dispatch).returns([])
84 profile = fast_create(Profile) 93 profile = fast_create(Profile)
85 name = 'My folder' 94 name = 'My folder'
86 folder = fast_create(Folder, :name => name, :profile_id => profile.id) 95 folder = fast_create(Folder, :name => name, :profile_id => profile.id)
87 confirm_message = "Are you sure that you want to remove the folder \"#{name}\"? Note that all the items inside it will also be removed!" 96 confirm_message = "Are you sure that you want to remove the folder \"#{name}\"? Note that all the items inside it will also be removed!"
88 - expects(:button_without_text).with(:delete, 'Delete', {:action => 'destroy', :id => folder.id}, :method => :post, :confirm => confirm_message) 97 + expects(:link_to).with('Delete', {:action => 'destroy', :id => folder.id}, :method => :post, :confirm => confirm_message, :class => 'button with-text icon-delete', :title => nil)
89 98
90 result = display_delete_button(folder) 99 result = display_delete_button(folder)
91 end 100 end
92 101
93 should 'display delete_button to article' do 102 should 'display delete_button to article' do
  103 + @controller = ApplicationController.new
  104 + @plugins.stubs(:dispatch).returns([])
94 profile = fast_create(Profile) 105 profile = fast_create(Profile)
95 name = 'My article' 106 name = 'My article'
96 article = fast_create(TinyMceArticle, :name => name, :profile_id => profile.id) 107 article = fast_create(TinyMceArticle, :name => name, :profile_id => profile.id)
97 confirm_message = "Are you sure that you want to remove the item \"#{name}\"?" 108 confirm_message = "Are you sure that you want to remove the item \"#{name}\"?"
98 - expects(:button_without_text).with(:delete, 'Delete', {:action => 'destroy', :id => article.id}, :method => :post, :confirm => confirm_message) 109 + expects(:link_to).with('Delete', {:action => 'destroy', :id => article.id}, :method => :post, :confirm => confirm_message, :class => 'button with-text icon-delete', :title => nil)
99 110
100 result = display_delete_button(article) 111 result = display_delete_button(article)
101 end 112 end
102 113
  114 + def link_to(text, *args); puts text; puts args.inspect; text; end
  115 +
103 end 116 end
104 117
105 module RssFeedHelper 118 module RssFeedHelper