From 67a2b5ec1bf9e34df18763490e14089733e8c774 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Thu, 5 Aug 2010 18:09:23 -0400 Subject: 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. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- activesupport/test/callbacks_test.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'activesupport') 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 -- cgit v1.2.3