From ca677a3ccd3a10b351f886885b4132331fae788f Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 13 Sep 2017 17:53:16 +1000 Subject: [PATCH] Reset I18n.locale to not affect other specs Otherwise spec/models/enterprise_spec.rb fails if run after this. --- spec/helpers/i18n_helper_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spec/helpers/i18n_helper_spec.rb b/spec/helpers/i18n_helper_spec.rb index 86e236a261..4e044b3ca2 100644 --- a/spec/helpers/i18n_helper_spec.rb +++ b/spec/helpers/i18n_helper_spec.rb @@ -3,6 +3,16 @@ require 'spec_helper' describe I18nHelper do let(:user) { create(:user) } + # In the real world, the helper is called in every request and sets + # I18n.locale to the chosen locale or the default. For testing purposes we + # have to restore I18n.locale for unit tests that don't call the helper, but + # rely on translated strings. + around do |example| + locale = I18n.locale + example.run + I18n.locale = locale + end + context "as guest" do before do allow(helper).to receive(:spree_current_user) { nil }