From e3113e954ea69e11c75966b2d6315e7f8c3e81b1 Mon Sep 17 00:00:00 2001 From: Jonathan Hooper Date: Mon, 10 Jun 2024 11:06:53 -0400 Subject: [PATCH] LG-13387 Remove SP cost tracking logic from `VerifyInfoConcern` In #10767 we changed the `ProgressiveProofer` class to begin tracking SP costs closer to where costly events occur. The logic for tracking costs was left in the `VerifyInfoConcern` to deal with the 50/50 state. When the changes in #10767 are fully deployed this can be merged to clean up dead code. [skip changelog] --- .../concerns/idv/verify_info_concern.rb | 30 ----- .../in_person/verify_info_controller_spec.rb | 111 ------------------ .../idv/verify_info_controller_spec.rb | 61 +--------- 3 files changed, 3 insertions(+), 199 deletions(-) diff --git a/app/controllers/concerns/idv/verify_info_concern.rb b/app/controllers/concerns/idv/verify_info_concern.rb index 9cf3f52c3e4..694592356a2 100644 --- a/app/controllers/concerns/idv/verify_info_concern.rb +++ b/app/controllers/concerns/idv/verify_info_concern.rb @@ -164,8 +164,6 @@ def process_async_state(current_async_state) end def async_state_done(current_async_state) - add_proofing_costs(current_async_state.result) - create_fraud_review_request_if_needed(current_async_state.result) form_response = idv_result_to_form_response( @@ -295,34 +293,6 @@ def move_applicant_to_idv_session idv_session.applicant['uuid'] = current_user.uuid end - def add_proofing_costs(results) - return if results[:context][:sp_costs_added] - - results[:context][:stages].each do |stage, hash| - if stage == :resolution - # transaction_id comes from ConversationId - add_cost(:lexis_nexis_resolution, transaction_id: hash[:transaction_id]) - elsif stage == :residential_address - next if pii[:same_address_as_id] == 'true' - next if hash[:vendor_name] == 'ResidentialAddressNotRequired' - add_cost(:lexis_nexis_resolution, transaction_id: hash[:transaction_id]) - elsif stage == :state_id - next if hash[:exception].present? - next if hash[:vendor_name] == 'UnsupportedJurisdiction' - # transaction_id comes from TransactionLocatorId - add_cost(:aamva, transaction_id: hash[:transaction_id]) - elsif stage == :threatmetrix - # transaction_id comes from request_id - if hash[:transaction_id] - add_cost( - :threatmetrix, - transaction_id: hash[:transaction_id], - ) - end - end - end - end - def add_cost(token, transaction_id: nil) Db::SpCost::AddSpCost.call(current_sp, token, transaction_id: transaction_id) end diff --git a/spec/controllers/idv/in_person/verify_info_controller_spec.rb b/spec/controllers/idv/in_person/verify_info_controller_spec.rb index 7b090f67b9a..b0bae4bfe0e 100644 --- a/spec/controllers/idv/in_person/verify_info_controller_spec.rb +++ b/spec/controllers/idv/in_person/verify_info_controller_spec.rb @@ -115,117 +115,6 @@ ) end end - - context 'tracks costs' do - let(:review_status) { 'pass' } - let(:async_state) { instance_double(ProofingSessionAsyncResult) } - let(:adjudicated_result) do - { - context: { - stages: { - threatmetrix: { - transaction_id: 1, - }, - resolution: { - transaction_id: 'resolution-mock-transaction-id-123', - vendor_name: 'ResolutionMock', - }, - residential_address: { - transaction_id: 'resolution-mock-transaction-id-123', - vendor_name: 'ResolutionMock', - }, - state_id: { - transaction_id: 'state-id-mock-transaction-id-456', - vendor_name: 'StateIdMock', - }, - }, - }, - } - end - - before do - allow(controller).to receive(:load_async_state).and_return(async_state) - allow(async_state).to receive(:done?).and_return(true) - end - - context 'when same address as id is true and in aamva jurisdiction' do - it 'adds costs to database' do - allow(async_state).to receive(:result).and_return(adjudicated_result) - - get :show - - lexis_nexis_costs = SpCost.where(cost_type: 'lexis_nexis_resolution') - expect(lexis_nexis_costs.count).to eq(1) - - aamva_costs = SpCost.where(cost_type: 'aamva') - expect(aamva_costs.count).to eq(1) - - threatmetrix_costs = SpCost.where(cost_type: 'threatmetrix') - expect(threatmetrix_costs.count).to eq(1) - end - end - - context 'when same address as id is true and not in aamva jurisdiction' do - it 'adds costs to database' do - adjudicated_result[:context][:stages][:state_id][:vendor_name] = 'UnsupportedJurisdiction' - allow(async_state).to receive(:result).and_return(adjudicated_result) - - get :show - - lexis_nexis_costs = SpCost.where(cost_type: 'lexis_nexis_resolution') - expect(lexis_nexis_costs.count).to eq(1) - - aamva_costs = SpCost.where(cost_type: 'aamva') - expect(aamva_costs.count).to eq(0) - - threatmetrix_costs = SpCost.where(cost_type: 'threatmetrix') - expect(threatmetrix_costs.count).to eq(1) - end - end - - context 'when same address as id is false and in aamva jurisdiction' do - let(:pii_from_user) do - { same_address_as_id: 'false' } - end - - it 'adds costs to database' do - allow(async_state).to receive(:result).and_return(adjudicated_result) - - get :show - - lexis_nexis_costs = SpCost.where(cost_type: 'lexis_nexis_resolution') - expect(lexis_nexis_costs.count).to eq(2) - - aamva_costs = SpCost.where(cost_type: 'aamva') - expect(aamva_costs.count).to eq(1) - - threatmetrix_costs = SpCost.where(cost_type: 'threatmetrix') - expect(threatmetrix_costs.count).to eq(1) - end - end - - context 'when same address as id is false and not in aamva jurisdiction' do - let(:pii_from_user) do - { same_address_as_id: 'false' } - end - - it 'adds costs to database' do - adjudicated_result[:context][:stages][:state_id][:vendor_name] = 'UnsupportedJurisdiction' - allow(async_state).to receive(:result).and_return(adjudicated_result) - - get :show - - lexis_nexis_costs = SpCost.where(cost_type: 'lexis_nexis_resolution') - expect(lexis_nexis_costs.count).to eq(2) - - aamva_costs = SpCost.where(cost_type: 'aamva') - expect(aamva_costs.count).to eq(0) - - threatmetrix_costs = SpCost.where(cost_type: 'threatmetrix') - expect(threatmetrix_costs.count).to eq(1) - end - end - end end describe '#update' do diff --git a/spec/controllers/idv/verify_info_controller_spec.rb b/spec/controllers/idv/verify_info_controller_spec.rb index 98eb9ff05d2..d19bd415338 100644 --- a/spec/controllers/idv/verify_info_controller_spec.rb +++ b/spec/controllers/idv/verify_info_controller_spec.rb @@ -296,26 +296,14 @@ hash_including(**analytics_args, success: true, analytics_id: 'Doc Auth'), ) end - - it 'records the cost as billable' do - expect { put :show }.to change { SpCost.where(cost_type: 'aamva').count }.by(1) - end end context 'when aamva returns success: false but no exception' do let(:success) { false } - it 'logs a cost' do - expect { put :show }.to change { SpCost.where(cost_type: 'aamva').count }.by(1) - end - end - - context 'when the jurisdiction is unsupported' do - let(:success) { true } - let(:vendor_name) { 'UnsupportedJurisdiction' } - - it 'does not consider the request billable' do - expect { put :show }.to_not change { SpCost.where(cost_type: 'aamva').count } + it 'redirects to the warning URL' do + put :show + expect(response).to redirect_to(idv_session_errors_warning_url) end end @@ -337,10 +325,6 @@ remaining_submit_attempts: kind_of(Numeric), ) end - - it 'does not log a cost' do - expect { put :show }.to change { SpCost.where(cost_type: 'aamva').count }.by(0) - end end end end @@ -423,43 +407,4 @@ end end end - - describe '#add_proofing_costs' do - let(:sp_costs_added) { nil } - let(:result) do - { - context: { - sp_costs_added:, - stages: { - resolution: { - transaction_id: 'ABCD1234', - }, - residential_address: { - vendor_name: 'ResidentialAddressNotRequired', - }, - state_id: { - transaction_id: 'EFGH5678', - }, - threatmetrix: { - transaction_id: 'IJKL9012', - }, - }, - }, - } - end - - it 'adds proofing costs' do - expect(subject).to receive(:add_cost).exactly(3).times - subject.send(:add_proofing_costs, result) - end - - context 'when proofing costs have already been added' do - let(:sp_costs_added) { true } - - it 'does not add proofing costs' do - expect(subject).not_to receive(:add_cost) - subject.send(:add_proofing_costs, result) - end - end - end end