Skip to content

Commit

Permalink
Override add_to_service to no-op in service orchestration subclass
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u committed Jan 17, 2019
1 parent 4c9780c commit c953e29
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/models/service_orchestration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ def all_vms
orchestration_stack.vms
end

def add_resource(rsc, _options = {})
raise "Service Orchestration subclass does not support add_resource for #{rsc.class.name}" unless rsc.kind_of?(OrchestrationStack)
super
end

# This is called when provision is completed and stack is added to VMDB through a refresh
def post_provision_configure
add_stack_to_resource
Expand Down
11 changes: 11 additions & 0 deletions spec/models/service_orchestration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@
end
end

describe "#add_resource" do
it "doesn't allow service to be added" do
expect { service_with_dialog_options.add_resource(FactoryBot.create(:service), {}) }.to raise_error(/Service Orchestration subclass does not support add_resource for/)
end

it "allows stack to be added" do
service_with_dialog_options.add_resource(FactoryBot.create(:orchestration_stack))
expect(service_with_dialog_options.service_resources.pluck(:resource_type)).to include("OrchestrationStack", "OrchestrationTemplate")
end
end

describe "#my_zone" do
it "deployed stack, takes the zone from ext_management_system" do
deployed_stack.ext_management_system = manager_by_setter
Expand Down

0 comments on commit c953e29

Please sign in to comment.