Skip to content

Commit

Permalink
Add list of custom errors to display
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuelfaure committed Sep 6, 2024
1 parent 5d35f73 commit a4888a9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/models/api_entreprise/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
8 changes: 8 additions & 0 deletions spec/features/api_entreprise/endpoints/show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a4888a9

Please sign in to comment.