A platform for community discussion. Free, open, simple.
FIX: When destroying a topic, destroy its associated published page. (#12358)
Roman Rizzi56262349a9e6
diff --git a/lib/post_destroyer.rb b/lib/post_destroyer.rbindex 5f8d793add8..4353adf5e07 100644--- a/lib/post_destroyer.rb+++ b/lib/post_destroyer.rb@@ -165,6 +165,7 @@ class PostDestroyerif @post.topic && @post.is_first_post?permanent? ? @post.topic.destroy! : @post.topic.trash!(@user)+ PublishedPage.unpublish!(@user, @post.topic) if @post.topic.published_pageendupdate_associated_category_latest_topicupdate_user_countsdiff --git a/spec/components/post_destroyer_spec.rb b/spec/components/post_destroyer_spec.rbindex 88f14b07470..1428fe1db6c 100644--- a/spec/components/post_destroyer_spec.rb+++ b/spec/components/post_destroyer_spec.rb@@ -439,6 +439,17 @@ describe PostDestroyer doexpect(user2.user_stat.post_count).to eq(0)end+ it 'deletes the published page associated with the topic' do+ slug = 'my-published-page'+ publish_result = PublishedPage.publish!(admin, post.topic, slug)+ pp = publish_result.last+ expect(publish_result.first).to eq(true)++ PostDestroyer.new(admin, post).destroy++ expect(PublishedPage.find_by(id: pp.id)).to be_nil+ end+it "accepts a delete_removed_posts_after option" doSiteSetting.delete_removed_posts_after = 0