Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include task_id in result of ResourceActionWorkflow#process_request #17788

Merged
merged 1 commit into from
Aug 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(123) }

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 => 123)
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