Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 7 additions & 2 deletions app/models/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,13 @@ def self.build_compound_pii(pii)
end

def includes_liveness_check?
return if proofing_components.blank?
proofing_components['liveness_check']
return false if proofing_components.blank?
proofing_components['liveness_check'].present?
end

def includes_phone_check?
return false if proofing_components.blank?
proofing_components['address_check'] == 'lexis_nexis_address'
end

private
Expand Down
44 changes: 40 additions & 4 deletions spec/models/profile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
it 'is the empty string' do
expect(profile.proofing_components).to eq('')
end

it 'does not blow up in #includes_liveness_check?' do
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this into a dedicated test around #includes_liveness_check?

expect(profile.includes_liveness_check?).to be_falsey
end
end

context 'when the value is a JSON object' do
Expand All @@ -49,6 +45,46 @@
end
end

describe '#includes_liveness_check?' do
it 'returns true if a component for liveness is present' do
profile = create(:profile, proofing_components: { liveness_check: 'acuant' })

expect(profile.includes_liveness_check?).to eq(true)
end

it 'returns false if a component for liveness is not present' do
profile = create(:profile, proofing_components: { liveness_check: nil })

expect(profile.includes_liveness_check?).to eq(false)
end

it 'returns false if proofing_components is blank' do
profile = create(:profile, proofing_components: '')

expect(profile.includes_liveness_check?).to eq(false)
end
end

describe '#includes_phone_check?' do
it 'returns true if the address_check component is lexis_nexis_address' do
profile = create(:profile, proofing_components: { address_check: 'lexis_nexis_address' })

expect(profile.includes_phone_check?).to eq(true)
end

it 'returns false if the address_check componet is gpo_letter' do
profile = create(:profile, proofing_components: { address_check: 'gpo_letter' })

expect(profile.includes_phone_check?).to eq(false)
end

it 'returns false if proofing_components is blank' do
profile = create(:profile, proofing_components: '')

expect(profile.includes_phone_check?).to eq(false)
end
end

describe '#encrypt_pii' do
subject(:encrypt_pii) { profile.encrypt_pii(pii, user.password) }

Expand Down