From 682bc0530727324cee0767d990c83146e2f5ce7e Mon Sep 17 00:00:00 2001 From: d-m-u Date: Mon, 8 Apr 2019 11:52:19 -0400 Subject: [PATCH] Check that reconfigure is supported before we try it --- app/models/service.rb | 1 + spec/models/service_spec.rb | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/service.rb b/app/models/service.rb index da28817eee5c..f6776fb2ec04 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -339,6 +339,7 @@ def reconfigure_resource_action end def reconfigure_dialog + raise unsupported_reason(:reconfigure) unless supports_reconfigure? resource_action = reconfigure_resource_action options = {:target => self, :reconfigure => true} diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb index c0bfc60e7591..9cd8cd5d96e3 100644 --- a/spec/models/service_spec.rb +++ b/spec/models/service_spec.rb @@ -895,19 +895,20 @@ def create_deep_tree let(:service) { described_class.new(:options => {:dialog => "dialog_options"}) } let(:dialog_serializer) { instance_double("DialogSerializer") } let(:workflow) { instance_double("ResourceActionWorkflow", :dialog => "workflow_dialog") } + let(:ra) { FactoryBot.create(:resource_action, :dialog_id => 58, :ae_namespace => "foo", :ae_class => "bar", :ae_instance => "baz", :ae_attributes => {:service_action=>"reconfigure"}) } before do allow(DialogSerializer).to receive(:new).and_return(dialog_serializer) allow(dialog_serializer).to receive(:serialize).and_return("serialized_reconfigure_dialog") allow(ResourceActionWorkflow).to receive(:new).and_return(workflow) - allow(service).to receive(:reconfigure_resource_action).and_return("reconfigure_resource_action") + allow(service).to receive(:reconfigure_resource_action).and_return(ra) end it "creates a new resource action workflow" do expect(ResourceActionWorkflow).to receive(:new).with( "dialog_options", User.current_user, - "reconfigure_resource_action", + ra, :target => service, :reconfigure => true ) service.reconfigure_dialog