incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [6/7] git commit: [#5571] Fixed paging issue from comments marked as spam
Date Wed, 22 May 2013 22:31:46 GMT
[#5571] Fixed paging issue from comments marked as spam

Signed-off-by: Cory Johns <cjohns@slashdotmedia.com>


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

Branch: refs/heads/master
Commit: 7af81ddef820aabee7d5e39436a10519bd82c850
Parents: 6624f69
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Wed May 22 21:49:44 2013 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Wed May 22 21:49:44 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/discuss.py               |    3 ++-
 Allura/allura/tests/model/test_discussion.py |   19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7af81dde/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index b1102e3..f04ba47 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -215,7 +215,8 @@ class Thread(Artifact, ActivityObject):
     def post_count(self):
         return Post.query.find(dict(
                 discussion_id=self.discussion_id,
-                thread_id=self._id)).count()
+                thread_id=self._id,
+                status={'$in': ['ok', 'pending']})).count()
 
     def primary(self):
         if self.ref is None:

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7af81dde/Allura/allura/tests/model/test_discussion.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_discussion.py b/Allura/allura/tests/model/test_discussion.py
index 7d64589..ec23e3b 100644
--- a/Allura/allura/tests/model/test_discussion.py
+++ b/Allura/allura/tests/model/test_discussion.py
@@ -441,3 +441,22 @@ def test_thread_subject_not_included_in_text_checked(spam_checker):
     post = t.post('Hello')
     spam_checker.check.assert_called_once()
     assert_equal(spam_checker.check.call_args[0][0], 'Hello')
+
+
+def test_post_count():
+    d = M.Discussion(shortname='test', name='test')
+    t = M.Thread(discussion_id=d._id, subject='Test Thread')
+    p1 = M.Post(discussion_id=d._id, thread_id=t._id, status='spam')
+    p2 = M.Post(discussion_id=d._id, thread_id=t._id, status='ok')
+    p3 = M.Post(discussion_id=d._id, thread_id=t._id, status='pending')
+    ThreadLocalORMSession.flush_all()
+    assert_equal(t.post_count, 2)
+
+
+@mock.patch('allura.controllers.discuss.g.spam_checker')
+def test_spam_num_replies(spam_checker):
+    d = M.Discussion(shortname='test', name='test')
+    t = M.Thread(discussion_id=d._id, subject='Test Thread', num_replies=2)
+    p1 = M.Post(discussion_id=d._id, thread_id=t._id, status='spam')
+    p1.spam()
+    assert_equal(t.num_replies, 1)


Mime
View raw message