diff --git a/app/controllers/concerns/inherited_proofing_session.rb b/app/controllers/concerns/inherited_proofing_session.rb deleted file mode 100644 index db2b0af83f6..00000000000 --- a/app/controllers/concerns/inherited_proofing_session.rb +++ /dev/null @@ -1,23 +0,0 @@ -module InheritedProofingSession - extend ActiveSupport::Concern - include InheritedProofingConcern - - private - - def destroy_inherited_proofing - inherited_proofing_clear_session - inherited_proofing_log_analytics - end - - def inherited_proofing_clear_session - user_session['idv/inherited_proofing'] = {} - end - - # LG-7128: Implement Inherited Proofing analytics here. - def inherited_proofing_log_analytics - # analytics.inherited_proofing_start_over( - # step: location_params[:step], - # location: location_params[:location], - # ) - end -end diff --git a/app/controllers/idv/sessions_controller.rb b/app/controllers/idv/sessions_controller.rb index efcdd30c46b..525fd500539 100644 --- a/app/controllers/idv/sessions_controller.rb +++ b/app/controllers/idv/sessions_controller.rb @@ -1,33 +1,28 @@ module Idv class SessionsController < ApplicationController include IdvSession - include InheritedProofingSession + include InheritedProofingConcern before_action :confirm_two_factor_authenticated def destroy - destroy_idv - destroy_inherited_proofing if inherited_proofing? + cancel_verification_attempt_if_pending_profile + cancel_in_person_enrollment_if_exists + cancel_inherited_proofing_if_exists + analytics.idv_start_over( + step: location_params[:step], + location: location_params[:location], + ) + user_session['idv/doc_auth'] = {} + user_session['idv/in_person'] = {} + user_session['idv/inherited_proofing'] = {} + idv_session.clear + Pii::Cacher.new(current_user, user_session).delete redirect_to idv_url end private - def location_params - params.permit(:step, :location).to_h.symbolize_keys - end - - def destroy_idv - cancel_processing - clear_session - log_analytics - end - - def cancel_processing - cancel_verification_attempt_if_pending_profile - cancel_in_person_enrollment_if_exists - end - def cancel_verification_attempt_if_pending_profile return if current_user.profiles.gpo_verification_pending.blank? Idv::CancelVerificationAttempt.new(user: current_user).call @@ -40,18 +35,17 @@ def cancel_in_person_enrollment_if_exists cancel_stale_establishing_enrollments_for_user(current_user) end - def clear_session - user_session['idv/doc_auth'] = {} - user_session['idv/in_person'] = {} - idv_session.clear - Pii::Cacher.new(current_user, user_session).delete + def cancel_inherited_proofing_if_exists + return if !inherited_proofing? + # LG-7128: Implement Inherited Proofing analytics here. + # analytics.inherited_proofing_start_over( + # step: location_params[:step], + # location: location_params[:location], + # ) end - def log_analytics - analytics.idv_start_over( - step: location_params[:step], - location: location_params[:location], - ) + def location_params + params.permit(:step, :location).to_h.symbolize_keys end end end diff --git a/spec/controllers/idv/sessions_controller_spec.rb b/spec/controllers/idv/sessions_controller_spec.rb index 116fba2a602..84b31b08878 100644 --- a/spec/controllers/idv/sessions_controller_spec.rb +++ b/spec/controllers/idv/sessions_controller_spec.rb @@ -24,7 +24,7 @@ end end -shared_examples 'a redirect occurs to the start of identity verificaton' do +shared_examples 'a redirect occurs to the start of identity verification' do it 'redirects' do delete :destroy @@ -121,7 +121,7 @@ # so that analytics can be logged, throttling and quotes can be # properly checked; this could not take place if we simply redirected # to idv_inherited_proofing_url. - it_behaves_like 'a redirect occurs to the start of identity verificaton' + it_behaves_like 'a redirect occurs to the start of identity verification' it_behaves_like 'logs IDV start over analytics with step and location params' it_behaves_like 'logs Inherited Proofing start over analytics with step and location params' end @@ -139,7 +139,7 @@ end it_behaves_like 'logs IDV start over analytics with step and location params' - it_behaves_like 'a redirect occurs to the start of identity verificaton' + it_behaves_like 'a redirect occurs to the start of identity verification' context 'pending profile' do let(:user) do diff --git a/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb b/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb index c952da2a8bd..39b6eb4b715 100644 --- a/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb +++ b/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb @@ -1,36 +1,5 @@ require 'rails_helper' -# rubocop:disable Layout/LineLength -shared_examples 'steps up to "Get started..." are completed' do - it 'should have current path equal to the Getting Started page' do - expect(page).to have_current_path(/inherited_proofing[?|\/].*get_started/) - end -end - -shared_examples 'steps up to "How verifying..." are completed' do - it 'should have current path equal to the How Verifying (agreement step) page' do - expect(page).to have_current_path(/inherited_proofing[?|\/].*agreement/) - end -end - -shared_examples 'steps up to "We are retrieving..." are completed' do - it 'should have current path equal to the We are retrieving (verify_wait step) page' do - expect(page).to have_current_path(/inherited_proofing[?|\/].*verify_wait/) - end -end - -shared_examples 'steps up to "Verify your information..." are completed' do - it 'should have current path equal to the Verify your information (verify_info step) page' do - expect(page).to have_current_path(/inherited_proofing[?|\/].*verify_info/) - end -end - -shared_examples 'the user is redirected to the Cancellation View' do - it 'redirects to the Cancellations view' do - expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :get_started)) - end -end - # Simulates a user (in this case, a VA inherited proofing-authorized user) # coming over to login.gov from a service provider, and hitting the # OpenidConnect::AuthorizationController#index action. @@ -60,8 +29,10 @@ def complete_idv_steps_up_to_inherited_proofing_how_verifying_step(user, expect_ def complete_idv_steps_up_to_inherited_proofing_we_are_retrieving_step(user, expect_accessible: false) - complete_idv_steps_up_to_inherited_proofing_how_verifying_step user, - expect_accessible: expect_accessible + complete_idv_steps_up_to_inherited_proofing_how_verifying_step( + user, + expect_accessible: expect_accessible, + ) unless current_path.match?(/inherited_proofing[?|\/].*verify_wait/) check t('inherited_proofing.instructions.consent', app_name: APP_NAME), allow_label_click: true click_on t('inherited_proofing.buttons.continue') @@ -93,7 +64,9 @@ def complete_idv_steps_up_to_inherited_proofing_verify_your_info_step(user, complete_idv_steps_up_to_inherited_proofing_get_started_step user end - it_behaves_like 'steps up to "Get started..." are completed' + it 'should have current path equal to the Getting Started page' do + expect(page).to have_current_path(/inherited_proofing[?|\/].*get_started/) + end context 'when clicking the "Start Over" button from the "Cancel" view' do before do @@ -137,7 +110,9 @@ def complete_idv_steps_up_to_inherited_proofing_verify_your_info_step(user, complete_idv_steps_up_to_inherited_proofing_how_verifying_step user end - it_behaves_like 'steps up to "How verifying..." are completed' + it 'should have current path equal to the How Verifying (agreement step) page' do + expect(page).to have_current_path(/inherited_proofing[?|\/].*agreement/) + end context 'when clicking the "Start Over" button from the "Cancel" view' do before do @@ -180,18 +155,21 @@ def complete_idv_steps_up_to_inherited_proofing_verify_your_info_step(user, # includes ActiveJob to move to the next step. Marking the necessary step as completed below, # does not seem to do the trick for some reason. This has been manually verified in the # meantime. - xcontext 'from the "We are retrieving your information..." view, and clicking the "Cancel" link' do + xcontext 'from the "We are retrieving your information..." view, and clicking "Cancel"' do before do - allow_any_instance_of(Idv::Steps::InheritedProofing::AgreementStep).to receive(:enqueue_job).and_wrap_original do |target, *args| - target.receiver.mark_step_complete(:agreement) - # Omit the original call. - # target.call(*args) - nil - end + allow_any_instance_of(Idv::Steps::InheritedProofing::AgreementStep). + to receive(:enqueue_job).and_wrap_original do |target, *args| + target.receiver.mark_step_complete(:agreement) + # Omit the original call. + # target.call(*args) + nil + end complete_idv_steps_up_to_inherited_proofing_we_are_retrieving_step user end - it_behaves_like 'steps up to "We are retrieving..." are completed' + it 'should have current path equal to the We are retrieving (verify_wait step) page' do + expect(page).to have_current_path(/inherited_proofing[?|\/].*verify_wait/) + end context 'when clicking the "Start Over" button from the "Cancel" view' do before do @@ -235,7 +213,9 @@ def complete_idv_steps_up_to_inherited_proofing_verify_your_info_step(user, complete_idv_steps_up_to_inherited_proofing_verify_your_info_step user end - it_behaves_like 'steps up to "Verify your information..." are completed' + it 'should have current path equal to the Verify your information (verify_info step) page' do + expect(page).to have_current_path(/inherited_proofing[?|\/].*verify_info/) + end context 'when clicking the "Start Over" button from the "Cancel" view' do before do @@ -275,4 +255,3 @@ def complete_idv_steps_up_to_inherited_proofing_verify_your_info_step(user, end end end -# rubocop:enable Layout/LineLength