Reset I18n.locale to not affect other specs

Otherwise spec/models/enterprise_spec.rb fails if run after this.
This commit is contained in:
Maikel Linke
2017-09-13 17:53:16 +10:00
parent 4cdd0831e8
commit ca677a3ccd

View File

@@ -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 }