diff --git a/app/controllers/api/service_orders_controller.rb b/app/controllers/api/service_orders_controller.rb index a13ffb96b4..1ac3996b70 100644 --- a/app/controllers/api/service_orders_controller.rb +++ b/app/controllers/api/service_orders_controller.rb @@ -90,7 +90,7 @@ def service_request_workflow(service_request) raise BadRequestError, "Must specify a service_template_href for adding a service_request" end service_template = resource_search(service_template_id, :service_templates, ServiceTemplate) - service_template.provision_workflow(User.current_user, service_request) + service_template.provision_workflow(User.current_user, service_request, :submit_workflow => true) end def check_validation(validation) diff --git a/spec/requests/service_orders_spec.rb b/spec/requests/service_orders_spec.rb index 7dadfa0ae7..a33e11946e 100644 --- a/spec/requests/service_orders_spec.rb +++ b/spec/requests/service_orders_spec.rb @@ -85,6 +85,18 @@ expect(response.parsed_body).to include(expected) end + it "provisions with workflow with the correct options" do + dialog = FactoryGirl.create(:dialog, :label => "ServiceDialog1") + resource_action = FactoryGirl.create(:resource_action, :action => "Provision", :dialog => dialog) + service_template = FactoryGirl.create(:service_template, :resource_actions => [resource_action]) + + expect_any_instance_of(ServiceTemplate).to receive(:provision_workflow).with(@user, {}, :submit_workflow => true) + + api_basic_authorize collection_action_identifier(:service_orders, :create) + + post(api_service_orders_url, :params => { :service_requests => [{ :service_template_href => api_service_template_url(nil, service_template) }] }) + end + specify "the default state for a service order is 'cart'" do api_basic_authorize collection_action_identifier(:service_orders, :create)