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

Translatable spec should pass even if some languages are disabled #3526

Closed
PierreMesure opened this issue May 22, 2019 · 3 comments · Fixed by #3537
Closed

Translatable spec should pass even if some languages are disabled #3526

PierreMesure opened this issue May 22, 2019 · 3 comments · Fixed by #3537

Comments

@PierreMesure
Copy link
Collaborator

Description

When disabling some of the languages used for the translatable specs, for example Spanish, English, French or Portuguese, the corresponding tests fail. This should not happen.

I don't know which solution would be best:

  • that the test suite overrides the available languages in config/application.rb and uses whichever languages it wants. With the risk that tests passing with the default languages fail with the ones actually used in production
  • that the test suite dynamically picks the available languages and uses only these to test. To put it in other way, no harcoding of the languages used for test, just variables. And if there is only one language available, these translatable specs should not run as they test unused functions.

Type: Bug

Related issues: #3130
Related PRs: #3359 #3455

Steps to reproduce

  • Remove pt-BR from the list of available languages
  • Get the following message for 18 failing specs:
Failure/Error: select "Português brasileiro", from: "translation_locale"
     
     Capybara::ElementNotFound:
       Unable to find visible option "Português brasileiro" within #<Capybara::Node::Element tag="select" path="/html/body/div/div/div[3]/div/div[2]/div/div/div[3]/div[6]/select">

Definition of Done

Specs should pass with any combination of available languages, even just one.

@PierreMesure
Copy link
Collaborator Author

Ping @Senen as you have probably thought of this already. What do you think is best?

@PierreMesure
Copy link
Collaborator Author

OK, I solved the problem by adding these lines in environment/test.rb:

  # The tests for the translatable function require the following languages (en, es, fr, pt-BR)
  # so we override the available languages for the test environment so they can pass.
  config.i18n.default_locale = :en
  available_locales = [
    "en",
    "es",
    "fr",
    "pt-BR"
  ]
  config.i18n.available_locales = available_locales

This is the second option I mentioned. @decabeza, does that seem OK to you? If so, I can submit a pull request with the code above or maybe with all the locales available:

    config.i18n.default_locale = :en
    available_locales = [
      "ar",
      "de",
      "en",
      "es",
      "fa",
      "fr",
      "gl",
      "he",
      "id",
      "it",
      "nl",
      "pl",
      "pt-BR",
      "ru",
      "sl",
      "sq",
      "so",
      "sv",
      "val",
      "zh-CN",
      "zh-TW"]
    config.i18n.available_locales = available_locales

@Senen
Copy link
Member

Senen commented Jun 1, 2019

Hi @PierreMesure, your final solution looks good to me! 👌 And the build passes! 😌

Let's see what the @consul/core says.

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.

2 participants