Commit f49dbb2e6fe689f008864e6f1a0e786b98e2043d

Authored by Antonio Terceiro
1 parent 8cc8aa8e

Marking comments as ham atomically

ActionItem2306
app/models/comment.rb
... ... @@ -204,4 +204,9 @@ class Comment < ActiveRecord::Base
204 204 self.save!
205 205 end
206 206  
  207 + def ham!
  208 + self.spam = false
  209 + self.save!
  210 + end
  211 +
207 212 end
... ...
test/unit/comment_test.rb
... ... @@ -460,4 +460,11 @@ class CommentTest < ActiveSupport::TestCase
460 460 assert_equivalent [c3], Comment.spam
461 461 end
462 462  
  463 + should 'be able to mark as ham atomically' do
  464 + c1 = fast_create(Comment, :name => 'foo', :email => 'foo@example.com', :spam => true)
  465 + c1.ham!
  466 + c1.reload
  467 + assert c1.ham?
  468 + end
  469 +
463 470 end
... ...