Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/services/pii/attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def self.new_from_hash(hash)
attrs = new
hash.with_indifferent_access.
slice(*members).
each { |key, val| attrs[key] = val }
each { |key, val| attrs[key] = val.is_a?(String) ? val&.squish : val }
Comment thread
matthinz marked this conversation as resolved.
Outdated
attrs
end

Expand Down
22 changes: 22 additions & 0 deletions spec/services/pii/attributes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,28 @@
expect(pii.identity_doc_zipcode).to eq('20005')
expect(pii.identity_doc_address_state).to eq('NY')
end

it 'normalizes whitespace in values' do
pii = described_class.new_from_hash(
identity_doc_address1: " 1600\r\r Pennsylvania Avenue\t",
identity_doc_address2: ' Apt 2 ',
identity_doc_city: ' Washington ',
state_id_jurisdiction: ' DC ',
identity_doc_zipcode: ' 20005 ',
identity_doc_address_state: ' NY ',
)
expect(pii.identity_doc_address1).to eq('1600 Pennsylvania Avenue')
expect(pii.identity_doc_address2).to eq('Apt 2')
expect(pii.identity_doc_city).to eq('Washington')
expect(pii.state_id_jurisdiction).to eq('DC')
expect(pii.identity_doc_zipcode).to eq('20005')
expect(pii.identity_doc_address_state).to eq('NY')
end

it 'accepts Date values' do
pii = described_class.new_from_hash(dob: Date.new(2000, 1, 2))
expect(pii.dob).to eql(Date.new(2000, 1, 2))
end
end

describe '#new_from_json' do
Expand Down