Skip to content

Commit

Permalink
Override get_description method
Browse files Browse the repository at this point in the history
  • Loading branch information
bzwei committed Feb 28, 2018
1 parent fbfaeec commit 955ef67
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
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)
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 'describe a request' do
expect(described_class.get_description(request)).to eq(plan.name)
end
end
end
end

0 comments on commit 955ef67

Please sign in to comment.