FIX: Skip post validations for system revisions when author deletes post (#14824)

FIX: Skip post validations for system revisions when author deletes post (#14824)

diff --git a/lib/post_destroyer.rb b/lib/post_destroyer.rb
index f87a191..9d09c7e 100644
--- a/lib/post_destroyer.rb
+++ b/lib/post_destroyer.rb
@@ -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
diff --git a/spec/components/post_destroyer_spec.rb b/spec/components/post_destroyer_spec.rb
index a1e3b98..530df23 100644
--- a/spec/components/post_destroyer_spec.rb
+++ b/spec/components/post_destroyer_spec.rb
@@ -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

GitHub sha: e2afa1b799b21382a536e1b1034b4f6ca7a4a4f4

This commit appears in #14824 which was approved by eviltrout. It was merged by tgxworld.