Skip to content

Commit

Permalink
Added test to demonstrate issue 11263 isn't there anymore.
Browse files Browse the repository at this point in the history
Thanks veena for the report and jaklaassen for the patch. Fixes #11263.
  • Loading branch information
ramiro committed Feb 2, 2013
1 parent 5f7eecd commit c4b6659
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions tests/modeltests/generic_relations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,7 @@ def get_query_set(self):
class Gecko(models.Model):
has_tail = models.BooleanField()
objects = GeckoManager()

# To test fix for #11263
class Rock(Mineral):
tags = generic.GenericRelation(TaggedItem)
12 changes: 11 additions & 1 deletion tests/modeltests/generic_relations/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.test import TestCase

from .models import (TaggedItem, ValuableTaggedItem, Comparison, Animal,
Vegetable, Mineral, Gecko)
Vegetable, Mineral, Gecko, Rock)


class GenericRelationsTests(TestCase):
Expand Down Expand Up @@ -231,6 +231,16 @@ def test_gfk_manager(self):
tag = TaggedItem.objects.create(content_object=tailless, tag="lizard")
self.assertEqual(tag.content_object, tailless)

def test_subclasses_with_gen_rel(self):
"""
Test that concrete model subclasses with generic relations work
correctly (ticket 11263).
"""
granite = Rock.objects.create(name='granite', hardness=5)
TaggedItem.objects.create(content_object=granite, tag="countertop")
self.assertEqual(Rock.objects.filter(tags__tag="countertop").count(), 1)


class CustomWidget(forms.TextInput):
pass

Expand Down

0 comments on commit c4b6659

Please sign in to comment.