Skip to content

Commit

Permalink
Destroy topic's collection when topic is destroyed
Browse files Browse the repository at this point in the history
  • Loading branch information
angusmcleod committed Oct 22, 2024
1 parent 958132b commit be1f8eb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@
actors.as_json
end

Topic.has_one :activity_pub_object, class_name: "DiscourseActivityPubCollection", as: :model
Topic.has_one :activity_pub_object,
class_name: "DiscourseActivityPubCollection",
as: :model,
dependent: :destroy
Topic.include DiscourseActivityPub::AP::ModelHelpers

add_to_class(:topic, :activity_pub_taxonomies) do
Expand Down
7 changes: 7 additions & 0 deletions spec/models/topic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@
end
end

describe "#destroy!" do
it "destroys associated collections" do
topic1.destroy!
expect(DiscourseActivityPubCollection.exists?(collection1.id)).to eq(false)
end
end

describe "move_posts" do
before { toggle_activity_pub(category1, publication_type: "full_topic") }

Expand Down

0 comments on commit be1f8eb

Please sign in to comment.