Commit bf8b5fe336c99d6d4bdf4b58d35d7996a1e8c1be
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branch 'AI3205-comment-paragraph' into stable
Showing
2 changed files
with
10 additions
and
7 deletions
Show diff stats
plugins/comment_paragraph/lib/comment_paragraph_plugin.rb
| ... | ... | @@ -47,7 +47,7 @@ class CommentParagraphPlugin < Noosfero::Plugin |
| 47 | 47 | def article_toolbar_actions(article) |
| 48 | 48 | return unless article.comment_paragraph_plugin_enabled? |
| 49 | 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 | 51 | end |
| 52 | 52 | end |
| 53 | 53 | ... | ... |
plugins/comment_paragraph/test/unit/comment_paragraph_plugin_test.rb
| ... | ... | @@ -37,29 +37,32 @@ class CommentParagraphPluginTest < ActiveSupport::TestCase |
| 37 | 37 | end |
| 38 | 38 | |
| 39 | 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 | 42 | article.expects(:comment_paragraph_plugin_enabled?).returns(true) |
| 42 | 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 | 46 | expects(:button).once |
| 46 | 47 | instance_eval(&content) |
| 47 | 48 | end |
| 48 | 49 | |
| 49 | 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 | 53 | article.expects(:comment_paragraph_plugin_enabled?).returns(true) |
| 52 | 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 | 57 | assert_equal nil, instance_eval(&content) |
| 56 | 58 | end |
| 57 | 59 | |
| 58 | 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 | 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 | 66 | end |
| 64 | 67 | |
| 65 | 68 | end | ... | ... |