summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMatthias Kestenholz <mk@feinheit.ch>2020-01-30 18:08:56 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-01-31 09:07:58 +0100
commit4e8d89020cca87fcf484eb6b6b514b4c9bfa592f (patch)
tree754224a36ca246ab1b3288bb3be0bd97cd41f5d8 /tests
parent8c0c0235b6a23a0d69cd77286d0212de90d4af44 (diff)
Fixed #31219 -- Fixed object deletion crash for nested protected related objects.
Diffstat (limited to 'tests')
-rw-r--r--tests/delete/tests.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/delete/tests.py b/tests/delete/tests.py
index 279788d2d3..1731342bc1 100644
--- a/tests/delete/tests.py
+++ b/tests/delete/tests.py
@@ -90,6 +90,17 @@ class OnDeleteTests(TestCase):
with self.assertRaisesMessage(ProtectedError, msg):
a.protect.delete()
+ def test_protect_path(self):
+ a = create_a('protect')
+ a.protect.p = P.objects.create()
+ a.protect.save()
+ msg = (
+ "Cannot delete some instances of model 'P' because they are "
+ "referenced through protected foreign keys: 'R.p'."
+ )
+ with self.assertRaisesMessage(ProtectedError, msg):
+ a.protect.p.delete()
+
def test_do_nothing(self):
# Testing DO_NOTHING is a bit harder: It would raise IntegrityError for a normal model,
# so we connect to pre_delete and set the fk to a known value.