aboutsummaryrefslogtreecommitdiffstats
path: root/integrations/issue_test.go
diff options
context:
space:
mode:
authorMura Li <typeless@users.noreply.github.com>2017-06-18 21:25:58 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2017-06-18 21:25:58 +0800
commit4d2ea7dc41f2a09f0b9b5833b18bc07a81490e4b (patch)
tree4517efe24ab09b1a6f8740b334415cfa25f47c04 /integrations/issue_test.go
parent255adc40ae1e0a03547326f143f685be41fa591f (diff)
downloadgitea-4d2ea7dc41f2a09f0b9b5833b18bc07a81490e4b.tar.gz
gitea-4d2ea7dc41f2a09f0b9b5833b18bc07a81490e4b.zip
Add integration test for issue creating (#2002)
Diffstat (limited to 'integrations/issue_test.go')
-rw-r--r--integrations/issue_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/integrations/issue_test.go b/integrations/issue_test.go
index b07fac3a3a..4d2b8bf4eb 100644
--- a/integrations/issue_test.go
+++ b/integrations/issue_test.go
@@ -6,6 +6,7 @@ package integrations
import (
"net/http"
+ "path"
"strconv"
"strings"
"testing"
@@ -75,3 +76,33 @@ func TestNoLoginViewIssue(t *testing.T) {
resp := MakeRequest(req)
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
}
+
+func testNewIssue(t *testing.T, session *TestSession, user, repo, title string) {
+
+ req := NewRequest(t, "GET", path.Join(user, repo, "issues", "new"))
+ resp := session.MakeRequest(t, req)
+ assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
+
+ htmlDoc := NewHTMLParser(t, resp.Body)
+ link, exists := htmlDoc.doc.Find("form.ui.form").Attr("action")
+ assert.True(t, exists, "The template has changed")
+ req = NewRequestWithValues(t, "POST", link, map[string]string{
+ "_csrf": htmlDoc.GetCSRF(),
+ "title": title,
+ })
+ req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
+ resp = session.MakeRequest(t, req)
+ assert.EqualValues(t, http.StatusFound, resp.HeaderCode)
+ redirectedURL := resp.Headers["Location"]
+ assert.NotEmpty(t, redirectedURL, "Redirected URL is not found")
+
+ req = NewRequest(t, "GET", redirectedURL[0])
+ resp = session.MakeRequest(t, req)
+ assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
+}
+
+func TestNewIssue(t *testing.T) {
+ prepareTestEnv(t)
+ session := loginUser(t, "user2")
+ testNewIssue(t, session, "user2", "repo1", "Title")
+}