Skip to content

Commit

Permalink
Check that reconfigure is supported before we try it
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u committed Apr 9, 2019
1 parent 0d66d43 commit 441ad79
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/models/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ def reconfigure_resource_action
end

def reconfigure_dialog
return nil unless supports_reconfigure?
resource_action = reconfigure_resource_action
options = {:target => self, :reconfigure => true}

Expand Down
5 changes: 3 additions & 2 deletions spec/models/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 441ad79

Please sign in to comment.