diff --git a/app/models/comment.rb b/app/models/comment.rb index de6991b..92cf2e2 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -11,6 +11,7 @@ class Comment < ActiveRecord::Base belongs_to :reply_of, :class_name => 'Comment', :foreign_key => 'reply_of_id' named_scope :without_spam, :conditions => ['spam IS NULL OR spam = ?', false] + named_scope :spam, :conditions => ['spam = ?', true] # unauthenticated authors: validates_presence_of :name, :if => (lambda { |record| !record.email.blank? }) diff --git a/test/unit/comment_test.rb b/test/unit/comment_test.rb index 77036e5..4c6c2bb 100644 --- a/test/unit/comment_test.rb +++ b/test/unit/comment_test.rb @@ -452,4 +452,12 @@ class CommentTest < ActiveSupport::TestCase assert c1.spam? end + should 'be able to select spammy comments' do + c1 = fast_create(Comment) + c2 = fast_create(Comment, :spam => false) + c3 = fast_create(Comment, :spam => true) + + assert_equivalent [c3], Comment.spam + end + end -- libgit2 0.21.2