Permalink
Browse files

added ham! method

  • Loading branch information...
1 parent 8722c62 commit 61d74c3f777ccbd8975f4b544e83bc6f1dd0f9b4 rsl committed Apr 15, 2008
Showing with 14 additions and 2 deletions.
  1. +4 −0 lib/lucky_sneaks/acts_as_snook.rb
  2. +10 −2 test/acts_as_snook_interface_test.rb
@@ -81,6 +81,10 @@ def moderate?
snook_spam_status == "moderate"
end
+ def ham!
+ update_attribute self.class.fields_for_snooking[:spam_status_field], "ham"
+ end
+
private
def calculate_snook_for_body_links
link_count = snook_body.scan(/http:/).size
@@ -3,10 +3,10 @@
class ActsAsSnookInterfaceTest < Test::Unit::TestCase
def test_marks_spam_as_spam
SPAM_COMMENTS.each do |comment_attributes|
- @comment = Comment.create(comment_attributes)
+ @comment = Comment.new(comment_attributes)
+ @comment.valid?
assert_equal "spam", @comment.spam_status
end
- Comment.destroy_all
end
def test_marks_ham_as_ham
@@ -75,4 +75,12 @@ def test_does_not_save_if_snook_credits_lower_than_negative_ten
assert @comment.snook_credits < -10
assert !@comment.save
end
+
+ def test_ham_exclamation_point_updates_spam_status_to_ham
+ @comment = Comment.create!(SPAM_COMMENTS[2])
+ assert @comment.spam?
+ @comment.ham!
+ assert @comment.ham?
+ @comment.destroy
+ end
end

0 comments on commit 61d74c3

Please sign in to comment.