Mercurial > kallithea
changeset 2059:d7f1fe9cb146 beta
fixes issue #366 setting null on parent_group didn't propagate to actually db field.
- added relevant test for this
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 28 Feb 2012 07:05:03 +0200 |
parents | fb51a6fc10ae |
children | 572855f7a392 |
files | docs/changelog.rst rhodecode/model/repos_group.py rhodecode/tests/test_models.py |
diffstat | 3 files changed, 37 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/docs/changelog.rst Tue Feb 28 05:25:16 2012 +0200 +++ b/docs/changelog.rst Tue Feb 28 07:05:03 2012 +0200 @@ -21,6 +21,8 @@ - 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**) ----------------------
--- a/rhodecode/model/repos_group.py Tue Feb 28 05:25:16 2012 +0200 +++ b/rhodecode/model/repos_group.py Tue Feb 28 07:05:03 2012 +0200 @@ -187,20 +187,20 @@ # 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())
--- a/rhodecode/tests/test_models.py Tue Feb 28 05:25:16 2012 +0200 +++ b/rhodecode/tests/test_models.py Tue Feb 28 07:05:03 2012 +0200 @@ -23,7 +23,6 @@ return gr gr = ReposGroupModel().create(path, desc, parent_id) - Session.commit() return gr @@ -31,13 +30,19 @@ 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 @@ 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 @@ 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()