From e30bbb62f4a16667728b7230c013ea77ff5b28c6 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 25 2019 16:09:33 +0000 Subject: Ensure the comment & close button shows up for the author We had a bug where the person who opened a ticket could close it via the button at the top right above the meta-data but couldn't use the "Comment & Close" button. This commit fixes that. Fixes https://pagure.io/pagure/issue/4150 Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/templates/issue.html b/pagure/templates/issue.html index e3a01f8..baa1465 100644 --- a/pagure/templates/issue.html +++ b/pagure/templates/issue.html @@ -225,7 +225,7 @@ namespace=repo.namespace, repo=repo.name, issueid=issueid) target="_blank" rel="noopener noreferrer" class="notblue">Markdown Syntax
- {% if g.authenticated and g.repo_user %} + {% if g.authenticated and (g.repo_user or open_access or g.fas_user.username == issue.user.user) %} {% if issue.status == 'Open' %} {% if repo.close_status %}
diff --git a/tests/test_pagure_flask_ui_issues.py b/tests/test_pagure_flask_ui_issues.py index ff1ea45..a9186ac 100644 --- a/tests/test_pagure_flask_ui_issues.py +++ b/tests/test_pagure_flask_ui_issues.py @@ -4347,6 +4347,51 @@ class PagureFlaskIssuestests(tests.Modeltests): @patch('pagure.lib.git.update_git') @patch('pagure.lib.notify.send_email') + def test_view_issue_comment_and_close(self, p_send_email, p_ugt): + """ Test if the comment and close button shows up on a ticket opened + by the user + """ + # Create the project ns/test + item = pagure.lib.model.Project( + user_id=1, # pingou + name='test3', + namespace='ns', + description='test project #3', + hook_token='aaabbbcccdd', + ) + self.session.add(item) + self.session.commit() + self.assertEqual(item.fullname, 'ns/test3') + pygit2.init_repository( + os.path.join(self.path, 'repos', 'ns', 'test3.git'), + bare=True) + + # Create 1 issue + iss = pagure.lib.query.new_issue( + issue_id=1, + session=self.session, + repo=item, + title='test issue2', + content='content test issue2', + user='foo', + ) + self.session.commit() + self.assertEqual(iss.id, 1) + self.assertEqual(iss.title, 'test issue2') + self.assertEqual(iss.project.fullname, 'ns/test3') + + user = tests.FakeUser(username='foo') + with tests.user_set(self.app.application, user): + output = self.app.get('/ns/test3/issue/1') + self.assertEqual(output.status_code, 200) + self.assertIn( + '\n' + ' Comment & Close\n', + output.get_data(as_text=True)) + + @patch('pagure.lib.git.update_git') + @patch('pagure.lib.notify.send_email') def test_view_issue_forked_namespace_comment(self, p_send_email, p_ugt): """ Test comment on the view_issue endpoint on namespaced project. """