Merge pull request #3537 from PierreMesure/set-locales-in-test-environment
Set locales in test environment to avoid failed specs
This commit is contained in:
@@ -1,6 +1,11 @@
|
|||||||
Rails.application.configure do
|
Rails.application.configure do
|
||||||
# Settings specified here will take precedence over those in config/application.rb.
|
# Settings specified here will take precedence over those in config/application.rb.
|
||||||
|
|
||||||
|
# Some tests require the following languages (en, es, fr, nl, pt-BR)
|
||||||
|
# so we override the available languages for the test environment.
|
||||||
|
config.i18n.default_locale = :en
|
||||||
|
config.i18n.available_locales = %w[de en es fr nl pt-BR zh-CN]
|
||||||
|
|
||||||
# The test environment is used exclusively to run your application's
|
# The test environment is used exclusively to run your application's
|
||||||
# test suite. You never need to work with it otherwise. Remember that
|
# test suite. You never need to work with it otherwise. Remember that
|
||||||
# your test database is "scratch space" for the test suite and is wiped
|
# your test database is "scratch space" for the test suite and is wiped
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ describe "Remote Translations" do
|
|||||||
before do
|
before do
|
||||||
Setting["feature.remote_translations"] = true
|
Setting["feature.remote_translations"] = true
|
||||||
create(:proposal)
|
create(:proposal)
|
||||||
available_locales_response = ["ar", "de", "en", "es", "fa", "fr", "he", "it", "nl", "pl",
|
available_locales_response = %w[de en es fr pt zh-Hans]
|
||||||
"pt", "sv", "zh-Hans", "zh-Hant"]
|
|
||||||
expect(RemoteTranslations::Microsoft::AvailableLocales).to receive(:available_locales).
|
expect(RemoteTranslations::Microsoft::AvailableLocales).to receive(:available_locales).
|
||||||
and_return(available_locales_response)
|
and_return(available_locales_response)
|
||||||
end
|
end
|
||||||
@@ -27,18 +26,14 @@ describe "Remote Translations" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "should display text in English" do
|
scenario "should display text in English" do
|
||||||
available_locales_with_fallback_en = [:ar, :de, :fa, :he, :nl, :pl, :sv]
|
visit root_path(locale: :de)
|
||||||
|
|
||||||
visit root_path(locale: available_locales_with_fallback_en.sample)
|
|
||||||
|
|
||||||
expect(page).to have_css ".remote-translations-button"
|
expect(page).to have_css ".remote-translations-button"
|
||||||
expect(page).to have_content "The content of this page is not available in your language"
|
expect(page).to have_content "The content of this page is not available in your language"
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "should display text in English after parse key" do
|
scenario "should display text in English after parse key" do
|
||||||
available_locales_with_fallback_en = [:"zh-CN", :"zh-TW"]
|
visit root_path(locale: :"zh-CN")
|
||||||
|
|
||||||
visit root_path(locale: available_locales_with_fallback_en.sample)
|
|
||||||
|
|
||||||
expect(page).to have_css ".remote-translations-button"
|
expect(page).to have_css ".remote-translations-button"
|
||||||
expect(page).to have_content "The content of this page is not available in your language"
|
expect(page).to have_content "The content of this page is not available in your language"
|
||||||
@@ -53,9 +48,7 @@ describe "Remote Translations" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "with locale that has :es fallback" do
|
scenario "with locale that has :es fallback" do
|
||||||
available_locales_with_fallback_es = [:es, :fr, :it]
|
visit root_path(locale: :fr)
|
||||||
|
|
||||||
visit root_path(locale: available_locales_with_fallback_es.sample)
|
|
||||||
|
|
||||||
expect(page).to have_css ".remote-translations-button"
|
expect(page).to have_css ".remote-translations-button"
|
||||||
expect(page).to have_content "El contenido de esta página no está disponible en tu idioma"
|
expect(page).to have_content "El contenido de esta página no está disponible en tu idioma"
|
||||||
@@ -72,9 +65,7 @@ describe "Remote Translations" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Not display remote translation button when locale is not included in microsoft translate client" do
|
scenario "Not display remote translation button when locale is not included in microsoft translate client" do
|
||||||
not_available_locales = [:val, :gl, :sq]
|
visit root_path(locale: :nl)
|
||||||
|
|
||||||
visit root_path(locale: not_available_locales.sample)
|
|
||||||
|
|
||||||
expect(page).not_to have_css ".remote-translations-button"
|
expect(page).not_to have_css ".remote-translations-button"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ require "capybara/rspec"
|
|||||||
require "selenium/webdriver"
|
require "selenium/webdriver"
|
||||||
|
|
||||||
Rails.application.load_tasks if Rake::Task.tasks.empty?
|
Rails.application.load_tasks if Rake::Task.tasks.empty?
|
||||||
I18n.default_locale = :en
|
|
||||||
|
|
||||||
include Warden::Test::Helpers
|
include Warden::Test::Helpers
|
||||||
Warden.test_mode!
|
Warden.test_mode!
|
||||||
|
|||||||
Reference in New Issue
Block a user