summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-04-02 10:35:33 -0400
committerTim Graham <timograham@gmail.com>2016-04-02 10:35:33 -0400
commitd2569f89f28883d07ede0e44a0a69ae678d3b35f (patch)
treede95ca89c52894f4fa10ce6e177d6f29d1c8ce7b /tests
parent55c843f2ef702b4ebcd024920d4193bdf4c3fe07 (diff)
Fixed #26428 -- Added support for relative path redirects in assertRedirects().
Thanks Trac alias master for the report and review.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_client/tests.py8
-rw-r--r--tests/test_client/urls.py2
2 files changed, 10 insertions, 0 deletions
diff --git a/tests/test_client/tests.py b/tests/test_client/tests.py
index 6a6b5d31a2..43f6d84a65 100644
--- a/tests/test_client/tests.py
+++ b/tests/test_client/tests.py
@@ -623,6 +623,14 @@ class ClientTest(TestCase):
# Check some response details
self.assertContains(response, 'This is a test')
+ def test_relative_redirect(self):
+ response = self.client.get('/accounts/')
+ self.assertRedirects(response, '/accounts/login/')
+
+ def test_relative_redirect_no_trailing_slash(self):
+ response = self.client.get('/accounts/no_trailing_slash')
+ self.assertRedirects(response, '/accounts/login/')
+
def test_mass_mail_sending(self):
"Test that mass mail is redirected to a dummy outbox during test setup"
diff --git a/tests/test_client/urls.py b/tests/test_client/urls.py
index f605448b5b..a7b0ed310d 100644
--- a/tests/test_client/urls.py
+++ b/tests/test_client/urls.py
@@ -34,6 +34,8 @@ urlpatterns = [
url(r'^nesting_exception_view/$', views.nesting_exception_view),
url(r'^django_project_redirect/$', views.django_project_redirect),
+ url(r'^accounts/$', RedirectView.as_view(url='login/')),
+ url(r'^accounts/no_trailing_slash$', RedirectView.as_view(url='login/')),
url(r'^accounts/login/$', auth_views.login, {'template_name': 'login.html'}),
url(r'^accounts/logout/$', auth_views.logout),
]