webhooks_gitea: Add tests and fixture for correct actor on PR close.

Previously, closing a pull request by someone other than its creator could result in Zulip notifications attributing the action to the wrong user.

This change adds a focused test and a fixture capturing the case where the webhook sender differs from pull_request.user, ensuring the correct actor is mentioned for pull_request close events.

Follow-up to #36184.
This commit is contained in:
Aneesh Hegde
2025-10-12 20:51:02 +05:30
committed by Tim Abbott
parent ffa9c1e6a3
commit f778c853ea
2 changed files with 484 additions and 0 deletions

View File

@@ -51,6 +51,11 @@ class GiteaHookTests(WebhookTestCase):
expected_message = """kostekIV closed [PR #5](https://try.gitea.io/kostekIV/test/pulls/5) from `d` to `master`."""
self.check_webhook("pull_request__closed", expected_topic_name, expected_message)
def test_pull_request_closed_different_user(self) -> None:
expected_topic_name = "test / PR #126085 PR closed"
expected_message = """Aneesh-Hegde closed [PR #1](https://gitea.com/Aneesh-Hegde/test-repo/pulls/1) from `main` to `main`."""
self.check_webhook("pull_request__closed_diff_user", expected_topic_name, expected_message)
def test_pull_request_assigned(self) -> None:
expected_topic_name = "test / PR #1906 test 2"
expected_message = """kostekIV assigned kostekIV to [PR #5](https://try.gitea.io/kostekIV/test/pulls/5) from `d` to `master` (assigned to kostekIV)."""