From aea02ddfb7c610db9a7cb291b113d6e561d8eba9 Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Mon, 16 Mar 2015 21:55:44 +0000 Subject: Fixed #24490 -- Set LogEntry.change_message when adding an object. --- tests/admin_views/tests.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'tests/admin_views') diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 429f9d7b6c..7c299a4774 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -8,7 +8,7 @@ import unittest from django.contrib.admin import ModelAdmin from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME -from django.contrib.admin.models import DELETION, LogEntry +from django.contrib.admin.models import ADDITION, DELETION, LogEntry from django.contrib.admin.options import TO_FIELD_VAR from django.contrib.admin.templatetags.admin_static import static from django.contrib.admin.templatetags.admin_urls import add_preserved_filters @@ -1542,6 +1542,17 @@ class AdminViewPermissionsTest(TestCase): self.assertEqual(mail.outbox[0].subject, 'Greetings from a created object') self.client.get(reverse('admin:logout')) + # Check that the addition was logged correctly + addition_log = LogEntry.objects.all()[0] + new_article = Article.objects.last() + article_ct = ContentType.objects.get_for_model(Article) + self.assertEqual(addition_log.user_id, self.u2.pk) + self.assertEqual(addition_log.content_type_id, article_ct.pk) + self.assertEqual(addition_log.object_id, str(new_article.pk)) + self.assertEqual(addition_log.object_repr, "Døm ikke") + self.assertEqual(addition_log.action_flag, ADDITION) + self.assertEqual(addition_log.change_message, "Added.") + # Super can add too, but is redirected to the change list view self.client.get(self.index_url) self.client.post(login_url, self.super_login) -- cgit v1.3