-
Notifications
You must be signed in to change notification settings - Fork 167
LG-14317 Fix Cancelled and Failed enrollments put users in broken account state #11149
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 3 commits
ddfe7d2
c82a049
48ce278
95a9a2c
1e45ddd
6cf768e
bbc5c45
95ecebd
0ba230b
644e190
02389f0
5fd937f
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 |
|---|---|---|
|
|
@@ -265,6 +265,8 @@ | |
| profile = enrollment.profile | ||
| profile.update(in_person_verification_pending_at: enrollment.created_at) | ||
| end | ||
| pending_enrollment.reload | ||
|
|
||
| allow(InPersonEnrollment).to receive(:needs_usps_status_check). | ||
| and_return(enrollment_records) | ||
| allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true) | ||
|
|
@@ -824,6 +826,16 @@ | |
| request_passed_proofing_unsupported_id_results_response, | ||
| ) | ||
|
|
||
| it 'updates the profile' do | ||
| expect(pending_enrollment.profile.in_person_verification_pending_at).not_to be_nil | ||
| job.perform Time.zone.now | ||
| pending_enrollment.reload | ||
|
|
||
| expect(pending_enrollment.profile.in_person_verification_pending_at).to be_nil | ||
| expect(pending_enrollment.profile.active).to be false | ||
| expect(pending_enrollment.profile.deactivation_reason).to eq('verification_cancelled') | ||
| end | ||
|
|
||
| it 'logs a message about the unsupported ID' do | ||
| expected_wait_until = nil | ||
| freeze_time do | ||
|
|
@@ -989,6 +1001,17 @@ | |
| ), | ||
| ) | ||
| end | ||
|
|
||
| it 'updates the profile' do | ||
| expect(pending_enrollment.profile.in_person_verification_pending_at).not_to be_nil | ||
| job.perform(Time.zone.now) | ||
| pending_enrollment.reload | ||
|
|
||
| expect(pending_enrollment.profile.in_person_verification_pending_at).to be_nil | ||
| expect(pending_enrollment.profile.active).to be false | ||
| expect(pending_enrollment.profile.deactivation_reason). | ||
| to eq('verification_cancelled') | ||
| end | ||
| end | ||
|
|
||
| context 'when a unique id is invalid' do | ||
|
|
@@ -1348,57 +1371,92 @@ | |
| ), | ||
| ) | ||
| end | ||
| end | ||
|
|
||
| context 'when the enrollment has failed' do | ||
| before do | ||
| stub_request_failed_proofing_results | ||
| end | ||
| context 'when the enrollment has failed' do | ||
|
gina-yamada marked this conversation as resolved.
|
||
| before do | ||
| stub_request_failed_proofing_results | ||
| end | ||
|
|
||
| it 'sends proofing failed email on response with failed status' do | ||
| user = pending_enrollment.user | ||
|
|
||
| freeze_time do | ||
| expect do | ||
| job.perform(Time.zone.now) | ||
| end.to have_enqueued_mail(UserMailer, :in_person_failed).with( | ||
| params: { user: user, email_address: user.email_addresses.first }, | ||
| args: [{ enrollment: pending_enrollment }], | ||
| ) | ||
| expect(job_analytics).to have_logged_event( | ||
| 'GetUspsProofingResultsJob: Success or failure email initiated', | ||
| hash_including( | ||
| email_type: 'Failed', | ||
| job_name: 'GetUspsProofingResultsJob', | ||
| ), | ||
| ) | ||
| end | ||
| it 'sends proofing failed email on response with failed status' do | ||
| user = pending_enrollment.user | ||
|
|
||
| freeze_time do | ||
| expect do | ||
| job.perform(Time.zone.now) | ||
| end.to have_enqueued_mail(UserMailer, :in_person_failed).with( | ||
| params: { user: user, email_address: user.email_addresses.first }, | ||
| args: [{ enrollment: pending_enrollment }], | ||
| ) | ||
| expect(job_analytics).to have_logged_event( | ||
| 'GetUspsProofingResultsJob: Success or failure email initiated', | ||
| hash_including( | ||
| email_type: 'Failed', | ||
| job_name: 'GetUspsProofingResultsJob', | ||
| ), | ||
| ) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| it 'deactivates and sets fraud related fields of an expired enrollment' do | ||
| stub_request_expired_id_ipp_proofing_results | ||
| it 'updates the profile' do | ||
| expect(pending_enrollment.profile.in_person_verification_pending_at).not_to be_nil | ||
|
|
||
| job.perform(Time.zone.now) | ||
| job.perform(Time.zone.now) | ||
| pending_enrollment.reload | ||
| expect(pending_enrollment.profile.in_person_verification_pending_at).to be_nil | ||
| expect(pending_enrollment.profile.active).to be false | ||
| expect(pending_enrollment.profile.deactivation_reason). | ||
| to eq('verification_cancelled') | ||
| end | ||
|
|
||
| profile = pending_enrollment.reload.profile | ||
| expect(profile).not_to be_active | ||
| expect(profile.fraud_review_pending_at).to be_nil | ||
| expect(profile.fraud_rejection_at).not_to be_nil | ||
| expect(job_analytics).to have_logged_event( | ||
| :idv_ipp_deactivated_for_never_visiting_post_office, | ||
| ) | ||
| it 'deactivates and sets fraud related fields of an expired enrollment' do | ||
| stub_request_expired_id_ipp_proofing_results | ||
|
|
||
| job.perform(Time.zone.now) | ||
|
|
||
| profile = pending_enrollment.reload.profile | ||
| expect(profile).not_to be_active | ||
| expect(profile.fraud_review_pending_at).to be_nil | ||
| expect(profile.fraud_rejection_at).not_to be_nil | ||
| expect(job_analytics).to have_logged_event( | ||
| :idv_ipp_deactivated_for_never_visiting_post_office, | ||
| ) | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
|
|
||
| describe 'Proofed with secondary id' do | ||
| let(:pending_enrollment) do | ||
| create( | ||
| :in_person_enrollment, :pending | ||
| ) | ||
| let!(:pending_enrollments) do | ||
| ['BALTIMORE', 'FRIENDSHIP', 'WASHINGTON', 'ARLINGTON', 'DEANWOOD'].map do |name| | ||
| create( | ||
| :in_person_enrollment, | ||
| :pending, | ||
| :with_notification_phone_configuration, | ||
| issuer: 'http://localhost:3000', | ||
| selected_location_details: { name: name }, | ||
| sponsor_id: usps_ipp_sponsor_id, | ||
| ) | ||
| end | ||
| end | ||
| let(:pending_enrollment) { pending_enrollments.first } | ||
|
|
||
| before do | ||
| enrollment_records = InPersonEnrollment.where(id: pending_enrollments.map(&:id)) | ||
| # Below sets in_person_verification_pending_at | ||
| # on the profile associated with each pending enrollment | ||
| enrollment_records.each do |enrollment| | ||
|
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. Is it possible to update the I know we have a ticket to clean up 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 added this to the in_person_enrollment factory. see commit
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. Thanks for adding that, @shanechesnutt-ft! |
||
| profile = enrollment.profile | ||
| profile.update(in_person_verification_pending_at: enrollment.created_at) | ||
| end | ||
| pending_enrollment.reload | ||
| # binding.pry | ||
|
eileen-nava marked this conversation as resolved.
Outdated
|
||
| allow(InPersonEnrollment).to receive(:needs_usps_status_check). | ||
| and_return(enrollment_records) | ||
| allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true) | ||
| end | ||
|
|
||
| before do | ||
| allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true) | ||
| end | ||
|
|
@@ -1417,6 +1475,16 @@ | |
| request_passed_proofing_secondary_id_type_results_response, | ||
| ) | ||
|
|
||
| it 'updates the profile' do | ||
| expect(pending_enrollment.profile.in_person_verification_pending_at).not_to be_nil | ||
| job.perform(Time.zone.now) | ||
| pending_enrollment.reload | ||
|
|
||
| expect(pending_enrollment.profile.in_person_verification_pending_at).to be_nil | ||
| expect(pending_enrollment.profile.active).to be false | ||
| expect(pending_enrollment.profile.deactivation_reason).to eq('verification_cancelled') | ||
| end | ||
|
|
||
| it 'logs a message about enrollment with secondary ID' do | ||
| allow(IdentityConfig.store).to receive( | ||
| :in_person_send_proofing_notifications_enabled, | ||
|
|
@@ -1428,6 +1496,7 @@ | |
| end.to have_enqueued_job(InPerson::SendProofingNotificationJob). | ||
| with(pending_enrollment.id).at(1.hour.from_now).on_queue(:intentionally_delayed) | ||
| end | ||
|
|
||
| expect(pending_enrollment.proofed_at).to eq(transaction_end_date_time) | ||
| expect(pending_enrollment.profile.active).to eq(false) | ||
| expect(job_analytics).to have_logged_event( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.