|
|
|
|
@ -62,6 +62,30 @@ func testPullCreate(t *testing.T, session *TestSession, user, repo, branch, titl
|
|
|
|
|
return resp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func testPullCreateDirectly(t *testing.T, session *TestSession, baseRepoOwner, baseRepoName, baseBranch, headRepoOwner, headRepoName, headBranch, title string) *httptest.ResponseRecorder {
|
|
|
|
|
headCompare := headBranch
|
|
|
|
|
if headRepoOwner != "" {
|
|
|
|
|
if headRepoName != "" {
|
|
|
|
|
headCompare = fmt.Sprintf("%s/%s:%s", headRepoOwner, headRepoName, headBranch)
|
|
|
|
|
} else {
|
|
|
|
|
headCompare = fmt.Sprintf("%s:%s", headRepoOwner, headBranch)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
req := NewRequest(t, "GET", fmt.Sprintf("/%s/%s/compare/%s...%s", baseRepoOwner, baseRepoName, baseBranch, headCompare))
|
|
|
|
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
|
|
|
|
|
|
|
|
|
// Submit the form for creating the pull
|
|
|
|
|
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,
|
|
|
|
|
})
|
|
|
|
|
resp = session.MakeRequest(t, req, http.StatusOK)
|
|
|
|
|
return resp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPullCreate(t *testing.T) {
|
|
|
|
|
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
|
|
|
|
session := loginUser(t, "user1")
|
|
|
|
|
|