From 83cb53200972798fb543d3d8d7bcb4a88e04b641 Mon Sep 17 00:00:00 2001 From: wycats Date: Sun, 15 Aug 2010 16:23:47 -0700 Subject: [PATCH] Test callbacks --- activesupport/test/callbacks_test.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/activesupport/test/callbacks_test.rb b/activesupport/test/callbacks_test.rb index 70a2950f9b..6917585ecd 100644 --- a/activesupport/test/callbacks_test.rb +++ b/activesupport/test/callbacks_test.rb @@ -1,6 +1,7 @@ require 'abstract_unit' require 'test/unit' require 'active_support' +require 'active_support/testing/deprecation' module CallbacksTest class Record @@ -60,6 +61,10 @@ module CallbacksTest def save run_callbacks :save end + + def deprecated_save + callback :save + end end class PersonSkipper < Person @@ -317,6 +322,8 @@ module CallbacksTest end class CallbacksTest < Test::Unit::TestCase + include ActiveSupport::Testing::Deprecation + def test_save_person person = Person.new assert_equal [], person.history @@ -334,6 +341,25 @@ module CallbacksTest [:after_save, :symbol] ], person.history end + + def test_save_person_deprecated + person = Person.new + assert_equal [], person.history + assert_deprecated { person.deprecated_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] + ], person.history + end + end class ConditionalCallbackTest < Test::Unit::TestCase