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

Prevent leaking of locale between requests #949

Merged
merged 1 commit into from Jun 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/controllers/application_controller.rb
Expand Up @@ -67,6 +67,9 @@ def locale_from_request_params
end

def set_locale
# Prevent leaking of I18n.locale between requests
I18n.locale = I18n.default_locale

return unless Flipper.enabled?(:localization, current_user)
# TODO: Remove debug logging when feature flag is removed

Expand Down
3 changes: 1 addition & 2 deletions spec/rails_helper.rb
Expand Up @@ -78,9 +78,8 @@
# (Un-stub before each example as needed, overriding with specific args)
allow(Flipper).to receive(:enabled?).with(any_args).and_call_original

# Reset locale settings to defaults
# Reset default locale between examples
I18n.default_locale = :en
I18n.locale = I18n.default_locale
end
end

Expand Down