summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2010-12-04 11:20:30 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2010-12-04 11:20:30 +0000
commit324658ef265fb9a4c5cc695a4b0f560575048604 (patch)
tree31f9d8dfb5f609cebf27aa04093ed1f5c1c13f09 /tests
parentac91d5ef086f466c27e77157c67fe4f1df9b7557 (diff)
Fixed #14803 -- Corrected an inconsistency in redirection handling between old-style generic views and class-based views. Thanks to gg for the report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14808 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/generic_views/edit.py20
-rw-r--r--tests/regressiontests/generic_views/urls.py6
2 files changed, 25 insertions, 1 deletions
diff --git a/tests/regressiontests/generic_views/edit.py b/tests/regressiontests/generic_views/edit.py
index 2579b2af78..7991ef0d04 100644
--- a/tests/regressiontests/generic_views/edit.py
+++ b/tests/regressiontests/generic_views/edit.py
@@ -47,6 +47,14 @@ class CreateViewTests(TestCase):
self.assertRedirects(res, 'http://testserver/edit/authors/create/')
self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe>'])
+ def test_create_with_interpolated_redirect(self):
+ res = self.client.post('/edit/authors/create/interpolate_redirect/',
+ {'name': 'Randall Munroe', 'slug': 'randall-munroe'})
+ self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe>'])
+ self.assertEqual(res.status_code, 302)
+ pk = Author.objects.all()[0].pk
+ self.assertRedirects(res, 'http://testserver/edit/author/%d/update/' % pk)
+
def test_create_with_special_properties(self):
res = self.client.get('/edit/authors/create/special/')
self.assertEqual(res.status_code, 200)
@@ -145,6 +153,18 @@ class UpdateViewTests(TestCase):
self.assertRedirects(res, 'http://testserver/edit/authors/create/')
self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe (author of xkcd)>'])
+ def test_update_with_interpolated_redirect(self):
+ a = Author.objects.create(
+ name='Randall Munroe',
+ slug='randall-munroe',
+ )
+ res = self.client.post('/edit/author/%d/update/interpolate_redirect/' % a.pk,
+ {'name': 'Randall Munroe (author of xkcd)', 'slug': 'randall-munroe'})
+ self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe (author of xkcd)>'])
+ self.assertEqual(res.status_code, 302)
+ pk = Author.objects.all()[0].pk
+ self.assertRedirects(res, 'http://testserver/edit/author/%d/update/' % pk)
+
def test_update_with_special_properties(self):
a = Author.objects.create(
name='Randall Munroe',
diff --git a/tests/regressiontests/generic_views/urls.py b/tests/regressiontests/generic_views/urls.py
index 61f0387331..0643b400ff 100644
--- a/tests/regressiontests/generic_views/urls.py
+++ b/tests/regressiontests/generic_views/urls.py
@@ -51,6 +51,8 @@ urlpatterns = patterns('',
views.NaiveAuthorCreate.as_view()),
(r'^edit/authors/create/redirect/$',
views.NaiveAuthorCreate.as_view(success_url='/edit/authors/create/')),
+ (r'^edit/authors/create/interpolate_redirect/$',
+ views.NaiveAuthorCreate.as_view(success_url='/edit/author/%(id)d/update/')),
(r'^edit/authors/create/restricted/$',
views.AuthorCreateRestricted.as_view()),
(r'^edit/authors/create/$',
@@ -62,6 +64,8 @@ urlpatterns = patterns('',
views.NaiveAuthorUpdate.as_view()),
(r'^edit/author/(?P<pk>\d+)/update/redirect/$',
views.NaiveAuthorUpdate.as_view(success_url='/edit/authors/create/')),
+ (r'^edit/author/(?P<pk>\d+)/update/interpolate_redirect/$',
+ views.NaiveAuthorUpdate.as_view(success_url='/edit/author/%(id)d/update/')),
(r'^edit/author/(?P<pk>\d+)/update/$',
views.AuthorUpdate.as_view()),
(r'^edit/author/(?P<pk>\d+)/update/special/$',
@@ -185,4 +189,4 @@ urlpatterns = patterns('',
# Useful for testing redirects
(r'^accounts/login/$', 'django.contrib.auth.views.login')
-) \ No newline at end of file
+)