diff options
author | Guillermo Iguaran <guilleiguaran@gmail.com> | 2017-06-15 07:03:41 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-15 07:03:41 -0500 |
commit | eb053fa8e22c95b1f8e2114c16f1e23299e90619 (patch) | |
tree | 91b57b1a0e95bef7360d7eca0e4d5cac1bf09afd /activerecord | |
parent | 95ae033e7f6747fa7a65c74c66922c8d9fe66808 (diff) | |
parent | 249fcbec4aa64a5f9e9f1671bf9180db4ebf9a37 (diff) | |
download | rails-eb053fa8e22c95b1f8e2114c16f1e23299e90619.tar.gz rails-eb053fa8e22c95b1f8e2114c16f1e23299e90619.tar.bz2 rails-eb053fa8e22c95b1f8e2114c16f1e23299e90619.zip |
Merge pull request #29453 from kamipo/add_test_case_for_28274
Add test cases for #28274
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/transactions_test.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/activerecord/test/cases/transactions_test.rb b/activerecord/test/cases/transactions_test.rb index 5c6d78b574..79ba306ef5 100644 --- a/activerecord/test/cases/transactions_test.rb +++ b/activerecord/test/cases/transactions_test.rb @@ -595,6 +595,52 @@ class TransactionTest < ActiveRecord::TestCase assert_not topic.frozen? end + def test_restore_id_after_rollback + topic = Topic.new + + Topic.transaction do + topic.save! + raise ActiveRecord::Rollback + end + + assert_nil topic.id + end + + def test_restore_custom_primary_key_after_rollback + movie = Movie.new(name: "foo") + + Movie.transaction do + movie.save! + raise ActiveRecord::Rollback + end + + assert_nil movie.id + end + + def test_assign_id_after_rollback + topic = Topic.create! + + Topic.transaction do + topic.save! + raise ActiveRecord::Rollback + end + + topic.id = nil + assert_nil topic.id + end + + def test_assign_custom_primary_key_after_rollback + movie = Movie.create!(name: "foo") + + Movie.transaction do + movie.save! + raise ActiveRecord::Rollback + end + + movie.id = nil + assert_nil movie.id + end + def test_rollback_of_frozen_records topic = Topic.create.freeze Topic.transaction do |