-
Notifications
You must be signed in to change notification settings - Fork 166
Update pending in-person profile queries to consider enrollment expiration #11129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f38b276
1001121
7718b83
6a8077b
1508418
6feccd1
26a9203
d1a1bc7
2894f13
9738b03
b4a195a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -214,9 +214,9 @@ | |
| end | ||
|
|
||
| trait :with_pending_in_person_enrollment do | ||
| after :build do |user| | ||
| profile = create(:profile, :with_pii, :in_person_verification_pending, user: user) | ||
| create(:in_person_enrollment, :pending, user: user, profile: profile) | ||
| fully_registered | ||
| profiles do | ||
| [association(:profile, :with_pii, :in_person_verification_pending, user: instance)] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ooo love this cleanup to use the factory associations better
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, to be honest it was a bit of a nightmare to figure out how to implement this correctly, but it does feel a lot more reliable / portable, and supports overriding trait attributes in a way that's not possible with the lifecycle hooks.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same! Big fan. 🤩 |
||
| end | ||
| end | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -47,13 +47,10 @@ | |||||||||||
| end | ||||||||||||
|
|
||||||||||||
| describe '#in_person_verification_pending?' do | ||||||||||||
| it 'returns true if the in_person_verification_pending_at is present' do | ||||||||||||
| profile = create( | ||||||||||||
| :profile, | ||||||||||||
| :in_person_verification_pending, | ||||||||||||
| user: user, | ||||||||||||
| ) | ||||||||||||
| let(:profile) { create(:profile, :in_person_verification_pending, user:) } | ||||||||||||
| subject(:result) { profile.in_person_verification_pending? } | ||||||||||||
|
|
||||||||||||
| it 'returns true if the in_person_verification_pending_at is present' do | ||||||||||||
| allow(profile).to receive(:update!).and_raise(RuntimeError) | ||||||||||||
|
|
||||||||||||
| expect(profile.activated_at).to be_nil | ||||||||||||
|
|
@@ -66,6 +63,27 @@ | |||||||||||
| expect(profile.initiating_service_provider).to be_nil | ||||||||||||
| expect(profile.verified_at).to be_nil | ||||||||||||
| end | ||||||||||||
|
|
||||||||||||
| context 'with unlinked establishing enrollment' do | ||||||||||||
| # When marking profile as pending in-person proofing, the enrollment hasn't yet been linked to | ||||||||||||
| # the profile. | ||||||||||||
| # | ||||||||||||
| # See: Idv::Session#create_profile_from_applicant_with_password | ||||||||||||
|
|
||||||||||||
| before do | ||||||||||||
|
Comment on lines
+71
to
+73
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style, I'd remove the space between?
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, yeah. The padding line was intentional to try to "link" it more with the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess my thinking is the context description is what we want to happen, the before block (or sometimes a let) is how we want that to happen, and in this case, the comment clarifies the how |
||||||||||||
| profile.in_person_enrollment.update(status: :establishing, profile: nil) | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When would a Profile be associated with an InPersonEnrollment and the InPersonEnrollment have profile set to nil?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the comment above help clarify? identity-idp/spec/models/profile_spec.rb Lines 68 to 71 in d1a1bc7
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe clarify that it's still linked to the user via the |
||||||||||||
| end | ||||||||||||
|
|
||||||||||||
| it { is_expected.to eq(true) } | ||||||||||||
| end | ||||||||||||
|
|
||||||||||||
| context 'with expired enrollment' do | ||||||||||||
| before do | ||||||||||||
| profile.in_person_enrollment.update(status: :expired) | ||||||||||||
| end | ||||||||||||
|
|
||||||||||||
| it { is_expected.to eq(false) } | ||||||||||||
| end | ||||||||||||
| end | ||||||||||||
|
|
||||||||||||
| describe '#encrypt_pii' do | ||||||||||||
|
|
@@ -1140,9 +1158,17 @@ | |||||||||||
| end | ||||||||||||
|
|
||||||||||||
| describe '.in_person_verification_pending' do | ||||||||||||
| it 'returns only in_person_verification_pending Profiles' do | ||||||||||||
| user.profiles.create(in_person_verification_pending_at: Time.zone.now) | ||||||||||||
| user.profiles.create(in_person_verification_pending_at: nil) | ||||||||||||
| it 'returns only profiles pending in person verification with unexpired enrollment' do | ||||||||||||
| user.profiles << [ | ||||||||||||
| create(:profile, :in_person_verification_pending), | ||||||||||||
| create(:profile), | ||||||||||||
| create( | ||||||||||||
| :profile, | ||||||||||||
| :in_person_verification_pending, | ||||||||||||
| in_person_enrollment: create(:in_person_enrollment, :expired, user:), | ||||||||||||
| ), | ||||||||||||
| ] | ||||||||||||
|
|
||||||||||||
| expect(user.profiles.in_person_verification_pending.count).to eq 1 | ||||||||||||
| end | ||||||||||||
| end | ||||||||||||
|
|
||||||||||||
Uh oh!
There was an error while loading. Please reload this page.