Skip to content

Commit 5554165

Browse files
ethantkoenigappleboy
authored andcommitted
Fix pull request compare link (#1832)
* Fix pull request compare link * Integration test
1 parent bfb44f8 commit 5554165

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

integrations/pull_compare_test.go

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2017 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package integrations
6+
7+
import (
8+
"net/http"
9+
"testing"
10+
11+
"github.com/stretchr/testify/assert"
12+
)
13+
14+
func TestPullCompare(t *testing.T) {
15+
prepareTestEnv(t)
16+
17+
session := loginUser(t, "user2", "password")
18+
req, err := http.NewRequest("GET", "/user2/repo1/pulls", nil)
19+
assert.NoError(t, err)
20+
resp := session.MakeRequest(t, req)
21+
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
22+
htmlDoc, err := NewHtmlParser(resp.Body)
23+
assert.NoError(t, err)
24+
link, exists := htmlDoc.doc.Find(".navbar").Find(".ui.green.button").Attr("href")
25+
assert.True(t, exists, "The template has changed")
26+
27+
req, err = http.NewRequest("GET", link, nil)
28+
assert.NoError(t, err)
29+
resp = session.MakeRequest(t, req)
30+
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
31+
}

models/fixtures/repo_unit.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@
1717
-
1818
id: 3
1919
repo_id: 1
20+
type: 3
21+
index: 0
22+
config: "{}"
23+
created_unix: 946684810
24+
25+
-
26+
id: 4
27+
repo_id: 1
2028
type: 7
2129
index: 0
2230
config: "{}"
23-
created_unix: 946684810
31+
created_unix: 946684810

templates/repo/home.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<div class="ui secondary menu">
1111
{{if .PullRequestCtx.Allowed}}
1212
<div class="fitted item">
13-
<a href="{{.BaseRepo.Link}}/compare/{{.BaseRepo.DefaultBranch}}...{{.Username}}:{{.BranchName}}">
13+
<a href="{{.BaseRepo.Link}}/compare/{{.BaseRepo.DefaultBranch}}...{{.SignedUser.Name}}:{{.BranchName}}">
1414
<button class="ui green small button"><i class="octicon octicon-git-compare"></i></button>
1515
</a>
1616
</div>

0 commit comments

Comments
 (0)