allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [1/12] git commit: [#5382] Make sure new topics get spam checked
Date Wed, 05 Dec 2012 20:01:50 GMT
Updated Branches:
  refs/heads/tv/5382 ecb8f931b -> 71931d173 (forced update)


[#5382] Make sure new topics get spam checked


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

Branch: refs/heads/tv/5382
Commit: 71931d173ed0ed70ab8fdac88429fde069aa01eb
Parents: 130a037
Author: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Authored: Wed Dec 5 20:00:32 2012 +0000
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Wed Dec 5 20:00:32 2012 +0000

----------------------------------------------------------------------
 .../forgediscussion/controllers/root.py            |    1 +
 .../forgediscussion/tests/functional/test_forum.py |    6 +++++-
 2 files changed, 6 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/71931d17/ForgeDiscussion/forgediscussion/controllers/root.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/controllers/root.py b/ForgeDiscussion/forgediscussion/controllers/root.py
index 0bc6c72..6cb1b3b 100644
--- a/ForgeDiscussion/forgediscussion/controllers/root.py
+++ b/ForgeDiscussion/forgediscussion/controllers/root.py
@@ -103,6 +103,7 @@ class RootController(BaseController, DispatchIndex):
         thd = discussion.get_discussion_thread(dict(
                 headers=dict(Subject=subject)))[0]
         post = thd.post(subject, text)
+        is_spam = g.spam_checker.check('%s\n%s' % (subject, text), artifact=post, user=c.user)
         flash('Message posted')
         redirect(thd.url())
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/71931d17/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 93d9023..0cecc0f 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
@@ -1,4 +1,5 @@
 # -*- coding: utf-8 -*-
+import mock
 import random
 import logging
 from email.mime.text import MIMEText
@@ -368,7 +369,8 @@ class TestForum(TestController):
                 'delete': 'Delete Marked'})
         _check()
 
-    def test_posting(self):
+    @mock.patch('forgediscussion.controllers.root.g.spam_checker')
+    def test_posting(self, spam_checker):
         r = self.app.get('/discussion/create_topic/')
         f = r.html.find('form',{'action':'/p/test/discussion/save_new_topic'})
         params = dict()
@@ -380,6 +382,8 @@ class TestForum(TestController):
         params[f.find('select')['name']] = 'testforum'
         params[f.find('input',{'style':'width: 90%'})['name']] = 'Test Thread'
         r = self.app.post('/discussion/save_new_topic', params=params)
+        spam_checker.check.call_args[0] == 'Test Thread\nThis is a *test thread*', \
+            spam_checker.check.call_args[0]
         r = self.app.get('/admin/discussion/forums')
         assert 'Message posted' in r
         r = self.app.get('/discussion/testforum/moderate/')


Mime
View raw message