Reload I18n after stubbing available locales
Not doing so might cause the following test to use translations for only one locale. This scenario happens if the previous test executes I18n.reload!, which resets I18n.config.backend's "@translations" instance variable. So, the sequence could be as follows: 1. The previous tests sets `@translations = nil` 2. This test stubs `available_locales` to `[:en]` 3. `@translations` gets only translations for `en` 4. The following test doesn't find translations for Spanish and fails
This commit is contained in:
@@ -41,12 +41,19 @@ feature 'Localization' do
|
|||||||
expect(page).to have_select('locale-switcher', selected: 'Español')
|
expect(page).to have_select('locale-switcher', selected: 'Español')
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Locale switcher not present if only one locale' do
|
context "Only one locale" do
|
||||||
allow(I18n).to receive(:available_locales).and_return([:en])
|
before do
|
||||||
|
allow(I18n).to receive(:available_locales).and_return([:en])
|
||||||
|
I18n.reload!
|
||||||
|
end
|
||||||
|
|
||||||
visit '/'
|
after { I18n.reload! }
|
||||||
expect(page).not_to have_content('Language')
|
|
||||||
expect(page).not_to have_css('div.locale')
|
scenario "Locale switcher not present" do
|
||||||
|
visit '/'
|
||||||
|
expect(page).not_to have_content('Language')
|
||||||
|
expect(page).not_to have_css('div.locale')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "Missing language names" do
|
context "Missing language names" do
|
||||||
|
|||||||
Reference in New Issue
Block a user