Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend enhancements for transformation plan request to better support UI #17071

Merged
merged 2 commits into from
Mar 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions app/models/miq_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 } }
Expand Down
7 changes: 6 additions & 1 deletion app/models/service_template_transformation_plan_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ def self.base_model
ServiceTemplateTransformationPlanTask
end

def self.get_description(req_obj)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I followed the example in parent class' implementation

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
Expand Down
10 changes: 10 additions & 0 deletions spec/models/service_template_transformation_plan_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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