Commit 11216f6b258a0e3980c9692eacd8ffd8dbbaa499
1 parent
60b07c1c
Exists in
ratings_minor_fixes
and in
4 other branches
comment_paragraph: don't show button to activate comments for discussions
Showing
2 changed files
with
9 additions
and
1 deletions
Show diff stats
plugins/comment_paragraph/lib/comment_paragraph_plugin.rb
| @@ -46,7 +46,7 @@ class CommentParagraphPlugin < Noosfero::Plugin | @@ -46,7 +46,7 @@ class CommentParagraphPlugin < Noosfero::Plugin | ||
| 46 | 46 | ||
| 47 | def article_extra_toolbar_buttons(article) | 47 | def article_extra_toolbar_buttons(article) |
| 48 | user = context.send :user | 48 | user = context.send :user |
| 49 | - return [] if !article.comment_paragraph_plugin_enabled? || !article.allow_edit?(user) | 49 | + return [] if !article.comment_paragraph_plugin_enabled? || !article.allow_edit?(user) || article.kind_of?(CommentParagraphPlugin::Discussion) |
| 50 | { | 50 | { |
| 51 | :title => article.comment_paragraph_plugin_activated? ? _('Deactivate Comments') : _('Activate Comments'), | 51 | :title => article.comment_paragraph_plugin_activated? ? _('Deactivate Comments') : _('Activate Comments'), |
| 52 | :url => {:controller => 'comment_paragraph_plugin_myprofile', :profile => article.profile.identifier, :action => 'toggle_activation', :id => article.id}, | 52 | :url => {:controller => 'comment_paragraph_plugin_myprofile', :profile => article.profile.identifier, :action => 'toggle_activation', :id => article.id}, |
plugins/comment_paragraph/test/unit/comment_paragraph_plugin_test.rb
| @@ -84,4 +84,12 @@ class CommentParagraphPluginTest < ActiveSupport::TestCase | @@ -84,4 +84,12 @@ class CommentParagraphPluginTest < ActiveSupport::TestCase | ||
| 84 | assert_equal 'Deactivate Comments', plugin.article_extra_toolbar_buttons(article)[:title] | 84 | assert_equal 'Deactivate Comments', plugin.article_extra_toolbar_buttons(article)[:title] |
| 85 | end | 85 | end |
| 86 | 86 | ||
| 87 | + should 'not display button to toggle comment paragraph if article is a discussion' do | ||
| 88 | + profile = fast_create(Profile) | ||
| 89 | + article = fast_create(CommentParagraphPlugin::Discussion, :profile_id => profile.id) | ||
| 90 | + article.expects(:comment_paragraph_plugin_enabled?).returns(true) | ||
| 91 | + article.expects(:allow_edit?).with(user).returns(true) | ||
| 92 | + | ||
| 93 | + assert_equal [], plugin.article_extra_toolbar_buttons(article) | ||
| 94 | + end | ||
| 87 | end | 95 | end |