Commit 11216f6b258a0e3980c9692eacd8ffd8dbbaa499

Authored by Victor Costa
1 parent 60b07c1c

comment_paragraph: don't show button to activate comments for discussions

plugins/comment_paragraph/lib/comment_paragraph_plugin.rb
... ... @@ -46,7 +46,7 @@ class CommentParagraphPlugin < Noosfero::Plugin
46 46  
47 47 def article_extra_toolbar_buttons(article)
48 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 51 :title => article.comment_paragraph_plugin_activated? ? _('Deactivate Comments') : _('Activate Comments'),
52 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 84 assert_equal 'Deactivate Comments', plugin.article_extra_toolbar_buttons(article)[:title]
85 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 95 end
... ...