Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

orchestrate destroy of dependent managers #15590

Merged
merged 1 commit into from
Sep 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions app/models/ext_management_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions spec/models/ext_management_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down