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
10 changes: 8 additions & 2 deletions app/controllers/idv/jurisdiction_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class JurisdictionController < ApplicationController
before_action :confirm_two_factor_authenticated
before_action :confirm_idv_attempts_allowed
before_action :confirm_idv_needed
before_action :confirm_step_needed, only: %i[new create]
before_action :set_jurisdiction_form, except: [:failure]

def new
Expand All @@ -14,7 +15,7 @@ def new
def create
result = @jurisdiction_form.submit(jurisdiction_params)
analytics.track_event(Analytics::IDV_JURISDICTION_FORM, result.to_h)
user_session[:idv_jurisdiction] = @jurisdiction_form.state
idv_session.selected_jurisdiction = @jurisdiction_form.state

if result.success?
redirect_to idv_session_url
Expand All @@ -29,7 +30,7 @@ def create
def failure
presenter = Idv::JurisdictionFailurePresenter.new(
reason: params[:reason],
jurisdiction: user_session[:idv_jurisdiction],
jurisdiction: idv_session.selected_jurisdiction,
view_context: view_context
)
render_full_width('shared/_failure', locals: { presenter: presenter })
Expand All @@ -45,6 +46,11 @@ def set_jurisdiction_form
@jurisdiction_form ||= Idv::JurisdictionForm.new
end

def confirm_step_needed
return if idv_session.selected_jurisdiction.nil?
redirect_to idv_session_url
end

def failure_url(reason)
idv_jurisdiction_failure_url(reason)
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/idv/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class SessionsController < ApplicationController
def new
analytics.track_event(Analytics::IDV_BASIC_INFO_VISIT)
set_idv_form
@selected_state = user_session[:idv_jurisdiction]
@selected_state = idv_session.selected_jurisdiction
end

def create
Expand Down
1 change: 1 addition & 0 deletions app/services/idv/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Session
profile_step_params
personal_key
resolution_successful
selected_jurisdiction
step_attempts
].freeze

Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/idv/jurisdiction_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
it 'puts the jurisdiction into the user session' do
post :create, params: { jurisdiction: { state: supported_jurisdiction } }

expect(controller.user_session[:idv_jurisdiction]).to eq(supported_jurisdiction)
expect(controller.user_session[:idv][:selected_jurisdiction]).to eq(supported_jurisdiction)
end

context 'with an unsupported jurisdiction' do
Expand All @@ -73,7 +73,7 @@
let(:reason) { 'unsupported_jurisdiction' }

before do
controller.user_session[:idv_jurisdiction] = supported_jurisdiction
controller.user_session[:idv] = { selected_jurisdiction: supported_jurisdiction }
end

it 'renders the `_failure` template' do
Expand Down
17 changes: 17 additions & 0 deletions spec/features/idv/steps/jurisdiction_step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,23 @@
end
end

it 'is not re-entrant' do
start_idv_from_sp
complete_idv_steps_before_jurisdiction_step

select 'Virginia', from: 'jurisdiction_state'
click_idv_continue
visit idv_jurisdiction_path

expect(page).to have_current_path(idv_session_path)

fill_out_idv_form_ok
click_idv_continue
visit idv_jurisdiction_path

expect(page).to have_current_path(idv_session_success_path)
end

context 'cancelling idv' do
it_behaves_like 'cancel at idv step', :jurisdiction
it_behaves_like 'cancel at idv step', :jurisdiction, :oidc
Expand Down
4 changes: 2 additions & 2 deletions spec/support/idv_examples/max_attempts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ def expect_user_to_fail_at_phone_step
end

def advance_to_phone_step
fill_out_idv_jurisdiction_ok
click_idv_continue
# Currently on the session success path
# Click continue to advance to the phone step
click_idv_continue
end
end