Skip to content

Commit

Permalink
[rails6] Fix .update_attributes deprecation
Browse files Browse the repository at this point in the history
Fixing the following deprecation warning:

  DEPRECATION WARNING: update_attributes is deprecated and will be
  removed from Rails 6.1 (please, use update instead)
  • Loading branch information
NickLaMuro committed Dec 15, 2020
1 parent eb9b2b0 commit bf26d74
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/models/archived_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions spec/save_inventory/single_inventory_collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down Expand Up @@ -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|
Expand Down Expand Up @@ -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|
Expand Down Expand Up @@ -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|
Expand Down

0 comments on commit bf26d74

Please sign in to comment.