diff --git a/app/models/miq_request_task.rb b/app/models/miq_request_task.rb index bb3cba5dcaf..2aa79be770c 100644 --- a/app/models/miq_request_task.rb +++ b/app/models/miq_request_task.rb @@ -266,7 +266,7 @@ def valid_states end def workflow_inputs - dialog_values + {:dialog => dialog_values} end def dialog_values diff --git a/spec/models/service_template_provision_task_spec.rb b/spec/models/service_template_provision_task_spec.rb index cdc8b991623..804e634ef78 100644 --- a/spec/models/service_template_provision_task_spec.rb +++ b/spec/models/service_template_provision_task_spec.rb @@ -117,6 +117,61 @@ def service_resource_id(index, scaling_max) end context "with configuration_script_payload" do + it "creates a configuration_script instance" do + zone = FactoryBot.create(:zone, :name => "special") + automation_manager = FactoryBot.create(:ems_workflows_automation, :zone => zone) + payload = FactoryBot.create(:embedded_workflow, :manager => automation_manager) + @task_0.source = FactoryBot.create( + :service_template_generic, + :name => "Provision", + :resource_actions => [ + FactoryBot.create(:resource_action, :action => "Provision", :configuration_script_payload => payload) + ] + ) + + @task_0.deliver_queue + + expect(@task_0.reload.options.keys).to include(:miq_task_id, :configuration_script_id, :configuration_script_payload_id) + + configuration_script = ConfigurationScript.find(@task_0.options[:configuration_script_id]) + + expect(configuration_script).to have_attributes(:manager => automation_manager, :run_by_userid => @admin.userid, :status => "pending", :context => hash_including("Execution" => hash_including("Input" => {"dialog" => {}}))) + expect(MiqQueue.first).to have_attributes( + :instance_id => configuration_script.id, + :class_name => configuration_script.type, + :method_name => "run", + :queue_name => "automate", + :role => "automate", + :args => [hash_including(:object_type => "ServiceTemplateProvisionTask", :object_id => @task_0.id)] + ) + end + + context "with dialog_values" do + let(:dialog_values) { {:foo => "bar"} } + before { @task_0.options[:dialog] = dialog_values } + + it "creates a configuration_script instance" do + zone = FactoryBot.create(:zone, :name => "special") + automation_manager = FactoryBot.create(:ems_workflows_automation, :zone => zone) + payload = FactoryBot.create(:embedded_workflow, :manager => automation_manager) + @task_0.source = FactoryBot.create( + :service_template_generic, + :name => "Provision", + :resource_actions => [ + FactoryBot.create(:resource_action, :action => "Provision", :configuration_script_payload => payload) + ] + ) + + @task_0.deliver_queue + + configuration_script = ConfigurationScript.find(@task_0.options[:configuration_script_id]) + + expect(configuration_script.context).to include("Execution" => hash_including("Input" => {"dialog" => dialog_values})) + end + end + end + + context "with a configuration_script_payload in options" do it "creates a configuration_script instance" do zone = FactoryBot.create(:zone, :name => "special") automation_manager = FactoryBot.create(:ems_workflows_automation, :zone => zone)