Skip to content

Commit

Permalink
Merge pull request #29453 from kamipo/add_test_case_for_28274
Browse files Browse the repository at this point in the history
Add test cases for #28274
  • Loading branch information
guilleiguaran committed Jun 15, 2017
2 parents 95ae033 + 249fcbe commit eb053fa
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions activerecord/test/cases/transactions_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -595,6 +595,52 @@ def test_restore_frozen_state_after_double_destroy
assert_not topic.frozen? assert_not topic.frozen?
end 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 def test_rollback_of_frozen_records
topic = Topic.create.freeze topic = Topic.create.freeze
Topic.transaction do Topic.transaction do
Expand Down

0 comments on commit eb053fa

Please sign in to comment.