diff --git a/app/models/miq_provision.rb b/app/models/miq_provision.rb index b22dacd71e5..ac52217a8e3 100644 --- a/app/models/miq_provision.rb +++ b/app/models/miq_provision.rb @@ -68,7 +68,7 @@ def update_vm_name(new_name, update_request: true) options[:vm_target_hostname] = get_hostname(new_name) update_attributes(:description => self.class.get_description(self, new_name), :options => options) - miq_request.update_description_from_tasks if update_request + miq_request.try(:update_description_from_tasks) if update_request end def after_ae_delivery(ae_result) diff --git a/spec/models/miq_provision_spec.rb b/spec/models/miq_provision_spec.rb index d3e7a6a7d53..a16ab9fed5d 100644 --- a/spec/models/miq_provision_spec.rb +++ b/spec/models/miq_provision_spec.rb @@ -107,6 +107,17 @@ @vm_prov.update_vm_name(@target_vm_name, :update_request => false) end + + it "When task is part of a ServiceTemplateProvisionRequest the description should not update" do + request_descripton = "Service Name Test" + service_provision_request = FactoryGirl.create(:service_template_provision_request, :description => request_descripton) + @vm_prov.update_attributes(:miq_request_id => service_provision_request.id) + + expect(service_provision_request).not_to receive(:update_description_from_tasks) + @vm_prov.update_vm_name(@target_vm_name, :update_request => true) + + expect(service_provision_request.description).to eq(request_descripton) + end end context "when auto naming sequence exceeds the range" do