summaryrefslogtreecommitdiffstats
path: root/routers/web/repo
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-03-19 15:00:01 +0800
committerGitHub <noreply@github.com>2024-03-19 15:00:01 +0800
commitb9dd5dd471858c52cd7b202995ab64f6fe28a519 (patch)
treeaed1c80335a8fe34753084ab11285ec5ec97155a /routers/web/repo
parent440be51a451baf08098501e300181cd77d798e11 (diff)
downloadgitea-b9dd5dd471858c52cd7b202995ab64f6fe28a519.tar.gz
gitea-b9dd5dd471858c52cd7b202995ab64f6fe28a519.zip
Fix template error when comment review doesn't exist (#29888) (#29889)
Backport #29888
Diffstat (limited to 'routers/web/repo')
-rw-r--r--routers/web/repo/pull_review_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/routers/web/repo/pull_review_test.go b/routers/web/repo/pull_review_test.go
index 7e6594774a..af6e0ece18 100644
--- a/routers/web/repo/pull_review_test.go
+++ b/routers/web/repo/pull_review_test.go
@@ -4,6 +4,7 @@
package repo
import (
+ "net/http"
"net/http/httptest"
"testing"
@@ -73,4 +74,20 @@ func TestRenderConversation(t *testing.T) {
renderConversation(ctx, preparedComment, "timeline")
assert.Contains(t, resp.Body.String(), `<div id="code-comments-`)
})
+ run("diff non-existing review", func(t *testing.T, ctx *context.Context, resp *httptest.ResponseRecorder) {
+ err := db.TruncateBeans(db.DefaultContext, &issues_model.Review{})
+ assert.NoError(t, err)
+ ctx.Data["ShowOutdatedComments"] = true
+ renderConversation(ctx, preparedComment, "diff")
+ assert.Equal(t, http.StatusOK, resp.Code)
+ assert.NotContains(t, resp.Body.String(), `status-page-500`)
+ })
+ run("timeline non-existing review", func(t *testing.T, ctx *context.Context, resp *httptest.ResponseRecorder) {
+ err := db.TruncateBeans(db.DefaultContext, &issues_model.Review{})
+ assert.NoError(t, err)
+ ctx.Data["ShowOutdatedComments"] = true
+ renderConversation(ctx, preparedComment, "timeline")
+ assert.Equal(t, http.StatusOK, resp.Code)
+ assert.NotContains(t, resp.Body.String(), `status-page-500`)
+ })
}