mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-21 08:31:27 -05:00
Merge pull request '[BUG] save empty comments' (#3442) from oliverpool/forgejo:empty_comments into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3442 Reviewed-by: Otto <otto@codeberg.org> Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
This commit is contained in:
commit
94d7523f83
2 changed files with 10 additions and 6 deletions
|
@ -3160,12 +3160,6 @@ func UpdateCommentContent(ctx *context.Context) {
|
||||||
|
|
||||||
oldContent := comment.Content
|
oldContent := comment.Content
|
||||||
comment.Content = ctx.FormString("content")
|
comment.Content = ctx.FormString("content")
|
||||||
if len(comment.Content) == 0 {
|
|
||||||
ctx.JSON(http.StatusOK, map[string]any{
|
|
||||||
"content": "",
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err = issue_service.UpdateComment(ctx, comment, ctx.Doer, oldContent); err != nil {
|
if err = issue_service.UpdateComment(ctx, comment, ctx.Doer, oldContent); err != nil {
|
||||||
ctx.ServerError("UpdateComment", err)
|
ctx.ServerError("UpdateComment", err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -307,6 +307,16 @@ func TestIssueCommentUpdate(t *testing.T) {
|
||||||
|
|
||||||
comment = unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: commentID})
|
comment = unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: commentID})
|
||||||
assert.Equal(t, modifiedContent, comment.Content)
|
assert.Equal(t, modifiedContent, comment.Content)
|
||||||
|
|
||||||
|
// make the comment empty
|
||||||
|
req = NewRequestWithValues(t, "POST", fmt.Sprintf("/%s/%s/comments/%d", "user2", "repo1", commentID), map[string]string{
|
||||||
|
"_csrf": GetCSRF(t, session, issueURL),
|
||||||
|
"content": "",
|
||||||
|
})
|
||||||
|
session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
|
comment = unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: commentID})
|
||||||
|
assert.Equal(t, "", comment.Content)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIssueReaction(t *testing.T) {
|
func TestIssueReaction(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue