summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/admin_views/tests.py11
-rw-r--r--tests/templates/custom_admin/index.html2
2 files changed, 12 insertions, 1 deletions
diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
index 1e3b334221..a70016d540 100644
--- a/tests/regressiontests/admin_views/tests.py
+++ b/tests/regressiontests/admin_views/tests.py
@@ -236,8 +236,19 @@ class AdminViewPermissionsTest(TestCase):
request = self.client.get('/test_admin/admin/')
self.assertTemplateUsed(request, 'custom_admin/index.html')
self.assert_('Hello from a custom index template' in request.content)
+
+ # Finally, using monkey patching check we can inject custom_context arguments in to index
+ original_index = admin.site.index
+ def index(*args, **kwargs):
+ kwargs['extra_context'] = {'foo': '*bar*'}
+ return original_index(*args, **kwargs)
+ admin.site.index = index
+ request = self.client.get('/test_admin/admin/')
+ self.assertTemplateUsed(request, 'custom_admin/index.html')
+ self.assert_('Hello from a custom index template *bar*' in request.content)
self.client.get('/test_admin/admin/logout/')
+ del admin.site.index # Resets to using the original
admin.site.login_template = None
admin.site.index_template = None
diff --git a/tests/templates/custom_admin/index.html b/tests/templates/custom_admin/index.html
index d52033ee2d..75b6ca3d18 100644
--- a/tests/templates/custom_admin/index.html
+++ b/tests/templates/custom_admin/index.html
@@ -1,6 +1,6 @@
{% extends "admin/index.html" %}
{% block content %}
-Hello from a custom index template
+Hello from a custom index template {{ foo }}
{{ block.super }}
{% endblock %}