From fbfaeec3def82a58e5bcd18653610b547a2fe9a4 Mon Sep 17 00:00:00 2001 From: Bill Wei Date: Wed, 28 Feb 2018 16:10:39 -0500 Subject: [PATCH 1/2] Treat ServiceTemplateTransformationPlanRequest as backend only So that it does not show on the service requests screen --- app/models/miq_request.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/models/miq_request.rb b/app/models/miq_request.rb index 7f420e93d68..23aaaa7fa32 100644 --- a/app/models/miq_request.rb +++ b/app/models/miq_request.rb @@ -97,14 +97,13 @@ class MiqRequest < ApplicationRecord :automation => N_("Automation") } }, - :Transformation => { - :ServiceTemplateTransformationPlanRequest => { - :transformation_plan => N_("Transformation Plan") - } - } }.freeze - REQUEST_TYPES_BACKEND_ONLY = {:MiqProvisionRequestTemplate => {:template => "VM Provision Template"}} + REQUEST_TYPES_BACKEND_ONLY = { + :MiqProvisionRequestTemplate => {:template => "VM Provision Template"}, + :ServiceTemplateTransformationPlanRequest => {:transformation_plan => "Transformation Plan"} + } + REQUEST_TYPES = MODEL_REQUEST_TYPES.values.each_with_object(REQUEST_TYPES_BACKEND_ONLY) { |i, h| i.each { |k, v| h[k] = v } } REQUEST_TYPE_TO_MODEL = MODEL_REQUEST_TYPES.values.each_with_object({}) do |i, h| i.each { |k, v| v.keys.each { |vk| h[vk] = k } } From ba8d6226677d34ef118b83f3880accfdca4aed09 Mon Sep 17 00:00:00 2001 From: Bill Wei Date: Wed, 28 Feb 2018 16:11:51 -0500 Subject: [PATCH 2/2] Override get_description method --- .../service_template_transformation_plan_task.rb | 7 ++++++- .../service_template_transformation_plan_task_spec.rb | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/models/service_template_transformation_plan_task.rb b/app/models/service_template_transformation_plan_task.rb index 9df73dc4abc..24377b32293 100644 --- a/app/models/service_template_transformation_plan_task.rb +++ b/app/models/service_template_transformation_plan_task.rb @@ -3,8 +3,13 @@ def self.base_model ServiceTemplateTransformationPlanTask end + def self.get_description(req_obj) + source_name = req_obj.source.name + req_obj.kind_of?(ServiceTemplateTransformationPlanRequest) ? source_name : "Transforming VM [#{source_name}]" + end + def after_request_task_create - update_attributes(:description => "Transforming VM #{source.name}") + update_attributes(:description => get_description) end def resource_action diff --git a/spec/models/service_template_transformation_plan_task_spec.rb b/spec/models/service_template_transformation_plan_task_spec.rb index 5af6bd9aa7c..566f7d26d30 100644 --- a/spec/models/service_template_transformation_plan_task_spec.rb +++ b/spec/models/service_template_transformation_plan_task_spec.rb @@ -72,5 +72,15 @@ expect(plan.vm_resources.first.status).to eq('Completed') end end + + describe '.get_description' do + it 'describes a task' do + expect(described_class.get_description(task)).to include("Transforming VM") + end + + it 'describes a request' do + expect(described_class.get_description(request)).to eq(plan.name) + end + end end end