Permalink
Browse files

If certain sections of skip_callback method are commented out then

no test was failing. Tests have been added to ensure that commenting
out the code within if loop would cause test failure.

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent d8db571 commit 67a2b5ec1bf9e34df18763490e14089733e8c774 Neeraj Singh committed with josevalim Aug 5, 2010
Showing with 27 additions and 0 deletions.
  1. +27 −0 activesupport/test/callbacks_test.rb
@@ -524,4 +524,31 @@ def test_save
assert_equal "ACTION", obj.stuff
end
end
+
+ class WriterSkipper < Person
+ attr_accessor :age
+ skip_callback :save, :before, :before_save_method, :if => lambda {self.age > 21}
+ end
+
+ class WriterCallbacksTest < Test::Unit::TestCase
+ def test_skip_writer
+ writer = WriterSkipper.new
+ writer.age = 18
+ assert_equal [], writer.history
+ writer.save
+ assert_equal [
+ [:before_save, :symbol],
+ [:before_save, :string],
+ [:before_save, :proc],
+ [:before_save, :object],
+ [:before_save, :block],
+ [:after_save, :block],
+ [:after_save, :object],
+ [:after_save, :proc],
+ [:after_save, :string],
+ [:after_save, :symbol]
+ ], writer.history
+ end
+ end
+
end

0 comments on commit 67a2b5e

Please sign in to comment.