Commit 85b0bd4dde944b206433190f4a50a31ce3622778
1 parent
8df53b7e
Exists in
master
and in
29 other branches
[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 | 5 | include CmsHelper |
6 | 6 | include BlogHelper |
7 | 7 | include ApplicationHelper |
8 | + include ActionView::Helpers::UrlHelper | |
8 | 9 | |
9 | 10 | should 'show default options for article' do |
10 | 11 | CmsHelperTest.any_instance.stubs(:controller).returns(ActionController::Base.new) |
... | ... | @@ -47,14 +48,18 @@ class CmsHelperTest < ActiveSupport::TestCase |
47 | 48 | end |
48 | 49 | |
49 | 50 | should 'display spread button when profile is a person' do |
51 | + @controller = ApplicationController.new | |
52 | + @plugins.stubs(:dispatch).returns([]) | |
50 | 53 | profile = fast_create(Person) |
51 | 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 | 57 | result = display_spread_button(profile, article) |
55 | 58 | end |
56 | 59 | |
57 | 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 | 63 | env = fast_create(Environment) |
59 | 64 | env.expects(:portal_community).returns(true) |
60 | 65 | profile = fast_create(Community, :environment_id => env.id) |
... | ... | @@ -62,12 +67,14 @@ class CmsHelperTest < ActiveSupport::TestCase |
62 | 67 | |
63 | 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 | 72 | result = display_spread_button(profile, article) |
68 | 73 | end |
69 | 74 | |
70 | 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 | 78 | env = fast_create(Environment) |
72 | 79 | env.expects(:portal_community).returns(nil) |
73 | 80 | profile = fast_create(Community, :environment_id => env.id) |
... | ... | @@ -75,31 +82,37 @@ class CmsHelperTest < ActiveSupport::TestCase |
75 | 82 | |
76 | 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 | 87 | result = display_spread_button(profile, article) |
81 | 88 | end |
82 | 89 | |
83 | 90 | should 'display delete_button to folder' do |
91 | + @controller = ApplicationController.new | |
92 | + @plugins.stubs(:dispatch).returns([]) | |
84 | 93 | profile = fast_create(Profile) |
85 | 94 | name = 'My folder' |
86 | 95 | folder = fast_create(Folder, :name => name, :profile_id => profile.id) |
87 | 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 | 99 | result = display_delete_button(folder) |
91 | 100 | end |
92 | 101 | |
93 | 102 | should 'display delete_button to article' do |
103 | + @controller = ApplicationController.new | |
104 | + @plugins.stubs(:dispatch).returns([]) | |
94 | 105 | profile = fast_create(Profile) |
95 | 106 | name = 'My article' |
96 | 107 | article = fast_create(TinyMceArticle, :name => name, :profile_id => profile.id) |
97 | 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 | 111 | result = display_delete_button(article) |
101 | 112 | end |
102 | 113 | |
114 | + def link_to(text, *args); puts text; puts args.inspect; text; end | |
115 | + | |
103 | 116 | end |
104 | 117 | |
105 | 118 | module RssFeedHelper | ... | ... |