Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 6.0 #95

Merged
merged 5 commits into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion inventory_refresh.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_dependency "activerecord", "~> 5.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, agreed. Since this is a gem we publish, and there is seemingly no other change, just supporting Rails 5 and 6 should be sufficient for our purposes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we can do this now, since there is a .update_attributes change I did. I probably can remove that change, but wanted to get everyone else's opinion before I do.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NickLaMuro it looks like the only changes from #update_attributes to #update were in specs, I'm good with ">=5.0", "< 6.1"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I think I saw lib/inventory_refresh/inventory_collection/helpers/initialize_helper.rb in the files changed diff, and didn't take a look at the contents, which only changes a comment and is fine.

spec.add_dependency "activerecord", ">=5.0", "< 6.1"
spec.add_dependency "more_core_extensions", ">=3.5", "< 5"
spec.add_dependency "pg", "> 0"

Expand Down
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
26 changes: 13 additions & 13 deletions spec/factories/hardware.rb
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
FactoryBot.define do
factory :hardware do
trait(:cpu1x1) do
cpu_sockets 1
cpu_cores_per_socket 1
cpu_total_cores 1
cpu_sockets { 1 }
cpu_cores_per_socket { 1 }
cpu_total_cores { 1 }
end

trait(:cpu2x2) do
cpu_sockets 2
cpu_cores_per_socket 2
cpu_total_cores 4
cpu_sockets { 2 }
cpu_cores_per_socket { 2 }
cpu_total_cores { 4 }
end

trait(:cpu1x2) do
cpu_sockets 1
cpu_cores_per_socket 2
cpu_total_cores 2
cpu_sockets { 1 }
cpu_cores_per_socket { 2 }
cpu_total_cores { 2 }
end

trait(:cpu4x2) do
cpu_sockets 4
cpu_cores_per_socket 2
cpu_total_cores 8
cpu_sockets { 4 }
cpu_cores_per_socket { 2 }
cpu_total_cores { 8 }
end

trait(:ram1GB) { memory_mb 1024 }
trait(:ram1GB) { memory_mb { 1024 } }
end
end
8 changes: 4 additions & 4 deletions spec/factories/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
factory :host do
sequence(:name) { |n| "host_#{seq_padded_for_sorting(n)}" }
sequence(:hostname) { |n| "host-#{seq_padded_for_sorting(n)}" }
vmm_vendor "vmware"
ipaddress "127.0.0.1"
user_assigned_os "linux_generic"
power_state "on"
vmm_vendor { "vmware" }
ipaddress { "127.0.0.1" }
user_assigned_os { "linux_generic" }
power_state { "on" }
end
end
2 changes: 1 addition & 1 deletion spec/factories/orchestration_stack.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FactoryBot.define do
factory :orchestration_stack do
ems_ref "1"
ems_ref { "1" }
end

factory :orchestration_stack_cloud, :parent => :orchestration_stack, :class => "ManageIQ::Providers::CloudManager::OrchestrationStack"
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/physical_server.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FactoryBot.define do
factory :physical_server do
vendor "lenovo"
vendor { "lenovo" }
end
end
14 changes: 7 additions & 7 deletions spec/factories/vm_or_template.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
FactoryBot.define do
factory :vm_or_template do
sequence(:name) { |n| "vm_#{seq_padded_for_sorting(n)}" }
location "unknown"
location { "unknown" }
uid_ems { SecureRandom.uuid }
vendor "unknown"
template false
raw_power_state "running"
vendor { "unknown" }
template { false }
raw_power_state { "running" }
end

factory :template, :class => "MiqTemplate", :parent => :vm_or_template do
sequence(:name) { |n| "template_#{seq_padded_for_sorting(n)}" }
template true
raw_power_state "never"
template { true }
raw_power_state { "never" }
end

factory(:vm, :class => "Vm", :parent => :vm_or_template)
factory(:vm_cloud, :class => "ManageIQ::Providers::CloudManager::Vm", :parent => :vm) { cloud true }
factory(:vm_cloud, :class => "ManageIQ::Providers::CloudManager::Vm", :parent => :vm) { cloud { true } }
factory(:miq_template, :parent => :template)
end
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
2 changes: 1 addition & 1 deletion spec/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
t.bigint "size"
t.bigint "free_space"
t.bigint "size_on_disk"
t.boolean "present", default: true
t.boolean "connected", default: true
t.boolean "start_connected", default: true
t.boolean "auto_detect"
t.datetime "created_on"
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require "bundler/setup"
require "inventory_refresh"
require "active_record"
require "active_support/all"

RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
Expand Down