Commit f862eb4fdf58a8a84404b7a05fb4d06a2ae554f9
1 parent
5b423b02
Exists in
master
and in
27 other branches
publish-button: refactor display logic and remove useless tests
Showing
5 changed files
with
5 additions
and
36 deletions
Show diff stats
app/helpers/application_helper.rb
... | ... | @@ -1306,7 +1306,7 @@ module ApplicationHelper |
1306 | 1306 | end |
1307 | 1307 | |
1308 | 1308 | def content_remove_spread(content) |
1309 | - not (profile != user || user.communities.present? || @portal_enabled) | |
1309 | + !content.public? || content.folder? || (profile == user && user.communities.blank? && !environment.portal_enabled) | |
1310 | 1310 | end |
1311 | 1311 | |
1312 | 1312 | def remove_content_button(action) | ... | ... |
app/helpers/cms_helper.rb
... | ... | @@ -41,9 +41,7 @@ module CmsHelper |
41 | 41 | end |
42 | 42 | |
43 | 43 | def display_spread_button(article) |
44 | - if article.public? | |
45 | - expirable_button article, :spread, _('Spread this'), {:action => 'publish', :id => article.id}, {:class => 'colorbox'} | |
46 | - end | |
44 | + expirable_button article, :spread, _('Spread this'), {:action => 'publish', :id => article.id}, {:class => 'colorbox'} | |
47 | 45 | end |
48 | 46 | |
49 | 47 | def display_delete_button(article) | ... | ... |
app/views/content_viewer/_article_toolbar.html.erb
... | ... | @@ -15,7 +15,7 @@ |
15 | 15 | <%= expirable_button @page, :delete, content, url, options %> |
16 | 16 | <% end %> |
17 | 17 | |
18 | - <% if !@page.folder? && @page.allow_spread?(user) && !remove_content_button(:spread) %> | |
18 | + <% if @page.allow_spread?(user) && !remove_content_button(:spread) %> | |
19 | 19 | <% url = profile.admin_url.merge({ :controller => 'cms', :action => 'publish', :id => @page.id }) %> |
20 | 20 | <%= expirable_button @page, :spread, content_tag( 'span', _('Spread this') ), url, {:class => 'colorbox'} if url %> |
21 | 21 | <% end %> | ... | ... |
test/functional/content_viewer_controller_test.rb
... | ... | @@ -319,26 +319,6 @@ class ContentViewerControllerTest < ActionController::TestCase |
319 | 319 | assert_tag :content => /list my comment/ |
320 | 320 | end |
321 | 321 | |
322 | - should 'show link to publication on view' do | |
323 | - page = profile.articles.create!(:name => 'myarticle', :body => 'the body of the text') | |
324 | - login_as(profile.identifier) | |
325 | - | |
326 | - xhr :get, :view_page, :profile => profile.identifier, :page => ['myarticle'], :toolbar => true | |
327 | - | |
328 | - assert_tag :tag => 'a', :attributes => {:href => ('/myprofile/' + profile.identifier + '/cms/publish/' + page.id.to_s)} | |
329 | - end | |
330 | - | |
331 | - should 'not show link to publication on view if not on person profile' do | |
332 | - prof = Community.create!(:name => 'test comm', :identifier => 'test_comm') | |
333 | - page = prof.articles.create!(:name => 'myarticle', :body => 'the body of the text') | |
334 | - prof.affiliate(profile, Profile::Roles.all_roles(prof.environment.id)) | |
335 | - login_as(profile.identifier) | |
336 | - | |
337 | - xhr :get, :view_page, :profile => prof.identifier, :page => ['myarticle'], :toolbar => true | |
338 | - | |
339 | - assert_no_tag :tag => 'a', :attributes => {:href => ('/myprofile/' + prof.identifier + '/cms/publish/' + page.id.to_s)} | |
340 | - end | |
341 | - | |
342 | 322 | should 'redirect to new article path under an old path' do |
343 | 323 | p = create_user('test_user').person |
344 | 324 | a = p.articles.create(:name => 'old-name') | ... | ... |
test/unit/cms_helper_test.rb
... | ... | @@ -48,20 +48,11 @@ class CmsHelperTest < ActionView::TestCase |
48 | 48 | result = link_to_article(file) |
49 | 49 | end |
50 | 50 | |
51 | - should 'display spread button when content is public' do | |
51 | + should 'display spread button' do | |
52 | 52 | plugins.stubs(:dispatch).returns([]) |
53 | 53 | profile = fast_create(Person) |
54 | 54 | article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id) |
55 | - expects(:link_to).with('Spread this', {:action => 'publish', :id => article.id}, :class => 'button with-text icon-spread', :title => nil) | |
56 | - | |
57 | - result = display_spread_button(article) | |
58 | - end | |
59 | - | |
60 | - should 'not display spread button when content is not public' do | |
61 | - plugins.stubs(:dispatch).returns([]) | |
62 | - profile = fast_create(Person) | |
63 | - article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id, :published => false) | |
64 | - expects(:link_to).with('Spread this', {:action => 'publish', :id => article.id}, :class => 'button with-text icon-spread', :title => nil).never | |
55 | + expects(:link_to).with('Spread this', {:action => 'publish', :id => article.id}, :class => 'button with-text icon-spread colorbox', :title => nil) | |
65 | 56 | |
66 | 57 | result = display_spread_button(article) |
67 | 58 | end | ... | ... |