aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2010-08-05 18:09:23 -0400
committerJosé Valim <jose.valim@gmail.com>2010-08-31 17:45:06 +0200
commit67a2b5ec1bf9e34df18763490e14089733e8c774 (patch)
tree6d8ee78a0b4da5d76b232933f58a4be7c78505bf /activesupport
parentd8db5714aa7d3c094395e7152249d347c95bae0e (diff)
downloadrails-67a2b5ec1bf9e34df18763490e14089733e8c774.tar.gz
rails-67a2b5ec1bf9e34df18763490e14089733e8c774.tar.bz2
rails-67a2b5ec1bf9e34df18763490e14089733e8c774.zip
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>
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/test/callbacks_test.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/activesupport/test/callbacks_test.rb b/activesupport/test/callbacks_test.rb
index 70a2950f9b..292383e3d8 100644
--- a/activesupport/test/callbacks_test.rb
+++ b/activesupport/test/callbacks_test.rb
@@ -524,4 +524,31 @@ module CallbacksTest
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