mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-14 04:04:23 +00:00
Merge pull request #2128 from mkllnk/2113-i18n-config
2113 Display only selected languages in switcher
This commit is contained in:
@@ -71,11 +71,10 @@ feature 'Multilingual', js: true do
|
||||
|
||||
describe "using the language switcher UI" do
|
||||
context "when there is only one language available" do
|
||||
around do |example|
|
||||
available_locales = I18n.available_locales
|
||||
I18n.available_locales = ['en']
|
||||
example.run
|
||||
I18n.available_locales = available_locales
|
||||
before do
|
||||
allow(ENV).to receive(:[]).and_call_original
|
||||
allow(ENV).to receive(:[]).with("LOCALE").and_return("en")
|
||||
allow(ENV).to receive(:[]).with("AVAILABLE_LOCALES").and_return("en")
|
||||
end
|
||||
|
||||
it "hides the dropdown language menu" do
|
||||
@@ -84,21 +83,29 @@ feature 'Multilingual', js: true do
|
||||
end
|
||||
end
|
||||
|
||||
it "allows switching language via the main navigation" do
|
||||
visit root_path
|
||||
|
||||
expect(page).to have_content 'SHOPS'
|
||||
|
||||
find('ul.right li.language-switcher').click
|
||||
within'ul.right li.language-switcher ul.dropdown' do
|
||||
expect(page).to have_link I18n.t('language_name', locale: :en), href: '?locale=en'
|
||||
expect(page).to have_link I18n.t('language_name', locale: :es, default: 'Language Name'), href: '?locale=es'
|
||||
|
||||
find('li a[href="?locale=es"]').click
|
||||
context "when there are multiple languages available" do
|
||||
before do
|
||||
allow(ENV).to receive(:[]).and_call_original
|
||||
allow(ENV).to receive(:[]).with("LOCALE").and_return("en")
|
||||
allow(ENV).to receive(:[]).with("AVAILABLE_LOCALES").and_return("en,es")
|
||||
end
|
||||
|
||||
expect(page.driver.browser.cookies['locale'].value).to eq 'es'
|
||||
expect(page).to have_content 'TIENDAS'
|
||||
it "allows switching language via the main navigation" do
|
||||
visit root_path
|
||||
|
||||
expect(page).to have_content 'SHOPS'
|
||||
|
||||
find('ul.right li.language-switcher').click
|
||||
within'ul.right li.language-switcher ul.dropdown' do
|
||||
expect(page).to have_link I18n.t('language_name', locale: :en), href: '?locale=en'
|
||||
expect(page).to have_link I18n.t('language_name', locale: :es, default: 'Language Name'), href: '?locale=es'
|
||||
|
||||
find('li a[href="?locale=es"]').click
|
||||
end
|
||||
|
||||
expect(page.driver.browser.cookies['locale'].value).to eq 'es'
|
||||
expect(page).to have_content 'TIENDAS'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user