1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add test cases for #28274

`object.id` is correctly restored since #29378 has merged.

Closes #28274, Closes #28395.

[Ryuta Kamizono & Eugene Kenny]
This commit is contained in:
Ryuta Kamizono 2017-06-15 06:30:55 +09:00
parent f340490b98
commit 249fcbec4a

View file

@ -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