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
30 changes: 0 additions & 30 deletions app/controllers/concerns/idv/verify_info_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
111 changes: 0 additions & 111 deletions spec/controllers/idv/in_person/verify_info_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
61 changes: 3 additions & 58 deletions spec/controllers/idv/verify_info_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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