summaryrefslogtreecommitdiff
path: root/tests/admin_views
diff options
context:
space:
mode:
authorAkshesh <aksheshdoshi@gmail.com>2016-03-21 16:20:30 +0530
committerTim Graham <timograham@gmail.com>2016-03-21 19:25:27 -0400
commit49ac10b4de03279da9d67aeac5cb8561fc055085 (patch)
tree7cee8e8415aa20531d1e3b93208812851a4baa41 /tests/admin_views
parentabf07355aa5d85f4bb4dd9912d70fa62511fa40f (diff)
Fixed #26235 -- Handled ProtectedError in a POST to admin's delete_view().
Diffstat (limited to 'tests/admin_views')
-rw-r--r--tests/admin_views/tests.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py
index a6b77dd44b..a0c7e51c2b 100644
--- a/tests/admin_views/tests.py
+++ b/tests/admin_views/tests.py
@@ -2062,6 +2062,18 @@ class AdminViewDeletedObjectsTest(TestCase):
'<li>Answer: <a href="%s">Yes.</a></li>' % reverse('admin:admin_views_answer_change', args=(a2.pk,))
)
+ def test_post_delete_protected(self):
+ """
+ A POST request to delete protected objects should display the page
+ which says the deletion is prohibited.
+ """
+ q = Question.objects.create(question='Why?')
+ a = Answer.objects.create(question=q, answer='Because.')
+
+ response = self.client.post(reverse('admin:admin_views_question_delete', args=(q.pk,)), {'post': 'yes'})
+ self.assertEqual(Question.objects.count(), 1)
+ self.assertContains(response, "would require deleting the following protected related objects")
+
def test_not_registered(self):
should_contain = """<li>Secret hideout: underground bunker"""
response = self.client.get(reverse('admin:admin_views_villain_delete', args=(self.v1.pk,)))