summaryrefslogtreecommitdiff
path: root/tests/regressiontests/comment_tests
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2009-10-23 19:22:31 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2009-10-23 19:22:31 +0000
commit8be1bb2268b09e5ea33ccf07d602feed8b075146 (patch)
tree2da3dcacb5e5d313f2486dd2aaa51f5dc45d2931 /tests/regressiontests/comment_tests
parent162fade2b70d56ee5cbc3a57d1863f3c989775d6 (diff)
Fixed #11625: added comment moderation via admin actions.
This is BACKWARDS INCOMPATIBLE if you were using the completely undocumented moderation view from 1.1. That view's been removed in favor of the admin actions. Thanks, Thejaswi Puthraya. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11639 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/comment_tests')
-rw-r--r--tests/regressiontests/comment_tests/tests/moderation_view_tests.py44
-rw-r--r--tests/regressiontests/comment_tests/urls_admin.py8
2 files changed, 29 insertions, 23 deletions
diff --git a/tests/regressiontests/comment_tests/tests/moderation_view_tests.py b/tests/regressiontests/comment_tests/tests/moderation_view_tests.py
index b9eadd78b4..61e90bc220 100644
--- a/tests/regressiontests/comment_tests/tests/moderation_view_tests.py
+++ b/tests/regressiontests/comment_tests/tests/moderation_view_tests.py
@@ -159,31 +159,29 @@ class ApproveViewTests(CommentTestCase):
response = self.client.get("/approved/", data={"c":pk})
self.assertTemplateUsed(response, "comments/approved.html")
+class AdminActionsTests(CommentTestCase):
+ urls = "regressiontests.comment_tests.urls_admin"
+
+ def setUp(self):
+ super(AdminActionsTests, self).setUp()
+
+ # Make "normaluser" a moderator
+ u = User.objects.get(username="normaluser")
+ u.is_staff = True
+ u.user_permissions.add(Permission.objects.get(codename='add_comment'))
+ u.user_permissions.add(Permission.objects.get(codename='change_comment'))
+ u.user_permissions.add(Permission.objects.get(codename='delete_comment'))
+ u.save()
-class ModerationQueueTests(CommentTestCase):
-
- def testModerationQueuePermissions(self):
- """Only moderators can view the moderation queue"""
+ def testActionsNonModerator(self):
+ comments = self.createSomeComments()
self.client.login(username="normaluser", password="normaluser")
- response = self.client.get("/moderate/")
- self.assertEqual(response["Location"], "http://testserver/accounts/login/?next=/moderate/")
-
- makeModerator("normaluser")
- response = self.client.get("/moderate/")
- self.assertEqual(response.status_code, 200)
+ response = self.client.get("/admin/comments/comment/")
+ self.assertEquals("approve_comments" in response.content, False)
- def testModerationQueueContents(self):
- """Moderation queue should display non-public, non-removed comments."""
- c1, c2, c3, c4 = self.createSomeComments()
+ def testActionsModerator(self):
+ comments = self.createSomeComments()
makeModerator("normaluser")
self.client.login(username="normaluser", password="normaluser")
-
- c1.is_public = c2.is_public = False
- c1.save(); c2.save()
- response = self.client.get("/moderate/")
- self.assertEqual(list(response.context[0]["comments"]), [c1, c2])
-
- c2.is_removed = True
- c2.save()
- response = self.client.get("/moderate/")
- self.assertEqual(list(response.context[0]["comments"]), [c1])
+ response = self.client.get("/admin/comments/comment/")
+ self.assertEquals("approve_comments" in response.content, True)
diff --git a/tests/regressiontests/comment_tests/urls_admin.py b/tests/regressiontests/comment_tests/urls_admin.py
new file mode 100644
index 0000000000..9e43d34865
--- /dev/null
+++ b/tests/regressiontests/comment_tests/urls_admin.py
@@ -0,0 +1,8 @@
+from django.conf.urls.defaults import *
+from django.contrib import admin
+
+admin.autodiscover()
+
+urlpatterns = patterns('',
+ (r'^admin/', include(admin.site.urls)),
+)