From ec2d5d004e0c6ba39a14de51adc082b8658145b0 Mon Sep 17 00:00:00 2001 From: lpichler Date: Tue, 26 Feb 2019 16:59:34 +0100 Subject: [PATCH] Delete also vms_and_templates and miq_templates to parent_manager in NetworkManager --- app/models/manageiq/providers/network_manager.rb | 4 ++++ .../manageiq/providers/network_manager_spec.rb | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 spec/models/manageiq/providers/network_manager_spec.rb diff --git a/app/models/manageiq/providers/network_manager.rb b/app/models/manageiq/providers/network_manager.rb index 20357804726..ff96c9d0328 100644 --- a/app/models/manageiq/providers/network_manager.rb +++ b/app/models/manageiq/providers/network_manager.rb @@ -71,6 +71,10 @@ class << model_name :resource_groups, :vms, :total_vms, + :vms_and_templates, + :total_vms_and_templates, + :miq_templates, + :total_miq_templates, :hosts, :to => :parent_manager, :allow_nil => true diff --git a/spec/models/manageiq/providers/network_manager_spec.rb b/spec/models/manageiq/providers/network_manager_spec.rb new file mode 100644 index 00000000000..ecabbbb771c --- /dev/null +++ b/spec/models/manageiq/providers/network_manager_spec.rb @@ -0,0 +1,16 @@ +describe ManageIQ::Providers::NetworkManager do + let(:vms) { FactoryBot.create(:vm) } + let(:template) { FactoryBot.create(:miq_template) } + + let(:ems) { FactoryBot.create(:ems_openstack, :vms => [vms], :miq_templates => [template]) } + + it "delegates vms and templates to parent manager (ExtManagementSystem)" do + expect(ems.id).not_to eq(ems.network_manager.id) + expect(ems.vms).to match_array([vms]) + expect(ems.network_manager.vms).to match_array([vms]) + expect(ems.miq_templates).to match_array([template]) + expect(ems.network_manager.miq_templates).to match_array([template]) + expect(ems.vms_and_templates).to match_array([vms, template]) + expect(ems.network_manager.vms_and_templates).to match_array([vms, template]) + end +end