Add controller tests for switch_locale
This way it'll be easier to change it while checking we haven't broken existing behavior. While writing the tests, I noticed we were sometimes storing a symbol in the session while sometimes we were storing a string. So we're adding a `to_s` call so we always store a string in the session.
This commit is contained in:
@@ -19,5 +19,13 @@ describe SubscriptionsController do
|
||||
expect(response).to redirect_to "/"
|
||||
expect(flash[:alert]).to eq "No tienes permiso para acceder a esta página."
|
||||
end
|
||||
|
||||
it "uses the user locale where there's no locale in the parameters" do
|
||||
create(:user, locale: "es", subscriptions_token: "mytoken")
|
||||
|
||||
get :edit, params: { token: "mytoken" }
|
||||
|
||||
expect(session[:locale]).to eq "es"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user