Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localization test is flaky (maybe mainly in CI) #1663

Closed
jagthedrummer opened this issue Aug 22, 2024 · 0 comments · Fixed by #1664
Closed

Localization test is flaky (maybe mainly in CI) #1663

jagthedrummer opened this issue Aug 22, 2024 · 0 comments · Fixed by #1664

Comments

@jagthedrummer
Copy link
Contributor

In one of my projects I often get errors in test/controllers/application/localization_test.rb.

I notice it most often in GitHub Actions.

The errors look like this:

ApplicationControllerTest
  test_team_locale_is_nil,_user_locale_is_nil                    ERROR (0.42s)
Minitest::UnexpectedError:         ActionController::UrlGenerationError: No route matches {:action=>"any_action", :controller=>"application"}
            test/controllers/application/localization_test.rb:35:in `block in <class:ApplicationControllerTest>'

  test_user_not_signed_in_and_browser_sends_HTTP_ACCEPT_LANGUAGE_with_unknown_valueERROR (0.11s)
Minitest::UnexpectedError:         ActionController::UrlGenerationError: No route matches {:action=>"any_action", :controller=>"application"}
            test/controllers/application/localization_test.rb:96:in `block in <class:ApplicationControllerTest>'

When it happens there are always 9 errors coming from that test file. Often it's the only failure. Just re-running the tests usually doesn't help, but pushing an empty commit does. This may to indicate some sort of ordering problem.

kaspth added a commit that referenced this issue Aug 22, 2024
Fixes #1663

We shouldn't replace the whole Rails' app's RouteSet, particularly when the `@routes`
instance variable already provides the hook.

Instead we can mirror what Rails does internally:
https://github.com/rails/rails/blob/a59ddc714fa0403cbd8c7ae6abdec2f71ee7b63f/actionpack/test/controller/test_case_test.rb#L1224C1-L1236C8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant