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
50 changes: 50 additions & 0 deletions app/controllers/concerns/idv/step_indicator_concern.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module Idv
module StepIndicatorConcern
extend ActiveSupport::Concern

include IdvSession

included do
helper_method :step_indicator_steps
end

def step_indicator_steps
if in_person_proofing?
if gpo_address_verification?
Idv::Flows::InPersonFlow::STEP_INDICATOR_STEPS_GPO
else
Idv::Flows::InPersonFlow::STEP_INDICATOR_STEPS
end
elsif gpo_address_verification?
Idv::Flows::DocAuthFlow::STEP_INDICATOR_STEPS_GPO
else
Idv::Flows::DocAuthFlow::STEP_INDICATOR_STEPS
end
end

private

def in_person_proofing?
proofing_components_as_hash['document_check'] == Idp::Constants::Vendors::USPS
end

def gpo_address_verification?
# Proofing component values are (currently) never reset between proofing attempts, hence why
# this refers to the session address verification mechanism and not the proofing component.
!!current_user.pending_profile || idv_session.address_verification_mechanism == 'gpo'
end

def proofing_components_as_hash
# A proofing component record exists as a zero-or-one-to-one relation with a user, and values
# are set during identity verification. These values are recorded to the profile at creation,
# including for a pending profile.
@proofing_components_as_hash ||= begin
if current_user.pending_profile
current_user.pending_profile.proofing_components
else
ProofingComponent.find_by(user: current_user).as_json
end
end.to_h
end
end
end
2 changes: 2 additions & 0 deletions app/controllers/idv/come_back_later_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module Idv
class ComeBackLaterController < ApplicationController
include StepIndicatorConcern

before_action :confirm_two_factor_authenticated
before_action :confirm_user_needs_gpo_confirmation

Expand Down
10 changes: 10 additions & 0 deletions app/controllers/idv/gpo_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Idv
class GpoController < ApplicationController
include IdvSession
include StepIndicatorConcern

before_action :confirm_two_factor_authenticated
before_action :confirm_idv_needed
Expand All @@ -10,6 +11,7 @@ class GpoController < ApplicationController

def index
@presenter = GpoPresenter.new(current_user, url_options)
@step_indicator_current_step = step_indicator_current_step
analytics.idv_gpo_address_visited(
letter_already_sent: @presenter.letter_already_sent?,
)
Expand All @@ -35,6 +37,14 @@ def gpo_mail_service

private

def step_indicator_current_step
if resend_requested?
:get_a_letter
else
:verify_phone_or_address
end
end

def update_tracking
analytics.idv_gpo_address_letter_requested(resend: resend_requested?)
irs_attempts_api_tracker.idv_letter_requested(success: true, resend: resend_requested?)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/idv/gpo_verify_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Idv
class GpoVerifyController < ApplicationController
include IdvSession
include StepIndicatorConcern

before_action :confirm_two_factor_authenticated
before_action :confirm_verification_needed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Idv
module InPerson
class ReadyToVerifyController < ApplicationController
include RenderConditionConcern
include StepIndicatorConcern

check_or_render_not_found -> { IdentityConfig.store.in_person_proofing_enabled }

Expand Down
1 change: 1 addition & 0 deletions app/controllers/idv/otp_delivery_method_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Idv
class OtpDeliveryMethodController < ApplicationController
include IdvSession
include StepIndicatorConcern
include PhoneOtpRateLimitable
include PhoneOtpSendable

Expand Down
1 change: 1 addition & 0 deletions app/controllers/idv/otp_verification_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Idv
class OtpVerificationController < ApplicationController
include IdvSession
include StepIndicatorConcern
include PhoneOtpRateLimitable

# confirm_two_factor_authenticated before action is in PhoneOtpRateLimitable
Expand Down
10 changes: 1 addition & 9 deletions app/controllers/idv/personal_key_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Idv
class PersonalKeyController < ApplicationController
include IdvSession
include StepIndicatorConcern
include SecureHeadersConcern

before_action :apply_secure_headers_override
Expand All @@ -9,7 +10,6 @@ class PersonalKeyController < ApplicationController
before_action :confirm_profile_has_been_created

def show
@step_indicator_steps = step_indicator_steps
analytics.idv_personal_key_visited
add_proofing_component

Expand All @@ -26,14 +26,6 @@ def update

private

def step_indicator_steps
if idv_session.address_verification_mechanism == 'gpo'
Idv::Flows::DocAuthFlow::STEP_INDICATOR_STEPS_GPO
else
Idv::Flows::DocAuthFlow::STEP_INDICATOR_STEPS
end
end

def next_step
if pending_profile? && idv_session.address_verification_mechanism == 'gpo'
idv_come_back_later_url
Expand Down
1 change: 1 addition & 0 deletions app/controllers/idv/phone_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Idv
class PhoneController < ApplicationController
include IdvStepConcern
include StepIndicatorConcern

attr_reader :idv_form

Expand Down
10 changes: 1 addition & 9 deletions app/controllers/idv/review_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class ReviewController < ApplicationController
before_action :personal_key_confirmed

include IdvStepConcern
include StepIndicatorConcern
include PhoneConfirmation

before_action :confirm_idv_steps_complete
Expand Down Expand Up @@ -34,7 +35,6 @@ def confirm_current_password

def new
@applicant = idv_session.applicant
@step_indicator_steps = step_indicator_steps
analytics.idv_review_info_visited

gpo_mail_service = Idv::GpoMail.new(current_user)
Expand Down Expand Up @@ -64,14 +64,6 @@ def redirect_to_idv_app_if_enabled
redirect_to idv_app_path
end

def step_indicator_steps
if idv_session.address_verification_mechanism == 'gpo'
Idv::Flows::DocAuthFlow::STEP_INDICATOR_STEPS_GPO
else
Idv::Flows::DocAuthFlow::STEP_INDICATOR_STEPS
end
end

def flash_message_content
if idv_session.address_verification_mechanism != 'gpo'
phone_of_record_msg = ActionController::Base.helpers.content_tag(
Expand Down
12 changes: 8 additions & 4 deletions app/services/idv/flows/in_person_flow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ class InPersonFlow < Flow::BaseFlow
redo_ssn: Idv::Actions::RedoSsnAction,
}.freeze

# WILLFIX: (LG-6308) move this to the barcode page when
# we finish setting up IPP step indicators
# i18n-tasks-use t('step_indicator.flows.idv.go_to_the_post_office')

STEP_INDICATOR_STEPS = [
{ name: :find_a_post_office },
{ name: :verify_info },
Expand All @@ -36,6 +32,14 @@ class InPersonFlow < Flow::BaseFlow
{ name: :go_to_the_post_office },
].freeze

STEP_INDICATOR_STEPS_GPO = [
{ name: :find_a_post_office },
{ name: :verify_info },
{ name: :secure_account },
{ name: :get_a_letter },
{ name: :go_to_the_post_office },
].freeze

def initialize(controller, session, name)
@idv_session = self.class.session_idv(session)
super(controller, STEPS, ACTIONS, session[name])
Expand Down
2 changes: 1 addition & 1 deletion app/views/idv/come_back_later/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% content_for(:pre_flash_content) do %>
<%= render 'shared/step_indicator', {
steps: Idv::Flows::DocAuthFlow::STEP_INDICATOR_STEPS_GPO,
steps: step_indicator_steps,
current_step: :get_a_letter,
locale_scope: 'idv',
class: 'margin-x-neg-2 margin-top-neg-4 tablet:margin-x-neg-6 tablet:margin-top-neg-4',
Expand Down
4 changes: 2 additions & 2 deletions app/views/idv/gpo/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<% content_for(:pre_flash_content) do %>
<%= render 'shared/step_indicator', {
steps: Idv::Flows::DocAuthFlow::STEP_INDICATOR_STEPS,
current_step: :verify_phone_or_address,
steps: step_indicator_steps,
current_step: @step_indicator_current_step,
locale_scope: 'idv',
class: 'margin-x-neg-2 margin-top-neg-4 tablet:margin-x-neg-6 tablet:margin-top-neg-4',
} %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/idv/gpo_verify/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% content_for(:pre_flash_content) do %>
<%= render 'shared/step_indicator', {
steps: Idv::Flows::DocAuthFlow::STEP_INDICATOR_STEPS_GPO,
steps: step_indicator_steps,
current_step: :get_a_letter,
locale_scope: 'idv',
class: 'margin-x-neg-2 margin-top-neg-4 tablet:margin-x-neg-6 tablet:margin-top-neg-4',
Expand Down
2 changes: 1 addition & 1 deletion app/views/idv/in_person/ready_to_verify/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<% content_for(:pre_flash_content) do %>
<%= render 'shared/step_indicator', {
steps: Idv::Flows::InPersonFlow::STEP_INDICATOR_STEPS,
steps: step_indicator_steps,
current_step: :go_to_the_post_office,
locale_scope: 'idv',
class: 'margin-x-neg-2 margin-top-neg-4 tablet:margin-x-neg-6 tablet:margin-top-neg-4',
Expand Down
2 changes: 1 addition & 1 deletion app/views/idv/otp_delivery_method/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% content_for(:pre_flash_content) do %>
<%= render 'shared/step_indicator', {
steps: Idv::Flows::DocAuthFlow::STEP_INDICATOR_STEPS,
steps: step_indicator_steps,
current_step: :verify_phone_or_address,
locale_scope: 'idv',
class: 'margin-x-neg-2 margin-top-neg-4 tablet:margin-x-neg-6 tablet:margin-top-neg-4',
Expand Down
2 changes: 1 addition & 1 deletion app/views/idv/otp_verification/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% content_for(:pre_flash_content) do %>
<%= render 'shared/step_indicator', {
steps: Idv::Flows::DocAuthFlow::STEP_INDICATOR_STEPS,
steps: step_indicator_steps,
current_step: :verify_phone_or_address,
locale_scope: 'idv',
class: 'margin-x-neg-2 margin-top-neg-4 tablet:margin-x-neg-6 tablet:margin-top-neg-4',
Expand Down
2 changes: 1 addition & 1 deletion app/views/idv/personal_key/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% content_for(:pre_flash_content) do %>
<%= render 'shared/step_indicator', {
steps: @step_indicator_steps,
steps: step_indicator_steps,
current_step: :secure_account,
locale_scope: 'idv',
class: 'margin-x-neg-2 margin-top-neg-4 tablet:margin-x-neg-6 tablet:margin-top-neg-4',
Expand Down
2 changes: 1 addition & 1 deletion app/views/idv/phone/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% content_for(:pre_flash_content) do %>
<%= render 'shared/step_indicator', {
steps: Idv::Flows::DocAuthFlow::STEP_INDICATOR_STEPS,
steps: step_indicator_steps,
current_step: :verify_phone_or_address,
locale_scope: 'idv',
class: 'margin-x-neg-2 margin-top-neg-4 tablet:margin-x-neg-6 tablet:margin-top-neg-4',
Expand Down
2 changes: 1 addition & 1 deletion app/views/idv/review/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<% content_for(:pre_flash_content) do %>
<%= render 'shared/step_indicator', {
steps: @step_indicator_steps,
steps: step_indicator_steps,
current_step: :secure_account,
locale_scope: 'idv',
class: 'margin-x-neg-2 margin-top-neg-4 tablet:margin-x-neg-6 tablet:margin-top-neg-4',
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_step_indicator.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ locals:
status: step[:status] ||
if current_step == step[:name]
:current
elsif current_step_index > index
elsif current_step_index.to_i > index
:complete
end,
) { step[:title] } %>
Expand Down
82 changes: 82 additions & 0 deletions spec/controllers/concerns/idv/step_indicator_concern_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
require 'rails_helper'

RSpec.describe Idv::StepIndicatorConcern, type: :controller do
controller ApplicationController do
include Idv::StepIndicatorConcern
end

let(:profile) { nil }
let(:user) { create(:user, profiles: [profile].compact) }

before { stub_sign_in(user) }

describe '#step_indicator_steps' do
subject(:steps) { controller.step_indicator_steps }

it 'returns doc auth steps' do
expect(steps).to eq Idv::Flows::DocAuthFlow::STEP_INDICATOR_STEPS
end

context 'with pending profile' do
let(:profile) { create(:profile, deactivation_reason: :gpo_verification_pending) }

it 'returns doc auth gpo steps' do
expect(steps).to eq Idv::Flows::DocAuthFlow::STEP_INDICATOR_STEPS_GPO
end
end

context 'with gpo address verification method' do
before do
idv_session = instance_double(Idv::Session)
allow(idv_session).to receive(:method_missing).
with(:address_verification_mechanism).
and_return('gpo')
allow(controller).to receive(:idv_session).and_return(idv_session)
end

it 'returns doc auth gpo steps' do
expect(steps).to eq Idv::Flows::DocAuthFlow::STEP_INDICATOR_STEPS_GPO
end
end

context 'with in person proofing component' do
context 'with proofing component via pending profile' do
let(:profile) do
create(
:profile,
deactivation_reason: :gpo_verification_pending,
proofing_components: { 'document_check' => Idp::Constants::Vendors::USPS },
)
end

it 'returns in person gpo steps' do
expect(steps).to eq Idv::Flows::InPersonFlow::STEP_INDICATOR_STEPS_GPO
end
end

context 'with proofing component via current idv session' do
before do
ProofingComponent.create(user: user, document_check: Idp::Constants::Vendors::USPS)
end

it 'returns in person steps' do
expect(steps).to eq Idv::Flows::InPersonFlow::STEP_INDICATOR_STEPS
end

context 'with gpo address verification method' do
before do
idv_session = instance_double(Idv::Session)
allow(idv_session).to receive(:method_missing).
with(:address_verification_mechanism).
and_return('gpo')
allow(controller).to receive(:idv_session).and_return(idv_session)
end

it 'returns in person gpo steps' do
expect(steps).to eq Idv::Flows::InPersonFlow::STEP_INDICATOR_STEPS_GPO
end
end
end
end
end
end
Loading