diff options
Diffstat (limited to 'activerecord/test/cases/transaction_callbacks_test.rb')
-rw-r--r-- | activerecord/test/cases/transaction_callbacks_test.rb | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/activerecord/test/cases/transaction_callbacks_test.rb b/activerecord/test/cases/transaction_callbacks_test.rb index 961ba8d9ba..2ddc449c12 100644 --- a/activerecord/test/cases/transaction_callbacks_test.rb +++ b/activerecord/test/cases/transaction_callbacks_test.rb @@ -247,87 +247,6 @@ class TransactionCallbacksTest < ActiveRecord::TestCase end -class TransactionObserverCallbacksTest < ActiveRecord::TestCase - self.use_transactional_fixtures = false - fixtures :topics - - class TopicWithObserverAttached < ActiveRecord::Base - self.table_name = :topics - def history - @history ||= [] - end - end - - class TopicWithObserverAttachedObserver < ActiveRecord::Observer - def after_commit(record) - record.history.push "after_commit" - end - - def after_rollback(record) - 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 %w{ after_commit }, topic.history - end - - def test_after_rollback_called - assert TopicWithObserverAttachedObserver.instance, 'should have observer' - - topic = TopicWithObserverAttached.new - - Topic.transaction do - topic.save! - raise ActiveRecord::Rollback - end - - assert topic.id.nil? - assert !topic.persisted? - assert_equal %w{ after_rollback }, topic.history - end - - class TopicWithManualRollbackObserverAttached < ActiveRecord::Base - self.table_name = :topics - def history - @history ||= [] - end - end - - class TopicWithManualRollbackObserverAttachedObserver < ActiveRecord::Observer - def after_save(record) - record.history.push "after_save" - raise ActiveRecord::Rollback - end - end - - def test_after_save_called_with_manual_rollback - assert TopicWithManualRollbackObserverAttachedObserver.instance, 'should have observer' - - topic = TopicWithManualRollbackObserverAttached.new - - assert !topic.save - assert_equal nil, topic.id - assert !topic.persisted? - assert_equal %w{ after_save }, topic.history - end - def test_after_save_called_with_manual_rollback_bang - assert TopicWithManualRollbackObserverAttachedObserver.instance, 'should have observer' - - topic = TopicWithManualRollbackObserverAttached.new - - topic.save! - assert_equal nil, topic.id - assert !topic.persisted? - assert_equal %w{ after_save }, topic.history - end -end - class SaveFromAfterCommitBlockTest < ActiveRecord::TestCase self.use_transactional_fixtures = false |