From bc4b07cc0f24301e0a374c457534d8294731bf73 Mon Sep 17 00:00:00 2001 From: Jure Grabnar Date: Fri, 28 Jun 2019 02:26:31 +0200 Subject: [PATCH] Refactor hardcoded protocol_source in SearchService --- app/controllers/external_protocols_controller.rb | 3 ++- app/services/protocol_importers/search_protocols_service.rb | 2 +- app/views/protocols/index/_external_protocols_tab.html.erb | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/external_protocols_controller.rb b/app/controllers/external_protocols_controller.rb index 718d66c6b..1384646b2 100644 --- a/app/controllers/external_protocols_controller.rb +++ b/app/controllers/external_protocols_controller.rb @@ -7,7 +7,8 @@ class ExternalProtocolsController < ApplicationController # GET list_external_protocols def index service_call = ProtocolImporters::SearchProtocolsService - .call(protocol_source: 'protocolsio/v3', query_params: index_params) + .call(protocol_source: index_params[:protocol_source], + query_params: index_params) if service_call.succeed? render json: { diff --git a/app/services/protocol_importers/search_protocols_service.rb b/app/services/protocol_importers/search_protocols_service.rb index 7c71a7a4f..fdd61e5c5 100644 --- a/app/services/protocol_importers/search_protocols_service.rb +++ b/app/services/protocol_importers/search_protocols_service.rb @@ -11,7 +11,7 @@ module ProtocolImporters def initialize(protocol_source:, query_params: {}) @protocol_source = protocol_source - @query_params = query_params + @query_params = query_params.except(:protocol_source) @errors = Hash.new { |h, k| h[k] = {} } end diff --git a/app/views/protocols/index/_external_protocols_tab.html.erb b/app/views/protocols/index/_external_protocols_tab.html.erb index dc85ed439..515525f6b 100644 --- a/app/views/protocols/index/_external_protocols_tab.html.erb +++ b/app/views/protocols/index/_external_protocols_tab.html.erb @@ -9,6 +9,7 @@ <%= image_tag 'external_protocols/protocolsio_logo.png', class: 'protocolsio-logo' %> <%= t('protocols.index.external_protocols.protocolsio_title') %> + <%= hidden_field_tag 'protocol_source', 'protocolsio/v3' %>