changeset 2822:1670ee0aded7 beta

fixed issue #559 fixed bug in routing that mapped repo names with <name>_<num> in name as if it was a request to url by repository ID
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 07 Sep 2012 18:00:31 +0200
parents 9c90be87ae05
children 87bac9b78eb9
files rhodecode/config/routing.py rhodecode/tests/functional/test_summary.py
diffstat 2 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/config/routing.py	Fri Sep 07 17:53:14 2012 +0200
+++ b/rhodecode/config/routing.py	Fri Sep 07 18:00:31 2012 +0200
@@ -34,7 +34,7 @@
 
         try:
             by_id = repo_name.split('_')
-            if len(by_id) == 2 and by_id[1].isdigit():
+            if len(by_id) == 2 and by_id[1].isdigit() and by_id[0] == '':
                 repo_name = Repository.get(by_id[1]).repo_name
                 match_dict['repo_name'] = repo_name
         except:
--- a/rhodecode/tests/functional/test_summary.py	Fri Sep 07 17:53:14 2012 +0200
+++ b/rhodecode/tests/functional/test_summary.py	Fri Sep 07 18:00:31 2012 +0200
@@ -1,6 +1,9 @@
 from rhodecode.tests import *
 from rhodecode.model.db import Repository
 from rhodecode.lib.utils import invalidate_cache
+from rhodecode.model.repo import RepoModel
+from rhodecode.tests.models.common import _make_repo
+from rhodecode.model.meta import Session
 
 
 class TestSummaryController(TestController):
@@ -82,6 +85,20 @@
                         """title="public repository" alt="public """
                         """repository" src="/images/icons/lock_open.png"/>""")
 
+    def test_index_by_repo_having_id_path_in_name_hg(self):
+        self.log_user()
+        _make_repo(name='repo_1')
+        Session().commit()
+        response = self.app.get(url(controller='summary',
+                                    action='index',
+                                    repo_name='repo_1'))
+
+        try:
+            response.mustcontain("""repo_1""")
+        finally:
+            RepoModel().delete(Repository.get_by_repo_name('repo_1'))
+            Session().commit()
+
     def test_index_by_id_git(self):
         self.log_user()
         ID = Repository.get_by_repo_name(GIT_REPO).repo_id