diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-08-20 00:06:25 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-08-20 00:06:49 -0700 |
commit | 949c7e2d0e847e56444bb14b1df56e7fc464ed3f (patch) | |
tree | f353167dab4eb50ccb85a74bef574f811b2a5e0c /activerecord/test | |
parent | b91dcb63d055c1228453e55c913d640a9739b644 (diff) | |
download | rails-949c7e2d0e847e56444bb14b1df56e7fc464ed3f.tar.gz rails-949c7e2d0e847e56444bb14b1df56e7fc464ed3f.tar.bz2 rails-949c7e2d0e847e56444bb14b1df56e7fc464ed3f.zip |
fisting after_rollback and after commit callbacks
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/callbacks_test.rb | 7 | ||||
-rw-r--r-- | activerecord/test/cases/transaction_callbacks_test.rb | 12 |
2 files changed, 14 insertions, 5 deletions
diff --git a/activerecord/test/cases/callbacks_test.rb b/activerecord/test/cases/callbacks_test.rb index dc7f82b001..8a84f19836 100644 --- a/activerecord/test/cases/callbacks_test.rb +++ b/activerecord/test/cases/callbacks_test.rb @@ -461,7 +461,12 @@ class CallbacksTest < ActiveRecord::TestCase [ :before_validation, :proc ], [ :before_validation, :object ], [ :before_validation, :block ], - [ :before_validation, :returning_false ] + [ :before_validation, :returning_false ], + [ :after_rollback, :block ], + [ :after_rollback, :object ], + [ :after_rollback, :proc ], + [ :after_rollback, :string ], + [ :after_rollback, :method ], ], david.history end diff --git a/activerecord/test/cases/transaction_callbacks_test.rb b/activerecord/test/cases/transaction_callbacks_test.rb index cc146f5574..85f222bca2 100644 --- a/activerecord/test/cases/transaction_callbacks_test.rb +++ b/activerecord/test/cases/transaction_callbacks_test.rb @@ -260,22 +260,26 @@ class TransactionObserverCallbacksTest < ActiveRecord::TestCase class TopicWithObserverAttachedObserver < ActiveRecord::Observer def after_commit(record) - record.history.push :"TopicWithObserverAttachedObserver#after_commit" + record.history.push "after_commit" end def after_rollback(record) - record.history.push :"TopicWithObserverAttachedObserver#after_rollback" + record.history.push "after_rollback" end end def test_after_commit_called + assert TopicWithObserverAttachedObserver.instance, 'should have observer' + topic = TopicWithObserverAttached.new topic.save! - assert_equal topic.history, [:"TopicWithObserverAttachedObserver#after_commit"] + assert_equal %w{ after_commit }, topic.history end def test_after_rollback_called + assert TopicWithObserverAttachedObserver.instance, 'should have observer' + topic = TopicWithObserverAttached.new Topic.transaction do @@ -283,6 +287,6 @@ class TransactionObserverCallbacksTest < ActiveRecord::TestCase raise ActiveRecord::Rollback end - assert_equal topic.history, [:"TopicWithObserverObserver#after_rollback"] + assert_equal %w{ after_rollback }, topic.history end end |