diff --git a/app/helpers/comment_helper.rb b/app/helpers/comment_helper.rb index 440bf1c..b9a909a 100644 --- a/app/helpers/comment_helper.rb +++ b/app/helpers/comment_helper.rb @@ -34,7 +34,7 @@ module CommentHelper @plugins.dispatch(:comment_actions, comment).collect do |action| actions << (action.kind_of?(Proc) ? self.instance_eval(&action) : action) end - actions.flatten + actions.flatten.compact end def link_for_report_abuse(comment) diff --git a/test/unit/comment_helper_test.rb b/test/unit/comment_helper_test.rb index f30e089..6929572 100644 --- a/test/unit/comment_helper_test.rb +++ b/test/unit/comment_helper_test.rb @@ -29,6 +29,16 @@ class CommentHelperTest < ActiveSupport::TestCase menu = comment_actions(comment) assert !menu end + + should 'do not show menu if it has nil actions only' do + comment = Comment.new + self.stubs(:link_for_report_abuse).returns(nil) + self.stubs(:link_for_spam).returns(nil) + self.stubs(:link_for_edit).returns(nil) + self.stubs(:link_for_remove).returns(nil) + menu = comment_actions(comment) + assert !menu + end should 'include actions of plugins in menu' do comment = Comment.new -- libgit2 0.21.2