Reset I18n.local for each spec

This avoids a locale setting leaking from one spec to another. It also
means that we don't have to reset the locale in individual specs.

Also:

- `cookies` is reset automatically and we don't need to do that.
- Removed some unused code (German number format and helper methods).
This commit is contained in:
Maikel Linke
2024-04-11 10:05:49 +10:00
parent b2172ef8d8
commit c2c7910357
5 changed files with 8 additions and 40 deletions

View File

@@ -48,16 +48,9 @@ describe UserRegistrationsController, type: :controller do
end
it "sets user.locale from cookie on create" do
original_i18n_locale = I18n.locale
original_locale_cookie = cookies[:locale]
# changes to +I18n.locale+ will only persist within the +with_locale+ block
I18n.with_locale(original_i18n_locale) do
cookies[:locale] = "pt"
post :create, xhr: true, params: { spree_user: user_params, use_route: :spree }
expect(assigns[:user].locale).to eq("pt")
cookies[:locale] = original_locale_cookie
end
cookies[:locale] = "pt"
post :create, xhr: true, params: { spree_user: user_params, use_route: :spree }
expect(assigns[:user].locale).to eq("pt")
end
end
end