diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-07-28 15:02:28 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-07-28 15:02:28 -0300 |
commit | 6501aeb286ee25d3993e39c5badb9879b544c6bb (patch) | |
tree | cb5324065cb45d5e8912af5342d8c44b444f467f /activerecord/test | |
parent | 4e116c56a84bd995c6f9524a84b9227b5d32a09a (diff) | |
parent | d37bcc1d5a781687384fbe632a1850ab218ccbfd (diff) | |
download | rails-6501aeb286ee25d3993e39c5badb9879b544c6bb.tar.gz rails-6501aeb286ee25d3993e39c5badb9879b544c6bb.tar.bz2 rails-6501aeb286ee25d3993e39c5badb9879b544c6bb.zip |
Merge pull request #16284 from arthurnn/transactions
Transactions refactoring
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/transactions_test.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/activerecord/test/cases/transactions_test.rb b/activerecord/test/cases/transactions_test.rb index de1f624191..f28a7b00e2 100644 --- a/activerecord/test/cases/transactions_test.rb +++ b/activerecord/test/cases/transactions_test.rb @@ -424,6 +424,26 @@ class TransactionTest < ActiveRecord::TestCase end end + def test_savepoints_name + Topic.transaction do + assert_nil Topic.connection.current_savepoint_name + assert_nil Topic.connection.current_transaction.savepoint_name + + Topic.transaction(requires_new: true) do + assert_equal "active_record_1", Topic.connection.current_savepoint_name + assert_equal "active_record_1", Topic.connection.current_transaction.savepoint_name + + Topic.transaction(requires_new: true) do + assert_equal "active_record_2", Topic.connection.current_savepoint_name + assert_equal "active_record_2", Topic.connection.current_transaction.savepoint_name + end + + assert_equal "active_record_1", Topic.connection.current_savepoint_name + assert_equal "active_record_1", Topic.connection.current_transaction.savepoint_name + end + end + end + def test_rollback_when_commit_raises Topic.connection.expects(:begin_db_transaction) Topic.connection.expects(:commit_db_transaction).raises('OH NOES') |