FIX: Skip post validations for system revisions when author deletes post (#14824)
This commit is contained in:
parent
b1dc0dc944
commit
e2afa1b799
|
@ -205,7 +205,8 @@ class PostDestroyer
|
|||
@post.revise(@user,
|
||||
{ raw: I18n.t(key) },
|
||||
force_new_version: true,
|
||||
deleting_post: true
|
||||
deleting_post: true,
|
||||
skip_validations: true
|
||||
)
|
||||
|
||||
Post.transaction do
|
||||
|
|
|
@ -473,6 +473,18 @@ describe PostDestroyer do
|
|||
expect_job_enqueued(job: :sync_topic_user_bookmarked, args: { topic_id: post2.topic_id })
|
||||
end
|
||||
|
||||
it "skips post revise validations when post is marked for deletion by the author" do
|
||||
SiteSetting.min_first_post_length = 100
|
||||
post = create_post(raw: "this is a long post what passes the min_first_post_length validation " * 3)
|
||||
PostDestroyer.new(post.user, post).destroy
|
||||
post.reload
|
||||
expect(post.errors).to be_blank
|
||||
expect(post.revisions.count).to eq(1)
|
||||
expect(post.raw).to eq(I18n.t("js.topic.deleted_by_author_simple"))
|
||||
expect(post.user_deleted).to eq(true)
|
||||
expect(post.topic.closed).to eq(true)
|
||||
end
|
||||
|
||||
context "as a moderator" do
|
||||
it "deletes the post" do
|
||||
author = post.user
|
||||
|
|
Loading…
Reference in New Issue