summaryrefslogtreecommitdiff
path: root/tests/generic_relations_regress
diff options
context:
space:
mode:
authorMorgan Wahl <morgan@addgene.org>2017-12-05 16:08:50 -0500
committerTim Graham <timograham@gmail.com>2017-12-08 14:06:28 -0500
commita9e5ac823df8ba8b786b6450c967ca378c008d0e (patch)
tree7fec12bc3d690361d2348b3e3dd01d692fa1e4ee /tests/generic_relations_regress
parent81abece192923d1ec9b1dca91bdb3393e1a07037 (diff)
Refs #28856 -- Added test for caching of a GenericForeignKey pointing to a model that uses more than one level of MTI.
Forwardport of test and release notes of 35222035029863f95769e2e59beeeb953d125689 from stable/1.11.x
Diffstat (limited to 'tests/generic_relations_regress')
-rw-r--r--tests/generic_relations_regress/models.py5
-rw-r--r--tests/generic_relations_regress/tests.py12
2 files changed, 14 insertions, 3 deletions
diff --git a/tests/generic_relations_regress/models.py b/tests/generic_relations_regress/models.py
index 2011ea14b9..c9572eb961 100644
--- a/tests/generic_relations_regress/models.py
+++ b/tests/generic_relations_regress/models.py
@@ -38,6 +38,11 @@ class Restaurant(Place):
return "Restaurant: %s" % self.name
+class Cafe(Restaurant):
+ def __str__(self):
+ return "Cafe: %s" % self.name
+
+
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 cfac484053..91158d8198 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):
"""