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

Check that reconfigure is supported before we try it #18636

Merged
merged 1 commit into from
Apr 11, 2019
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
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