From b11c1b15402a381638fd1c00d4d57b8e56826695 Mon Sep 17 00:00:00 2001 From: Jillian Tullo Date: Thu, 9 Feb 2017 10:31:44 -0500 Subject: [PATCH 1/2] return config_info of service_templates --- .../api/service_templates_controller.rb | 8 ++++++ spec/requests/api/service_templates_spec.rb | 26 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/app/controllers/api/service_templates_controller.rb b/app/controllers/api/service_templates_controller.rb index fa497e14e44..74a3b046c1c 100644 --- a/app/controllers/api/service_templates_controller.rb +++ b/app/controllers/api/service_templates_controller.rb @@ -4,5 +4,13 @@ class ServiceTemplatesController < BaseController include Subcollections::Tags include Subcollections::ResourceActions include Subcollections::ServiceRequests + + before_action :set_additional_attributes, :only => [:index, :show] + + private + + def set_additional_attributes + @additional_attributes = %w(config_info) + end end end diff --git a/spec/requests/api/service_templates_spec.rb b/spec/requests/api/service_templates_spec.rb index 3f258894b7a..6561b85a046 100644 --- a/spec/requests/api/service_templates_spec.rb +++ b/spec/requests/api/service_templates_spec.rb @@ -64,6 +64,32 @@ "resource_id" => template.id, "image_href" => /^http:.*#{picture.image_href}$/) end + + it 'returns config_info on all service template resources' do + api_basic_authorize collection_action_identifier(:service_templates, :read, :get) + + run_get(service_templates_url, :expand => 'resources') + + expected = { + 'resources' => [ + a_hash_including('config_info' => template.config_info.deep_stringify_keys) + ] + } + expect(response).to have_http_status(:ok) + expect(response.parsed_body).to include(expected) + end + + it 'returns config_info for a specific service_template resource' do + api_basic_authorize action_identifier(:service_templates, :read, :resource_actions, :get) + + run_get(service_templates_url(template.id)) + + expected = { + 'config_info' => template.config_info.deep_stringify_keys + } + expect(response).to have_http_status(:ok) + expect(response.parsed_body).to include(expected) + end end describe "Service Templates edit" do From 6b6c6aab6264a8f0f565f88719ea3c8603b59cae Mon Sep 17 00:00:00 2001 From: Jillian Tullo Date: Mon, 13 Feb 2017 14:27:12 -0500 Subject: [PATCH 2/2] removing config_info on index --- .../api/service_templates_controller.rb | 2 +- spec/requests/api/service_templates_spec.rb | 14 -------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/app/controllers/api/service_templates_controller.rb b/app/controllers/api/service_templates_controller.rb index 74a3b046c1c..9349793e754 100644 --- a/app/controllers/api/service_templates_controller.rb +++ b/app/controllers/api/service_templates_controller.rb @@ -5,7 +5,7 @@ class ServiceTemplatesController < BaseController include Subcollections::ResourceActions include Subcollections::ServiceRequests - before_action :set_additional_attributes, :only => [:index, :show] + before_action :set_additional_attributes, :only => [:show] private diff --git a/spec/requests/api/service_templates_spec.rb b/spec/requests/api/service_templates_spec.rb index 6561b85a046..f11a323224f 100644 --- a/spec/requests/api/service_templates_spec.rb +++ b/spec/requests/api/service_templates_spec.rb @@ -65,20 +65,6 @@ "image_href" => /^http:.*#{picture.image_href}$/) end - it 'returns config_info on all service template resources' do - api_basic_authorize collection_action_identifier(:service_templates, :read, :get) - - run_get(service_templates_url, :expand => 'resources') - - expected = { - 'resources' => [ - a_hash_including('config_info' => template.config_info.deep_stringify_keys) - ] - } - expect(response).to have_http_status(:ok) - expect(response.parsed_body).to include(expected) - end - it 'returns config_info for a specific service_template resource' do api_basic_authorize action_identifier(:service_templates, :read, :resource_actions, :get)