Refactor locale with around method

This commit is contained in:
Sebastian Serth
2021-06-25 15:42:21 +02:00
parent e7cf4ef5db
commit 1b71163a77
3 changed files with 19 additions and 10 deletions

View File

@ -59,6 +59,8 @@ describe ApplicationController do
context "with a 'locale' value in the session" do
it 'sets this locale' do
session[:locale] = locale
# The around block first sets the default language and then the language requested
expect(I18n).to receive(:locale=).with(I18n.default_locale)
expect(I18n).to receive(:locale=).with(locale)
get :welcome
end
@ -67,7 +69,7 @@ describe ApplicationController do
context "without a 'locale' value in the session" do
it 'sets the default locale' do
expect(session[:locale]).to be_blank
expect(I18n).to receive(:locale=).with(I18n.default_locale)
expect(I18n).to receive(:locale=).with(I18n.default_locale).at_least(:once)
get :welcome
end
end