Skip to content

Commit 608c1bf

Browse files
authored
Merge pull request rails#51281 from fatkodima/fix-flaky-insert_all-test
2 parents 83702d6 + 3c61c3d commit 608c1bf

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

activerecord/test/cases/insert_all_test.rb

+12-10
Original file line numberDiff line numberDiff line change
@@ -337,19 +337,21 @@ def test_upsert_logs_message_including_model_name
337337
end
338338
end
339339

340-
def test_upsert_and_db_warnings
341-
skip unless supports_insert_on_duplicate_update?
340+
unless in_memory_db?
341+
def test_upsert_and_db_warnings
342+
skip unless supports_insert_on_duplicate_update?
342343

343-
begin
344-
with_db_warnings_action(:raise) do
345-
assert_nothing_raised do
346-
Book.upsert({ id: 1001, name: "Remote", author_id: 1 })
344+
begin
345+
with_db_warnings_action(:raise) do
346+
assert_nothing_raised do
347+
Book.upsert({ id: 1001, name: "Remote", author_id: 1 })
348+
end
347349
end
350+
ensure
351+
# We need to explicitly remove the record, because `with_db_warnings_action`
352+
# prevents the wrapping transaction to be rolled back.
353+
Book.delete(1001)
348354
end
349-
ensure
350-
# We need to explicitly remove the record, because `with_db_warnings_action`
351-
# prevents the wrapping transaction to be rolled back.
352-
Book.delete(1001)
353355
end
354356
end
355357

0 commit comments

Comments
 (0)