changeset 2718:82fb2a161ddf beta

fixes issue #524 - fixed search by filename - added missing test for this search
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 16 Aug 2012 11:05:04 +0200
parents dd240b2b7a12
children 2e7f7568ea92
files rhodecode/lib/indexers/__init__.py rhodecode/tests/functional/test_search.py
diffstat 2 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/lib/indexers/__init__.py	Wed Aug 15 18:25:38 2012 +0200
+++ b/rhodecode/lib/indexers/__init__.py	Thu Aug 16 11:05:04 2012 +0200
@@ -89,6 +89,7 @@
 
 CHGSET_IDX_NAME = 'CHGSET_INDEX'
 
+
 class MakeIndex(BasePasterCommand):
 
     max_args = 1
@@ -218,6 +219,11 @@
                         'content_short_hl': self.highlight(content_short),
                         'f_path': f_path
                       })
+        elif self.search_type == 'path':
+            full_repo_path = jn(self.repo_location, res['repository'])
+            f_path = res['path'].split(full_repo_path)[-1]
+            f_path = f_path.lstrip(os.sep)
+            res.update({'f_path': f_path})
         elif self.search_type == 'message':
             res.update({'message_hl': self.highlight(res['message'])})
 
--- a/rhodecode/tests/functional/test_search.py	Wed Aug 15 18:25:38 2012 +0200
+++ b/rhodecode/tests/functional/test_search.py	Thu Aug 16 11:05:04 2012 +0200
@@ -90,3 +90,10 @@
                      'type': 'commit'})
 
         response.mustcontain('1 results')
+
+    def test_search_file_name(self):
+        self.log_user()
+        response = self.app.get(url(controller='search', action='index'),
+                    {'q': 'README.rst', 'type': 'path'})
+
+        response.mustcontain('2 results')
\ No newline at end of file