fix: show mergebox when only manual merge is allowed (#8681)

- If a repository only has the 'manual merge' strategy allowed, the mergebox should still be shown.
- The condition that checks if all merge strategies are disabled didn't check for the manual merge strategy.
- Add a integration test that demonstrates this fix is effective.

Reported-by: apteryx
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8681
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-committed-by: Gusted <postmaster@gusted.xyz>
This commit is contained in:
Gusted 2025-07-26 05:47:06 +02:00 committed by Earl Warren
parent 02de040a5e
commit d22f9d1f38
2 changed files with 22 additions and 1 deletions

View file

@ -136,3 +136,24 @@ func TestPullCombinedReviewRequest(t *testing.T) {
helper(t, "detach", "9", "removed review request for user11")
helper(t, "detach", "2", "removed review requests for user11, user2")
}
func TestShowMergeForManualMerge(t *testing.T) {
defer tests.PrintCurrentTest(t)()
// Only allow manual merge strategy for this repository.
pullRepoUnit := unittest.AssertExistsAndLoadBean(t, &repo_model.RepoUnit{ID: 5, RepoID: 1, Type: unit.TypePullRequests})
pullRepoUnit.Config = &repo_model.PullRequestsConfig{
AllowManualMerge: true,
DefaultMergeStyle: repo_model.MergeStyleManuallyMerged,
}
repo_model.UpdateRepoUnit(t.Context(), pullRepoUnit)
session := loginUser(t, "user2")
req := NewRequest(t, "GET", "/user2/repo1/pulls/5")
resp := session.MakeRequest(t, req, http.StatusOK)
// Assert that the mergebox is shown.
htmlDoc := NewHTMLParser(t, resp.Body)
htmlDoc.AssertElement(t, "#pull-request-merge-form", true)
}