summaryrefslogtreecommitdiff
path: root/tests/admin_docs
diff options
context:
space:
mode:
authorPaul Donohue <git@PaulSD.com>2018-04-08 13:35:24 -0400
committerTim Graham <timograham@gmail.com>2018-04-12 13:11:08 -0400
commit33a0b7ac815588ed92dca215e153390af8bdbdda (patch)
tree151047d74bb30076489c6b1b846ede5826c161a2 /tests/admin_docs
parentee17bb8a67a9e7e688da6e6f4b3be1b3a69c09b0 (diff)
downloaddjango-33a0b7ac815588ed92dca215e153390af8bdbdda.tar.gz
Fixed #29296 -- Fixed crashes in admindocs when a view is a callable object.
Diffstat (limited to 'tests/admin_docs')
-rw-r--r--tests/admin_docs/test_middleware.py5
-rw-r--r--tests/admin_docs/test_views.py6
-rw-r--r--tests/admin_docs/urls.py2
-rw-r--r--tests/admin_docs/views.py5
4 files changed, 18 insertions, 0 deletions
diff --git a/tests/admin_docs/test_middleware.py b/tests/admin_docs/test_middleware.py
index 8a818e15d1..ab53716481 100644
--- a/tests/admin_docs/test_middleware.py
+++ b/tests/admin_docs/test_middleware.py
@@ -40,3 +40,8 @@ class XViewMiddlewareTest(TestDataMixin, AdminDocsTestCase):
user.save()
response = self.client.head('/xview/class/')
self.assertNotIn('X-View', response)
+
+ def test_callable_object_view(self):
+ self.client.force_login(self.superuser)
+ response = self.client.head('/xview/callable_object/')
+ self.assertEqual(response['X-View'], 'admin_docs.views.XViewCallableObject')
diff --git a/tests/admin_docs/test_views.py b/tests/admin_docs/test_views.py
index be69799d70..c55891a3c0 100644
--- a/tests/admin_docs/test_views.py
+++ b/tests/admin_docs/test_views.py
@@ -51,6 +51,12 @@ class AdminDocViewTests(TestDataMixin, AdminDocsTestCase):
)
self.assertContains(response, 'Views by namespace test')
self.assertContains(response, 'Name: <code>test:func</code>.')
+ self.assertContains(
+ response,
+ '<h3><a href="/admindocs/views/admin_docs.views.XViewCallableObject/">'
+ '/xview/callable_object_without_xview/</a></h3>',
+ html=True,
+ )
def test_view_index_with_method(self):
"""
diff --git a/tests/admin_docs/urls.py b/tests/admin_docs/urls.py
index 0bcdee4b4b..67c72b249c 100644
--- a/tests/admin_docs/urls.py
+++ b/tests/admin_docs/urls.py
@@ -13,4 +13,6 @@ urlpatterns = [
url(r'^', include(ns_patterns, namespace='test')),
url(r'^xview/func/$', views.xview_dec(views.xview)),
url(r'^xview/class/$', views.xview_dec(views.XViewClass.as_view())),
+ url(r'^xview/callable_object/$', views.xview_dec(views.XViewCallableObject())),
+ url(r'^xview/callable_object_without_xview/$', views.XViewCallableObject()),
]
diff --git a/tests/admin_docs/views.py b/tests/admin_docs/views.py
index 31d253f7e2..21fe382bba 100644
--- a/tests/admin_docs/views.py
+++ b/tests/admin_docs/views.py
@@ -13,3 +13,8 @@ def xview(request):
class XViewClass(View):
def get(self, request):
return HttpResponse()
+
+
+class XViewCallableObject(View):
+ def __call__(self, request):
+ return HttpResponse()