diff options
Diffstat (limited to 'integrations')
-rw-r--r-- | integrations/editor_test.go | 25 | ||||
-rw-r--r-- | integrations/integration_test.go | 2 | ||||
-rw-r--r-- | integrations/internal_test.go | 2 |
3 files changed, 21 insertions, 8 deletions
diff --git a/integrations/editor_test.go b/integrations/editor_test.go index 79b6bb790a..cc94edfd3f 100644 --- a/integrations/editor_test.go +++ b/integrations/editor_test.go @@ -43,16 +43,15 @@ func TestCreateFileOnProtectedBranch(t *testing.T) { csrf := GetCSRF(t, session, "/user2/repo1/settings/branches") // Change master branch to protected - req := NewRequestWithValues(t, "POST", "/user2/repo1/settings/branches?action=protected_branch", map[string]string{ - "_csrf": csrf, - "branchName": "master", - "canPush": "true", + req := NewRequestWithValues(t, "POST", "/user2/repo1/settings/branches/master", map[string]string{ + "_csrf": csrf, + "protected": "on", }) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := session.MakeRequest(t, req, http.StatusFound) // Check if master branch has been locked successfully flashCookie := session.GetCookie("macaron_flash") assert.NotNil(t, flashCookie) - assert.EqualValues(t, flashCookie.Value, "success%3Dmaster%2BLocked%2Bsuccessfully") + assert.EqualValues(t, "success%3DBranch%2Bmaster%2Bprotect%2Boptions%2Bchanged%2Bsuccessfully.", flashCookie.Value) // Request editor page req = NewRequest(t, "GET", "/user2/repo1/_new/master/") @@ -74,6 +73,20 @@ func TestCreateFileOnProtectedBranch(t *testing.T) { resp = session.MakeRequest(t, req, http.StatusOK) // Check body for error message assert.Contains(t, string(resp.Body), "Can not commit to protected branch 'master'.") + + // remove the protected branch + csrf = GetCSRF(t, session, "/user2/repo1/settings/branches") + // Change master branch to protected + req = NewRequestWithValues(t, "POST", "/user2/repo1/settings/branches/master", map[string]string{ + "_csrf": csrf, + "protected": "off", + }) + resp = session.MakeRequest(t, req, http.StatusFound) + // Check if master branch has been locked successfully + flashCookie = session.GetCookie("macaron_flash") + assert.NotNil(t, flashCookie) + assert.EqualValues(t, "success%3DBranch%2Bmaster%2Bprotect%2Boptions%2Bremoved%2Bsuccessfully", flashCookie.Value) + } func testEditFile(t *testing.T, session *TestSession, user, repo, branch, filePath string) *TestResponse { diff --git a/integrations/integration_test.go b/integrations/integration_test.go index d43f3977b8..0b5d8a764d 100644 --- a/integrations/integration_test.go +++ b/integrations/integration_test.go @@ -269,7 +269,7 @@ func MakeRequest(t testing.TB, req *http.Request, expectedStatus int) *TestRespo mac.ServeHTTP(respWriter, req) if expectedStatus != NoExpectedStatus { assert.EqualValues(t, expectedStatus, respWriter.HeaderCode, - "Request URL: %s", req.URL.String()) + "Request URL: %s %s", req.URL.String(), buffer.String()) } return &TestResponse{ HeaderCode: respWriter.HeaderCode, diff --git a/integrations/internal_test.go b/integrations/internal_test.go index c22e951bc5..d58b8b0b4e 100644 --- a/integrations/internal_test.go +++ b/integrations/internal_test.go @@ -31,7 +31,7 @@ func assertProtectedBranch(t *testing.T, repoID int64, branchName string, isErr, var branch models.ProtectedBranch t.Log(string(resp.Body)) assert.NoError(t, json.Unmarshal(resp.Body, &branch)) - assert.Equal(t, canPush, branch.CanPush) + assert.Equal(t, canPush, !branch.IsProtected()) } } |