incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [3/3] git commit: [#5382] Make sure new topics get spam checked
Date Tue, 11 Dec 2012 21:44:01 GMT
[#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/335e9a30
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/335e9a30
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/335e9a30

Branch: refs/heads/master
Commit: 335e9a301280f5da5d83817ef18fada11d734eca
Parents: 00b6c79
Author: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Authored: Wed Dec 5 20:00:32 2012 +0000
Committer: Cory Johns <johnsca@geek.net>
Committed: Tue Dec 11 21:43:25 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/335e9a30/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/335e9a30/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 b46dc20..7d6f4e4 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