From c195eab46bc1e31301d49401ab8d29686fc4ef2c Mon Sep 17 00:00:00 2001 From: Joe Rafaniello Date: Fri, 30 Aug 2024 14:21:35 -0400 Subject: [PATCH] Merge pull request #1267 from agrare/fix_cloud_networks_a_collection_including Fix CloudNetworks spec with empty including() (cherry picked from commit 4e4e1a07c1f14575a11ad8eb09265331f96adba4) --- spec/requests/cloud_networks_spec.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/spec/requests/cloud_networks_spec.rb b/spec/requests/cloud_networks_spec.rb index a4ef51401f..4d271ca408 100644 --- a/spec/requests/cloud_networks_spec.rb +++ b/spec/requests/cloud_networks_spec.rb @@ -62,16 +62,21 @@ it 'successfully returns providers on query when providers do not have cloud_networks attribute' do FactoryBot.create(:ems_container) # Openshift container manager does not respond to #cloud_networks - FactoryBot.create(:ems_cloud).tap { |x| 2.times { x.cloud_networks << FactoryBot.create(:cloud_network) } } # Provider with cloud networks - api_basic_authorize collection_action_identifier(:providers, :read, :get) + ems_cloud = FactoryBot.create(:ems_cloud) # Provider with cloud networks + cloud_network_1 = FactoryBot.create(:cloud_network, :ext_management_system => ems_cloud.network_manager) + cloud_network_2 = FactoryBot.create(:cloud_network, :ext_management_system => ems_cloud.network_manager) + api_basic_authorize collection_action_identifier(:providers, :read, :get) get api_providers_url, :params => { :expand => 'resources,cloud_networks' } expected = { 'resources' => a_collection_including( a_hash_including( 'type' => 'ManageIQ::Providers::Amazon::CloudManager', - 'cloud_networks' => a_collection_including + 'cloud_networks' => a_collection_including( + a_hash_including('id' => cloud_network_1.id.to_s), + a_hash_including('id' => cloud_network_2.id.to_s) + ) ), a_hash_including( 'type' => 'ManageIQ::Providers::Openshift::ContainerManager'