Always set Globalize.locale after I18n.locale.

The test "Budget Investments Show milestones" was failing in certain
cases where `Globalize.locale` had been changed in a previous test.

Since having different values in `Globalize.locale` and `I18n.locale`
has proven to be an issue on the test enviroment, this commit also
changes application code in order to avoid similar situations on
production.

See issue #2718.
This commit is contained in:
Javier Martín
2018-07-02 23:12:41 +02:00
parent cd15e3f23a
commit f2ef27d3ae
4 changed files with 3 additions and 5 deletions

View File

@@ -59,6 +59,7 @@ class ApplicationController < ActionController::Base
end
I18n.locale = locale
Globalize.locale = I18n.locale
end
def set_layout

View File

@@ -2,7 +2,6 @@ module Translatable
extend ActiveSupport::Concern
included do
before_action :set_translation_locale
before_action :delete_translations, only: [:update]
end
@@ -12,10 +11,6 @@ module Translatable
resource_model.globalize_attribute_names.select { |k, v| params.include?(k.to_sym) && params[k].present? }
end
def set_translation_locale
Globalize.locale = I18n.locale
end
def delete_translations
locales = resource_model.globalize_locales.
select { |k, v| params[:delete_translations].include?(k.to_sym) && params[:delete_translations][k] == "1" }

View File

@@ -39,6 +39,7 @@ class Management::BaseController < ActionController::Base
session[:locale] ||= I18n.default_locale
I18n.locale = session[:locale]
Globalize.locale = I18n.locale
end
def current_budget

View File

@@ -41,6 +41,7 @@ RSpec.configure do |config|
config.before do |example|
DatabaseCleaner.strategy = :transaction
I18n.locale = :en
Globalize.locale = I18n.locale
load Rails.root.join('db', 'seeds.rb').to_s
Setting["feature.user.skip_verification"] = nil
end