-
Notifications
You must be signed in to change notification settings - Fork 166
LG-7446 Create "Cancel" Links and Supporting Cancellation Code for Identity Proofing Process (2 of n) #7144
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
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
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
191 changes: 191 additions & 0 deletions
191
spec/controllers/idv/inherited_proofing_cancellations_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,191 @@ | ||
| require 'rails_helper' | ||
|
|
||
| shared_examples 'an HTML 404 not found' do | ||
| it 'returns a 404 not found' do | ||
| expect(response).to have_http_status(:not_found) | ||
| end | ||
| end | ||
|
|
||
| describe Idv::InheritedProofingCancellationsController do | ||
| let(:step) { Idv::Flows::InheritedProofingFlow::STEPS.keys.first } | ||
|
|
||
| describe 'before_actions' do | ||
| it 'includes before_actions from IdvSession' do | ||
| expect(subject).to have_actions(:before, :redirect_if_sp_context_needed) | ||
| end | ||
|
|
||
| it 'includes before_actions from InheritedProofing404Concern' do | ||
| expect(subject).to have_actions(:before, :render_404_if_disabled) | ||
| end | ||
|
|
||
| it 'includes before_actions from AllowlistedFlowStepConcern' do | ||
| expect(subject).to have_actions(:before, :flow_step!) | ||
| end | ||
| end | ||
|
|
||
| describe '#new' do | ||
| let(:go_back_path) { '/path/to/return' } | ||
|
|
||
| before do | ||
| allow(controller).to receive(:go_back_path).and_return(go_back_path) | ||
| end | ||
|
|
||
| context 'when the inherited proofing feature flipper is turned off' do | ||
| before do | ||
| allow(IdentityConfig.store).to receive(:inherited_proofing_enabled).and_return(false) | ||
| stub_sign_in | ||
| end | ||
|
|
||
| describe '#new' do | ||
| before do | ||
| get :new, params: { step: step } | ||
| end | ||
|
|
||
| it_behaves_like 'an HTML 404 not found' | ||
| end | ||
|
|
||
| describe '#update' do | ||
| before do | ||
| get :update, params: { step: step } | ||
| end | ||
|
|
||
| it_behaves_like 'an HTML 404 not found' | ||
| end | ||
|
|
||
| describe '#destroy' do | ||
| before do | ||
| get :destroy, params: { step: step } | ||
| end | ||
|
|
||
| it_behaves_like 'an HTML 404 not found' | ||
| end | ||
| end | ||
|
|
||
| context 'when the flow step is not in the allowed list' do | ||
| before do | ||
| stub_sign_in | ||
| end | ||
|
|
||
| let(:step) { :not_found_step } | ||
| let(:expected_logger_warning) { "Flow step param \"#{step})\" was not whitelisted!" } | ||
|
|
||
| describe '#new' do | ||
| before do | ||
| expect(Rails.logger).to receive(:warn).with(expected_logger_warning) | ||
| get :new, params: { step: step } | ||
| end | ||
|
|
||
| it_behaves_like 'an HTML 404 not found' | ||
| end | ||
|
|
||
| describe '#update' do | ||
| before do | ||
| expect(Rails.logger).to receive(:warn).with(expected_logger_warning) | ||
| get :update, params: { step: step } | ||
| end | ||
|
|
||
| it_behaves_like 'an HTML 404 not found' | ||
| end | ||
|
|
||
| describe '#destroy' do | ||
| before do | ||
| expect(Rails.logger).to receive(:warn).with(expected_logger_warning) | ||
| get :destroy, params: { step: step } | ||
| end | ||
|
|
||
| it_behaves_like 'an HTML 404 not found' | ||
| end | ||
| end | ||
|
|
||
| context 'when there is no session' do | ||
| it 'redirects to root' do | ||
| get :new | ||
|
|
||
| expect(response).to redirect_to(root_url) | ||
| end | ||
| end | ||
|
|
||
| context 'when there is a session' do | ||
| before do | ||
| stub_sign_in | ||
| end | ||
|
|
||
| it 'renders template' do | ||
| get :new, params: { step: step } | ||
|
|
||
| expect(response).to render_template(:new) | ||
| end | ||
|
|
||
| it 'stores go back path' do | ||
| get :new, params: { step: step } | ||
|
|
||
| expect(controller.user_session[:idv][:go_back_path]).to eq(go_back_path) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| describe '#update' do | ||
| before do | ||
| stub_sign_in | ||
| end | ||
|
|
||
| it 'redirects to idv_inherited_proofing_path' do | ||
| put :update, params: { step: step, cancel: 'true' } | ||
|
|
||
| expect(response).to redirect_to idv_inherited_proofing_url | ||
| end | ||
|
|
||
| context 'when a go back path is stored in session' do | ||
| let(:go_back_path) { '/path/to/return' } | ||
|
|
||
| before do | ||
| allow(controller).to receive(:user_session).and_return( | ||
| idv: { go_back_path: go_back_path }, | ||
| ) | ||
| end | ||
|
|
||
| it 'redirects to go back path' do | ||
| put :update, params: { step: step, cancel: 'true' } | ||
|
|
||
| expect(response).to redirect_to go_back_path | ||
| end | ||
| end | ||
| end | ||
|
|
||
| describe '#destroy' do | ||
| context 'when there is no session' do | ||
| it 'redirects to root' do | ||
| delete :destroy, params: { step: step } | ||
|
|
||
| expect(response).to redirect_to(root_url) | ||
| end | ||
| end | ||
|
|
||
| context 'when there is a session' do | ||
| let(:user) { create(:user) } | ||
|
|
||
| before do | ||
| stub_sign_in user | ||
| end | ||
|
|
||
| before do | ||
| allow(controller).to receive(:user_session). | ||
| and_return(idv: { go_back_path: '/path/to/return' }) | ||
| end | ||
|
|
||
| it 'destroys session' do | ||
| expect(subject).to receive(:cancel_session).once | ||
|
|
||
| delete :destroy, params: { step: step } | ||
| end | ||
|
|
||
| it 'renders a json response with the redirect path set to account_path' do | ||
| delete :destroy, params: { step: step } | ||
|
|
||
| parsed_body = JSON.parse(response.body, symbolize_names: true) | ||
| expect(response).not_to render_template(:destroy) | ||
| expect(parsed_body).to eq({ redirect_url: account_path }) | ||
| end | ||
| end | ||
| end | ||
| end |
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.