mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-04 14:46:57 -05:00
Backport #27903 by @lng2020 Fix #27767 Add a test to ensure its behavior Co-authored-by: Nanguan Lin <70063547+lng2020@users.noreply.github.com>
This commit is contained in:
parent
28e3d0b0d3
commit
61d3d9205b
@ -898,6 +898,16 @@ func DeleteReview(ctx context.Context, r *Review) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
opts = FindCommentsOptions{
|
||||||
|
Type: CommentTypeDismissReview,
|
||||||
|
IssueID: r.IssueID,
|
||||||
|
ReviewID: r.ID,
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := sess.Where(opts.ToConds()).Delete(new(Comment)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if _, err := sess.ID(r.ID).Delete(new(Review)); err != nil {
|
if _, err := sess.ID(r.ID).Delete(new(Review)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
"code.gitea.io/gitea/models/db"
|
"code.gitea.io/gitea/models/db"
|
||||||
issues_model "code.gitea.io/gitea/models/issues"
|
issues_model "code.gitea.io/gitea/models/issues"
|
||||||
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
user_model "code.gitea.io/gitea/models/user"
|
user_model "code.gitea.io/gitea/models/user"
|
||||||
|
|
||||||
@ -258,3 +259,32 @@ func TestDeleteReview(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.True(t, review1.Official)
|
assert.True(t, review1.Official)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDeleteDismissedReview(t *testing.T) {
|
||||||
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||||
|
|
||||||
|
issue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 2})
|
||||||
|
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
||||||
|
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: issue.RepoID})
|
||||||
|
review, err := issues_model.CreateReview(db.DefaultContext, issues_model.CreateReviewOptions{
|
||||||
|
Content: "reject",
|
||||||
|
Type: issues_model.ReviewTypeReject,
|
||||||
|
Official: false,
|
||||||
|
Issue: issue,
|
||||||
|
Reviewer: user,
|
||||||
|
})
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.NoError(t, issues_model.DismissReview(db.DefaultContext, review, true))
|
||||||
|
comment, err := issues_model.CreateComment(db.DefaultContext, &issues_model.CreateCommentOptions{
|
||||||
|
Type: issues_model.CommentTypeDismissReview,
|
||||||
|
Doer: user,
|
||||||
|
Repo: repo,
|
||||||
|
Issue: issue,
|
||||||
|
ReviewID: review.ID,
|
||||||
|
Content: "dismiss",
|
||||||
|
})
|
||||||
|
assert.NoError(t, err)
|
||||||
|
unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: comment.ID})
|
||||||
|
assert.NoError(t, issues_model.DeleteReview(db.DefaultContext, review))
|
||||||
|
unittest.AssertNotExistsBean(t, &issues_model.Comment{ID: comment.ID})
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user