FIX: deleted misconfigured embeddable hosts (#19833)

When EmbeddableHost is configured for a specific category and that category is deleted, then EmbeddableHost should be deleted as well.

In addition, migration was added to fix existing data.
This commit is contained in:
Krzysztof Kotlarek
2023-01-20 13:29:49 +11:00
committed by GitHub
parent f122f24b35
commit f409e977a9
3 changed files with 26 additions and 0 deletions

View File

@ -577,6 +577,12 @@ RSpec.describe Category do
expect(SiteSetting.shared_drafts_category).to be_blank
end
it "deletes related embeddable host" do
embeddable_host = Fabricate(:embeddable_host, category: @category)
@category.destroy!
expect { embeddable_host.reload }.to raise_error(ActiveRecord::RecordNotFound)
end
it "triggers a extensibility event" do
event = DiscourseEvent.track(:category_destroyed) { @category.destroy }