diff --git a/lib/inventory_refresh/inventory_collection/helpers/initialize_helper.rb b/lib/inventory_refresh/inventory_collection/helpers/initialize_helper.rb index 7c33f3dd..7350a6fa 100644 --- a/lib/inventory_refresh/inventory_collection/helpers/initialize_helper.rb +++ b/lib/inventory_refresh/inventory_collection/helpers/initialize_helper.rb @@ -289,7 +289,7 @@ def init_arels(arel, targeted_arel) # hash = inventory_object.attributes # Loads possible dependencies into saveable hash # obj = SomeModel.find_by(:attr => hash[:attr]) # Note: doing find_by for many models produces N+1 # # queries, avoid this, this is just a simple example :-) - # obj.update_attributes(hash) if obj + # obj.update(hash) if obj # obj ||= SomeModel.create(hash) # inventory_object.id = obj.id # If this InventoryObject is referenced elsewhere, we need to store its # primary key back to the InventoryObject diff --git a/spec/models/archived_mixin.rb b/spec/models/archived_mixin.rb index d5e0af42..f326478a 100644 --- a/spec/models/archived_mixin.rb +++ b/spec/models/archived_mixin.rb @@ -17,11 +17,11 @@ def active? alias_method :active, :active? def archive! - update_attributes!(:archived_at => Time.now.utc) + update!(:archived_at => Time.now.utc) end def unarchive! - update_attributes!(:archived_at => nil) + update!(:archived_at => nil) end def self.archive!(ids) diff --git a/spec/save_inventory/single_inventory_collection_spec.rb b/spec/save_inventory/single_inventory_collection_spec.rb index 819f857d..c95c7836 100644 --- a/spec/save_inventory/single_inventory_collection_spec.rb +++ b/spec/save_inventory/single_inventory_collection_spec.rb @@ -541,8 +541,8 @@ context 'with VM InventoryCollection with changed parent and association' do it 'deletes missing and creates new VMs with AvailabilityZone parent, ' do availability_zone = FactoryBot.create(:availability_zone, :ext_management_system => @ems) - @vm1.update_attributes(:availability_zone => availability_zone) - @vm2.update_attributes(:availability_zone => availability_zone) + @vm1.update(:availability_zone => availability_zone) + @vm2.update(:availability_zone => availability_zone) # Initialize the InventoryCollections @persister.add_collection(:vms) do |builder| @@ -571,8 +571,8 @@ it 'deletes missing and creates new VMs with CloudTenant parent' do cloud_tenant = FactoryBot.create(:cloud_tenant, :ext_management_system => @ems) - @vm1.update_attributes(:cloud_tenant => cloud_tenant) - @vm2.update_attributes(:cloud_tenant => cloud_tenant) + @vm1.update(:cloud_tenant => cloud_tenant) + @vm2.update(:cloud_tenant => cloud_tenant) # Initialize the InventoryCollections @persister.add_collection(:vms) do |builder| @@ -601,8 +601,8 @@ it 'affects oly relation to CloudTenant when not providing EMS relation and with CloudTenant parent' do cloud_tenant = FactoryBot.create(:cloud_tenant, :ext_management_system => @ems) - @vm1.update_attributes(:cloud_tenant => cloud_tenant) - @vm2.update_attributes(:cloud_tenant => cloud_tenant) + @vm1.update(:cloud_tenant => cloud_tenant) + @vm2.update(:cloud_tenant => cloud_tenant) # Initialize the InventoryCollections @persister.add_collection(:vms) do |builder| @@ -639,8 +639,8 @@ it 'does not delete the missing VMs with :complete => false and with CloudTenant parent' do cloud_tenant = FactoryBot.create(:cloud_tenant, :ext_management_system => @ems) - @vm1.update_attributes(:cloud_tenant => cloud_tenant) - @vm2.update_attributes(:cloud_tenant => cloud_tenant) + @vm1.update(:cloud_tenant => cloud_tenant) + @vm2.update(:cloud_tenant => cloud_tenant) # Initialize the InventoryCollections @persister.add_collection(:vms) do |builder|