diff --git a/app/helpers/comment_helper.rb b/app/helpers/comment_helper.rb index 9359654..c1b7f13 100644 --- a/app/helpers/comment_helper.rb +++ b/app/helpers/comment_helper.rb @@ -56,7 +56,7 @@ module CommentHelper end def link_for_edit(comment) - if comment.author && comment.author == user + if comment.can_be_updated_by?(user) {:link => expirable_comment_link(comment, :edit, _('Edit'), url_for(:profile => profile.identifier, :controller => :comment, :action => :edit, :id => comment.id),:class => 'colorbox')} end end diff --git a/test/unit/comment_helper_test.rb b/test/unit/comment_helper_test.rb index e73fe41..ddc1c54 100644 --- a/test/unit/comment_helper_test.rb +++ b/test/unit/comment_helper_test.rb @@ -105,13 +105,14 @@ class CommentHelperTest < ActiveSupport::TestCase should 'do not return link for edit comment' do comment = Comment.new + comment.stubs(:can_be_updated_by?).with(user).returns(false) link = link_for_edit(comment) - assert !link + assert_nil link end should 'return link for edit comment' do comment = Comment.new - comment.author = user + comment.stubs(:can_be_updated_by?).with(user).returns(true) link = link_for_edit(comment) assert link end -- libgit2 0.21.2