summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHasan Ramezani <hasan.r67@gmail.com>2019-08-30 10:28:18 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-09-23 11:45:33 +0200
commit2362f2726558dd0cc6e447878545dd3ddbd9b633 (patch)
tree92bf0ca38ac697c895af7405e0c8b15374187e87 /tests
parent368832e80308c15df7082ea4c42a2381529b4471 (diff)
[3.0.x] Fixed #13296 -- Fixed ordering by Options.order_with_respect_to after deleting objects.
Thanks Simon Meers for the original patch. Backport of f97bbad908df128189eff77d98af9a25ed1ecf23 from master
Diffstat (limited to 'tests')
-rw-r--r--tests/order_with_respect_to/base_tests.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/order_with_respect_to/base_tests.py b/tests/order_with_respect_to/base_tests.py
index be67b068de..a99b632436 100644
--- a/tests/order_with_respect_to/base_tests.py
+++ b/tests/order_with_respect_to/base_tests.py
@@ -87,3 +87,17 @@ class BaseOrderWithRespectToTests:
self.Post.objects.create(title="2.1", parent=p2)
p1_3 = self.Post.objects.create(title="1.3", parent=p1)
self.assertSequenceEqual(p1.get_post_order(), [p1_1.pk, p1_2.pk, p1_3.pk])
+
+ def test_delete_and_insert(self):
+ q1 = self.Question.objects.create(text='What is your favorite color?')
+ q2 = self.Question.objects.create(text='What color is it?')
+ a1 = self.Answer.objects.create(text='Blue', question=q1)
+ a2 = self.Answer.objects.create(text='Red', question=q1)
+ a3 = self.Answer.objects.create(text='Green', question=q1)
+ a4 = self.Answer.objects.create(text='Yellow', question=q1)
+ self.assertSequenceEqual(q1.answer_set.all(), [a1, a2, a3, a4])
+ a3.question = q2
+ a3.save()
+ a1.delete()
+ new_answer = self.Answer.objects.create(text='Black', question=q1)
+ self.assertSequenceEqual(q1.answer_set.all(), [a2, a4, new_answer])