diff --git a/app/models/ext_management_system.rb b/app/models/ext_management_system.rb index 228a07dedc1..89728a0c34c 100644 --- a/app/models/ext_management_system.rb +++ b/app/models/ext_management_system.rb @@ -432,16 +432,14 @@ def enable! update!(:enabled => true) end + # override destroy_queue from AsyncDeleteMixin def self.destroy_queue(ids) - ids = Array.wrap(ids) - _log.info("Queuing destroy of #{name} with the following ids: #{ids.inspect}") - ids.each do |id| - schedule_destroy_queue(id) - end + find(Array.wrap(ids)).each(&:destroy_queue) end - # override destroy_queue from AsyncDeleteMixin def destroy_queue + _log.info("Queuing destroy of #{self.class.name} with id: #{id}") + child_managers.each(&:destroy_queue) self.class.schedule_destroy_queue(id) end diff --git a/spec/models/ext_management_system_spec.rb b/spec/models/ext_management_system_spec.rb index e9468423072..aaf4df5f8fd 100644 --- a/spec/models/ext_management_system_spec.rb +++ b/spec/models/ext_management_system_spec.rb @@ -408,6 +408,14 @@ ems.destroy expect(ExtManagementSystem.count).to eq(1) end + + it "queues up destroy for child_managers" do + child_manager = FactoryGirl.create(:ext_management_system) + ems = FactoryGirl.create(:ext_management_system, :child_managers => [child_manager]) + expect(described_class).to receive(:schedule_destroy_queue).with(ems.id) + expect(described_class).to receive(:schedule_destroy_queue).with(child_manager.id) + described_class.destroy_queue(ems.id) + end end context "virtual column :supports_block_storage" do