diff --git a/app/models/profile.rb b/app/models/profile.rb index de5ac27ec8e..325b0e54e76 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -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 diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb index 3f45f7bf24a..291d70d4b0b 100644 --- a/spec/models/profile_spec.rb +++ b/spec/models/profile_spec.rb @@ -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 - expect(profile.includes_liveness_check?).to be_falsey - end end context 'when the value is a JSON object' do @@ -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) }