From 513375c429435ba60a667b219bdfb00e5b760b38 Mon Sep 17 00:00:00 2001 From: Ethan Koenig Date: Sun, 29 Oct 2017 19:04:25 -0700 Subject: Make URL scheme unambiguous (#2408) * Make URL scheme unambiguous Redirect old routes to new routes * Fix redirects to new URL scheme, and update template * Fix branches/_new endpoints, and update integration test --- integrations/links_test.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'integrations/links_test.go') diff --git a/integrations/links_test.go b/integrations/links_test.go index 27e4054694..7eaf1c51ef 100644 --- a/integrations/links_test.go +++ b/integrations/links_test.go @@ -10,6 +10,8 @@ import ( "testing" api "code.gitea.io/sdk/gitea" + + "github.com/stretchr/testify/assert" ) func TestLinksNoLogin(t *testing.T) { @@ -38,6 +40,20 @@ func TestLinksNoLogin(t *testing.T) { } } +func TestRedirectsNoLogin(t *testing.T) { + prepareTestEnv(t) + + var redirects = map[string]string{ + "/user2/repo1/commits/master": "/user2/repo1/commits/branch/master", + "/user2/repo1/src/master": "/user2/repo1/src/branch/master", + } + for link, redirectLink := range redirects { + req := NewRequest(t, "GET", link) + resp := MakeRequest(t, req, http.StatusFound) + assert.EqualValues(t, redirectLink, RedirectURL(t, resp)) + } +} + func testLinksAsUser(userName string, t *testing.T) { var links = []string{ "/explore/repos", @@ -99,7 +115,7 @@ func testLinksAsUser(userName string, t *testing.T) { "", "/issues", "/pulls", - "/commits/master", + "/commits/branch/master", "/graph", "/settings", "/settings/collaboration", -- cgit v1.2.3