1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Refs #15902 -- Made set_language() view always set the current language in a cookie.

The plan is to later deprecate/remove storing the language in the session.
This commit is contained in:
Claude Paroz
2017-12-02 13:00:30 +01:00
committed by Tim Graham
parent ccc25bfe4f
commit b3cd9fb18b
3 changed files with 23 additions and 14 deletions

View File

@@ -37,6 +37,12 @@ class SetLanguageTests(TestCase):
response = self.client.post('/i18n/setlang/', post_data, HTTP_REFERER='/i_should_not_be_used/')
self.assertRedirects(response, '/')
self.assertEqual(self.client.session[LANGUAGE_SESSION_KEY], lang_code)
# The language is set in a cookie.
language_cookie = self.client.cookies[settings.LANGUAGE_COOKIE_NAME]
self.assertEqual(language_cookie.value, lang_code)
self.assertEqual(language_cookie['domain'], '')
self.assertEqual(language_cookie['path'], '/')
self.assertEqual(language_cookie['max-age'], '')
def test_setlang_unsafe_next(self):
"""