From 9fb1dfca2340aff35d2a5cc97d78e0a1a60a7416 Mon Sep 17 00:00:00 2001 From: Erez Freiberger Date: Sun, 6 Aug 2017 15:36:15 +0300 Subject: [PATCH] adding tests for OPTOINS /api/providers --- app/controllers/api/providers_controller.rb | 2 +- spec/requests/api/providers_spec.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/providers_controller.rb b/app/controllers/api/providers_controller.rb index 8f7d3e1fbd..aef1f516c5 100644 --- a/app/controllers/api/providers_controller.rb +++ b/app/controllers/api/providers_controller.rb @@ -91,7 +91,7 @@ def options .select { |param| param.starts_with?("ems_type") } # 'parameters with "ems_type" name .first.split('=').last # choosing only the first occuracne. ems_class = ExtManagementSystem.descendants.select { |ems| ems.ems_type == req_class_name }.first - render :json => ems_class.respond_to?(:provider_settings) ? ems_class.provider_settings : {} + render_options(:providers, ems_class.respond_to?(:provider_settings) ? ems_class.provider_settings : {}) end private diff --git a/spec/requests/api/providers_spec.rb b/spec/requests/api/providers_spec.rb index f34b15757c..80017705ec 100644 --- a/spec/requests/api/providers_spec.rb +++ b/spec/requests/api/providers_spec.rb @@ -1116,4 +1116,14 @@ def gen_import_request end end end + + context "#options" do + it "returns options for queried provider class" do + api_basic_authorize + ExtManagementSystem.descendants.select { |ems| ems.respond_to?(:provider_settings) }.each do |ems_type| + run_options("#{providers_url}?ems_type=#{ems_type.ems_type}") + expect(response.parsed_body.to_json).to eq(ems_type.provider_settings.to_json) + end + end + end end