Note that, for everything to work consistently, we need to make sure that the default locale is one of the available locales. Also note that we aren't overwriting the `#save ` method set by globalize. I didn't feel too comfortable changing a monkey-patch which ideally shouldn't be there in the first place, I haven't found a case where `Globalize.locale` is `nil` (since it defaults to `I18n.locale`, which should never be `nil`), so using `I18n.default_locale` probably doesn't affect us.
27 lines
701 B
Ruby
27 lines
701 B
Ruby
require "rails_helper"
|
|
|
|
describe SearchDictionarySelector do
|
|
context "from I18n default locale" do
|
|
before { allow(subject).to receive(:call).and_call_original }
|
|
|
|
it "returns correct dictionary for simple locale" do
|
|
Setting["locales.default"] = "es"
|
|
|
|
expect(subject.call).to eq("spanish")
|
|
end
|
|
|
|
it "returns correct dictionary for compound locale" do
|
|
Setting["locales.default"] = "pt-BR"
|
|
|
|
expect(subject.call).to eq("portuguese")
|
|
end
|
|
|
|
it "returns simple for unsupported locale" do
|
|
allow(I18n).to receive(:available_locales).and_return(%i[en pl])
|
|
Setting["locales.default"] = "pl"
|
|
|
|
expect(subject.call).to eq("simple")
|
|
end
|
|
end
|
|
end
|