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:
parent
f340490b98
commit
249fcbec4a
1 changed files with 46 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue