Skip to content

Commit

Permalink
Don't create retire subtask for ServiceTemplate
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u committed Nov 13, 2018
1 parent a6d4569 commit 55ca759
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/service_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ def archive
archive!
end

def retireable?
false
end

def request_class
ServiceTemplateProvisionRequest
end
Expand Down
19 changes: 19 additions & 0 deletions spec/models/service_retire_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,32 @@
service.service_resources << FactoryGirl.create(:service_resource, :resource_type => "VmOrTemplate", :service_id => service_c1.id, :resource_id => vm.id)
service.service_resources << FactoryGirl.create(:service_resource, :resource_type => "VmOrTemplate", :service_id => service_c1.id, :resource_id => vm1.id)
service.service_resources << FactoryGirl.create(:service_resource, :resource_type => "Service", :service_id => service_c1.id, :resource_id => service_c1.id)
service.service_resources << FactoryGirl.create(:service_resource, :resource_type => "ServiceTemplate", :service_id => service_c1.id, :resource_id => service_c1.id)

@service_retire_task.after_request_task_create
expect(VmRetireTask.count).to eq(2)
expect(VmRetireTask.all.pluck(:message)).to eq(["Automation Starting", "Automation Starting"])
expect(ServiceRetireTask.count).to eq(1)
expect(ServiceRetireRequest.count).to eq(1)
end

it "doesn't creates subtask for ServiceTemplates" do
@service_retire_task = FactoryGirl.create(:service_retire_task, :source => service, :miq_request_task_id => nil, :miq_request_id => @miq_request.id, :options => {:src_ids => [service.id] })
service.service_resources << FactoryGirl.create(:service_resource, :resource_type => "ServiceTemplate", :service_id => service_c1.id, :resource_id => service_c1.id)

@service_retire_task.after_request_task_create
expect(ServiceRetireTask.count).to eq(1)
expect(ServiceRetireRequest.count).to eq(1)
end

it "doesn't creates subtask for service resources whose resources are nil" do
@service_retire_task = FactoryGirl.create(:service_retire_task, :source => service, :miq_request_task_id => nil, :miq_request_id => @miq_request.id, :options => {:src_ids => [service.id] })
service.service_resources << FactoryGirl.create(:service_resource, :resource_type => "ServiceTemplate", :service_id => service_c1.id, :resource => nil)

@service_retire_task.after_request_task_create
expect(ServiceRetireTask.count).to eq(1)
expect(ServiceRetireRequest.count).to eq(1)
end
end
end

Expand Down

0 comments on commit 55ca759

Please sign in to comment.