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:
Javi Martín
2024-05-22 00:01:18 +02:00
parent a2177b4575
commit 3e13f93ebd
6 changed files with 110 additions and 4 deletions

View File

@@ -46,7 +46,7 @@ class ApplicationController < ActionController::Base
current_user.update(locale: locale)
end
session[:locale] = locale
session[:locale] = locale.to_s
I18n.with_locale(locale, &action)
end