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
1 change: 1 addition & 0 deletions app/jobs/get_usps_proofing_results_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ def handle_expired_status_update(enrollment, response, response_message)
status: :expired,
status_check_completed_at: Time.zone.now,
)
enrollment.profile.deactivate_due_to_ipp_expiration

if fraud_result_pending?(enrollment)
analytics(user: enrollment.user).idv_ipp_deactivated_for_never_visiting_post_office(
Expand Down
8 changes: 8 additions & 0 deletions app/models/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ def deactivate_due_to_gpo_expiration
)
end

def deactivate_due_to_ipp_expiration
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seeing that this largely follows from the equivalent GPO behavior, would we have a similar need to track the "expired at" value as is done with GPO?

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.

If we need to see when an in_person_enrollment was expired, we could inspect the in_person_enrollment's status_check_completed_at field. It's set in the GetUspsProofingResultsJob when we expire an enrollment.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think for parity with other profile features we should get an ipp_enrollment_expired_at field added to Profile, then use the status_check_completed_at to seed those values.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(That does not need to block this PR though)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Might recommend writing tests for this in spec/models/profile_spec.rb

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.

See 554c8f6.

update!(
active: false,
deactivation_reason: :verification_cancelled,
in_person_verification_pending_at: nil,
)
end

def deactivate_for_in_person_verification
update!(active: false, in_person_verification_pending_at: Time.zone.now)
end
Expand Down
23 changes: 23 additions & 0 deletions spec/jobs/get_usps_proofing_results_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@

before do
enrollment_records = InPersonEnrollment.where(id: pending_enrollments.map(&:id))
# Below sets in_person_verification_pending_at
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

We have a ticket for refactoring the in_person_enrollments factory, LG-14237. I agree that this isn't the ideal set-up, but due to the time-sensitive nature of the bug, this was the approach we took.

# on the profile associated with each pending enrollment
enrollment_records.each do |enrollment|
profile = enrollment.profile
profile.update(in_person_verification_pending_at: enrollment.created_at)
end
allow(InPersonEnrollment).to receive(:needs_usps_status_check).
and_return(enrollment_records)
allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true)
Expand Down Expand Up @@ -877,6 +883,15 @@
)
end

it 'deactivates the associated profile' do
job.perform(Time.zone.now)

pending_enrollment.reload
expect(pending_enrollment.profile).not_to be_active
expect(pending_enrollment.profile.in_person_verification_pending_at).to be_nil
expect(pending_enrollment.profile.deactivation_reason).to eq('verification_cancelled')
end

context 'when the in_person_stop_expiring_enrollments flag is true' do
before do
allow(IdentityConfig.store).to(
Expand All @@ -897,6 +912,14 @@
),
)
end

it 'does not deactivate the profile' do
job.perform(Time.zone.now)

pending_enrollment.reload
expect(pending_enrollment.profile.in_person_verification_pending_at).to_not be_nil
expect(pending_enrollment.profile.deactivation_reason).to be_nil
end
end
end

Expand Down
11 changes: 11 additions & 0 deletions spec/models/profile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,17 @@
end
end

describe '#deactivate_due_to_ipp_expiration' do
let(:profile) { create(:profile, :in_person_verification_pending) }
it 'updates the profile' do
profile.deactivate_due_to_ipp_expiration

expect(profile.active).to be false
expect(profile.deactivation_reason).to eq('verification_cancelled')
expect(profile.in_person_verification_pending_at).to be nil
end
end

describe '#deactivate_due_to_gpo_expiration' do
let(:profile) { create(:profile, :verify_by_mail_pending, user: user) }

Expand Down