allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [15/28] git commit: [#2835] ticket:292 Don't use c.app if doing project search. Fix tests.
Date Wed, 24 Apr 2013 18:13:49 GMT
[#2835] ticket:292 Don't use c.app if doing project search. Fix tests.


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

Branch: refs/heads/master
Commit: ee3e61520680b82790c0b7c5047d07e47a377bff
Parents: bfee10f
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Wed Mar 27 12:13:24 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed Apr 24 16:34:42 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/search.py                       |   17 +++++++--------
 Allura/allura/tests/functional/test_search.py     |    6 ++++-
 ForgeWiki/forgewiki/tests/functional/test_root.py |    2 +-
 3 files changed, 14 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ee3e6152/Allura/allura/lib/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index cf92af8..6c96d4a 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -119,24 +119,23 @@ def search_app(q='', fq=None, app=True, **kw):
         # It's 'fuzzier' than standard parser, which matches only on `text`.
         if search_comments:
             allowed_types += ['Post']
-        search_params = {
-            'qt': 'dismax',
-            'qf': 'title^2 text',
-            'pf': 'title^2 text',
-            'fq': [
+        if app:
+            fq = [
                 'project_id_s:%s'  % c.project._id,
                 'mount_point_s:%s' % c.app.config.options.mount_point,
                 '-deleted_b:true',
                 'type_s:(%s)' % ' OR '.join(['"%s"' % t for t in allowed_types])
-            ] + fq,
+            ] + fq
+        search_params = {
+            'qt': 'dismax',
+            'qf': 'title^2 text',
+            'pf': 'title^2 text',
+            'fq': fq,
             'hl': 'true',
             'hl.simple.pre': '<strong>',
             'hl.simple.post': '</strong>',
             'sort': sort,
         }
-        if not app:
-            # Not app-restricted search. Use only provided filter query (fq)
-            search_params['fq'] = fq
         if not history:
            search_params['fq'].append('is_history_b:False')
         if parser == 'standard':

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ee3e6152/Allura/allura/tests/functional/test_search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_search.py b/Allura/allura/tests/functional/test_search.py
index 2712e58..f63d4c2 100644
--- a/Allura/allura/tests/functional/test_search.py
+++ b/Allura/allura/tests/functional/test_search.py
@@ -15,14 +15,18 @@
 #       specific language governing permissions and limitations
 #       under the License.
 
+from mock import patch
 from allura.tests import TestController
 
 
 class TestSearch(TestController):
 
-    def test_global_search_controller(self):
+    @patch('allura.lib.search.search')
+    def test_global_search_controller(self, search):
         r = self.app.get('/gsearch/')
+        assert not search.called, search.called
         r = self.app.get('/gsearch/', params=dict(q='Root'))
+        assert search.called, search.called
 
     def test_project_search_controller(self):
         r = self.app.get('/search/')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ee3e6152/ForgeWiki/forgewiki/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py
index 029bf56..ccc3098 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -80,7 +80,7 @@ class TestRootController(TestController):
         response = self.app.get('/wiki/search?q=tést')
         assert 'Search wiki: tést' in response
 
-    @patch('forgewiki.wiki_main.search')
+    @patch('allura.lib.search.search')
     def test_search(self, search):
         r = self.app.get('/wiki/search?q=test')
         assert_in('<a href="/wiki/search?q=test&amp;sort=score+asc" class="strong">relevance</a>',
r)


Mime
View raw message