diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-07 17:39:46 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-07 17:39:46 -0300 |
commit | 73fb39b6faa9de593ae75ad4e3b8e065ea0e53af (patch) | |
tree | 442bcf6ce4f31d2527ae3851e1345b7a6e28fc07 /activerecord/test/cases | |
parent | 37c1e47da09fba4ee76143da05bbd4faabbaa53e (diff) | |
parent | 37c238927fbed059de3f26a90d8923fb377568a5 (diff) | |
download | rails-73fb39b6faa9de593ae75ad4e3b8e065ea0e53af.tar.gz rails-73fb39b6faa9de593ae75ad4e3b8e065ea0e53af.tar.bz2 rails-73fb39b6faa9de593ae75ad4e3b8e065ea0e53af.zip |
Merge branch 'rm-trasaction-fix-13166'
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/transactions_test.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/activerecord/test/cases/transactions_test.rb b/activerecord/test/cases/transactions_test.rb index e6ed85394b..7f2e830083 100644 --- a/activerecord/test/cases/transactions_test.rb +++ b/activerecord/test/cases/transactions_test.rb @@ -274,6 +274,48 @@ class TransactionTest < ActiveRecord::TestCase end end + def test_rollback_when_changing_inside_transaction + assert !@first.approved? + Topic.transaction do + @first.approved = true + @first.save! + raise ActiveRecord::Rollback + end + assert @first.approved + assert @first.changes["approved"] + @first.save! + assert @first.reload.approved + end + + def test_rollback_when_changing_outside_transaction + assert !@first.approved? + @first.approved = true + Topic.transaction do + @first.save! + raise ActiveRecord::Rollback + end + assert @first.changes["approved"] + assert @first.approved + @first.save! + assert @first.reload.approved + end + + def test_rollback_when_changing_back_to_prev_stage + assert !@first.approved? + Topic.transaction do + @first.approved = true + @first.save! + @first.approved = false + @first.save! + raise ActiveRecord::Rollback + end + assert !@first.approved + assert !@first.changes["approved"] + @first.save! + assert !@first.reload.approved + end + + def test_force_savepoint_in_nested_transaction Topic.transaction do @first.approved = true |