Skip to content

Commit

Permalink
Merge pull request #15903 from Ladas/have_parent_inventory_collection…
Browse files Browse the repository at this point in the history
…_as_internal_dependencies

Have parent inventory collections as dependencies
  • Loading branch information
agrare authored Sep 5, 2017
2 parents 9d3b7d6 + 539beb5 commit b0955e8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/models/manager_refresh/inventory_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ def initialize(model_class: nil, manager_ref: nil, association: nil, parent: nil
@custom_save_block = custom_save_block
@custom_reconnect_block = custom_reconnect_block
@check_changed = check_changed.nil? ? true : check_changed
@internal_attributes = [:__feedback_edge_set_parent]
@internal_attributes = [:__feedback_edge_set_parent, :__parent_inventory_collections]
@complete = complete.nil? ? true : complete
@update_only = update_only.nil? ? false : update_only
@builder_params = builder_params
Expand Down
13 changes: 9 additions & 4 deletions app/models/manager_refresh/inventory_collection/scanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,17 @@ def scan!
end

# Transform :parent_inventory_collections symbols to InventoryCollection objects
if targeted? && parent_inventory_collections.present?
if parent_inventory_collections.present?
self.parent_inventory_collections = parent_inventory_collections.map do |inventory_collection_index|
ic = indexed_inventory_collections[inventory_collection_index]
raise "Can't find InventoryCollection #{inventory_collection_index} from #{inventory_collection}" unless ic
ic
end
if ic.nil?
raise "Can't find InventoryCollection #{inventory_collection_index} from #{inventory_collection}" if targeted?
else
# Add parent_inventory_collection as a dependency, so e.g. disconnect is done in a right order
(dependency_attributes[:__parent_inventory_collections] ||= Set.new) << ic
ic
end
end.compact
end

# Mark InventoryCollection as finalized aka. scanned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@
:attributes_whitelist => [:raw_power_state, :ext_management_system]
)

expect(inventory_collection.attributes_whitelist).to match_array([:__feedback_edge_set_parent, :ems_ref,
expect(inventory_collection.attributes_whitelist).to match_array([:__feedback_edge_set_parent,
:__parent_inventory_collections, :ems_ref,
:name, :location, :raw_power_state,
:ext_management_system])
end
Expand All @@ -358,7 +359,8 @@
:attributes_whitelist => [:raw_power_state, :ext_management_system]
)

expect(inventory_collection.attributes_whitelist).to match_array([:__feedback_edge_set_parent, :uid_ems,
expect(inventory_collection.attributes_whitelist).to match_array([:__feedback_edge_set_parent,
:__parent_inventory_collections, :uid_ems,
:name, :location, :raw_power_state,
:ext_management_system])
end
Expand Down

0 comments on commit b0955e8

Please sign in to comment.