diff options
-rw-r--r-- | docs/changelog.rst | 2 | ||||
-rw-r--r-- | rhodecode/model/repos_group.py | 6 | ||||
-rw-r--r-- | rhodecode/tests/test_models.py | 39 |
3 files changed, 37 insertions, 10 deletions
diff --git a/docs/changelog.rst b/docs/changelog.rst index 70e54f08..993656ee 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -21,6 +21,8 @@ fixes - fixed git remote repos validator that prevented from cloning remote git repos - fixes #370 ending slashes fixes for repo and groups - fixes #368 improved git-protocol detection to handle other clients +- fixes #366 When Setting Repository Group To Blank Repo Group Wont Be + Moved To Root 1.3.1 (**2012-02-27**) ---------------------- diff --git a/rhodecode/model/repos_group.py b/rhodecode/model/repos_group.py index 94590ccb..5bc435e7 100644 --- a/rhodecode/model/repos_group.py +++ b/rhodecode/model/repos_group.py @@ -187,20 +187,20 @@ class ReposGroupModel(BaseModel): # change properties repos_group.group_description = form_data['group_description'] repos_group.parent_group = RepoGroup.get(form_data['group_parent_id']) + repos_group.group_parent_id = form_data['group_parent_id'] repos_group.group_name = repos_group.get_new_name(form_data['group_name']) - new_path = repos_group.full_path self.sa.add(repos_group) - self.__rename_group(old_path, new_path) - # we need to get all repositories from this new group and # rename them accordingly to new group path for r in repos_group.repositories: r.repo_name = r.get_new_name(r.just_name) self.sa.add(r) + self.__rename_group(old_path, new_path) + return repos_group except: log.error(traceback.format_exc()) diff --git a/rhodecode/tests/test_models.py b/rhodecode/tests/test_models.py index b0fd6e48..12c06615 100644 --- a/rhodecode/tests/test_models.py +++ b/rhodecode/tests/test_models.py @@ -23,7 +23,6 @@ def _make_group(path, desc='desc', parent_id=None, return gr gr = ReposGroupModel().create(path, desc, parent_id) - Session.commit() return gr @@ -31,13 +30,19 @@ class TestReposGroups(unittest.TestCase): def setUp(self): self.g1 = _make_group('test1', skip_if_exists=True) + Session.commit() self.g2 = _make_group('test2', skip_if_exists=True) + Session.commit() self.g3 = _make_group('test3', skip_if_exists=True) + Session.commit() def tearDown(self): print 'out' def __check_path(self, *path): + """ + Checks the path for existance ! + """ path = [TESTS_TMP_PATH] + list(path) path = os.path.join(*path) return os.path.isdir(path) @@ -49,12 +54,13 @@ class TestReposGroups(unittest.TestCase): ReposGroupModel().delete(id_) def __update_group(self, id_, path, desc='desc', parent_id=None): - form_data = dict(group_name=path, - group_description=desc, - group_parent_id=parent_id, - perms_updates=[], - perms_new=[]) - + form_data = dict( + group_name=path, + group_description=desc, + group_parent_id=parent_id, + perms_updates=[], + perms_new=[] + ) gr = ReposGroupModel().update(id_, form_data) return gr @@ -150,6 +156,25 @@ class TestReposGroups(unittest.TestCase): self.assertEqual(r.repo_name, os.path.join('g2', 'g1', r.just_name)) + def test_move_to_root(self): + g1 = _make_group('t11') + Session.commit() + g2 = _make_group('t22',parent_id=g1.group_id) + Session.commit() + + self.assertEqual(g2.full_path,'t11/t22') + self.assertTrue(self.__check_path('t11', 't22')) + + g2 = self.__update_group(g2.group_id, 'g22', parent_id=None) + Session.commit() + + self.assertEqual(g2.group_name,'g22') + # we moved out group from t1 to '' so it's full path should be 'g2' + self.assertEqual(g2.full_path,'g22') + self.assertFalse(self.__check_path('t11', 't22')) + self.assertTrue(self.__check_path('g22')) + + class TestUser(unittest.TestCase): def __init__(self, methodName='runTest'): Session.remove() |