DEV: Add a new type_source field to the Reviewable model. (#31325)

This change adds a new `type_source` field to the `Reviewable` model, indicating whether the Reviewable type was registered by `core`, a plugin, or an `unknown` source.

When a plugin that registered a Reviewable type is disabled, this allows us to tell the user which plugin they need to re-enable to handle any orphan reviewable items.
This commit is contained in:
Gary Pendergast
2025-02-20 09:09:47 +11:00
committed by GitHub
parent dd5901d51e
commit 29a8c6ee49
22 changed files with 232 additions and 8 deletions

View File

@ -625,13 +625,22 @@ TEXT
subject(:register_reviewable_type) { plugin_instance.register_reviewable_type(new_type) }
context "when the provided class inherits from `Reviewable`" do
let(:new_type) { Class.new(Reviewable) }
let(:new_type) do
class MyReviewable < Reviewable
end
MyReviewable
end
it "adds the provided class to the existing types" do
expect { register_reviewable_type }.to change { Reviewable.types.size }.by(1)
expect(Reviewable.types).to include(new_type)
end
it "shows the correct source for the new type" do
register_reviewable_type
expect(Reviewable.source_for(new_type)).to eq("discourse-sample-plugin")
end
context "when the plugin is disabled" do
before do
register_reviewable_type