From c54ce453e6c99bbbc18d22125a63cded11cf2981 Mon Sep 17 00:00:00 2001 From: Gilbert Cherrie Date: Fri, 28 Jun 2024 16:59:09 -0400 Subject: [PATCH] Fix rubocop issues --- lib/miq_automation_engine/engine/miq_ae_engine.rb | 9 --------- .../engine/miq_ae_engine/miq_ae_object.rb | 4 ++-- spec/miq_ae_engine_spec.rb | 2 +- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/lib/miq_automation_engine/engine/miq_ae_engine.rb b/lib/miq_automation_engine/engine/miq_ae_engine.rb index 1430f2da..36ae02ba 100644 --- a/lib/miq_automation_engine/engine/miq_ae_engine.rb +++ b/lib/miq_automation_engine/engine/miq_ae_engine.rb @@ -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 @@ -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 diff --git a/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb b/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb index c89fda9d..31cc4c42 100644 --- a/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb +++ b/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb @@ -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 @@ -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 diff --git a/spec/miq_ae_engine_spec.rb b/spec/miq_ae_engine_spec.rb index 045e0e7b..81c2debc 100644 --- a/spec/miq_ae_engine_spec.rb +++ b/spec/miq_ae_engine_spec.rb @@ -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)