Make branch deletion URL more like GitHub's, fixes #1397 (#1994)

* Make branch deletion URL more like GitHub's, fixes #1397

* Add PR branch deletion integration test

* Do not allow deleting protected branch

* Change http error code to 403 if user has no write rights to repository

* Add check to not panic if forked repository has alrady been deleted
This commit is contained in:
Lauris BH 2017-06-21 04:00:03 +03:00 committed by Lunny Xiao
parent 6db387a21e
commit 0a5dc640a1
7 changed files with 241 additions and 70 deletions

View file

@ -7,6 +7,7 @@ package integrations
import (
"net/http"
"path"
"strings"
"testing"
"github.com/stretchr/testify/assert"
@ -21,6 +22,9 @@ func testPullCreate(t *testing.T, session *TestSession, user, repo, branch strin
htmlDoc := NewHTMLParser(t, resp.Body)
link, exists := htmlDoc.doc.Find("button.ui.green.small.button").Parent().Attr("href")
assert.True(t, exists, "The template has changed")
if branch != "master" {
link = strings.Replace(link, ":master", ":"+branch, 1)
}
req = NewRequest(t, "GET", link)
resp = session.MakeRequest(t, req)