diff --git a/models/issues/comment.go b/models/issues/comment.go index 00db0966bc0..393579b1823 100644 --- a/models/issues/comment.go +++ b/models/issues/comment.go @@ -1174,6 +1174,11 @@ func UpdateComment(ctx context.Context, c *Comment, contentVersion int, doer *us if affected == 0 { return ErrCommentAlreadyChanged } + if c.Type == CommentTypeReview { + if _, err := db.GetEngine(ctx).ID(c.ReviewID).Cols("content").NoAutoTime().Update(&Review{Content: c.Content}); err != nil { // updated_unix picks a reviewer's latest review + return err + } + } if err := c.LoadIssue(ctx); err != nil { return err } diff --git a/tests/integration/api_pull_review_test.go b/tests/integration/api_pull_review_test.go index d5c8a4b41b3..e173b3b5237 100644 --- a/tests/integration/api_pull_review_test.go +++ b/tests/integration/api_pull_review_test.go @@ -130,6 +130,12 @@ func testAPIPullReviewGeneral(t *testing.T) { assert.EqualValues(t, "APPROVED", review.State) assert.Equal(t, 3, review.CodeCommentsCount) + reviewComment := unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ReviewID: review.ID, Type: issues_model.CommentTypeReview}) + req = NewRequestWithJSON(t, http.MethodPatch, fmt.Sprintf("/api/v1/repos/%s/%s/issues/comments/%d", repo.OwnerName, repo.Name, reviewComment.ID), &api.EditIssueCommentOption{Body: "just one nit"}).AddTokenAuth(getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteIssue)) + MakeRequest(t, req, http.StatusOK) + req = NewRequest(t, http.MethodGet, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/reviews/%d", repo.OwnerName, repo.Name, pullIssue.Index, review.ID)).AddTokenAuth(token) + assert.Equal(t, "just one nit", DecodeJSON(t, MakeRequest(t, req, http.StatusOK), &api.PullReview{}).Body) + // test dismiss review req = NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/reviews/%d/dismissals", repo.OwnerName, repo.Name, pullIssue.Index, review.ID), &api.DismissPullReviewOptions{ Message: "test",