Skip to content

Race Condition Check: spec/system/devise/passwords/new_spec.rb#6780

Open
stefannibrasil wants to merge 3 commits intorubyforgood:mainfrom
hexdevs:sb-passwords-system-test-6320
Open

Race Condition Check: spec/system/devise/passwords/new_spec.rb#6780
stefannibrasil wants to merge 3 commits intorubyforgood:mainfrom
hexdevs:sb-passwords-system-test-6320

Conversation

@stefannibrasil
Copy link
Contributor

@stefannibrasil stefannibrasil commented Mar 16, 2026

What github issue is this PR for, if any?

Resolves #6320

What changed, and why?

When github's free CI servers are under heavy load, a race condition
between the page loading and checking the database causes tests to flake.
This is caused by a system test inputting data into a form then
immediately checking the database without waiting for the form to finish submitting.

For every database check in the system files, this ensures it's preceded
by a capybara matcher with automatic waiting or replace the database
check with a check for something to appear on the page.

I also took the opportunity to refactor some small things:

  • build instead of create an user to save up test setup time
  • assert that an attribute is present instead of not nil (easier to comprehend)
  • uses the reserved email domain for tests: example.com to be RFC 2606 compliant

When github's free CI servers are under heavy load, a race condition
between the page loading and checking the database causes tests to flake.
This is caused by a system test inputting data into a form then
immediately checking the database without waiting for the form to finish submitting.

For every database check in the system files, make sure it's preceded
by a capybara matcher with automatic waiting or replace the database
check with a check for something to appear on the page.
This reduces test setup time. I also find it easier to understand
when the test checks that an attribute is present instead of not nil.
@github-actions github-actions bot added ruby Pull requests that update Ruby code Tests! 🎉💖👏 labels Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ruby Pull requests that update Ruby code Tests! 🎉💖👏

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Race Condition Check: spec/system/devise/passwords/new_spec.rb

1 participant