diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index c77a452..86fc5f0 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -2165,6 +2165,7 @@ def edit_file(repo, branchname, filename, username=None, namespace=None): flask.flash('Commit could not be done', 'error') data = form.content.data elif flask.request.method == 'GET': + form.email.data = user.default_email content = __get_file_in_tree( repo_obj, commit.tree, filename.split('/')) if not content or isinstance(content, pygit2.Tree): diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py index ab6faa0..455189b 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -4456,6 +4456,45 @@ index 0000000..fb7093d self.assertIn( '

No content found

', output_text) + def test_edit_file_default_email(self): + """ Test the default email shown by the edit_file endpoint. """ + + tests.create_projects(self.session) + tests.create_projects_git( + os.path.join(self.path, 'repos'), bare=True) + + # Add some content to the git repo + tests.add_content_git_repo( + os.path.join(self.path, 'repos', 'test.git')) + tests.add_readme_git_repo( + os.path.join(self.path, 'repos', 'test.git')) + + user = pagure.lib.search_user(self.session, username='pingou') + self.assertEquals(len(user.emails), 2) + self.assertEquals(user.default_email, 'bar@pingou.com') + + user = tests.FakeUser(username='pingou') + with tests.user_set(self.app.application, user): + + # Edit page + output = self.app.get('/test/edit/master/f/sources') + self.assertEqual(output.status_code, 200) + output_text = output.get_data(as_text=True) + self.assertIn( + '
  • ' + '  master
  • ' + '  sources
  • ', + output_text) + self.assertIn( + '', + output_text) + self.assertIn( + '', output_text) + self.assertIn( + '', + output_text) + @patch('pagure.decorators.admin_session_timedout') def test_change_ref_head(self,ast): """ Test the change_ref_head endpoint. """