-
Notifications
You must be signed in to change notification settings - Fork 260
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
Enhancement/i18n thread safe #647
Merged
DeeDeeG
merged 4 commits into
RefugeRestrooms:develop
from
brunoocasali:enhancement/i18n-thread-safe
Oct 29, 2020
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
65325ee
Provide a way to respond requests without thread-safe issues
brunoocasali 7b22422
Create a shared_example to test I18n locale switching
brunoocasali 2a0ecf4
Update spec/controllers/pages_controller_spec.rb
brunoocasali 3a076e1
Merge branch 'develop' into enhancement/i18n-thread-safe
brunoocasali File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
shared_examples_for 'localized request' do |action| | ||
it 'calls I18n.with_locale in requests' do | ||
allow(I18n).to receive(:with_locale) | ||
|
||
get action | ||
|
||
expect(I18n).to have_received(:with_locale).with(:en) | ||
end | ||
end | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brunoocasali would it be very difficult to also test loading a page with another locale? So far our test suite runs strictly against the site in English. I would love to have some test for a locale other than English, even if it was a very basic or simple test.
If you could do that, it would be much appreciated. If it's a lot of work (or really if you prefer not to for any reason), let me know, and I'll still accept this pull request without it.
Thank you, and best regards.
- DeeDeeg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @DeeDeeG, thanks for your review!
Don't you think that way we could start testing some code that are already tested by the framework?
The test in this PR just guarantees that every request will contain some kind of language definition.
When we add a multi-language switcher like a querystring called "lang" for example we could add another spec here, to check:
If the url contains the "lang" querystring all the messages will be translated properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be fairly easy to set the locale within a spec's code.
But I can see how that would be unrelated to this pull request. Perhaps when I re-add the language switcher feature, I will
@mention
you to see if you might be interested in adding some tests. No obligation, but certainly it would be appreciated if you wanted to help with that.Thanks for this, I'm going to merge now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DeeDeeG of course! just mention me and I see what can I do ;)