Skip to content
Browse files

changed snook calculation to only on create

  • Loading branch information...
1 parent f37f6d8 commit be95ec98ca27bf085ab6339c9c286601f3b0133c rsl committed
Showing with 13 additions and 1 deletion.
  1. +1 −1 lib/lucky_sneaks/acts_as_snook.rb
  2. +12 −0 test/acts_as_snook_interface_test.rb
View
2 lib/lucky_sneaks/acts_as_snook.rb
@@ -39,7 +39,7 @@ def acts_as_snook(options = {})
:spam_status_field => :spam_status
}.merge(options)
- before_validation :calculate_snook_score
+ before_validation_on_create :calculate_snook_score
attr_reader :snook_credits
attr_protected fields_for_snooking[:spam_status_field]
View
12 test/acts_as_snook_interface_test.rb
@@ -68,4 +68,16 @@ def test_cannot_mass_assign_spam_status
@comment = bad_comment(:spam_status => "ham")
assert_not_equal "ham", @comment.spam_status
end
+
+ def test_resaving_comment_with_changed_status_does_not_mark_as_spam
+ @comment = bad_comment
+ @comment.save!
+
+ @comment.update_attribute(:spam_status, "ham")
+ assert @comment.ham?
+ @comment.save
+ assert @comment.ham?
+
+ @comment.destroy
+ end
end

0 comments on commit be95ec9

Please sign in to comment.
Something went wrong with that request. Please try again.