From f49dbb2e6fe689f008864e6f1a0e786b98e2043d Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Tue, 21 Aug 2012 11:00:01 -0300 Subject: [PATCH] Marking comments as ham atomically --- app/models/comment.rb | 5 +++++ test/unit/comment_test.rb | 7 +++++++ 2 files changed, 12 insertions(+), 0 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index 92cf2e2..21ca41e 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -204,4 +204,9 @@ class Comment < ActiveRecord::Base self.save! end + def ham! + self.spam = false + self.save! + end + end diff --git a/test/unit/comment_test.rb b/test/unit/comment_test.rb index 4c6c2bb..7eb2d85 100644 --- a/test/unit/comment_test.rb +++ b/test/unit/comment_test.rb @@ -460,4 +460,11 @@ class CommentTest < ActiveSupport::TestCase assert_equivalent [c3], Comment.spam end + should 'be able to mark as ham atomically' do + c1 = fast_create(Comment, :name => 'foo', :email => 'foo@example.com', :spam => true) + c1.ham! + c1.reload + assert c1.ham? + end + end -- libgit2 0.21.2