diff --git a/app/lib/api/client.rb b/app/lib/api/client.rb index dcf8eab2d..e6dc22353 100644 --- a/app/lib/api/client.rb +++ b/app/lib/api/client.rb @@ -17,6 +17,12 @@ class API::Client timeout: TIMEOUT) end handle_response(response, schema:) + rescue StandardError => reason + if reason.is_a?(URI::InvalidURIError) + Failure(Error[:uri, 0, false, reason]) + else + Failure(Error[:error, 0, false, reason]) + end end private diff --git a/app/models/champs/rnf_champ.rb b/app/models/champs/rnf_champ.rb index e9ca751ea..67cc8407c 100644 --- a/app/models/champs/rnf_champ.rb +++ b/app/models/champs/rnf_champ.rb @@ -2,7 +2,7 @@ class Champs::RNFChamp < Champ store_accessor :data, :title, :email, :phone, :createdAt, :updatedAt, :dissolvedAt, :address, :status def rnf_id - external_id + external_id&.gsub(/[:space:]/, '') end def value diff --git a/spec/models/champs/rnf_champ_spec.rb b/spec/models/champs/rnf_champ_spec.rb index 27f90e439..bdd753f2a 100644 --- a/spec/models/champs/rnf_champ_spec.rb +++ b/spec/models/champs/rnf_champ_spec.rb @@ -48,6 +48,26 @@ describe Champs::RNFChamp, type: :model do end end + context 'success (with space)' do + let(:external_id) { '075-FDD- 00003-01 ' } + it { + expect(subject.value!).to include({ + id: 3, + rnfId: '075-FDD-00003-01' + }) + } + end + + context 'success (with tab)' do + let(:external_id) { '075-FDD-0 0003-01 ' } + it { + expect(subject.value!).to include({ + id: 3, + rnfId: '075-FDD-00003-01' + }) + } + end + context 'failure (schema)' do let(:response_type) { 'invalid' } it {