From 7f3a211145eb28713cb941b6ae2927e58c72c1c6 Mon Sep 17 00:00:00 2001 From: Brandon Dunne Date: Mon, 5 Feb 2018 11:20:16 -0500 Subject: [PATCH] Merge pull request #16949 from gmcculloug/provision_vm_update_name_service Follow up to update_vm_name for Service template provisioning (cherry picked from commit cdb1271d6d4f51d0f55253676f9170b2f7a1bbd0) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1539750 --- app/models/miq_provision.rb | 2 +- spec/models/miq_provision_spec.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) 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