-
Notifications
You must be signed in to change notification settings - Fork 166
LG-10464 FSM/Address Get route and controller #9377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
33b2b71
add routes, view and controller
svalexander 4222b68
add before action for 404
svalexander 3308d09
remove put route and update, include analytics args for visit event
svalexander facb8f6
include step indicator in view
svalexander 0f87b8f
add spec and update controller
svalexander fc3b2fc
update spec
svalexander fef330f
lint fix
svalexander 7af581a
update before action name and mock applicant
svalexander eadd7fb
add more before actions and spec for them
svalexander 8150412
update before action in ssn controller
svalexander 284ab15
lint fix
svalexander 9845173
remove unused title
svalexander 4f9558b
update test name
svalexander 5181ff5
add feature spec and update address controller spec
svalexander b9630b8
Merge branch 'main' into shannon/lg-10464-get-route-address
svalexander 91e6e1f
lint fix
svalexander File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| module Idv | ||
| module InPerson | ||
| class AddressController < ApplicationController | ||
| include IdvStepConcern | ||
|
|
||
| before_action :render_404_if_in_person_residential_address_controller_enabled_not_set | ||
| before_action :confirm_in_person_state_id_step_complete | ||
| before_action :confirm_in_person_address_step_needed | ||
|
|
||
| def show | ||
| analytics.idv_in_person_proofing_address_visited(**analytics_arguments) | ||
|
|
||
| render :show, locals: extra_view_variables | ||
| end | ||
|
|
||
| def extra_view_variables | ||
| { | ||
| form:, | ||
| pii:, | ||
| updating_address: updating_address?, | ||
| } | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def flow_session | ||
| user_session.fetch('idv/in_person', {}) | ||
| end | ||
|
|
||
| def updating_address? | ||
| flow_session[:pii_from_user].has_key?(:address1) && user_session[:idv].has_key?(:ssn) | ||
| end | ||
|
|
||
| def pii | ||
| data = flow_session[:pii_from_user] | ||
| data = data.merge(flow_params) if params.has_key?(:in_person_address) | ||
| data.deep_symbolize_keys | ||
| end | ||
|
|
||
| def form | ||
| @form ||= Idv::InPerson::AddressForm.new | ||
| end | ||
|
|
||
| def flow_params | ||
| params.require(:in_person_address).permit( | ||
| *Idv::InPerson::AddressForm::ATTRIBUTES, | ||
| ) | ||
| end | ||
|
|
||
| def form_submit | ||
| form.submit(flow_params) | ||
| end | ||
|
|
||
| def analytics_arguments | ||
| { | ||
| flow_path: flow_path, | ||
| step: 'address', | ||
| analytics_id: 'In Person Proofing', | ||
| irs_reproofing: irs_reproofing?, | ||
| } | ||
| end | ||
|
|
||
| def render_404_if_in_person_residential_address_controller_enabled_not_set | ||
| render_not_found unless | ||
| IdentityConfig.store.in_person_residential_address_controller_enabled | ||
| end | ||
|
|
||
| def confirm_in_person_state_id_step_complete | ||
| return if pii_from_user&.has_key?(:identity_doc_address1) | ||
| redirect_to idv_in_person_step_url(step: :state_id) | ||
| end | ||
|
|
||
| def confirm_in_person_address_step_needed | ||
| return if pii_from_user && pii_from_user[:same_address_as_id] == 'false' && | ||
| !pii_from_user.has_key?(:address1) | ||
| redirect_to idv_in_person_ssn_url | ||
| end | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| <% content_for(:pre_flash_content) do %> | ||
| <%= render StepIndicatorComponent.new( | ||
| steps: Idv::Flows::InPersonFlow::STEP_INDICATOR_STEPS, | ||
| current_step: :verify_info, | ||
| locale_scope: 'idv', | ||
| class: 'margin-x-neg-2 margin-top-neg-4 tablet:margin-x-neg-6 tablet:margin-top-neg-4', | ||
| ) %> | ||
| <% end %> | ||
|
|
||
| <% if updating_address %> | ||
| <%= render PageHeadingComponent.new.with_content(t('in_person_proofing.headings.update_address')) %> | ||
| <% else %> | ||
| <%= render PageHeadingComponent.new.with_content(t('in_person_proofing.headings.address')) %> | ||
| <% end %> | ||
|
|
||
| <%= simple_form_for( | ||
| form, url: url_for, method: 'PUT', | ||
| html: { autocomplete: 'off' } | ||
| ) do |f| %> | ||
| <%= render ValidatedFieldComponent.new( | ||
| collection: us_states_territories, | ||
| form: f, | ||
| input_html: { class: 'address-state-selector' }, | ||
| label: t('idv.form.state'), | ||
| label_html: { class: 'usa-label' }, | ||
| name: :state, | ||
| prompt: t('in_person_proofing.form.address.state_prompt'), | ||
| required: true, | ||
| selected: pii[:state], | ||
| ) %> | ||
| <%= render ValidatedFieldComponent.new( | ||
| form: f, | ||
| hint: t('in_person_proofing.form.state_id.address1_hint'), | ||
| hint_html: { class: ['display-none', 'puerto-rico-extras'] }, | ||
| input_html: { value: pii[:address1] }, | ||
| label: t('idv.form.address1'), | ||
| label_html: { class: 'usa-label' }, | ||
| maxlength: 255, | ||
| name: :address1, | ||
| required: true, | ||
| ) %> | ||
| <%= render ValidatedFieldComponent.new( | ||
| form: f, | ||
| hint: t('in_person_proofing.form.state_id.address2_hint'), | ||
| hint_html: { class: ['display-none', 'puerto-rico-extras'] }, | ||
| input_html: { value: pii[:address2] }, | ||
| label: t('idv.form.address2'), | ||
| label_html: { class: 'usa-label' }, | ||
| maxlength: 255, | ||
| name: :address2, | ||
| required: false, | ||
| ) %> | ||
| <%= render ValidatedFieldComponent.new( | ||
| form: f, | ||
| input_html: { value: pii[:city] }, | ||
| label: t('idv.form.city'), | ||
| label_html: { class: 'usa-label' }, | ||
| maxlength: 255, | ||
| name: :city, | ||
| required: true, | ||
| ) %> | ||
|
|
||
| <div class="tablet:grid-col-6"> | ||
| <%# using :tel for mobile numeric keypad %> | ||
| <%= render ValidatedFieldComponent.new( | ||
| as: :tel, | ||
| error_messages: { patternMismatch: t('idv.errors.pattern_mismatch.zipcode') }, | ||
| form: f, | ||
| input_html: { value: pii[:zipcode], class: 'zipcode' }, | ||
| label: t('idv.form.zipcode'), | ||
| label_html: { class: 'usa-label' }, | ||
| name: :zipcode, | ||
| pattern: '\d{5}([\-]\d{4})?', | ||
| required: true, | ||
| ) %> | ||
| </div> | ||
|
|
||
| <%= f.submit class: 'margin-top-1' do %> | ||
| <% if updating_address %> | ||
| <%= t('forms.buttons.submit.update') %> | ||
| <% else %> | ||
| <%= t('forms.buttons.continue') %> | ||
| <% end %> | ||
| <% end %> | ||
| <% end %> | ||
|
|
||
| <% if updating_address %> | ||
| <%= render 'idv/shared/back', action: 'cancel_update_address' %> | ||
| <% else %> | ||
| <%= render 'idv/doc_auth/cancel', step: 'address' %> | ||
| <% end %> | ||
|
|
||
| <%= javascript_packs_tag_once('formatted-fields', 'puerto-rico-guidance') %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
spec/controllers/idv/in_person/address_controller_spec.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| require 'rails_helper' | ||
|
|
||
| RSpec.describe Idv::InPerson::AddressController do | ||
| include InPersonHelper | ||
| let(:in_person_residential_address_controller_enabled) { true } | ||
| let(:pii_from_user) { Idp::Constants::MOCK_IPP_APPLICANT_SAME_ADDRESS_AS_ID_FALSE.dup } | ||
| let(:user) { build(:user) } | ||
| let(:flow_session) do | ||
| { pii_from_user: pii_from_user } | ||
| end | ||
| let(:flow_path) { 'standard' } | ||
|
|
||
| before(:each) do | ||
| allow(IdentityConfig.store).to receive(:in_person_residential_address_controller_enabled). | ||
| and_return(true) | ||
| allow(subject).to receive(:current_user). | ||
| and_return(user) | ||
| allow(subject).to receive(:pii_from_user).and_return(pii_from_user) | ||
| allow(subject).to receive(:flow_session).and_return(flow_session) | ||
| allow(subject).to receive(:flow_path).and_return(flow_path) | ||
| stub_sign_in(user) | ||
| stub_analytics | ||
| allow(@analytics).to receive(:track_event) | ||
| end | ||
|
|
||
| describe 'before_actions' do | ||
| context '#render_404_if_in_person_residential_address_controller_enabled not set' do | ||
| context 'flag not set' do | ||
| before do | ||
| allow(IdentityConfig.store).to receive(:in_person_residential_address_controller_enabled). | ||
| and_return(nil) | ||
| end | ||
| it 'renders a 404' do | ||
| get :show | ||
|
|
||
| expect(response).to be_not_found | ||
| end | ||
| end | ||
|
|
||
| context 'flag not enabled' do | ||
| before do | ||
| allow(IdentityConfig.store).to receive(:in_person_residential_address_controller_enabled). | ||
| and_return(false) | ||
| end | ||
| it 'renders a 404' do | ||
| get :show | ||
|
|
||
| expect(response).to be_not_found | ||
| end | ||
| end | ||
| end | ||
|
|
||
| context '#confirm_in_person_state_id_step_complete' do | ||
| it 'redirects to state id page if not complete' do | ||
| flow_session[:pii_from_user].delete(:identity_doc_address1) | ||
| get :show | ||
|
|
||
| expect(response).to redirect_to idv_in_person_step_url(step: :state_id) | ||
| end | ||
| end | ||
|
|
||
| context '#confirm_in_person_address_step_needed' do | ||
| context 'step is not needed' do | ||
| it 'redirects to ssn page when same address as id is true' do | ||
| flow_session[:pii_from_user][:same_address_as_id] = 'true' | ||
| get :show | ||
| expect(response).to redirect_to idv_in_person_ssn_url | ||
| end | ||
|
|
||
| it 'redirects to ssn page when address1 present' do | ||
| flow_session[:pii_from_user][:address1] = '123 Main St' | ||
| get :show | ||
| expect(response).to redirect_to idv_in_person_ssn_url | ||
| end | ||
| end | ||
| end | ||
| end | ||
|
|
||
| describe '#show' do | ||
| let(:analytics_name) { 'IdV: in person proofing address visited' } | ||
| let(:analytics_args) do | ||
| { | ||
| analytics_id: 'In Person Proofing', | ||
| flow_path: flow_path, | ||
| irs_reproofing: false, | ||
| step: 'address', | ||
| step_count: nil, | ||
| } | ||
| end | ||
|
|
||
| context 'with address controller flag enabled' do | ||
| it 'renders the show template' do | ||
| get :show | ||
|
|
||
| expect(response).to render_template :show | ||
| end | ||
|
|
||
| it 'logs idv_in_person_proofing_address_visited' do | ||
| get :show | ||
|
|
||
| expect(@analytics).to have_received( | ||
| :track_event, | ||
| ).with(analytics_name, analytics_args) | ||
| end | ||
|
|
||
| it 'has correct extra_view_variables' do | ||
| expect(subject.extra_view_variables).to include( | ||
| form: Idv::InPerson::AddressForm, | ||
| updating_address: false, | ||
| ) | ||
|
|
||
| expect(subject.extra_view_variables[:pii]).to_not have_key( | ||
| :address1, | ||
| ) | ||
| end | ||
| end | ||
| end | ||
| end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.