From d99f087237fd727ddfd51e2ae1294f2e4f8dc37b Mon Sep 17 00:00:00 2001 From: Tim Wade Date: Thu, 9 Feb 2017 10:25:45 -0800 Subject: [PATCH] Differentiate Vms/Instances in messages --- app/controllers/api/subcollections/snapshots.rb | 5 ++--- spec/requests/api/snapshots_spec.rb | 16 ++++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/controllers/api/subcollections/snapshots.rb b/app/controllers/api/subcollections/snapshots.rb index 3703b3fa4ed..7339d951f84 100644 --- a/app/controllers/api/subcollections/snapshots.rb +++ b/app/controllers/api/subcollections/snapshots.rb @@ -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 diff --git a/spec/requests/api/snapshots_spec.rb b/spec/requests/api/snapshots_spec.rb index f76a356cded..13019ba3499 100644 --- a/spec/requests/api/snapshots_spec.rb +++ b/spec/requests/api/snapshots_spec.rb @@ -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) ) @@ -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 @@ -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 @@ -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) ) @@ -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 @@ -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