allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject [3/7] allura git commit: [#8020] ticket:874 added tests for moderation
Date Thu, 24 Dec 2015 14:33:56 GMT
[#8020] ticket:874 added tests for moderation


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/d47f465b
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/d47f465b
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/d47f465b

Branch: refs/heads/ib/8020a
Commit: d47f465b1798d8e3bf3ce5a25513b2a1bf617ec1
Parents: 10a6833
Author: DeV1doR <dev1dor@ukr.net>
Authored: Thu Dec 10 19:22:04 2015 +0200
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Wed Dec 23 12:48:00 2015 +0200

----------------------------------------------------------------------
 Allura/allura/controllers/discuss.py            |  4 +--
 Allura/allura/lib/widgets/discuss.py            |  2 +-
 Allura/allura/tests/functional/test_discuss.py  | 36 ++++++++++++++++++++
 .../tests/functional/test_forum.py              | 12 -------
 4 files changed, 39 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/d47f465b/Allura/allura/controllers/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/discuss.py b/Allura/allura/controllers/discuss.py
index 13f3921..818cc10 100644
--- a/Allura/allura/controllers/discuss.py
+++ b/Allura/allura/controllers/discuss.py
@@ -441,8 +441,8 @@ class ModerationController(BaseController):
         if flag:
             query['flags'] = {'$gte': int(flag)}
         if username:
-            filtered_user = User.query.get(username=username)
-            query['author_id'] = getattr(filtered_user, '_id', None)
+            filtered_user = User.by_username(username)
+            query['author_id'] = filtered_user._id if filtered_user else None
         q = self.PostModel.query.find(query)
         count = q.count()
         limit, page, start = g.handle_paging(limit, page or 0, default=50)

http://git-wip-us.apache.org/repos/asf/allura/blob/d47f465b/Allura/allura/lib/widgets/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/discuss.py b/Allura/allura/lib/widgets/discuss.py
index 62adb16..94310e2 100644
--- a/Allura/allura/lib/widgets/discuss.py
+++ b/Allura/allura/lib/widgets/discuss.py
@@ -124,7 +124,7 @@ class PostFilter(ff.ForgeForm):
                         css_class='text',
                         if_missing=0),
             ew.InputField(name='username',
-                          label='Show post filtered by (username)'),
+                          label='Show post filtered by username'),
             ew.SubmitButton(label='Filter Posts')
         ])
     ]

http://git-wip-us.apache.org/repos/asf/allura/blob/d47f465b/Allura/allura/tests/functional/test_discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_discuss.py b/Allura/allura/tests/functional/test_discuss.py
index fb8a08b..d70664b 100644
--- a/Allura/allura/tests/functional/test_discuss.py
+++ b/Allura/allura/tests/functional/test_discuss.py
@@ -172,6 +172,42 @@ class TestDiscuss(TestDiscussBase):
         assert M.Post.query.find().count() == 1
         assert M.Post.query.find({'deleted': False}).count() == 0
 
+    def test_user_filter(self):
+        r = self._make_post('Test post')
+        post_link = str(
+            r.html.find('div', {'class': 'edit_post_form reply'}).find('form')['action'])
+        self.app.post(post_link + 'moderate', params=dict(spam='spam'))
+        post = M.Post.query.find().first()
+        post_username = post.author().username
+        moderate_link = '/p/test/wiki/_discuss/moderate'
+
+        # no filter
+        r_no_filtered = self.app.get(
+            moderate_link,
+            params=dict(
+                status=post.status
+            ))
+        assert r_no_filtered.html.tbody.findAll('tr') != []
+
+        # filter with existing user
+        r_filtered = self.app.get(
+            moderate_link,
+            params=dict(
+                username=post_username,
+                status=post.status
+            ))
+        assert r_filtered.html.tbody.findAll('tr') != []
+        assert post_username in r_filtered.html.tbody.findAll('td')[-5].string
+
+        # filter without existing user
+        r_bad_filtered = self.app.get(
+            moderate_link,
+            params=dict(
+                username='bad_filtered_user',
+                status=post.status
+            ))
+        assert r_bad_filtered.html.tbody.findAll('tr') == []
+
     @patch.object(M.Thread, 'is_spam')
     def test_feed_does_not_include_comments_held_for_moderation(self, is_spam):
         is_spam.return_value = True

http://git-wip-us.apache.org/repos/asf/allura/blob/d47f465b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
index a91b0c4..2e3ddaa 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
@@ -415,18 +415,6 @@ class TestForum(TestController):
         input_field = r.html.fieldset.find('input', {'value': username})
         assert input_field is not None
 
-        username = 341
-        r = self.app.get(
-            '/discussion/testforum/moderate?username=%s' % username)
-        input_field = r.html.fieldset.find('input', {'value': username})
-        assert input_field is not None
-
-        username = 123.43523
-        r = self.app.get(
-            '/discussion/testforum/moderate?username=%s' % username)
-        input_field = r.html.fieldset.find('input', {'value': username})
-        assert input_field is not None
-
         username = None
         r = self.app.get(
             '/discussion/testforum/moderate?username=%s' % username)


Mime
View raw message