fix cherry-pick

This commit is contained in:
oliverpool 2024-02-27 16:05:59 +01:00 committed by Earl Warren
parent f95fb8cc44
commit 3c9b176348
2 changed files with 10 additions and 6 deletions

View file

@ -989,10 +989,12 @@ func viewPullFiles(ctx *context.Context, specifiedStartCommit, specifiedEndCommi
for _, file := range diff.Files {
for _, section := range file.Sections {
for _, line := range section.Lines {
for _, comment := range line.Comments {
if err := comment.LoadAttachments(ctx); err != nil {
ctx.ServerError("LoadAttachments", err)
return
for _, comments := range line.Conversations {
for _, comment := range comments {
if err := comment.LoadAttachments(ctx); err != nil {
ctx.ServerError("LoadAttachments", err)
return
}
}
}
}

View file

@ -28,7 +28,8 @@ func TestRenderConversation(t *testing.T) {
run := func(name string, cb func(t *testing.T, ctx *context.Context, resp *httptest.ResponseRecorder)) {
t.Run(name, func(t *testing.T) {
ctx, resp := contexttest.MockContext(t, "/", contexttest.MockContextOption{Render: templates.HTMLRenderer()})
ctx, resp := contexttest.MockContext(t, "/")
ctx.Render = templates.HTMLRenderer()
contexttest.LoadUser(t, ctx, pr.Issue.PosterID)
contexttest.LoadRepo(t, ctx, pr.BaseRepoID)
contexttest.LoadGitRepo(t, ctx)
@ -61,7 +62,8 @@ func TestRenderConversation(t *testing.T) {
run("diff without outdated", func(t *testing.T, ctx *context.Context, resp *httptest.ResponseRecorder) {
ctx.Data["ShowOutdatedComments"] = false
renderConversation(ctx, preparedComment, "diff")
assert.Contains(t, resp.Body.String(), `conversation-not-existing`)
// unlike gitea, Forgejo renders the conversation (with the "outdated" label)
assert.Contains(t, resp.Body.String(), `repo.issues.review.outdated_description`)
})
run("timeline with outdated", func(t *testing.T, ctx *context.Context, resp *httptest.ResponseRecorder) {
ctx.Data["ShowOutdatedComments"] = true