fix(rnf): no crash on identifiers with spaces
This commit is contained in:
parent
3501208191
commit
25d4e7dfee
3 changed files with 27 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue