{{template "repo/header" .}} {{$showDiffBox := false}} + {{$canReadPullRequests := .Permission.CanRead $.UnitTypePullRequests}}

{{if and $.PageIsComparePull $.IsSigned (not .Repository.IsArchived)}} - {{ctx.Locale.Tr "repo.pulls.compare_changes"}} -
{{ctx.Locale.Tr "repo.pulls.compare_changes_desc"}}
+ {{if $canReadPullRequests}} + {{ctx.Locale.Tr "repo.pulls.compare_changes"}} +
{{ctx.Locale.Tr "repo.pulls.compare_changes_desc"}}
+ {{else}} + {{ctx.Locale.Tr "compare.branches.title"}} + {{end}} {{else}} {{ctx.Locale.Tr "action.compare_commits_general"}} {{end}} @@ -166,7 +171,7 @@ {{else}}
{{ctx.Locale.Tr "repo.pulls.nothing_to_compare_have_tag"}}
{{end}} - {{else if and .PageIsComparePull (gt .CommitCount 0)}} + {{else if and .PageIsComparePull (gt .CommitCount 0) $canReadPullRequests}} {{if .HasPullRequest}}
diff --git a/tests/integration/compare_test.go b/tests/integration/compare_test.go index 3c3e8adf94..581aa67659 100644 --- a/tests/integration/compare_test.go +++ b/tests/integration/compare_test.go @@ -267,13 +267,14 @@ func TestCompareWithPRsDisabled(t *testing.T) { []unit_model.Type{unit_model.TypePullRequests}) require.NoError(t, err) - t.Run("branch view doesn't offer creating PRs", func(t *testing.T) { + t.Run("branch view offer comparing branches", func(t *testing.T) { defer tests.PrintCurrentTest(t)() req := NewRequest(t, "GET", "/user1/repo1/branches") resp := session.MakeRequest(t, req, http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) - htmlDoc.AssertElement(t, "a[href='/user1/repo1/compare/master...recent-push']", false) + compareLink := htmlDoc.Find("a[href='/user1/repo1/compare/master...recent-push']") + assert.Equal(t, "Compare branches", strings.TrimSpace(compareLink.Text())) }) t.Run("compare doesn't offer local branches", func(t *testing.T) { @@ -290,11 +291,13 @@ func TestCompareWithPRsDisabled(t *testing.T) { } }) - t.Run("comparing against a disabled-PR repo is 404", func(t *testing.T) { + t.Run("comparing against a disabled-PR repo", func(t *testing.T) { defer tests.PrintCurrentTest(t)() req := NewRequest(t, "GET", "/user1/repo1/compare/master...recent-push") - session.MakeRequest(t, req, http.StatusNotFound) + resp := session.MakeRequest(t, req, http.StatusOK) + htmlDoc := NewHTMLParser(t, resp.Body) + assert.Equal(t, "Compare branches", strings.TrimSpace(htmlDoc.Find("h2.header").Text())) }) }) }