Skip to content

Commit

Permalink
Update daily fraud rejection job
Browse files Browse the repository at this point in the history
  • Loading branch information
shanechesnutt-ft committed Feb 13, 2025
1 parent 67c3608 commit 23b9af9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/jobs/fraud_rejection_daily_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class FraudRejectionDailyJob < ApplicationJob

def perform(_date)
profiles_eligible_for_fraud_rejection.find_each do |profile|
profile.in_person_enrollment&.failed!
profile.reject_for_fraud(notify_user: false)
analytics(user: profile.user).automatic_fraud_rejection(
fraud_rejection_at: profile.fraud_rejection_at,
Expand Down
21 changes: 21 additions & 0 deletions spec/jobs/fraud_rejection_daily_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,26 @@
fraud_rejection_at: rejected_profiles.first.fraud_rejection_at,
)
end

it 'rejects in-person profiles which have been review pending for more than 30 days' do
rejectedable_profile = create(:profile, fraud_review_pending_at: 31.days.ago)
enrollment = create(
:in_person_enrollment, :in_fraud_review, profile: rejectedable_profile,
user: rejectedable_profile.user
)
create(:profile, fraud_review_pending_at: 20.days.ago)

rejected_profiles = Profile.where.not(fraud_rejection_at: nil)

allow(job).to receive(:analytics).with(user: rejectedable_profile.user)
.and_return(job_analytics)

expect { job.perform(Time.zone.today) }.to change { rejected_profiles.count }.by(1)
expect(job_analytics).to have_logged_event(
'Fraud: Automatic Fraud Rejection',
fraud_rejection_at: rejected_profiles.first.fraud_rejection_at,
)
expect(enrollment.reload.status).to eq('failed')
end
end
end

0 comments on commit 23b9af9

Please sign in to comment.