From ecf249afe20b1b01d96429248d33882bf654a0cd Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 25 2018 09:06:43 +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 3e02ec8..755d6c6 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 c63c24d..70697fa 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -1505,6 +1505,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. """