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

Singularize plural model #16833

Merged
merged 3 commits into from
Feb 16, 2018
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
7 changes: 7 additions & 0 deletions app/models/asset_detail.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AssetDetail < ApplicationRecord
include NewWithTypeStiMixin

acts_as_miq_taggable

belongs_to :resource, :polymorphic => true
end
7 changes: 0 additions & 7 deletions app/models/asset_details.rb

This file was deleted.

6 changes: 3 additions & 3 deletions app/models/ems_refresh/save_inventory_physical_infra.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def save_physical_servers_inventory(ems, hashes, target = nil)
[]
end

child_keys = [:computer_system, :asset_details, :hosts]
child_keys = [:computer_system, :asset_detail, :hosts]
save_inventory_multi(ems.physical_servers, hashes, deletes, [:ems_ref], child_keys)
store_ids_for_new_records(ems.physical_servers, hashes, :ems_ref)
end
Expand All @@ -69,8 +69,8 @@ def save_customization_scripts_inventory(ems, hashes, target = nil)
#
# Saves asset details information of a resource
#
def save_asset_details_inventory(parent, hash)
def save_asset_detail_inventory(parent, hash)
return if hash.nil?
save_inventory_single(:asset_details, parent, hash)
save_inventory_single(:asset_detail, parent, hash)
end
end
2 changes: 1 addition & 1 deletion app/models/physical_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class PhysicalServer < ApplicationRecord
has_one :computer_system, :as => :managed_entity, :dependent => :destroy
has_one :hardware, :through => :computer_system
has_one :host, :inverse_of => :physical_server
has_one :asset_details, :as => :resource, :dependent => :destroy
has_one :asset_detail, :as => :resource, :dependent => :destroy

scope :with_hosts, -> { where("physical_servers.id in (select hosts.physical_server_id from hosts)") }

Expand Down
3 changes: 1 addition & 2 deletions spec/factories/asset_details.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
FactoryGirl.define do
factory :asset_details do
end
factory :asset_detail
end