From bdc2a749b6e9a4d0490fcbf5fb1d183e006ffafb Mon Sep 17 00:00:00 2001 From: elasticspoon Date: Tue, 16 Apr 2024 22:36:00 -0400 Subject: [PATCH] fix: persist with Thread.current Tracks the previous execution group. - seed or not seed base on flag on current group - truncate if the previous group seeded --- spec/rails_helper.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 758d046656..15f06b1b16 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -212,15 +212,15 @@ def seed_base_data_for_tests end config.before(:all) do - unless self.class.metadata[:skip_seed] - seed_base_data_for_tests - define_global_variables + unless Thread.current[:skipped_last_seeding] + DatabaseCleaner.clean_with(:truncation) end - end - config.after(:all) do + Thread.current[:skipped_last_seeding] = true unless self.class.metadata[:skip_seed] - DatabaseCleaner.clean_with(:truncation) + seed_base_data_for_tests + define_global_variables + Thread.current[:skipped_last_seeding] = false end end