Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set locales in test environment to avoid failed specs #3537

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Rails.application.configure do
# 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
PierreMesure marked this conversation as resolved.
Show resolved Hide resolved
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
# 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
Expand Down
19 changes: 5 additions & 14 deletions spec/features/remote_translations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
before do
Setting["feature.remote_translations"] = true
create(:proposal)
available_locales_response = ["ar", "de", "en", "es", "fa", "fr", "he", "it", "nl", "pl",
"pt", "sv", "zh-Hans", "zh-Hant"]
available_locales_response = %w[de en es fr pt zh-Hans]
expect(RemoteTranslations::Microsoft::AvailableLocales).to receive(:available_locales).
and_return(available_locales_response)
end
Expand All @@ -27,18 +26,14 @@
end

scenario "should display text in English" do
available_locales_with_fallback_en = [:ar, :de, :fa, :he, :nl, :pl, :sv]

visit root_path(locale: available_locales_with_fallback_en.sample)
visit root_path(locale: :de)

expect(page).to have_css ".remote-translations-button"
expect(page).to have_content "The content of this page is not available in your language"
end

scenario "should display text in English after parse key" do
available_locales_with_fallback_en = [:"zh-CN", :"zh-TW"]

visit root_path(locale: available_locales_with_fallback_en.sample)
visit root_path(locale: :"zh-CN")

expect(page).to have_css ".remote-translations-button"
expect(page).to have_content "The content of this page is not available in your language"
Expand All @@ -53,9 +48,7 @@
end

scenario "with locale that has :es fallback" do
available_locales_with_fallback_es = [:es, :fr, :it]

visit root_path(locale: available_locales_with_fallback_es.sample)
visit root_path(locale: :fr)

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"
Expand All @@ -72,9 +65,7 @@
end

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: not_available_locales.sample)
visit root_path(locale: :nl)

expect(page).not_to have_css ".remote-translations-button"
end
Expand Down
1 change: 0 additions & 1 deletion spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
require "selenium/webdriver"

Rails.application.load_tasks if Rake::Task.tasks.empty?
I18n.default_locale = :en

include Warden::Test::Helpers
Warden.test_mode!
Expand Down