mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 01:45:07 +08:00
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:
@ -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
|
||||
|
Reference in New Issue
Block a user