summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBrian Rosner <brosner@gmail.com>2008-08-29 16:46:46 +0000
committerBrian Rosner <brosner@gmail.com>2008-08-29 16:46:46 +0000
commitcd0b65bcf79dc61481d94a415a1598bb510d21c9 (patch)
treebf4ae8cbaf3f07768fadbdc282ce363fea18f385 /tests
parentddf7d7ab0257c6a6dc9ea141cba4b437431a85d1 (diff)
Fixed #7982 -- Corrected ModelAdmin url dispatching to ensure it matching exactly what it needs and doesn't stomp on primary key space. 'add' is a lost cause for now. This originated from #6470. Thanks jdetaeye for the original patch and basith for providing test cases.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8704 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/admin_views/tests.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
index d16889f45a..56937d8462 100644
--- a/tests/regressiontests/admin_views/tests.py
+++ b/tests/regressiontests/admin_views/tests.py
@@ -458,6 +458,31 @@ class AdminViewStringPrimaryKeyTest(TestCase):
response = self.client.get('/test_admin/admin/admin_views/modelwithstringprimarykey/%s/delete/' % quote(self.pk))
should_contain = """<a href="../../%s/">%s</a>""" % (quote(self.pk), escape(self.pk))
self.assertContains(response, should_contain)
+
+ def test_url_conflicts_with_add(self):
+ "A model with a primary key that ends with add should be visible"
+ add_model = ModelWithStringPrimaryKey(id="i have something to add")
+ add_model.save()
+ response = self.client.get('/test_admin/admin/admin_views/modelwithstringprimarykey/%s/' % quote(add_model.pk))
+ should_contain = """<h1>Change model with string primary key</h1>"""
+ self.assertContains(response, should_contain)
+
+ def test_url_conflicts_with_delete(self):
+ "A model with a primary key that ends with delete should be visible"
+ delete_model = ModelWithStringPrimaryKey(id="delete")
+ delete_model.save()
+ response = self.client.get('/test_admin/admin/admin_views/modelwithstringprimarykey/%s/' % quote(delete_model.pk))
+ should_contain = """<h1>Change model with string primary key</h1>"""
+ self.assertContains(response, should_contain)
+
+ def test_url_conflicts_with_history(self):
+ "A model with a primary key that ends with history should be visible"
+ history_model = ModelWithStringPrimaryKey(id="history")
+ history_model.save()
+ response = self.client.get('/test_admin/admin/admin_views/modelwithstringprimarykey/%s/' % quote(history_model.pk))
+ should_contain = """<h1>Change model with string primary key</h1>"""
+ self.assertContains(response, should_contain)
+
class SecureViewTest(TestCase):
fixtures = ['admin-views-users.xml']