From a4888a94262187a594116a5ff4838a281943f8c1 Mon Sep 17 00:00:00 2001 From: Samuelfaure Date: Fri, 6 Sep 2024 15:14:50 +0700 Subject: [PATCH] Add list of custom errors to display --- app/models/api_entreprise/endpoint.rb | 14 +++++++++++++- .../features/api_entreprise/endpoints/show_spec.rb | 8 ++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/models/api_entreprise/endpoint.rb b/app/models/api_entreprise/endpoint.rb index cbc8a537c..62dbb5532 100644 --- a/app/models/api_entreprise/endpoint.rb +++ b/app/models/api_entreprise/endpoint.rb @@ -24,7 +24,7 @@ def root_meta end def custom_provider_errors - @custom_provider_errors ||= error_examples('502').reject do |error_payload| + @custom_provider_errors ||= error_examples('502').reject { |error_payload| %w[ 000 051 @@ -34,9 +34,21 @@ def custom_provider_errors 055 999 ].include?(error_payload['code'][2..]) + }.concat(extra_provider_errors).flatten + end + + def extra_provider_errors + all_extra_provider_errors.map do |extra_provider_error| + error_examples(extra_provider_error[:status]).select do |error_payload| + error_payload['code'] == extra_provider_error[:subcode] + end end end + def all_extra_provider_errors + [{ status: '404', subcode: '38422' }] + end + def load_dummy_definition! missing_endpoints_definition = I18n.t("api_entreprise.missing_endpoints.#{path}", default: nil) diff --git a/spec/features/api_entreprise/endpoints/show_spec.rb b/spec/features/api_entreprise/endpoints/show_spec.rb index d787f7fb5..00960bfd5 100644 --- a/spec/features/api_entreprise/endpoints/show_spec.rb +++ b/spec/features/api_entreprise/endpoints/show_spec.rb @@ -73,6 +73,14 @@ expect(page).to have_css('#erreurs') end end + + context 'with an endpoint which has extra specific errors' do + let(:uid) { 'cibtp/attestations_cotisations_conges_payes_chomage_intemperies' } + + it 'displays errors part' do + expect(page).to have_css('#erreurs') + end + end end describe 'actions' do