Skip to content

DEV: Fix state leak in test #32835

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

Merged
merged 1 commit into from
May 21, 2025
Merged

DEV: Fix state leak in test #32835

merged 1 commit into from
May 21, 2025

Conversation

tgxworld
Copy link
Contributor

rspec --seed 52075 spec/models/site_spec.rb spec/lib/freedom_patches/translate_accelerator_spec.rb

Randomized with seed 52075
....................................................F

Failures:

  1) translate accelerator plugins loads plural rules from plugins
     Failure/Error: self.locale_no_cache = value

     I18n::InvalidLocale:
       :foo is not a valid locale
     # ./lib/freedom_patches/translate_accelerator.rb:254:in 'I18n.locale='
     # ./spec/lib/freedom_patches/translate_accelerator_spec.rb:118:in 'block (3 levels) in <main>'

This is because setting I18n.config.available_locales is equivalent to hard coding the
locales for the entire process. It should not be set so that I18n will
fallback to backend.locales.

```
rspec --seed 52075 spec/models/site_spec.rb spec/lib/freedom_patches/translate_accelerator_spec.rb

Randomized with seed 52075
....................................................F

Failures:

  1) translate accelerator plugins loads plural rules from plugins
     Failure/Error: self.locale_no_cache = value

     I18n::InvalidLocale:
       :foo is not a valid locale
     # ./lib/freedom_patches/translate_accelerator.rb:254:in 'I18n.locale='
     # ./spec/lib/freedom_patches/translate_accelerator_spec.rb:118:in 'block (3 levels) in <main>'
```

This is because setting `I18n.config.available_locales` is equivalent to hard coding the
locales for the entire process. It should not be set so that `I18n` will
fallback to `backend.locales`.
Copy link
Contributor

@jjaffeux jjaffeux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good thanks

@tgxworld tgxworld merged commit b7fcc0e into main May 21, 2025
17 checks passed
@tgxworld tgxworld deleted the fix_flaky_spec branch May 21, 2025 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants