Skip to content
Browse files

Test callbacks

  • Loading branch information...
1 parent c330e96 commit 83cb53200972798fb543d3d8d7bcb4a88e04b641 @wycats wycats committed
Showing with 26 additions and 0 deletions.
  1. +26 −0 activesupport/test/callbacks_test.rb
View
26 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 @@ class Person < Record
def save
run_callbacks :save
end
+
+ def deprecated_save
+ callback :save
+ end
end
class PersonSkipper < Person
@@ -317,6 +322,8 @@ def test_skip_person
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 @@ def test_save_person
[: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

0 comments on commit 83cb532

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