Skip to content

Commit

Permalink
Merge pull request rails#51281 from fatkodima/fix-flaky-insert_all-test
Browse files Browse the repository at this point in the history
  • Loading branch information
yahonda authored Mar 8, 2024
2 parents 83702d6 + 3c61c3d commit 608c1bf
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions activerecord/test/cases/insert_all_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -337,19 +337,21 @@ def test_upsert_logs_message_including_model_name
end
end

def test_upsert_and_db_warnings
skip unless supports_insert_on_duplicate_update?
unless in_memory_db?
def test_upsert_and_db_warnings
skip unless supports_insert_on_duplicate_update?

begin
with_db_warnings_action(:raise) do
assert_nothing_raised do
Book.upsert({ id: 1001, name: "Remote", author_id: 1 })
begin
with_db_warnings_action(:raise) do
assert_nothing_raised do
Book.upsert({ id: 1001, name: "Remote", author_id: 1 })
end
end
ensure
# We need to explicitly remove the record, because `with_db_warnings_action`
# prevents the wrapping transaction to be rolled back.
Book.delete(1001)
end
ensure
# We need to explicitly remove the record, because `with_db_warnings_action`
# prevents the wrapping transaction to be rolled back.
Book.delete(1001)
end
end

Expand Down

0 comments on commit 608c1bf

Please sign in to comment.