Repository navigation
Fix order-dependent youth_birthday_reminder spec (rake tasks loaded twice) - #7320
Merged
Merged
Conversation
…wice) seeds_spec called Rails.application.load_tasks unconditionally. If it ran after another spec had already loaded the tasks, every task got its body registered twice, so a later youth_birthday_reminder spec saw 2 notifications where it expected 1. Guard it like the other task specs do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The docker CI job failed today on #7300 and on the devise_invitable Renovate PR, both at
spec/lib/tasks/youth_birthday_reminder_spec.rb:33(expected change by 1, but was changed by 2).Cause:
spec/seeds/seeds_spec.rbcalledRails.application.load_taskswith no guard. Ifrake_tasks_constants_specloaded the tasks first, the seeds spec loaded them a second time. Rake then appends each task body again, soyouth_birthday_reminderran twice per invoke. It only fails under some random orders, which is why rspec.yml usually passes.Repro (fails before this change, passes after):
Before: 8 examples, 3 failures (2 vs 1, 4 vs 2, 2 vs 1). After: 8 examples, 0 failures.
Fix: use the same
if Rake::Task.tasks.empty?guard the other two task specs already use.🤖 Generated with Claude Code