summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMorgan Wahl <morgan@addgene.org>2017-12-05 16:08:50 -0500
committerMorgan Wahl <morgan@addgene.org>2017-12-07 09:34:54 -0500
commit35222035029863f95769e2e59beeeb953d125689 (patch)
treec4a9537b79c35340271e01e6de1463d6ed0983f7 /tests
parent1decd0197d241b27d54bb12eca04b7e89a9ccba6 (diff)
downloaddjango-35222035029863f95769e2e59beeeb953d125689.tar.gz
[1.11.x] Refs #28856 -- Fixed caching of a GenericForeignKey pointing to a model that uses more than one level of MTI.
Diffstat (limited to 'tests')
-rw-r--r--tests/generic_relations_regress/models.py6
-rw-r--r--tests/generic_relations_regress/tests.py12
2 files changed, 15 insertions, 3 deletions
diff --git a/tests/generic_relations_regress/models.py b/tests/generic_relations_regress/models.py
index 669e7b7186..5f3b2f849c 100644
--- a/tests/generic_relations_regress/models.py
+++ b/tests/generic_relations_regress/models.py
@@ -43,6 +43,12 @@ class Restaurant(Place):
@python_2_unicode_compatible
+class Cafe(Restaurant):
+ def __str__(self):
+ return "Cafe: %s" % self.name
+
+
+@python_2_unicode_compatible
class Address(models.Model):
street = models.CharField(max_length=80)
city = models.CharField(max_length=50)
diff --git a/tests/generic_relations_regress/tests.py b/tests/generic_relations_regress/tests.py
index e6d350aa5b..adb26f6883 100644
--- a/tests/generic_relations_regress/tests.py
+++ b/tests/generic_relations_regress/tests.py
@@ -5,9 +5,10 @@ from django.forms.models import modelform_factory
from django.test import TestCase, skipIfDBFeature
from .models import (
- A, Address, B, Board, C, CharLink, Company, Contact, Content, D, Developer,
- Guild, HasLinkThing, Link, Node, Note, OddRelation1, OddRelation2,
- Organization, Person, Place, Related, Restaurant, Tag, Team, TextLink,
+ A, Address, B, Board, C, Cafe, CharLink, Company, Contact, Content, D,
+ Developer, Guild, HasLinkThing, Link, Node, Note, OddRelation1,
+ OddRelation2, Organization, Person, Place, Related, Restaurant, Tag, Team,
+ TextLink,
)
@@ -53,6 +54,11 @@ class GenericRelationTests(TestCase):
CharLink.objects.create(content_object=restaurant)
charlink = CharLink.objects.latest('pk')
self.assertIs(charlink.content_object, charlink.content_object)
+ # If the model (Cafe) uses more than one level of multi-table inheritance.
+ cafe = Cafe.objects.create()
+ CharLink.objects.create(content_object=cafe)
+ charlink = CharLink.objects.latest('pk')
+ self.assertIs(charlink.content_object, charlink.content_object)
def test_q_object_or(self):
"""