From 5f4b8ea66d75def72948089111edf73b2700e43a Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jul 17 2018 13:08:01 +0000 Subject: Fix showing the 'more' button on the overview page Fixes https://pagure.io/pagure/issue/3218 Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/templates/repo_info.html b/pagure/templates/repo_info.html index aca0684..c4cfc43 100644 --- a/pagure/templates/repo_info.html +++ b/pagure/templates/repo_info.html @@ -52,7 +52,7 @@ git push -u origin master
Source GIT URLs{% if - (authenticated and g.repo_committer) or + (g.authenticated and g.repo_committer) or (config['DOC_APP_URL'] and repo and repo.settings.get('project_documentation', True)) %} diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py index f600b52..e8e3319 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -1444,6 +1444,79 @@ class PagureFlaskRepotests(tests.Modeltests): output = self.app.get('/TEST') self.assertEqual(output.status_code, 404) + def test_view_repo_more_button_absent_no_auth(self): + """ Test the view_repo endpoint and check if the "more" button is + absent when not logged in. """ + + tests.create_projects(self.session) + tests.create_projects_git(os.path.join(self.path, 'repos'), bare=True) + + output = self.app.get('/test') + self.assertEqual(output.status_code, 200) + output_text = output.get_data(as_text=True) + self.assertNotIn( + 'This repo is brand new!

', output_text) + self.assertIn( + '
\n' + 'test project #1
', output_text) + self.assertIn( + 'Stats ', + output_text) + self.perfMaxWalks(0, 0) + self.perfReset() + + def test_view_repo_more_button_present(self): + """ Test the view_repo endpoint and check if the "more" button is + present when it should be. """ + + tests.create_projects(self.session) + tests.create_projects_git(os.path.join(self.path, 'repos'), bare=True) + + user = tests.FakeUser(username='pingou') + with tests.user_set(self.app.application, user): + output = self.app.get('/test') + self.assertEqual(output.status_code, 200) + output_text = output.get_data(as_text=True) + self.assertIn( + '
This repo is brand new!

', output_text) + self.assertIn( + '
\n' + 'test project #1
', output_text) + self.assertIn( + 'Stats ', + output_text) + self.perfMaxWalks(0, 0) + self.perfReset() + + def test_view_repo_more_button_absent_no_access(self): + """ Test the view_repo endpoint and check if the "more" button is + absent if the user doesn't have access to the project. """ + + tests.create_projects(self.session) + tests.create_projects_git(os.path.join(self.path, 'repos'), bare=True) + + user = tests.FakeUser(username='foo') + with tests.user_set(self.app.application, user): + output = self.app.get('/test') + self.assertEqual(output.status_code, 200) + output_text = output.get_data(as_text=True) + self.assertNotIn( + '
This repo is brand new!

', output_text) + self.assertIn( + '
\n' + 'test project #1
', output_text) + self.assertIn( + 'Stats ', + output_text) + self.perfMaxWalks(0, 0) + self.perfReset() + def test_view_repo(self): """ Test the view_repo endpoint. """