summaryrefslogtreecommitdiffstats
path: root/models/pull_test.go
diff options
context:
space:
mode:
authorJulien Tant <julien@craftyx.fr>2018-08-13 21:04:39 +0200
committerLauris BH <lauris@nix.lv>2018-08-13 22:04:39 +0300
commit7781e8cef2dfe73d71be7804f4c5a7c5f1995d31 (patch)
tree7bbe6d2a031655478538e152912182f5ad3500eb /models/pull_test.go
parent52c2cb15db77a381880db7e44f133a49b3516dd5 (diff)
downloadgitea-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 'models/pull_test.go')
-rw-r--r--models/pull_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/models/pull_test.go b/models/pull_test.go
index e725193bb1..1dad664077 100644
--- a/models/pull_test.go
+++ b/models/pull_test.go
@@ -237,3 +237,34 @@ func TestChangeUsernameInPullRequests(t *testing.T) {
}
CheckConsistencyFor(t, &PullRequest{})
}
+
+func TestPullRequest_IsWorkInProgress(t *testing.T) {
+ assert.NoError(t, PrepareTestDatabase())
+
+ pr := AssertExistsAndLoadBean(t, &PullRequest{ID: 2}).(*PullRequest)
+ pr.LoadIssue()
+
+ assert.False(t, pr.IsWorkInProgress())
+
+ pr.Issue.Title = "WIP: " + pr.Issue.Title
+ assert.True(t, pr.IsWorkInProgress())
+
+ pr.Issue.Title = "[wip]: " + pr.Issue.Title
+ assert.True(t, pr.IsWorkInProgress())
+}
+
+func TestPullRequest_GetWorkInProgressPrefixWorkInProgress(t *testing.T) {
+ assert.NoError(t, PrepareTestDatabase())
+
+ pr := AssertExistsAndLoadBean(t, &PullRequest{ID: 2}).(*PullRequest)
+ pr.LoadIssue()
+
+ assert.Empty(t, pr.GetWorkInProgressPrefix())
+
+ original := pr.Issue.Title
+ pr.Issue.Title = "WIP: " + original
+ assert.Equal(t, "WIP:", pr.GetWorkInProgressPrefix())
+
+ pr.Issue.Title = "[wip] " + original
+ assert.Equal(t, "[wip]", pr.GetWorkInProgressPrefix())
+}