Merge pull request #10673 from tchak/fix-rnf-champ

fix(rnf): no crash on identifiers with spaces
This commit is contained in:
Colin Darie 2024-08-01 16:07:53 +00:00 committed by GitHub
commit 3660e01d76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 27 additions and 1 deletions

View file

@ -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

View file

@ -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

View file

@ -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 {