summaryrefslogtreecommitdiff
path: root/tests/admin_changelist
diff options
context:
space:
mode:
authorYair Chuchem <yairchu@gmail.com>2015-02-05 20:25:59 +0200
committerTim Graham <timograham@gmail.com>2015-03-20 08:32:25 -0400
commiteb5ebcc2d0b13737127e3478bced98a84962a5d0 (patch)
tree035612ee4b4f5e22151fdd7ca3c136a7b1b6ffcb /tests/admin_changelist
parent35b3158d52a5fe51d3b52aec1109a30a73c5abe9 (diff)
downloaddjango-eb5ebcc2d0b13737127e3478bced98a84962a5d0.tar.gz
Fixed #24285 -- Made for_user argument optional for {% get_admin_log %} tag
Diffstat (limited to 'tests/admin_changelist')
-rw-r--r--tests/admin_changelist/tests.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/admin_changelist/tests.py b/tests/admin_changelist/tests.py
index 2161c52f3e..7342e45830 100644
--- a/tests/admin_changelist/tests.py
+++ b/tests/admin_changelist/tests.py
@@ -3,11 +3,13 @@ from __future__ import unicode_literals
import datetime
from django.contrib import admin
+from django.contrib.admin.models import LogEntry
from django.contrib.admin.options import IncorrectLookupParameters
from django.contrib.admin.templatetags.admin_list import pagination
from django.contrib.admin.tests import AdminSeleniumWebDriverTestCase
from django.contrib.admin.views.main import ALL_VAR, SEARCH_VAR, ChangeList
from django.contrib.auth.models import User
+from django.contrib.contenttypes.models import ContentType
from django.core.urlresolvers import reverse
from django.template import Context, Template
from django.test import TestCase, override_settings
@@ -685,6 +687,24 @@ class AdminLogNodeTestCase(TestCase):
# it doesn't render any string.
self.assertEqual(template.render(context), '')
+ def test_get_admin_log_templatetag_no_user(self):
+ """
+ The {% get_admin_log %} tag should work without specifying a user.
+ """
+ user = User(username='jondoe', password='secret', email='super@example.com')
+ user.save()
+ ct = ContentType.objects.get_for_model(User)
+ LogEntry.objects.log_action(user.pk, ct.pk, user.pk, repr(user), 1)
+
+ t = Template(
+ '{% load log %}'
+ '{% get_admin_log 100 as admin_log %}'
+ '{% for entry in admin_log %}'
+ '{{ entry|safe }}'
+ '{% endfor %}'
+ )
+ self.assertEqual(t.render(Context({})), 'Added "<User: jondoe>".')
+
@override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'],
ROOT_URLCONF="admin_changelist.urls")