mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-13 04:00:21 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user