add and use api_djepva_up?
This commit is contained in:
parent
e994738a2e
commit
7b33963a67
4 changed files with 12 additions and 3 deletions
|
@ -12,7 +12,7 @@ module RNAChampAssociationFetchableConcern
|
|||
|
||||
update!(data: data)
|
||||
rescue APIEntreprise::API::Error => error
|
||||
error_key = :network_error if error.try(:network_error?) && !APIEntrepriseService.api_up?
|
||||
error_key = :network_error if error.try(:network_error?) && !APIEntrepriseService.api_djepva_up?
|
||||
clear_association!(error_key)
|
||||
end
|
||||
|
||||
|
|
|
@ -74,5 +74,14 @@ class APIEntrepriseService
|
|||
false
|
||||
end
|
||||
end
|
||||
|
||||
def api_djepva_up?
|
||||
response = Typhoeus.get("https://entreprise.api.gouv.fr/ping/djepva/api-association", timeout: 1)
|
||||
if response.success?
|
||||
JSON.parse(response.body).fetch('status') == 'ok'
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -85,7 +85,7 @@ describe Champs::RNAController, type: :controller do
|
|||
let(:body) { File.read('spec/fixtures/files/api_entreprise/associations.json') }
|
||||
|
||||
before do
|
||||
expect(APIEntrepriseService).to receive(:api_up?).and_return(false)
|
||||
expect(APIEntrepriseService).to receive(:api_djepva_up?).and_return(false)
|
||||
end
|
||||
|
||||
subject! { get :show, params: params, format: :turbo_stream }
|
||||
|
|
|
@ -52,7 +52,7 @@ RSpec.describe RNAChampAssociationFetchableConcern do
|
|||
let(:status) { 503 }
|
||||
let(:body) { File.read('spec/fixtures/files/api_entreprise/associations.json') }
|
||||
|
||||
before { expect(APIEntrepriseService).to receive(:api_up?).and_return(false) }
|
||||
before { expect(APIEntrepriseService).to receive(:api_djepva_up?).and_return(false) }
|
||||
|
||||
it_behaves_like "an association fetcher", false, :network_error, 'W595001988', nil
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue