diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index 499b9c5..3846338 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -1954,7 +1954,7 @@ def add_group_project(repo, username=None, namespace=None): new_group=form.group.data, user=flask.g.fas_user.username, access=form.access.data, - create=not pagure.APP.config.get('ENABLE_GROUP_MNGT', False), + create=pagure.APP.config.get('ENABLE_GROUP_MNGT', False), is_admin=pagure.is_admin(), ) SESSION.commit() diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py index ea20d0e..b6416a8 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -378,6 +378,32 @@ class PagureFlaskRepotests(tests.Modeltests): pagure.APP.config['ENABLE_USER_MNGT'] = True + @patch.dict('pagure.APP.config', {'ENABLE_GROUP_MNGT': False}) + @patch('pagure.ui.repo.admin_session_timedout') + def test_add_group_project_grp_mngt_off(self, ast): + """ Test the add_group_project endpoint when group management is + turned off in the pagure instance""" + ast.return_value = False + + + tests.create_projects(self.session) + tests.create_projects_git(os.path.join(self.path, 'repos')) + + user = tests.FakeUser(username='pingou') + with tests.user_set(pagure.APP, user): + + data = { + 'group': 'ralph', + 'access': 'ticket', + 'csrf_token': self.get_csrf(), + } + output = self.app.post( + '/test/addgroup', data=data, follow_redirects=True) + self.assertEqual(output.status_code, 200) + self.assertIn( + u'