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

Check remote translations locales at runtime #3992

Merged
merged 2 commits into from
May 13, 2020

Conversation

javierm
Copy link
Member

@javierm javierm commented Apr 28, 2020

References

Objectives

  • Avoid inconsistencies if remote translations available locales change while the application is running
  • Make it possible to run tests for remote translations with no internet connection

We were evaluating its value when the server starts. On production
enviroments, that could mean weeks or months before the available
locales are checked again, and so it would be possible to use a list
which is no longer in sync with the list provided by microsoft.
The method `available_locales` in
`RemoteTranslations::Microsoft::AvailableLocales` needs to execute a
request to an external server in order to work, meaning it will fail if
the machine its executed on doesn't have an internet connection.

So we're stubbing the method in the tests using it.
@@ -4,7 +4,7 @@ class RemoteTranslation < ApplicationRecord
validates :remote_translatable_id, presence: true
validates :remote_translatable_type, presence: true
validates :locale, presence: true
validates :locale, inclusion: { in: RemoteTranslations::Microsoft::AvailableLocales.available_locales }
validates :locale, inclusion: { in: ->(_) { RemoteTranslations::Microsoft::AvailableLocales.available_locales }}

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [114/110] (https://rubystyle.guide#80-character-limits)

@javierm javierm added this to Reviewing in Consul Democracy Apr 28, 2020
@taitus taitus self-requested a review May 13, 2020 15:43
Consul Democracy automation moved this from Reviewing to Testing May 13, 2020
@javierm javierm merged commit 8c9264f into master May 13, 2020
Consul Democracy automation moved this from Testing to Release 1.2.0 May 13, 2020
@javierm javierm deleted the remote_translations_runtime branch May 13, 2020 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants