From b00873a68811da823c5040f87b65aa9d48c9dbaa Mon Sep 17 00:00:00 2001 From: Fabien Dupont Date: Thu, 18 Oct 2018 11:03:13 -0400 Subject: [PATCH] Reapply ManageIQ/manageiq-content#439 fix --- .../TransformationThrottler.class/__methods__/utils.rb | 2 +- .../__methods__/utils_spec.rb | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/content/automate/ManageIQ/Transformation/TransformationThrottler.class/__methods__/utils.rb b/content/automate/ManageIQ/Transformation/TransformationThrottler.class/__methods__/utils.rb index dd01da8a7..357f54b1c 100644 --- a/content/automate/ManageIQ/Transformation/TransformationThrottler.class/__methods__/utils.rb +++ b/content/automate/ManageIQ/Transformation/TransformationThrottler.class/__methods__/utils.rb @@ -67,7 +67,7 @@ def self.launch(handle = $evm) :namespace => NAMESPACE, :class_name => CLASS_NAME, :instance_name => throttler_type(handle), - :user_id => 1, + :user_id => handle.vmdb(:user).find_by(:userid => 'admin').id, :attrs => { :ttl => throttler_ttl(handle) } }, 'admin', diff --git a/spec/content/automate/ManageIQ/Transformation/TransformationThrottler.class/__methods__/utils_spec.rb b/spec/content/automate/ManageIQ/Transformation/TransformationThrottler.class/__methods__/utils_spec.rb index 2a282a9bc..1a03bf753 100644 --- a/spec/content/automate/ManageIQ/Transformation/TransformationThrottler.class/__methods__/utils_spec.rb +++ b/spec/content/automate/ManageIQ/Transformation/TransformationThrottler.class/__methods__/utils_spec.rb @@ -84,6 +84,7 @@ end end + let(:svc_vmdb_handle_user) { MiqAeMethodService::MiqAeServiceUser } let(:svc_vmdb_handle_request) { MiqAeMethodService::MiqAeServiceAutomationRequest } let(:svc_vmdb_handle_conversion_host) { MiqAeMethodService::MiqAeServiceConversionHost } let(:svc_vmdb_handle_transformation_task) { MiqAeMethodService::MiqAeServiceServiceTemplateTransformationPlanTask } @@ -111,9 +112,11 @@ svc_model_automation_request_3.set_option(:class_name, 'TransformationThrottler') svc_model_automation_request_3.set_option(:instance_name, 'Invalid') + allow(ae_service).to receive(:vmdb).with(:user).and_return(svc_vmdb_handle_user) allow(ae_service).to receive(:vmdb).with(:miq_request).and_return(svc_vmdb_handle_request) - allow(ae_service).to receive(:vmdb).with(:service_template_transformation_plan_task).and_return(svc_vmdb_handle_transformation_task) allow(ae_service).to receive(:vmdb).with(:conversion_host).and_return(svc_vmdb_handle_conversion_host) + allow(ae_service).to receive(:vmdb).with(:service_template_transformation_plan_task).and_return(svc_vmdb_handle_transformation_task) + allow(svc_vmdb_handle_conversion_host).to receive(:all).and_return([svc_model_conversion_host_1, svc_model_conversion_host_2, svc_model_conversion_host_3]) allow(svc_model_transformation_task_1).to receive(:transformation_destination).with(svc_model_src_cluster).and_return(svc_model_dst_cluster) allow(svc_model_conversion_host_1).to receive(:ext_management_system).and_return(svc_model_dst_ems_1) @@ -215,13 +218,14 @@ context "#launch" do it "with default values" do + user_admin = FactoryGirl.create(:user, :userid => 'admin') expect(ae_service).to receive(:execute).with( :create_automation_request, { :namespace => 'Transformation/StateMachines', :class_name => 'TransformationThrottler', :instance_name => 'Default', - :user_id => 1, + :user_id => user_admin.id, :attrs => { :ttl => 3600 } }, 'admin',