diff --git a/app/models/resource_action_workflow.rb b/app/models/resource_action_workflow.rb index 550ef80bf8c..acffd8d287d 100644 --- a/app/models/resource_action_workflow.rb +++ b/app/models/resource_action_workflow.rb @@ -38,7 +38,7 @@ def process_request(state) result[:request] = generate_request(state, values) else ra = load_resource_action(values) - ra.deliver_to_automate_from_dialog(values, @target, @requester) + result[:task_id] = ra.deliver_to_automate_from_dialog(values, @target, @requester).id end result diff --git a/spec/models/resource_action_workflow_spec.rb b/spec/models/resource_action_workflow_spec.rb index eea11b8babe..3768d5ee83a 100644 --- a/spec/models/resource_action_workflow_spec.rb +++ b/spec/models/resource_action_workflow_spec.rb @@ -53,9 +53,12 @@ end end - context "#submit_request" do + describe "#submit_request" do subject { ResourceActionWorkflow.new({}, admin, resource_action, :target => target) } let(:resource_action) { @resource_action } + let(:task) { double } + + before { allow(task).to receive(:id).and_return(123) } context "with request class" do let(:target) { FactoryGirl.create(:service) } @@ -84,10 +87,10 @@ EvmSpecHelper.local_miq_server expect(subject).not_to receive(:make_request) expect_any_instance_of(ResourceAction).to receive(:deliver_to_automate_from_dialog).and_call_original - expect(MiqAeEngine).to receive(:deliver_queue) # calls into automate + expect(MiqAeEngine).to receive(:deliver_queue).and_return(task) # calls into automate expect(AuditEvent).not_to receive(:success) response = subject.submit_request - expect(response).to eq(:errors => []) + expect(response).to eq(:errors => [], :task_id => 123) end end @@ -101,7 +104,7 @@ it "calls automate" do expect(subject).not_to receive(:make_request) - expect_any_instance_of(ResourceAction).to receive(:deliver_to_automate_from_dialog) + expect_any_instance_of(ResourceAction).to receive(:deliver_to_automate_from_dialog).and_return(task) subject.submit_request end