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 _, file := range diff.Files {
for _, section := range file.Sections { for _, section := range file.Sections {
for _, line := range section.Lines { for _, line := range section.Lines {
for _, comment := range line.Comments { for _, comments := range line.Conversations {
if err := comment.LoadAttachments(ctx); err != nil { for _, comment := range comments {
ctx.ServerError("LoadAttachments", err) if err := comment.LoadAttachments(ctx); err != nil {
return 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)) { run := func(name string, cb func(t *testing.T, ctx *context.Context, resp *httptest.ResponseRecorder)) {
t.Run(name, func(t *testing.T) { 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.LoadUser(t, ctx, pr.Issue.PosterID)
contexttest.LoadRepo(t, ctx, pr.BaseRepoID) contexttest.LoadRepo(t, ctx, pr.BaseRepoID)
contexttest.LoadGitRepo(t, ctx) 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) { run("diff without outdated", func(t *testing.T, ctx *context.Context, resp *httptest.ResponseRecorder) {
ctx.Data["ShowOutdatedComments"] = false ctx.Data["ShowOutdatedComments"] = false
renderConversation(ctx, preparedComment, "diff") 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) { run("timeline with outdated", func(t *testing.T, ctx *context.Context, resp *httptest.ResponseRecorder) {
ctx.Data["ShowOutdatedComments"] = true ctx.Data["ShowOutdatedComments"] = true