diff options
author | Julien Tant <julien@craftyx.fr> | 2018-08-13 21:04:39 +0200 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2018-08-13 22:04:39 +0300 |
commit | 7781e8cef2dfe73d71be7804f4c5a7c5f1995d31 (patch) | |
tree | 7bbe6d2a031655478538e152912182f5ad3500eb /integrations/pull_merge_test.go | |
parent | 52c2cb15db77a381880db7e44f133a49b3516dd5 (diff) | |
download | gitea-7781e8cef2dfe73d71be7804f4c5a7c5f1995d31.tar.gz gitea-7781e8cef2dfe73d71be7804f4c5a7c5f1995d31.zip |
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>
Diffstat (limited to 'integrations/pull_merge_test.go')
-rw-r--r-- | integrations/pull_merge_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/integrations/pull_merge_test.go b/integrations/pull_merge_test.go index 27f3586406..b375a55f53 100644 --- a/integrations/pull_merge_test.go +++ b/integrations/pull_merge_test.go @@ -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") +} |