Commit bf8b5fe336c99d6d4bdf4b58d35d7996a1e8c1be

Authored by Victor Costa
2 parents 2e349278 17b7902f

Merge branch 'AI3205-comment-paragraph' into stable

plugins/comment_paragraph/lib/comment_paragraph_plugin.rb
@@ -47,7 +47,7 @@ class CommentParagraphPlugin < Noosfero::Plugin @@ -47,7 +47,7 @@ class CommentParagraphPlugin < Noosfero::Plugin
47 def article_toolbar_actions(article) 47 def article_toolbar_actions(article)
48 return unless article.comment_paragraph_plugin_enabled? 48 return unless article.comment_paragraph_plugin_enabled?
49 proc do 49 proc do
50 - button :toggle_comment_paragraph, article.comment_paragraph_plugin_activated? ? _('Deactivate Comments') : _('Activate Comments'), :controller => 'comment_paragraph_plugin_myprofile', :action => 'toggle_activation', :id => article.id if article.allow_edit?(user) 50 + button :toggle_comment_paragraph, article.comment_paragraph_plugin_activated? ? _('Deactivate Comments') : _('Activate Comments'), :controller => 'comment_paragraph_plugin_myprofile', :profile => article.profile.identifier, :action => 'toggle_activation', :id => article.id if article.allow_edit?(user)
51 end 51 end
52 end 52 end
53 53
plugins/comment_paragraph/test/unit/comment_paragraph_plugin_test.rb
@@ -37,29 +37,32 @@ class CommentParagraphPluginTest < ActiveSupport::TestCase @@ -37,29 +37,32 @@ class CommentParagraphPluginTest < ActiveSupport::TestCase
37 end 37 end
38 38
39 should 'display button to toggle comment paragraph for users which can edit the article' do 39 should 'display button to toggle comment paragraph for users which can edit the article' do
40 - article = fast_create(Article) 40 + profile = fast_create(Profile)
  41 + article = fast_create(Article, :profile_id => profile.id)
41 article.expects(:comment_paragraph_plugin_enabled?).returns(true) 42 article.expects(:comment_paragraph_plugin_enabled?).returns(true)
42 article.expects(:allow_edit?).with(user).returns(true) 43 article.expects(:allow_edit?).with(user).returns(true)
43 44
44 - content = plugin.article_header_extra_contents(article) 45 + content = plugin.article_toolbar_actions(article)
45 expects(:button).once 46 expects(:button).once
46 instance_eval(&content) 47 instance_eval(&content)
47 end 48 end
48 49
49 should 'not display button to toggle comment paragraph for users which can not edit the article' do 50 should 'not display button to toggle comment paragraph for users which can not edit the article' do
50 - article = fast_create(Article) 51 + profile = fast_create(Profile)
  52 + article = fast_create(Article, :profile_id => profile.id)
51 article.expects(:comment_paragraph_plugin_enabled?).returns(true) 53 article.expects(:comment_paragraph_plugin_enabled?).returns(true)
52 article.expects(:allow_edit?).with(user).returns(false) 54 article.expects(:allow_edit?).with(user).returns(false)
53 55
54 - content = plugin.article_header_extra_contents(article) 56 + content = plugin.article_toolbar_actions(article)
55 assert_equal nil, instance_eval(&content) 57 assert_equal nil, instance_eval(&content)
56 end 58 end
57 59
58 should 'not display button to toggle comment paragraph if plugin is not enabled' do 60 should 'not display button to toggle comment paragraph if plugin is not enabled' do
59 - article = fast_create(Article) 61 + profile = fast_create(Profile)
  62 + article = fast_create(Article, :profile_id => profile.id)
60 article.expects(:comment_paragraph_plugin_enabled?).returns(false) 63 article.expects(:comment_paragraph_plugin_enabled?).returns(false)
61 64
62 - assert_equal nil, plugin.article_header_extra_contents(article) 65 + assert_equal nil, plugin.article_toolbar_actions(article)
63 end 66 end
64 67
65 end 68 end