mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-25 18:02:44 +01:00
fix 500 when reviewer is deleted with integration tests (#6856)
This commit is contained in:
parent
dab38c375d
commit
2382f1b057
5 changed files with 49 additions and 2 deletions
20
integrations/pull_review_test.go
Normal file
20
integrations/pull_review_test.go
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
package integrations
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestPullView_ReviewerMissed(t *testing.T) {
|
||||||
|
prepareTestEnv(t)
|
||||||
|
session := loginUser(t, "user1")
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", "/pulls")
|
||||||
|
session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
|
req = NewRequest(t, "GET", "/user2/repo1/pulls/3")
|
||||||
|
session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
}
|
|
@ -52,3 +52,15 @@
|
||||||
tree_path: "README.md"
|
tree_path: "README.md"
|
||||||
created_unix: 946684812
|
created_unix: 946684812
|
||||||
invalidated: true
|
invalidated: true
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 7
|
||||||
|
type: 21 # code comment
|
||||||
|
poster_id: 100
|
||||||
|
issue_id: 3
|
||||||
|
content: "a review from a deleted user"
|
||||||
|
line: -4
|
||||||
|
review_id: 10
|
||||||
|
tree_path: "README.md"
|
||||||
|
created_unix: 946684812
|
||||||
|
invalidated: true
|
|
@ -70,3 +70,12 @@
|
||||||
content: "New review 3 rejected"
|
content: "New review 3 rejected"
|
||||||
updated_unix: 946684810
|
updated_unix: 946684810
|
||||||
created_unix: 946684810
|
created_unix: 946684810
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 10
|
||||||
|
type: 3
|
||||||
|
reviewer_id: 100
|
||||||
|
issue_id: 3
|
||||||
|
content: "a deleted user's review"
|
||||||
|
updated_unix: 946684810
|
||||||
|
created_unix: 946684810
|
|
@ -447,6 +447,7 @@ func (c *Comment) loadReview(e Engine) (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
c.Review.Issue = c.Issue
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -773,6 +773,8 @@ func ViewIssue(ctx *context.Context) {
|
||||||
// Render comments and and fetch participants.
|
// Render comments and and fetch participants.
|
||||||
participants[0] = issue.Poster
|
participants[0] = issue.Poster
|
||||||
for _, comment = range issue.Comments {
|
for _, comment = range issue.Comments {
|
||||||
|
comment.Issue = issue
|
||||||
|
|
||||||
if err := comment.LoadPoster(); err != nil {
|
if err := comment.LoadPoster(); err != nil {
|
||||||
ctx.ServerError("LoadPoster", err)
|
ctx.ServerError("LoadPoster", err)
|
||||||
return
|
return
|
||||||
|
@ -850,8 +852,11 @@ func ViewIssue(ctx *context.Context) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err = comment.Review.LoadAttributes(); err != nil {
|
if err = comment.Review.LoadAttributes(); err != nil {
|
||||||
ctx.ServerError("Review.LoadAttributes", err)
|
if !models.IsErrUserNotExist(err) {
|
||||||
return
|
ctx.ServerError("Review.LoadAttributes", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
comment.Review.Reviewer = models.NewGhostUser()
|
||||||
}
|
}
|
||||||
if err = comment.Review.LoadCodeComments(); err != nil {
|
if err = comment.Review.LoadCodeComments(); err != nil {
|
||||||
ctx.ServerError("Review.LoadCodeComments", err)
|
ctx.ServerError("Review.LoadCodeComments", err)
|
||||||
|
|
Loading…
Reference in a new issue