summaryrefslogtreecommitdiff
path: root/tests/contenttypes_tests/tests.py
diff options
context:
space:
mode:
authorThomas Sorrel <thomas@pandeiro.fr>2014-03-02 21:46:51 +0100
committerBaptiste Mispelon <bmispelon@gmail.com>2014-03-03 22:57:06 +0100
commit53c576452e2e8feef857cd67a5c17f9159d95eb6 (patch)
tree85e1a9f0fb60994a4743399684e4b65bd806bd9b /tests/contenttypes_tests/tests.py
parent7bbb6958dcb6a450f926e5bb49b07391f801aef1 (diff)
Fixed #16727 -- Added protocol-relative URL support to contenttypes.views.shortcut.
Diffstat (limited to 'tests/contenttypes_tests/tests.py')
-rw-r--r--tests/contenttypes_tests/tests.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/contenttypes_tests/tests.py b/tests/contenttypes_tests/tests.py
index af2cedd8b3..085ad2ec89 100644
--- a/tests/contenttypes_tests/tests.py
+++ b/tests/contenttypes_tests/tests.py
@@ -12,7 +12,7 @@ from django.test import TestCase
from django.test.utils import override_settings
from django.utils.encoding import force_str
-from .models import Author, Article
+from .models import Author, Article, SchemeIncludedURL
class ContentTypesViewsTests(TestCase):
@@ -27,6 +27,19 @@ class ContentTypesViewsTests(TestCase):
self.assertRedirects(response, 'http://testserver%s' % obj.get_absolute_url(),
status_code=302, target_status_code=404)
+ def test_shortcut_with_absolute_url_including_scheme(self):
+ """
+ Can view a shortcut when object's get_absolute_url returns a full URL
+ the tested URLs are in fixtures/testdata.json :
+ "http://...", "https://..." and "//..."
+ """
+ for obj in SchemeIncludedURL.objects.all():
+ short_url = '/shortcut/%s/%s/' % (ContentType.objects.get_for_model(SchemeIncludedURL).id, obj.pk)
+ response = self.client.get(short_url)
+ self.assertRedirects(response, obj.get_absolute_url(),
+ status_code=302,
+ fetch_redirect_response=False)
+
def test_shortcut_no_absolute_url(self):
"Shortcuts for an object that has no get_absolute_url method raises 404"
for obj in Article.objects.all():