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
3 changes: 1 addition & 2 deletions app/controllers/idv/welcome_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class WelcomeController < ApplicationController
include StepIndicatorConcern

before_action :confirm_not_rate_limited
before_action :cancel_previous_in_person_enrollments, only: :show

def show
idv_session.proofing_started_at ||= Time.zone.now.iso8601
Expand All @@ -23,7 +24,6 @@ def update
analytics.idv_doc_auth_welcome_submitted(**analytics_arguments)

create_document_capture_session
cancel_previous_in_person_enrollments

idv_session.welcome_visited = true

Expand Down Expand Up @@ -61,7 +61,6 @@ def create_document_capture_session
end

def cancel_previous_in_person_enrollments
return unless IdentityConfig.store.in_person_proofing_enabled
Copy link
Copy Markdown
Contributor Author

@gina-yamada gina-yamada Mar 3, 2025

Choose a reason for hiding this comment

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

I deleted this logic. I cannot think of a case where we'd not want to clean up in person enrollments. Let me know your opinions on this.

ie: If a user got as far as to create an establishing enrollment and then let their session expire, started again... and then if we turned IPP off for an outage during this time, I feel we'd still want to clean up the previous enrollment even if they cannot move through IPP again.

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.

This makes sense to me!

UspsInPersonProofing::EnrollmentHelper.cancel_establishing_and_in_progress_enrollments(
current_user,
)
Expand Down
79 changes: 51 additions & 28 deletions spec/controllers/idv/welcome_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,41 @@
:check_for_mail_only_outage,
)
end

it 'includes cancelling previous in person enrollments' do
expect(subject).to have_actions(
:before,
:cancel_previous_in_person_enrollments,
)
end

context 'with previous establishing and pending in-person enrollments' do
before do
allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true)
end

let!(:establishing_enrollment) { create(:in_person_enrollment, :establishing, user: user) }
let(:password_reset_profile) { create(:profile, :password_reset, user: user) }
let!(:pending_enrollment) do
create(:in_person_enrollment, :pending, user: user, profile: password_reset_profile)
end
let(:fraud_password_reset_profile) { create(:profile, :password_reset, user: user) }
let!(:fraud_review_enrollment) do
create(
:in_person_enrollment, :in_fraud_review, user: user, profile: fraud_password_reset_profile
)
end

it 'cancels all previous establishing, pending, and in_fraud_review enrollments' do
put :show

expect(establishing_enrollment.reload.status).to eq(InPersonEnrollment::STATUS_CANCELLED)
expect(pending_enrollment.reload.status).to eq(InPersonEnrollment::STATUS_CANCELLED)
expect(fraud_review_enrollment.reload.status).to eq(InPersonEnrollment::STATUS_CANCELLED)
expect(user.establishing_in_person_enrollment).to be_blank
expect(user.pending_in_person_enrollment).to be_blank
end
end
end

describe '#show' do
Expand Down Expand Up @@ -105,6 +140,22 @@

expect(response).to redirect_to(idv_please_call_url)
end

context 'has pending in-person enrollment' do
before do
allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true)
end

it 'redirects to ready to verify' do
profile = create(:profile, :in_person_verification_pending, user:)

stub_sign_in(profile.user)

get :show

expect(response).to redirect_to(idv_in_person_ready_to_verify_url)
end
end
end

describe '#update' do
Expand Down Expand Up @@ -133,33 +184,5 @@
expect { put :update }
.to change { subject.idv_session.document_capture_session_uuid }.from(nil)
end

context 'with previous establishing and pending in-person enrollments' do
let!(:establishing_enrollment) { create(:in_person_enrollment, :establishing, user: user) }
let(:password_reset_profile) { create(:profile, :password_reset, user: user) }
let!(:pending_enrollment) do
create(:in_person_enrollment, :pending, user: user, profile: password_reset_profile)
end
let(:fraud_password_reset_profile) { create(:profile, :password_reset, user: user) }
let!(:fraud_review_enrollment) do
create(
:in_person_enrollment, :in_fraud_review, user: user, profile: fraud_password_reset_profile
)
end

before do
allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true)
end

it 'cancels all previous establishing, pending, and in_fraud_review enrollments' do
put :update

expect(establishing_enrollment.reload.status).to eq(InPersonEnrollment::STATUS_CANCELLED)
expect(pending_enrollment.reload.status).to eq(InPersonEnrollment::STATUS_CANCELLED)
expect(fraud_review_enrollment.reload.status).to eq(InPersonEnrollment::STATUS_CANCELLED)
expect(user.establishing_in_person_enrollment).to be_blank
expect(user.pending_in_person_enrollment).to be_blank
end
end
end
end