From f77019ac4e9104fda812ee282d78b09b0bf9955c Mon Sep 17 00:00:00 2001 From: Ladislav Smola Date: Fri, 23 Mar 2018 17:34:09 +0100 Subject: [PATCH 1/2] Allow association to be nil and always stringify reference Allow association to be nil and always stringify reference. Not defined association should be nil not []. Reference for db_strategy needs to be stringified for g. --- app/models/manager_refresh/inventory_collection.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/manager_refresh/inventory_collection.rb b/app/models/manager_refresh/inventory_collection.rb index 8c5f320e966..4bfaa5cf2cf 100644 --- a/app/models/manager_refresh/inventory_collection.rb +++ b/app/models/manager_refresh/inventory_collection.rb @@ -411,7 +411,7 @@ def initialize(model_class: nil, manager_ref: nil, association: nil, parent: nil @secondary_refs = secondary_refs @custom_manager_uuid = custom_manager_uuid @custom_db_finder = custom_db_finder - @association = association || [] + @association = association || nil @parent = parent || nil @arel = arel @dependency_attributes = dependency_attributes || {} @@ -1086,7 +1086,8 @@ def extract_references(new_references = []) new_references.each do |manager_uuid| next if manager_uuid.nil? - uuids = manager_uuid.split(stringify_joiner) + + uuids = manager_uuid.to_s.split(stringify_joiner) reference = {} manager_ref.each_with_index do |ref, index| From 86a18b435cb6e99727c17dbf5936d00485247262 Mon Sep 17 00:00:00 2001 From: Ladislav Smola Date: Fri, 23 Mar 2018 17:35:29 +0100 Subject: [PATCH 2/2] In g release, lazy_find accepts only string In g release, lazy_find accepts only string --- .../manager_refresh/save_inventory/saver_strategies_spec.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/models/manager_refresh/save_inventory/saver_strategies_spec.rb b/spec/models/manager_refresh/save_inventory/saver_strategies_spec.rb index 418046c4ee6..e79b7598005 100644 --- a/spec/models/manager_refresh/save_inventory/saver_strategies_spec.rb +++ b/spec/models/manager_refresh/save_inventory/saver_strategies_spec.rb @@ -171,6 +171,7 @@ ) ) ) + @data[:container_quota_items] = ::ManagerRefresh::InventoryCollection.new( container_quota_items_init_data(inventory_collection_options(options)) ) @@ -221,10 +222,10 @@ @container_quota_items_data_2 = container_quota_items_data(2) @container_quota_items_attrs_data_1 = container_quota_items_attrs_data(1).merge( - :resource => @data[:container_quota_items].lazy_find(container_quota_items_data(1)[:quota_desired]) + :resource => @data[:container_quota_items].lazy_find(container_quota_items_data(1)[:quota_desired].to_s) ) @container_quota_items_attrs_data_2 = container_quota_items_attrs_data(2).merge( - :resource => @data[:container_quota_items].lazy_find(container_quota_items_data(2)[:quota_desired]) + :resource => @data[:container_quota_items].lazy_find(container_quota_items_data(2)[:quota_desired].to_s) ) # Fill InventoryCollections with data @@ -249,6 +250,7 @@ add_data_to_inventory_collection(@data[:container_quota_items_attrs], @container_quota_items_attrs_data_1, @container_quota_items_attrs_data_2) + # Assert data before save expect(@network_port1.device).to eq @vm1 expect(@network_port1.name).to eq "network_port_name_1"