Commit fdaee4f48def6a61aacb5e74b5c72981d65bb4cd
1 parent
dbd6c201
Exists in
master
and in
28 other branches
do not show comment actions menu if it has no items
Showing
2 changed files
with
11 additions
and
1 deletions
Show diff stats
app/helpers/comment_helper.rb
... | ... | @@ -34,7 +34,7 @@ module CommentHelper |
34 | 34 | @plugins.dispatch(:comment_actions, comment).collect do |action| |
35 | 35 | actions << (action.kind_of?(Proc) ? self.instance_eval(&action) : action) |
36 | 36 | end |
37 | - actions.flatten | |
37 | + actions.flatten.compact | |
38 | 38 | end |
39 | 39 | |
40 | 40 | def link_for_report_abuse(comment) | ... | ... |
test/unit/comment_helper_test.rb
... | ... | @@ -29,6 +29,16 @@ class CommentHelperTest < ActiveSupport::TestCase |
29 | 29 | menu = comment_actions(comment) |
30 | 30 | assert !menu |
31 | 31 | end |
32 | + | |
33 | + should 'do not show menu if it has nil actions only' do | |
34 | + comment = Comment.new | |
35 | + self.stubs(:link_for_report_abuse).returns(nil) | |
36 | + self.stubs(:link_for_spam).returns(nil) | |
37 | + self.stubs(:link_for_edit).returns(nil) | |
38 | + self.stubs(:link_for_remove).returns(nil) | |
39 | + menu = comment_actions(comment) | |
40 | + assert !menu | |
41 | + end | |
32 | 42 | |
33 | 43 | should 'include actions of plugins in menu' do |
34 | 44 | comment = Comment.new | ... | ... |