DEV: Add i18n fallback specs (#11669)
Those fail on the buggy i18n release (1.8.6) and pass on 1.8.5, 1.8.7 (the revert release), and with the second stab at thread safety on the current master (63a79cb929
)
This commit is contained in:
parent
f6e87e1e5e
commit
9da9b2e1cc
|
@ -24,7 +24,6 @@ def is_yaml_compatible?(english, translated)
|
|||
end
|
||||
|
||||
describe "i18n integrity checks" do
|
||||
|
||||
it 'has an i18n key for each Trust Levels' do
|
||||
TrustLevel.all.each do |ts|
|
||||
expect(ts.name).not_to match(/translation missing/)
|
||||
|
@ -98,16 +97,46 @@ describe "i18n integrity checks" do
|
|||
end
|
||||
|
||||
unless path["transliterate"]
|
||||
|
||||
it "is compatible with english" do
|
||||
expect(is_yaml_compatible?(english_yaml, yaml)).to eq(true)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "fallbacks" do
|
||||
before do
|
||||
I18n.backend = I18n::Backend::DiscourseI18n.new
|
||||
I18n.fallbacks = I18n::Backend::FallbackLocaleList.new
|
||||
I18n.reload!
|
||||
I18n.init_accelerator!
|
||||
end
|
||||
|
||||
it "finds the fallback translation" do
|
||||
I18n.backend.store_translations(:en, test: "en test")
|
||||
|
||||
I18n.with_locale("pl_PL") do
|
||||
expect(I18n.t("test")).to eq("en test")
|
||||
end
|
||||
end
|
||||
|
||||
context "in a multi-threaded environment" do
|
||||
it "finds the fallback translation" do
|
||||
I18n.backend.store_translations(:en, test: "en test")
|
||||
|
||||
thread = Thread.new do
|
||||
I18n.with_locale("pl_PL") do
|
||||
expect(I18n.t("test")).to eq("en test")
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
thread.join
|
||||
ensure
|
||||
thread.exit
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue