diff --git a/app/controllers/concept_service_controller.rb b/app/controllers/concept_service_controller.rb index f034c9f7..b144c84c 100644 --- a/app/controllers/concept_service_controller.rb +++ b/app/controllers/concept_service_controller.rb @@ -6,13 +6,17 @@ class ConceptServiceController < ApplicationController # GET /concepts/systems def systems - @response = HTTParty.get(CONCEPT_SYSTEM_URL) + @response = HTTParty.get(CONCEPT_SYSTEM_URL, open_timeout: 5) render json: @response.body, status: @response.code + rescue Net::OpenTimeout + render status: 504, json: { message: 'Error opening network connection' } end # GET /concepts/search def search - @response = HTTParty.get(CONCEPT_SEARCH_URL, query: { system: params[:system], version: params[:version], search: params[:search] }) + @response = HTTParty.get(CONCEPT_SEARCH_URL, { open_timeout: 5 }, query: { system: params[:system], version: params[:version], search: params[:search] }) render json: @response.body, status: @response.code + rescue Net::OpenTimeout + render status: 504, json: { message: 'Error opening network connection' } end end diff --git a/features/support/env.rb b/features/support/env.rb index 4e1711bf..e9ba969f 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -14,7 +14,7 @@ require_relative '../../test/elastic_helpers' FakeWeb.register_uri(:any, %r{http://example\.com:9200/}, body: '{}', content_type: 'application/json') -FakeWeb.register_uri(:any, %r{http://concept-manager\..*\.xip\.io}, body: '{}') +FakeWeb.register_uri(:any, %r{http://concept-manager\..*}, body: '{}') Capybara.register_driver :chrome do |app| driver = Capybara::Selenium::Driver.new(app, browser: :chrome)