Skip to content

Commit

Permalink
Load dialog fields with updated values on workflow submit
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u committed Aug 13, 2018
1 parent 5420771 commit 5d8eb9c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion app/models/resource_action_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@ def initialize(values, requester, resource_action, options = {})

Vmdb::Deprecation.deprecate_methods(self, :dialogs => :dialog)

def submit_request
def submit_request(data)
update_dialog_field_values(data) if data.present?
process_request(ServiceOrder::STATE_ORDERED)
end

def add_request_to_cart
process_request(ServiceOrder::STATE_CART)
end

def update_dialog_field_values(data)
@dialog.load_values_into_fields(data.values.first)
end

def process_request(state)
result = {:errors => validate_dialog}
return result unless result[:errors].blank?
Expand Down
2 changes: 1 addition & 1 deletion app/models/service_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def order(user_or_id, options = nil, request_options = nil, schedule_time = nil)
)
{:schedule => schedule}
else
workflow.submit_request
workflow.submit_request(data = nil)
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/models/resource_action_workflow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
:userid => admin.userid,
:message => "Service Reconfigure requested by <#{admin.userid}> for Service:[#{target.id}]"
)
response = subject.submit_request
response = subject.submit_request(data = nil)
expect(response).to include(:errors => [])
end
end
Expand All @@ -86,7 +86,7 @@
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(AuditEvent).not_to receive(:success)
response = subject.submit_request
response = subject.submit_request(data = nil)
expect(response).to eq(:errors => [])
end
end
Expand All @@ -103,7 +103,7 @@
expect(subject).not_to receive(:make_request)
expect_any_instance_of(ResourceAction).to receive(:deliver_to_automate_from_dialog)

subject.submit_request
subject.submit_request(data = nil)
end
end
end
Expand Down

0 comments on commit 5d8eb9c

Please sign in to comment.