Fix template error when comment review doesn't exist (#29888) (#29889)

Backport #29888
This commit is contained in:
wxiaoguang 2024-03-19 15:00:01 +08:00 committed by GitHub
parent 440be51a45
commit b9dd5dd471
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 260 additions and 198 deletions

View file

@ -13,6 +13,7 @@ import (
issues_model "code.gitea.io/gitea/models/issues"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/test"
repo_service "code.gitea.io/gitea/services/repository"
files_service "code.gitea.io/gitea/services/repository/files"
"code.gitea.io/gitea/tests"
@ -25,10 +26,19 @@ func TestPullView_ReviewerMissed(t *testing.T) {
session := loginUser(t, "user1")
req := NewRequest(t, "GET", "/pulls")
session.MakeRequest(t, req, http.StatusOK)
resp := session.MakeRequest(t, req, http.StatusOK)
assert.True(t, test.IsNormalPageCompleted(resp.Body.String()))
req = NewRequest(t, "GET", "/user2/repo1/pulls/3")
session.MakeRequest(t, req, http.StatusOK)
resp = session.MakeRequest(t, req, http.StatusOK)
assert.True(t, test.IsNormalPageCompleted(resp.Body.String()))
// if some reviews are missing, the page shouldn't fail
err := db.TruncateBeans(db.DefaultContext, &issues_model.Review{})
assert.NoError(t, err)
req = NewRequest(t, "GET", "/user2/repo1/pulls/2")
resp = session.MakeRequest(t, req, http.StatusOK)
assert.True(t, test.IsNormalPageCompleted(resp.Body.String()))
}
func TestPullView_CodeOwner(t *testing.T) {