aboutsummaryrefslogtreecommitdiffstats
path: root/integrations/issue_test.go
diff options
context:
space:
mode:
authorDavid Svantesson <david.svantesson@qrtech.se>2019-12-07 05:21:18 +0100
committertechknowlogick <techknowlogick@gitea.io>2019-12-06 23:21:18 -0500
commit9cb418e623a137fb03f6540517e6e5f4ff6e92cc (patch)
tree6bd9af2a628961647f02e86a9564b5b3c2e81875 /integrations/issue_test.go
parent82e0383d2104f454af5b3e0e768f0497113f3b13 (diff)
downloadgitea-9cb418e623a137fb03f6540517e6e5f4ff6e92cc.tar.gz
gitea-9cb418e623a137fb03f6540517e6e5f4ff6e92cc.zip
Redirect issue if repo has configured external tracker. (#9247)
* Redirect issue if repo has configured external tracker. * Handle error * Add tests for redirect * Fix test consistency
Diffstat (limited to 'integrations/issue_test.go')
-rw-r--r--integrations/issue_test.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/integrations/issue_test.go b/integrations/issue_test.go
index d46e35a946..fe66a00504 100644
--- a/integrations/issue_test.go
+++ b/integrations/issue_test.go
@@ -313,3 +313,23 @@ func testIssueChangeInfo(t *testing.T, user, issueURL, info string, value string
})
_ = session.MakeRequest(t, req, http.StatusOK)
}
+
+func TestIssueRedirect(t *testing.T) {
+ defer prepareTestEnv(t)()
+ session := loginUser(t, "user2")
+
+ // Test external tracker where style not set (shall default numeric)
+ req := NewRequest(t, "GET", path.Join("org26", "repo_external_tracker", "issues", "1"))
+ resp := session.MakeRequest(t, req, http.StatusFound)
+ assert.Equal(t, "https://tracker.com/org26/repo_external_tracker/issues/1", test.RedirectURL(resp))
+
+ // Test external tracker with numeric style
+ req = NewRequest(t, "GET", path.Join("org26", "repo_external_tracker_numeric", "issues", "1"))
+ resp = session.MakeRequest(t, req, http.StatusFound)
+ assert.Equal(t, "https://tracker.com/org26/repo_external_tracker_numeric/issues/1", test.RedirectURL(resp))
+
+ // Test external tracker with alphanumeric style (for a pull request)
+ req = NewRequest(t, "GET", path.Join("org26", "repo_external_tracker_alpha", "issues", "1"))
+ resp = session.MakeRequest(t, req, http.StatusFound)
+ assert.Equal(t, "/"+path.Join("org26", "repo_external_tracker_alpha", "pulls", "1"), test.RedirectURL(resp))
+}