From 910c0f9f81d5217d7e8f619fd528ff29c1d42034 Mon Sep 17 00:00:00 2001 From: Chris Zetter <253059100+zetter-rpf@users.noreply.github.com> Date: Mon, 19 Jan 2026 15:42:03 +0000 Subject: [PATCH 1/2] Output debug inforrmation to help with intermittent test This test has been intermittently failing. I want to see the details of the lessons in the database to see if there are clues as to where they might come from. --- spec/lib/tasks/for_education_spec.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/spec/lib/tasks/for_education_spec.rb b/spec/lib/tasks/for_education_spec.rb index 767d6f642..e6f9c50a3 100644 --- a/spec/lib/tasks/for_education_spec.rb +++ b/spec/lib/tasks/for_education_spec.rb @@ -76,8 +76,16 @@ end it 'adds two projects' do - lesson = Lesson.where(school_id: school.id) - expect(Project.where(lesson_id: lesson.pluck(:id)).length).to eq(2) + lessons = Lesson.where(school_id: school.id) + projects = Project.where(lesson_id: lessons.pluck(:id)) + + if projects.length != 2 + $stdout.puts('Debug info for intermittent test') + lessons.each { |lesson| $stdout.puts(lesson.inspect) } + projects.each { |project| $stdout.puts(project.inspect) } + end + + expect(projects.length).to eq(2) end it 'assigns a teacher' do From f9bd20c4fe77f9b645f2d40124fbf0b23ac0f029 Mon Sep 17 00:00:00 2001 From: Chris Zetter <253059100+zetter-rpf@users.noreply.github.com> Date: Mon, 19 Jan 2026 15:44:04 +0000 Subject: [PATCH 2/2] Try fixing intermittent tests with different database cleaner strategy The database cleaner documentation warns that using a different database connection breaks the ability to use the transaction strategy. I thought it's possible this might be the cause for the intermittent test if rake tasks use a different process or connection. I've also added logging in the previous commit so even if this doesn't fix the issue we may have other clues next time. --- spec/rails_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index c3ab74904..208a5d28f 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -101,7 +101,7 @@ config.around(type: :task) do |example| DatabaseCleaner.clean_with(:truncation) - DatabaseCleaner.strategy = :transaction + DatabaseCleaner.strategy = :truncation DatabaseCleaner.cleaning do Rails.application.load_tasks