Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bzwei committed Feb 19, 2018
1 parent 41ad27f commit ee4b78b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
10 changes: 3 additions & 7 deletions app/models/service_template_transformation_plan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,20 @@ def self.validate_config_info(options)
config_info[:transformation_mapping]
end

if mapping.blank?
raise _('Must provide an existing transformation mapping')
end
raise _('Must provide an existing transformation mapping') if mapping.blank?

vms = if config_info[:vm_ids]
VmOrTemplate.find(config_info[:vm_ids])
else
config_info[:vms]
end

if vms.blank?
raise _('Must select a list of valid vms')
end
raise _('Must select a list of valid vms') if vms.blank?

{
:transformation_mapping => mapping,
:vms => vms,
:provision => {}
:provision => config_info[:provision] || {}
}
end
private_class_method :validate_config_info
Expand Down
1 change: 1 addition & 0 deletions app/models/service_template_transformation_plan_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def source_vms
end

def validate_vm(_vm_id)
# TODO: enhance the logic to determine whether this VM can be included in this request
true
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
end

describe 'customize_request_task_attributes' do
it 'overrides #customize_request_task_attributes' do
expect(described_class.instance_methods(false)).to include(:customize_request_task_attributes)
it 'sets the source option to be the vm in the vm_request' do
req_task_attrs = {}
request.customize_request_task_attributes(req_task_attrs, vm_requests[0])
expect(req_task_attrs[:source]).to eq(vms[0])
end
end

Expand Down
1 change: 0 additions & 1 deletion spec/models/service_template_transformation_plan_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
describe '.create_catalog_item' do
it 'creates and returns a transformation plan' do
service_template = described_class.create_catalog_item(catalog_item_options)
service_template.reload

expect(service_template.name).to eq('Transformation Plan')
expect(service_template.transformation_mapping).to eq(transformation_mapping)
Expand Down
7 changes: 5 additions & 2 deletions spec/models/service_template_transformation_plan_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
end

describe '#after_request_task_create' do
it 'overrides #after_request_task_create' do
expect(described_class.instance_methods(false)).to include(:after_request_task_create)
it 'does not create child tasks' do
allow(subject).to receive(:source).and_return(double('vm', :name => 'any'))
expect(subject).not_to receive(:create_child_tasks)
expect(subject).to receive(:update_attributes).with(hash_including(:description))
subject.after_request_task_create
end
end

Expand Down

0 comments on commit ee4b78b

Please sign in to comment.