diff options
author | Arthur Neves <arthurnn@gmail.com> | 2015-01-20 12:23:17 -0500 |
---|---|---|
committer | Arthur Neves <arthurnn@gmail.com> | 2015-01-20 12:37:57 -0500 |
commit | 2e85224fb6ab2c9289287e97f825192e750e08d1 (patch) | |
tree | ad9a7ae92c6205fe2b9803aec80bbab5c4b82a7e | |
parent | b477ad54e586326b33528c4d68930e2efa73c72b (diff) | |
download | rails-2e85224fb6ab2c9289287e97f825192e750e08d1.tar.gz rails-2e85224fb6ab2c9289287e97f825192e750e08d1.tar.bz2 rails-2e85224fb6ab2c9289287e97f825192e750e08d1.zip |
TransactionManager should call rollback records
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/transaction.rb | 10 | ||||
-rw-r--r-- | 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 |