summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
Diffstat (limited to 'routers')
-rw-r--r--routers/repo/release.go1
-rw-r--r--routers/repo/release_test.go61
2 files changed, 62 insertions, 0 deletions
diff --git a/routers/repo/release.go b/routers/repo/release.go
index da99dd7713..a1babbc295 100644
--- a/routers/repo/release.go
+++ b/routers/repo/release.go
@@ -191,6 +191,7 @@ func NewReleasePost(ctx *context.Context, form auth.NewReleaseForm) {
rel.Title = form.Title
rel.Note = form.Content
+ rel.Target = form.Target
rel.IsDraft = len(form.Draft) > 0
rel.IsPrerelease = form.Prerelease
rel.PublisherID = ctx.User.ID
diff --git a/routers/repo/release_test.go b/routers/repo/release_test.go
new file mode 100644
index 0000000000..524c1c7346
--- /dev/null
+++ b/routers/repo/release_test.go
@@ -0,0 +1,61 @@
+// Copyright 2017 The Gitea Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package repo
+
+import (
+ "testing"
+
+ "code.gitea.io/gitea/models"
+ "code.gitea.io/gitea/modules/auth"
+ "code.gitea.io/gitea/modules/test"
+)
+
+func TestNewReleasePost(t *testing.T) {
+ for _, testCase := range []struct {
+ RepoID int64
+ UserID int64
+ TagName string
+ Form auth.NewReleaseForm
+ }{
+ {
+ RepoID: 1,
+ UserID: 2,
+ TagName: "v1.1", // pre-existing tag
+ Form: auth.NewReleaseForm{
+ TagName: "newtag",
+ Target: "master",
+ Title: "title",
+ Content: "content",
+ },
+ },
+ {
+ RepoID: 1,
+ UserID: 2,
+ TagName: "newtag",
+ Form: auth.NewReleaseForm{
+ TagName: "newtag",
+ Target: "master",
+ Title: "title",
+ Content: "content",
+ },
+ },
+ } {
+ models.PrepareTestEnv(t)
+
+ ctx := test.MockContext(t, "user2/repo1/releases/new")
+ test.LoadUser(t, ctx, 2)
+ test.LoadRepo(t, ctx, 1)
+ test.LoadGitRepo(t, ctx)
+ NewReleasePost(ctx, testCase.Form)
+ models.AssertExistsAndLoadBean(t, &models.Release{
+ RepoID: 1,
+ PublisherID: 2,
+ TagName: testCase.Form.TagName,
+ Target: testCase.Form.Target,
+ Title: testCase.Form.Title,
+ Note: testCase.Form.Content,
+ }, models.Cond("is_draft=?", len(testCase.Form.Draft) > 0))
+ }
+}