Commit 4955760191c2e8adc7488a0ceb2ce28b08672b63
1 parent
cff3d5b7
Exists in
master
and in
29 other branches
[comments-refactor-review] Encapsulating comment update check
Showing
2 changed files
with
24 additions
and
0 deletions
Show diff stats
app/models/comment.rb
test/unit/comment_test.rb
... | ... | @@ -670,6 +670,26 @@ class CommentTest < ActiveSupport::TestCase |
670 | 670 | assert comment.can_be_marked_as_spam_by?(user) |
671 | 671 | end |
672 | 672 | |
673 | + should 'not be able to update comment without user' do | |
674 | + comment = Comment.new | |
675 | + | |
676 | + assert !comment.can_be_updated_by?(nil) | |
677 | + end | |
678 | + | |
679 | + should 'not be able to update comment' do | |
680 | + user = Person.new | |
681 | + comment = Comment.new | |
682 | + | |
683 | + assert !comment.can_be_updated_by?(user) | |
684 | + end | |
685 | + | |
686 | + should 'be able to update comment if is the author' do | |
687 | + user = Person.new | |
688 | + comment = Comment.new(:author => user) | |
689 | + | |
690 | + assert comment.can_be_updated_by?(user) | |
691 | + end | |
692 | + | |
673 | 693 | private |
674 | 694 | |
675 | 695 | def create_comment(args = {}) | ... | ... |