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

Set Locales Within Test Environment to Match Locales Used Within App #931

Open
aaronskiba opened this issue Oct 18, 2024 · 1 comment
Open
Assignees

Comments

@aaronskiba
Copy link
Collaborator

aaronskiba commented Oct 18, 2024

Please complete the following fields as applicable:

What version of the DMPRoadmap code are you running? (e.g. v2.2.0)
4.1.1+portage-4.2.2

Expected behaviour:

  • The test suite includes several translation-focused tests (e.g. testing what is rendered for translation.#{LOCALE}.yml files and testing output of _(). We would like to be able to ensure that these tests are working for locales that exist within our app.

Actual behaviour:

  • Tests mostly appear to be configured for either :en (the default I18n locale) or :'en-GB'.
  • In order to test a file like config/locales/translation.en-CA.yml, overriding is required within a test.
  • Overriding example:
      before(:each) do
      @default_locale = I18n.default_locale
      I18n.default_locale = :'en-CA'
    end
    
    after(:each) do
      I18n.default_locale = @default_locale
    end

Relevant Files

  • spec/features/locales_spec.rb
  • spec/support/faker.rb
  • spec/support/locales.rb
@lagoan
Copy link
Collaborator

lagoan commented Oct 28, 2024

Will fix this at a later time since it only affects the test env.

aaronskiba added a commit that referenced this issue Oct 28, 2024
This change resolves the following error:
```
rspec ./spec/features/modal_search_spec.rb:25

1) ModalSearchDialog Modal search opens and closes and allows user to search, select and remove items
     Failure/Error: <td><%= l(plan.updated_at.to_date, formats: :short) %></td>

     ActionView::Template::Error:
       Translation missing: en-GB.date.formats.default
```
Because en-GB is not a locale used within DMP Assistant, commit f600ba0 removed the related en-GB files from the app.

Setting the locale to 'en-CA' unfortunately breaks the tests as well. There is an open issue that seeks to resolve this: #931
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

No branches or pull requests

2 participants