A platform for community discussion. Free, open, simple.
FIX: Unpublish a topic's published page when converting it to a private message (#44069)
Gabriel Grubbac02ca7b231a4
diff --git a/app/models/topic_converter.rb b/app/models/topic_converter.rbindex 4cde42bb953..149c945a34d 100644--- a/app/models/topic_converter.rb+++ b/app/models/topic_converter.rb@@ -70,6 +70,7 @@ class TopicConverterraise ActiveRecord::Rollback if !revised || [email protected]?+ PublishedPage.unpublish!(@user, @topic) if @topic.published_pageadd_allowed_usersupdate_post_uploads_secure_statusadd_small_action("private_topic") unless @silentdiff --git a/spec/requests/topics_controller_spec.rb b/spec/requests/topics_controller_spec.rbindex 5bdff9c1b4a..ff9c7c0f4c1 100644--- a/spec/requests/topics_controller_spec.rb+++ b/spec/requests/topics_controller_spec.rb@@ -6676,7 +6676,14 @@ RSpec.describe TopicsController doendcontext "with success" do- it "returns success" do+ it "revokes a public published page when converting the topic" do+ SiteSetting.enable_page_publishing = true+ published_page = Fabricate(:published_page, topic: topic, public: true)++ get published_page.path+ expect(response.status).to eq(200)+ expect(response.body).to include(post.raw)+sign_in(admin)put "/t/#{topic.id}/convert-topic/private.json"@@ -6687,6 +6694,12 @@ RSpec.describe TopicsController doresult = response.parsed_bodyexpect(result["success"]).to eq(true)expect(result["url"]).to be_present++ sign_out+ get published_page.path+ expect(response.status).to eq(404)+ expect(response.body).not_to include(post.raw)+ expect(PublishedPage.exists?(topic: topic)).to eq(false)endendend