summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2008-12-08 04:53:34 +0000
committerAdrian Holovaty <adrian@holovaty.com>2008-12-08 04:53:34 +0000
commitb76d7c1decb04cdb7ec363cd589f273952ab789a (patch)
tree2fa7743da37cca1ae94cfaaa21f11d9e9c9ca935 /tests
parente9b90d98998da48d4ac18aabe135fa4200547be5 (diff)
Added a 'permanent' argument the simple.redirect_to() generic view. It's True by default, to match existing behavior. If set to False, the redirect will be a 302 instead of a 301. This is technically backwards-incompatible if you were using the redirect_to generic view with a format-string key called 'permanent', which is highly, highly unlikely.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9594 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/modeltests/test_client/models.py6
-rw-r--r--tests/modeltests/test_client/urls.py3
2 files changed, 8 insertions, 1 deletions
diff --git a/tests/modeltests/test_client/models.py b/tests/modeltests/test_client/models.py
index 2cca618b4e..b975d139c6 100644
--- a/tests/modeltests/test_client/models.py
+++ b/tests/modeltests/test_client/models.py
@@ -118,6 +118,12 @@ class ClientTest(TestCase):
# Check that the response was a 301 (permanent redirect) with absolute URI
self.assertRedirects(response, 'http://django.testserver/test_client/get_view/', status_code=301)
+ def test_temporary_redirect(self):
+ "GET a URL that does a non-permanent redirect"
+ response = self.client.get('/test_client/temporary_redirect_view/')
+ # Check that the response was a 302 (non-permanent redirect)
+ self.assertRedirects(response, 'http://testserver/test_client/get_view/', status_code=302)
+
def test_redirect_to_strange_location(self):
"GET a URL that redirects to a non-200 page"
response = self.client.get('/test_client/double_redirect_view/')
diff --git a/tests/modeltests/test_client/urls.py b/tests/modeltests/test_client/urls.py
index 0e511d7360..3c84a768a0 100644
--- a/tests/modeltests/test_client/urls.py
+++ b/tests/modeltests/test_client/urls.py
@@ -8,7 +8,8 @@ urlpatterns = patterns('',
(r'^header_view/$', views.view_with_header),
(r'^raw_post_view/$', views.raw_post_view),
(r'^redirect_view/$', views.redirect_view),
- (r'^permanent_redirect_view/$', redirect_to, { 'url': '/test_client/get_view/' }),
+ (r'^permanent_redirect_view/$', redirect_to, {'url': '/test_client/get_view/'}),
+ (r'^temporary_redirect_view/$', redirect_to, {'url': '/test_client/get_view/', 'permanent': False}),
(r'^double_redirect_view/$', views.double_redirect_view),
(r'^bad_view/$', views.bad_view),
(r'^form_view/$', views.form_view),