Fix locale related specs (#3707)

* Use I18n.locale instead of ":en"
* Reset I18n.locale value after locale changing tests
This commit is contained in:
unarist 2017-06-12 17:58:03 +09:00 committed by Eugen Rochko
parent ddd3251912
commit abbdacedc5
3 changed files with 6 additions and 1 deletions

View file

@ -19,6 +19,7 @@ describe ApplicationController, type: :controller do
context 'when DEFAULT_LOCALE environment variable is set' do context 'when DEFAULT_LOCALE environment variable is set' do
around do |example| around do |example|
ClimateControl.modify 'DEFAULT_LOCALE' => 'ca', &example.method(:run) ClimateControl.modify 'DEFAULT_LOCALE' => 'ca', &example.method(:run)
I18n.locale = I18n.default_locale
end end
it 'sets language specified by ENV if preferred' do it 'sets language specified by ENV if preferred' do

View file

@ -3,7 +3,7 @@ require 'rails_helper'
RSpec.describe HomeHelper, type: :helper do RSpec.describe HomeHelper, type: :helper do
describe 'default_props' do describe 'default_props' do
it 'returns default properties according to the context' do it 'returns default properties according to the context' do
expect(helper.default_props).to eq locale: :en expect(helper.default_props).to eq locale: I18n.locale
end end
end end
end end

View file

@ -3,6 +3,10 @@
require 'rails_helper' require 'rails_helper'
describe 'Localization' do describe 'Localization' do
after(:all) do
I18n.locale = I18n.default_locale
end
it 'uses a specific region when provided' do it 'uses a specific region when provided' do
headers = { 'Accept-Language' => 'zh-HK' } headers = { 'Accept-Language' => 'zh-HK' }