diff options
| author | Stas Rudakou <stas@garage22.net> | 2014-05-16 18:56:25 +0300 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2014-05-16 18:38:26 +0200 |
| commit | 75d2da797e100442d3573dfa7ae490972cea32d8 (patch) | |
| tree | 2716af87a8b3cdb56eef4efa43487f127a20e64c /tests/admin_views | |
| parent | bd45139d4e17304229da5464c907c614e64278d1 (diff) | |
[1.7.x] Fixed #22266 - quote PK before redirecting away from add_view (django.contrib.admin)
Backport of ebd70d4d00c252d5122c13906da5bddc8de0bce5 from master.
Diffstat (limited to 'tests/admin_views')
| -rw-r--r-- | tests/admin_views/tests.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index fbea1d49c7..21f1eb818c 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -1779,6 +1779,30 @@ class AdminViewStringPrimaryKeyTest(TestCase): args=(quote(self.pk),)) self.assertContains(response, '<a href="%s" class="historylink"' % expected_link) + def test_redirect_on_add_view_continue_button(self): + """As soon as an object is added using "Save and continue editing" + button, the user should be redirected to the object's change_view. + + In case primary key is a string containing some special characters + like slash or underscore, these characters must be escaped (see #22266) + """ + response = self.client.post( + '/test_admin/admin/admin_views/modelwithstringprimarykey/add/', + { + 'string_pk': '123/history', + "_continue": "1", # Save and continue editing + } + ) + + self.assertEqual(response.status_code, 302) # temporary redirect + self.assertEqual( + response['location'], + ( + 'http://testserver/test_admin/admin/admin_views/' + 'modelwithstringprimarykey/123_2Fhistory/' # PK is quoted + ) + ) + @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class SecureViewTests(TestCase): |
