Skip to content

Commit

Permalink
Include task_id in result of ResourceActionWorkflow#process_request
Browse files Browse the repository at this point in the history
  • Loading branch information
skateman committed Aug 1, 2018
1 parent b20a725 commit 30ebb59
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/models/resource_action_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions spec/models/resource_action_workflow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(0) }

context "with request class" do
let(:target) { FactoryGirl.create(:service) }
Expand Down Expand Up @@ -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 => 0)
end
end

Expand All @@ -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
Expand Down

0 comments on commit 30ebb59

Please sign in to comment.