Allow different default locales per tenant

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.
This commit is contained in:
Javi Martín
2024-03-04 20:03:25 +01:00
parent 722e50a669
commit 6de4737b70
22 changed files with 156 additions and 26 deletions

View File

@@ -23,9 +23,11 @@ describe ApplicationController do
describe "#switch_locale" do
it "uses the default locale by default" do
Setting["locales.default"] = "pt-BR"
get :index
expect(response.body).to eq "en"
expect(response.body).to eq "pt-BR"
end
it "uses the locale in the parameters when it's there" do

View File

@@ -34,9 +34,11 @@ describe Management::BaseController do
describe "#switch_locale" do
it "uses the default locale by default" do
Setting["locales.default"] = "pt-BR"
get :index
expect(response.body).to eq "en"
expect(response.body).to eq "pt-BR"
end
it "uses the locale in the parameters when it's there" do

View File

@@ -29,13 +29,14 @@ describe SubscriptionsController do
end
it "only accepts enabled locales" do
Setting["locales.enabled"] = "en nl"
Setting["locales.default"] = "fr"
Setting["locales.enabled"] = "fr nl"
create(:user, locale: "es", subscriptions_token: "mytoken")
get :edit, params: { token: "mytoken" }
expect(session[:locale]).to eq "en"
expect(session[:locale]).to eq "fr"
end
end
end