From 7f5deeeee6c9e0384ff6667fb51e64fcfe381365 Mon Sep 17 00:00:00 2001 From: Jonathan Hefner Date: Mon, 4 May 2020 19:26:54 -0500 Subject: [PATCH] Fix flakey destroyed_by_association tests Example failure: https://buildkite.com/rails/rails/builds/68661#84f8790a-fc9e-42ef-a7fb-5bd15a489de8/1002-1012 The failing `destroyed_by_association` tests create an author (a DestroyByParentAuthor) and a book (a DestroyByParentBook) that belongs to that author. If the database already contains books that refer to that author's ID from previous tests (i.e. tests that disabled `use_transactional_tests`), then one of those books will be loaded and destroyed instead of the intended DestroyByParentBook book. By loading the `:books` fixtures, we ensure the database does not contain such unexpected books. Co-authored-by: Eugene Kenny Co-authored-by: Ryuta Kamizono --- .../test/cases/associations/has_one_associations_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/test/cases/associations/has_one_associations_test.rb b/activerecord/test/cases/associations/has_one_associations_test.rb index f9cbfebe0e..8796b03eaf 100644 --- a/activerecord/test/cases/associations/has_one_associations_test.rb +++ b/activerecord/test/cases/associations/has_one_associations_test.rb @@ -21,7 +21,7 @@ require "models/membership" class HasOneAssociationsTest < ActiveRecord::TestCase self.use_transactional_tests = false unless supports_savepoints? fixtures :accounts, :companies, :developers, :projects, :developers_projects, - :ships, :pirates, :authors, :author_addresses, :memberships, :clubs + :ships, :pirates, :authors, :author_addresses, :books, :memberships, :clubs def setup Account.destroyed_account_ids.clear