diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-05-19 10:10:18 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-19 10:10:18 +0900 |
commit | 870766017ab20541a1e3b10bf026d82522028028 (patch) | |
tree | cca7cff257f4d47ec7a0a6c02ccaec4835dc5687 /activerecord/test/cases | |
parent | 1efbc634b5707cfca1bec0cf39f90520396a979b (diff) | |
parent | 5359428a142239578b4d1dfb43dd8c417ab57b5c (diff) | |
download | rails-870766017ab20541a1e3b10bf026d82522028028.tar.gz rails-870766017ab20541a1e3b10bf026d82522028028.tar.bz2 rails-870766017ab20541a1e3b10bf026d82522028028.zip |
Merge pull request #32911 from eugeneius/finalize_transaction_record_state
Finalize transaction record state after real transaction
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/transactions_test.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/activerecord/test/cases/transactions_test.rb b/activerecord/test/cases/transactions_test.rb index 17aeabe34e..0d7857c0cf 100644 --- a/activerecord/test/cases/transactions_test.rb +++ b/activerecord/test/cases/transactions_test.rb @@ -679,6 +679,35 @@ class TransactionTest < ActiveRecord::TestCase assert_not_predicate topic, :frozen? end + def test_restore_new_record_after_double_save + topic = Topic.new + + Topic.transaction do + topic.save! + topic.save! + raise ActiveRecord::Rollback + end + + assert_predicate topic, :new_record? + end + + def test_dont_restore_new_record_in_subsequent_transaction + topic = Topic.new + + Topic.transaction do + topic.save! + topic.save! + end + + Topic.transaction do + topic.save! + raise ActiveRecord::Rollback + end + + assert_predicate topic, :persisted? + assert_not_predicate topic, :new_record? + end + def test_restore_id_after_rollback topic = Topic.new |