Skip to content

Commit

Permalink
Fix rubocop issues
Browse files Browse the repository at this point in the history
  • Loading branch information
GilbertCherrie committed Jun 28, 2024
1 parent a81de65 commit c54ce45
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
9 changes: 0 additions & 9 deletions lib/miq_automation_engine/engine/miq_ae_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,6 @@ def self.create_automation_attributes_string(hash)
args = create_automation_attributes(hash)
return args if args.kind_of?(String)

# result_array = []
# args.keys.each do |k|
# args[k].each do |item|
# result_array.push(item.id)
# end
# end
# result_string = result_array.join("\x1F")

args.collect { |a| a.join("=") }.join("&")
end

Expand Down Expand Up @@ -270,7 +262,6 @@ def self.create_automation_attribute_array_key(key)
end

def self.create_automation_attribute_array_value(value)
# value
value.collect do |obj|
obj.kind_of?(ActiveRecord::Base) ? obj.id.to_s : obj.to_s
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def user_info_attributes(user)
end

def process_args_as_attributes(args = {})
args.keys.each { |k| attribute_is_array?(args, k) ? process_args_array(args, k) : process_args_attribute(args, k) }
args.keys.each { |k| attribute_is_array?(k) ? process_args_array(args, k) : process_args_attribute(args, k) }
@attributes.merge!(args)
end

Expand All @@ -264,7 +264,7 @@ def process_args_array(args, args_key)
args[key.downcase] = load_array_objects_from_string(value)
end

def attribute_is_array?(object, attr)
def attribute_is_array?(attr)
attr.to_s.downcase.starts_with?("array::")
end

Expand Down
2 changes: 1 addition & 1 deletion spec/miq_ae_engine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def call_automate(obj_type, obj_id, open_url_task_id = nil)
FactoryBot.create(:host)
hash = {"hosts" => Host.all}
attrs = {"Array::my_hosts" => hash["hosts"].collect { |h| "Host::#{h.id}" }}
result_str = "Array%3A%3Amy_hosts=" + hash["hosts"].collect { |h| "Host%3A%3A#{h.id}" }.join("%1F") # After URL encoding the separator "\x1F" is converted to %1F
result_str = "Array%3A%3Amy_hosts=#{hash["hosts"].collect { |h| "Host%3A%3A#{h.id}" }.join("%1F")}" # After URL encoding the separator "\x1F" is converted to %1F
extras = "MiqServer%3A%3Amiq_server=#{miq_server_id}"
uri = "/System/Process/AUTOMATION?#{result_str}&#{extras}&object_name=AUTOMATION"
expect(MiqAeEngine.create_automation_object("AUTOMATION", attrs)).to eq(uri)
Expand Down

0 comments on commit c54ce45

Please sign in to comment.