From 11216f6b258a0e3980c9692eacd8ffd8dbbaa499 Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Tue, 10 May 2016 14:07:13 -0300 Subject: [PATCH] comment_paragraph: don't show button to activate comments for discussions --- plugins/comment_paragraph/lib/comment_paragraph_plugin.rb | 2 +- plugins/comment_paragraph/test/unit/comment_paragraph_plugin_test.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/comment_paragraph/lib/comment_paragraph_plugin.rb b/plugins/comment_paragraph/lib/comment_paragraph_plugin.rb index 87e24f6..def4113 100644 --- a/plugins/comment_paragraph/lib/comment_paragraph_plugin.rb +++ b/plugins/comment_paragraph/lib/comment_paragraph_plugin.rb @@ -46,7 +46,7 @@ class CommentParagraphPlugin < Noosfero::Plugin def article_extra_toolbar_buttons(article) user = context.send :user - return [] if !article.comment_paragraph_plugin_enabled? || !article.allow_edit?(user) + return [] if !article.comment_paragraph_plugin_enabled? || !article.allow_edit?(user) || article.kind_of?(CommentParagraphPlugin::Discussion) { :title => article.comment_paragraph_plugin_activated? ? _('Deactivate Comments') : _('Activate Comments'), :url => {:controller => 'comment_paragraph_plugin_myprofile', :profile => article.profile.identifier, :action => 'toggle_activation', :id => article.id}, diff --git a/plugins/comment_paragraph/test/unit/comment_paragraph_plugin_test.rb b/plugins/comment_paragraph/test/unit/comment_paragraph_plugin_test.rb index 42e1092..82a6e68 100644 --- a/plugins/comment_paragraph/test/unit/comment_paragraph_plugin_test.rb +++ b/plugins/comment_paragraph/test/unit/comment_paragraph_plugin_test.rb @@ -84,4 +84,12 @@ class CommentParagraphPluginTest < ActiveSupport::TestCase assert_equal 'Deactivate Comments', plugin.article_extra_toolbar_buttons(article)[:title] end + should 'not display button to toggle comment paragraph if article is a discussion' do + profile = fast_create(Profile) + article = fast_create(CommentParagraphPlugin::Discussion, :profile_id => profile.id) + article.expects(:comment_paragraph_plugin_enabled?).returns(true) + article.expects(:allow_edit?).with(user).returns(true) + + assert_equal [], plugin.article_extra_toolbar_buttons(article) + end end -- libgit2 0.21.2