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
2 changes: 1 addition & 1 deletion app/controllers/concerns/idv_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module IdvSession
before_action :redirect_if_sp_context_needed
end

def confirm_idv_session_started
def confirm_idv_applicant_created
redirect_to idv_verify_info_url if idv_session.applicant.blank?
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we leaving the issue of the hard-coded doc_auth verify redirect for a separate PR? I checked the flow, and it redirects to verify/doc_auth/document_capture. https://cm-jira.usa.gov/browse/LG-8983

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would like to leave that to a separate PR

end

Expand Down
1 change: 0 additions & 1 deletion app/controllers/concerns/idv_step_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ module IdvStepConcern
included do
before_action :confirm_two_factor_authenticated
before_action :confirm_idv_needed
before_action :confirm_idv_session_started
end
end
1 change: 1 addition & 0 deletions app/controllers/idv/phone_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class PhoneController < ApplicationController

attr_reader :idv_form

before_action :confirm_idv_applicant_created
before_action :confirm_step_needed
before_action :set_idv_form

Expand Down
1 change: 1 addition & 0 deletions app/controllers/idv/review_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class ReviewController < ApplicationController
include StepIndicatorConcern
include PhoneConfirmation

before_action :confirm_idv_applicant_created
before_action :confirm_idv_steps_complete
before_action :confirm_idv_phone_confirmed
before_action :confirm_current_password, only: [:create]
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/idv/verify_info_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Idv
class VerifyInfoController < ApplicationController
include IdvSession
include IdvStepConcern
include StepUtilitiesConcern

before_action :confirm_two_factor_authenticated
Expand Down
40 changes: 0 additions & 40 deletions spec/controllers/concerns/idv_step_concern_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,6 @@ class StepController < ApplicationController
end
end

describe '#confirm_idv_session_started' do
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These tests don't make sense in the post-FSM world as described in the pull request description. I added a test to the phone controller spec to test the equivalent logic. The review controller already had a matching test.

controller Idv::StepController do
before_action :confirm_idv_session_started

def show
render plain: 'Hello'
end
end

before(:each) do
stub_sign_in(user)
routes.draw do
get 'show' => 'idv/step#show'
end
end

context 'user has not started IdV session' do
it 'redirects to a previous step url' do
get :show

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

context 'user has started IdV session' do
before do
idv_session.applicant = { first_name: 'Jane' }
allow(subject).to receive(:idv_session).and_return(idv_session)
end

it 'allows request' do
get :show

expect(response.body).to eq 'Hello'
end
end
end

describe '#confirm_idv_needed' do
controller Idv::StepController do
before_action :confirm_idv_needed
Expand All @@ -70,7 +32,6 @@ def show
before do
allow(user).to receive(:active_profile).and_return(Profile.new)
allow(subject).to receive(:current_user).and_return(user)
allow(subject).to receive(:confirm_idv_session_started).and_return(true)
end

it 'redirects to activated page' do
Expand All @@ -83,7 +44,6 @@ def show
context 'user does not have active profile' do
before do
allow(subject).to receive(:current_user).and_return(user)
allow(subject).to receive(:confirm_idv_session_started).and_return(true)
end

it 'does not redirect to activated page' do
Expand Down
18 changes: 17 additions & 1 deletion spec/controllers/idv/phone_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
expect(subject).to have_actions(
:before,
:confirm_two_factor_authenticated,
:confirm_idv_session_started,
:confirm_idv_applicant_created,
)
end
end
Expand Down Expand Up @@ -66,6 +66,22 @@
end
end

context 'when the user has not finished the verify step' do
before do
subject.idv_session.applicant = nil
subject.idv_session.profile_confirmation = nil
subject.idv_session.resolution_successful = nil

allow(controller).to receive(:confirm_idv_applicant_created).and_call_original
end

it 'redirects to the verify step' do
get :new

expect(response).to redirect_to idv_verify_info_url
end
end

context 'when the user is throttled' do
before do
Throttle.new(throttle_type: :proof_address, user: user).increment_to_throttled!
Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/idv/review_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
expect(subject).to have_actions(
:before,
:confirm_two_factor_authenticated,
:confirm_idv_session_started,
:confirm_idv_applicant_created,
:confirm_idv_steps_complete,
)
end
Expand Down Expand Up @@ -192,7 +192,7 @@ def show
describe '#new' do
before do
stub_sign_in(user)
allow(subject).to receive(:confirm_idv_session_started).and_return(true)
allow(subject).to receive(:confirm_idv_applicant_created).and_return(true)
end

context 'user has completed all steps' do
Expand Down Expand Up @@ -264,7 +264,7 @@ def show
describe '#create' do
before do
stub_sign_in(user)
allow(subject).to receive(:confirm_idv_session_started).and_return(true)
allow(subject).to receive(:confirm_idv_applicant_created).and_return(true)
end

context 'user fails to supply correct password' do
Expand Down
6 changes: 3 additions & 3 deletions spec/support/controller_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def stub_idv_steps_before_verify_step(user)
dob: 50.years.ago.to_date.to_s,
ssn: '666-12-1234',
}.with_indifferent_access
allow(subject).to receive(:confirm_idv_session_started).and_return(true)
allow(subject).to receive(:confirm_idv_applicant_created).and_return(true)
allow(subject).to receive(:idv_session).and_return(idv_session)
allow(subject).to receive(:user_session).and_return(user_session)
end
Expand All @@ -67,7 +67,7 @@ def stub_verify_steps_one_and_two(user)
ssn: '666-12-1234',
}.with_indifferent_access
idv_session.profile_confirmation = true
allow(subject).to receive(:confirm_idv_session_started).and_return(true)
allow(subject).to receive(:confirm_idv_applicant_created).and_return(true)
allow(subject).to receive(:idv_session).and_return(idv_session)
allow(subject).to receive(:user_session).and_return(user_session)
end
Expand All @@ -81,7 +81,7 @@ def stub_user_with_applicant_data(user, applicant)
)
idv_session.applicant = applicant.with_indifferent_access
idv_session.profile_confirmation = true
allow(subject).to receive(:confirm_idv_session_started).and_return(true)
allow(subject).to receive(:confirm_idv_applicant_created).and_return(true)
allow(subject).to receive(:idv_session).and_return(idv_session)
allow(subject).to receive(:user_session).and_return(user_session)
end
Expand Down