From 2e85224fb6ab2c9289287e97f825192e750e08d1 Mon Sep 17 00:00:00 2001 From: Arthur Neves Date: Tue, 20 Jan 2015 12:23:17 -0500 Subject: TransactionManager should call rollback records --- .../active_record/connection_adapters/abstract/transaction.rb | 10 +++++----- activerecord/test/cases/transaction_callbacks_test.rb | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb b/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb index 84e5386c20..7f738e89c9 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb @@ -111,7 +111,6 @@ module ActiveRecord def rollback connection.rollback_to_savepoint(savepoint_name) super - rollback_records end def commit @@ -136,7 +135,6 @@ module ActiveRecord def rollback connection.rollback_db_transaction super - rollback_records end def commit @@ -176,8 +174,10 @@ module ActiveRecord end end - def rollback_transaction - @stack.pop.rollback + def rollback_transaction(transaction = nil) + transaction ||= @stack.pop + transaction.rollback + transaction.rollback_records end def within_new_transaction(options = {}) @@ -194,7 +194,7 @@ module ActiveRecord begin commit_transaction rescue Exception - transaction.rollback unless transaction.state.completed? + rollback_transaction(transaction) unless transaction.state.completed? raise end end diff --git a/activerecord/test/cases/transaction_callbacks_test.rb b/activerecord/test/cases/transaction_callbacks_test.rb index 9804707d00..f185cda263 100644 --- a/activerecord/test/cases/transaction_callbacks_test.rb +++ b/activerecord/test/cases/transaction_callbacks_test.rb @@ -201,7 +201,7 @@ class TransactionCallbacksTest < ActiveRecord::TestCase def test_call_after_rollback_when_commit_fails @first.after_commit_block { |r| r.history << :after_commit } @first.after_rollback_block { |r| r.history << :after_rollback } - + assert_raises RuntimeError do @first.transaction do tx = @first.class.connection.transaction_manager.current_transaction -- cgit v1.2.3