Add an trailing slash to dashboard links (#29555)

Fix #29533, and add some tests for "base/paginate.tmpl"

(cherry picked from commit 8553b4600e3035b6f6ad6907c37cebd013fa4d64)

Conflicts:
	services/contexttest/context_tests.go
	trivial conflict because
	"Improve user experience for outdated comments" was skipped
This commit is contained in:
wxiaoguang 2024-03-04 09:02:51 +08:00 committed by Earl Warren
parent cfce4e089e
commit de6768ed54
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
5 changed files with 33 additions and 10 deletions

View file

@ -11,6 +11,8 @@ import (
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unittest"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/templates"
"code.gitea.io/gitea/services/context"
"code.gitea.io/gitea/services/contexttest"
"github.com/stretchr/testify/assert"
@ -113,3 +115,18 @@ func TestMilestonesForSpecificRepo(t *testing.T) {
assert.Len(t, ctx.Data["Milestones"], 1)
assert.Len(t, ctx.Data["Repos"], 2) // both repo 42 and 1 have milestones and both are owned by user 2
}
func TestDashboardPagination(t *testing.T) {
ctx, _ := contexttest.MockContext(t, "/", contexttest.MockContextOption{Render: templates.HTMLRenderer()})
page := context.NewPagination(10, 3, 1, 3)
setting.AppSubURL = "/SubPath"
out, err := ctx.RenderToHTML("base/paginate", map[string]any{"Link": setting.AppSubURL, "Page": page})
assert.NoError(t, err)
assert.Contains(t, out, `<a class=" item navigation" href="/SubPath/?page=2">`)
setting.AppSubURL = ""
out, err = ctx.RenderToHTML("base/paginate", map[string]any{"Link": setting.AppSubURL, "Page": page})
assert.NoError(t, err)
assert.Contains(t, out, `<a class=" item navigation" href="/?page=2">`)
}