Skip to content

Commit

Permalink
Differentiate Vms/Instances in messages
Browse files Browse the repository at this point in the history
  • Loading branch information
imtayadeway committed Feb 17, 2017
1 parent 977f8ef commit d99f087
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
5 changes: 2 additions & 3 deletions app/controllers/api/subcollections/snapshots.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ def delete_resource_snapshots(parent, type, id, _data)
private

def snapshot_ident(parent)
klass = parent.class
klass_ident = klass.respond_to?(:base_model) ? klass.base_model.name : klass.name
"#{klass_ident} id:#{parent.id} name:'#{parent.name}'"
parent_ident = collection_config[@req.collection].description.singularize
"#{parent_ident} id:#{parent.id} name:'#{parent.name}'"
end
end
end
Expand Down
16 changes: 8 additions & 8 deletions spec/requests/api/snapshots_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"results" => [
a_hash_including(
"success" => true,
"message" => "Creating snapshot Alice's snapshot for Vm id:#{vm.id} name:'Alice's VM'",
"message" => "Creating snapshot Alice's snapshot for Virtual Machine id:#{vm.id} name:'Alice's VM'",
"task_id" => anything,
"task_href" => a_string_matching(tasks_url)
)
Expand Down Expand Up @@ -144,7 +144,7 @@
run_post("#{vms_url(vm.id)}/snapshots/#{snapshot.id}", :action => "delete")

expected = {
"message" => "Deleting snapshot Alice's snapshot for Vm id:#{vm.id} name:'Alice's VM'",
"message" => "Deleting snapshot Alice's snapshot for Virtual Machine id:#{vm.id} name:'Alice's VM'",
"success" => true,
"task_href" => a_string_matching(tasks_url),
"task_id" => anything
Expand Down Expand Up @@ -200,13 +200,13 @@
expected = {
"results" => a_collection_containing_exactly(
a_hash_including(
"message" => "Deleting snapshot Alice's snapshot for Vm id:#{vm.id} name:'Alice and Bob's VM'",
"message" => "Deleting snapshot Alice's snapshot for Virtual Machine id:#{vm.id} name:'Alice and Bob's VM'",
"success" => true,
"task_href" => a_string_matching(tasks_url),
"task_id" => anything
),
a_hash_including(
"message" => "Deleting snapshot Bob's snapshot for Vm id:#{vm.id} name:'Alice and Bob's VM'",
"message" => "Deleting snapshot Bob's snapshot for Virtual Machine id:#{vm.id} name:'Alice and Bob's VM'",
"success" => true,
"task_href" => a_string_matching(tasks_url),
"task_id" => anything
Expand Down Expand Up @@ -317,7 +317,7 @@
"results" => [
a_hash_including(
"success" => true,
"message" => "Creating snapshot Alice's snapshot for Vm id:#{instance.id} name:'Alice's Instance'",
"message" => "Creating snapshot Alice's snapshot for Instance id:#{instance.id} name:'Alice's Instance'",
"task_id" => anything,
"task_href" => a_string_matching(tasks_url)
)
Expand Down Expand Up @@ -387,7 +387,7 @@
run_post("#{instances_url(instance.id)}/snapshots/#{snapshot.id}", :action => "delete")

expected = {
"message" => "Deleting snapshot Alice's snapshot for Vm id:#{instance.id} name:'Alice's Instance'",
"message" => "Deleting snapshot Alice's snapshot for Instance id:#{instance.id} name:'Alice's Instance'",
"success" => true,
"task_href" => a_string_matching(tasks_url),
"task_id" => anything
Expand Down Expand Up @@ -444,13 +444,13 @@
expected = {
"results" => a_collection_containing_exactly(
a_hash_including(
"message" => "Deleting snapshot Alice's snapshot for Vm id:#{instance.id} name:'Alice and Bob's Instance'",
"message" => "Deleting snapshot Alice's snapshot for Instance id:#{instance.id} name:'Alice and Bob's Instance'",
"success" => true,
"task_href" => a_string_matching(tasks_url),
"task_id" => anything
),
a_hash_including(
"message" => "Deleting snapshot Bob's snapshot for Vm id:#{instance.id} name:'Alice and Bob's Instance'",
"message" => "Deleting snapshot Bob's snapshot for Instance id:#{instance.id} name:'Alice and Bob's Instance'",
"success" => true,
"task_href" => a_string_matching(tasks_url),
"task_id" => anything
Expand Down

0 comments on commit d99f087

Please sign in to comment.