Let Globalize use I18n locale
This is a mistake I made in commit f2ef27d3. Back then I thought we
needed to keep Globalize.locale and I18n.locale in sync, but the truth
is it automatically happens when setting Globalize.locale to nil.
So now we can use I18n.with_locale (at least in the tests) and forget
about Globalize, which will make it easier to switch to Mobility in the
future.
This commit is contained in:
@@ -824,9 +824,7 @@ describe "Admin budget investments" do
|
|||||||
|
|
||||||
before do
|
before do
|
||||||
I18n.with_locale(:es) do
|
I18n.with_locale(:es) do
|
||||||
Globalize.with_locale(:es) do
|
create(:budget_investment, title: "Proyecto de inversión", budget: budget)
|
||||||
create(:budget_investment, title: "Proyecto de inversión", budget: budget)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require "rails_helper"
|
|||||||
describe "Localization" do
|
describe "Localization" do
|
||||||
|
|
||||||
scenario "Wrong locale" do
|
scenario "Wrong locale" do
|
||||||
Globalize.with_locale(:es) do
|
I18n.with_locale(:es) do
|
||||||
create(:widget_card, title: "Bienvenido a CONSUL",
|
create(:widget_card, title: "Bienvenido a CONSUL",
|
||||||
description: "Software libre para la participación ciudadana.",
|
description: "Software libre para la participación ciudadana.",
|
||||||
link_text: "Más información",
|
link_text: "Más información",
|
||||||
|
|||||||
@@ -58,10 +58,10 @@ describe Budget::Group do
|
|||||||
budget = create(:budget, name: "Teams")
|
budget = create(:budget, name: "Teams")
|
||||||
charlie = create(:budget_group, budget: budget, name: "Charlie")
|
charlie = create(:budget_group, budget: budget, name: "Charlie")
|
||||||
delta = create(:budget_group, budget: budget, name: "Delta")
|
delta = create(:budget_group, budget: budget, name: "Delta")
|
||||||
zulu = Globalize.with_locale(:es) do
|
zulu = I18n.with_locale(:es) do
|
||||||
create(:budget_group, budget: budget, name: "Zulu", name_fr: "Alpha")
|
create(:budget_group, budget: budget, name: "Zulu", name_fr: "Alpha")
|
||||||
end
|
end
|
||||||
bravo = Globalize.with_locale(:es) do
|
bravo = I18n.with_locale(:es) do
|
||||||
create(:budget_group, budget: budget, name: "Bravo")
|
create(:budget_group, budget: budget, name: "Bravo")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -555,10 +555,8 @@ describe Budget::Investment do
|
|||||||
|
|
||||||
it "takes into consideration title fallbacks when there is no translation for current locale" do
|
it "takes into consideration title fallbacks when there is no translation for current locale" do
|
||||||
create(:budget_investment, title: "BBBB")
|
create(:budget_investment, title: "BBBB")
|
||||||
Globalize.with_locale(:es) do
|
I18n.with_locale(:es) do
|
||||||
I18n.with_locale(:es) do
|
create(:budget_investment, title: "AAAA")
|
||||||
create(:budget_investment, title: "AAAA")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(Budget::Investment.sort_by_title.map(&:title)).to eq %w[AAAA BBBB]
|
expect(Budget::Investment.sort_by_title.map(&:title)).to eq %w[AAAA BBBB]
|
||||||
@@ -570,11 +568,9 @@ describe Budget::Investment do
|
|||||||
|
|
||||||
let!(:investment) do
|
let!(:investment) do
|
||||||
I18n.with_locale(:es) do
|
I18n.with_locale(:es) do
|
||||||
Globalize.with_locale(:es) do
|
create(:budget_investment,
|
||||||
create(:budget_investment,
|
title_es: "Título del proyecto de inversión",
|
||||||
title_es: "Título del proyecto de inversión",
|
description_es: "Descripción del proyecto de inversión")
|
||||||
description_es: "Descripción del proyecto de inversión")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -54,9 +54,7 @@ RSpec.describe I18nContent, type: :model do
|
|||||||
it "responds accordingly to the current locale" do
|
it "responds accordingly to the current locale" do
|
||||||
expect(i18n_content.value).to eq("Text in english")
|
expect(i18n_content.value).to eq("Text in english")
|
||||||
|
|
||||||
Globalize.locale = :es
|
I18n.with_locale(:es) { expect(i18n_content.value).to eq("Texto en español") }
|
||||||
|
|
||||||
expect(i18n_content.value).to eq("Texto en español")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -402,10 +402,10 @@ describe Poll do
|
|||||||
starts_at = Time.current + 1.day
|
starts_at = Time.current + 1.day
|
||||||
poll1 = create(:poll, starts_at: starts_at, name: "Charlie")
|
poll1 = create(:poll, starts_at: starts_at, name: "Charlie")
|
||||||
poll2 = create(:poll, starts_at: starts_at, name: "Delta")
|
poll2 = create(:poll, starts_at: starts_at, name: "Delta")
|
||||||
poll3 = Globalize.with_locale(:es) do
|
poll3 = I18n.with_locale(:es) do
|
||||||
create(:poll, starts_at: starts_at, name: "Zzz...", name_fr: "Aaaah!")
|
create(:poll, starts_at: starts_at, name: "Zzz...", name_fr: "Aaaah!")
|
||||||
end
|
end
|
||||||
poll4 = Globalize.with_locale(:es) do
|
poll4 = I18n.with_locale(:es) do
|
||||||
create(:poll, starts_at: starts_at, name: "Bravo")
|
create(:poll, starts_at: starts_at, name: "Bravo")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -32,10 +32,7 @@ RSpec.describe Poll::Question, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "locale with non-underscored name" do
|
context "locale with non-underscored name" do
|
||||||
before do
|
before { I18n.locale = :"pt-BR" }
|
||||||
I18n.locale = :"pt-BR"
|
|
||||||
Globalize.locale = I18n.locale
|
|
||||||
end
|
|
||||||
|
|
||||||
it "correctly creates a translation" do
|
it "correctly creates a translation" do
|
||||||
poll_question.copy_attributes_from_proposal(proposal)
|
poll_question.copy_attributes_from_proposal(proposal)
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ RSpec.configure do |config|
|
|||||||
config.before do |example|
|
config.before do |example|
|
||||||
DatabaseCleaner.strategy = :transaction
|
DatabaseCleaner.strategy = :transaction
|
||||||
I18n.locale = :en
|
I18n.locale = :en
|
||||||
Globalize.locale = I18n.locale
|
Globalize.locale = nil
|
||||||
Globalize.set_fallbacks_to_all_available_locales
|
Globalize.set_fallbacks_to_all_available_locales
|
||||||
load Rails.root.join("db", "seeds.rb").to_s
|
load Rails.root.join("db", "seeds.rb").to_s
|
||||||
Setting["feature.user.skip_verification"] = nil
|
Setting["feature.user.skip_verification"] = nil
|
||||||
|
|||||||
Reference in New Issue
Block a user