forked from forgejo/forgejo
Disable merging a WIP Pull request (#4529)
* prevent pull request to be merged when PR is a WIP * add tests * add helper to prepend WIP: in PR title * move default wip prefixes into settings * use configurable WIP prefixes in javascript and default to first one in templates * add documentation * add unit test on pull model Signed-off-by: Julien Tant <julien@craftyx.fr>
This commit is contained in:
parent
52c2cb15db
commit
7781e8cef2
16 changed files with 218 additions and 5 deletions
|
@ -14,6 +14,7 @@ import (
|
|||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
|
||||
"github.com/Unknwon/i18n"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
@ -123,3 +124,23 @@ func TestPullCleanUpAfterMerge(t *testing.T) {
|
|||
|
||||
assert.EqualValues(t, "Branch 'user1/feature/test' has been deleted.", resultMsg)
|
||||
}
|
||||
|
||||
func TestCantMergeWorkInProgress(t *testing.T) {
|
||||
prepareTestEnv(t)
|
||||
session := loginUser(t, "user1")
|
||||
testRepoFork(t, session, "user2", "repo1", "user1", "repo1")
|
||||
testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n")
|
||||
|
||||
resp := testPullCreate(t, session, "user1", "repo1", "master", "[wip] This is a pull title")
|
||||
|
||||
req := NewRequest(t, "GET", resp.Header().Get("Location"))
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
text := strings.TrimSpace(htmlDoc.doc.Find(".merge.segment > .text.grey").Text())
|
||||
assert.NotEmpty(t, text, "Can't find WIP text")
|
||||
|
||||
// remove <strong /> from lang
|
||||
expected := i18n.Tr("en", "repo.pulls.cannot_merge_work_in_progress", "[wip]")
|
||||
replacer := strings.NewReplacer("<strong>", "", "</strong>", "")
|
||||
assert.Equal(t, replacer.Replace(expected), text, "Unable to find WIP text")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue