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
10 changes: 4 additions & 6 deletions app/models/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Profile < ApplicationRecord
attr_reader :personal_key

def fraud_review_pending?
fraud_review_pending_at.present?
fraud_pending_reason.present? && !fraud_rejection?
end

def fraud_rejection?
Expand Down Expand Up @@ -112,8 +112,10 @@ def activate_after_fraud_review_unnecessary
def activate_after_passing_in_person
transaction do
update!(
deactivation_reason: nil,
fraud_review_pending_at: nil,
fraud_rejection_at: nil,
fraud_pending_reason: nil,
deactivation_reason: nil,
)
activate
end
Expand All @@ -134,10 +136,6 @@ def deactivate(reason)
update!(active: false, deactivation_reason: reason)
end

def has_deactivation_reason?
deactivation_reason.present? || has_fraud_deactivation_reason? || gpo_verification_pending?
end

def has_fraud_deactivation_reason?
fraud_review_pending? || fraud_rejection?
end
Expand Down
4 changes: 1 addition & 3 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ def pending_profile
pending = profiles.where(deactivation_reason: :in_person_verification_pending).or(
profiles.where.not(gpo_verification_pending_at: nil),
).or(
profiles.where.not(fraud_review_pending_at: nil),
).or(
profiles.where.not(fraud_rejection_at: nil),
profiles.where.not(fraud_pending_reason: nil),
).order(created_at: :desc).first

if pending.blank?
Expand Down
9 changes: 6 additions & 3 deletions spec/controllers/idv/gpo_verify_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,9 @@
create(
:profile,
:with_pii,
:fraud_review_pending,
fraud_pending_reason: 'threatmetrix_reject',
Comment on lines +206 to +207
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it work to make the :fraud_review_pending attribute include setting fraud_pending_reason ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fraud_review_pending does set fraud_pending_reason. The reason for this is the description on the spec specifically says "when the threatmetrix status is reject" even though functionally the result is the same.

user: user,
fraud_review_pending_at: 1.day.ago,
)
end

Expand Down Expand Up @@ -239,8 +240,9 @@
create(
:profile,
:with_pii,
:fraud_review_pending,
fraud_pending_reason: 'threatmetrix_reject',
user: user,
fraud_review_pending_at: 1.day.ago,
)
end

Expand Down Expand Up @@ -276,8 +278,9 @@
create(
:profile,
:with_pii,
:fraud_review_pending,
fraud_pending_reason: 'threatmetrix_review',
user: user,
fraud_review_pending_at: 1.day.ago,
)
end

Expand Down
5 changes: 5 additions & 0 deletions spec/features/idv/steps/gpo_otp_verification_step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
dob: '1970-01-01',
},
fraud_review_pending_at: fraud_review_pending_timestamp,
fraud_pending_reason: fraud_pending_reason,
fraud_rejection_at: fraud_rejection_timestamp,
)
end
Expand All @@ -32,6 +33,7 @@
let(:user) { profile.user }
let(:threatmetrix_enabled) { false }
let(:fraud_review_pending_timestamp) { nil }
let(:fraud_pending_reason) { nil }
let(:fraud_rejection_timestamp) { nil }
let(:redirect_after_verification) { nil }
let(:profile_should_be_active) { true }
Expand All @@ -47,6 +49,7 @@
context 'ThreatMetrix disabled, but we have ThreatMetrix status on proofing component' do
let(:threatmetrix_enabled) { false }
let(:fraud_review_pending_timestamp) { 1.day.ago }
let(:fraud_pending_reason) { 'threatmetrix_review' }
it_behaves_like 'gpo otp verification'
end

Expand All @@ -60,13 +63,15 @@

context 'ThreatMetrix says "review"' do
let(:fraud_review_pending_timestamp) { 1.day.ago }
let(:fraud_pending_reason) { 'threatmetrix_review' }
let(:profile_should_be_active) { false }
let(:fraud_review_pending) { true }
it_behaves_like 'gpo otp verification'
end

context 'ThreatMetrix says "reject"' do
let(:fraud_rejection_timestamp) { 1.day.ago }
let(:fraud_pending_reason) { 'threatmetrix_review' }
let(:profile_should_be_active) { false }
let(:fraud_review_pending) { true }
it_behaves_like 'gpo otp verification'
Expand Down
20 changes: 4 additions & 16 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -577,10 +577,7 @@
describe '#fraud_review_pending?' do
it 'returns true if fraud review is pending' do
user = create(:user)
user.profiles.create(
active: false,
fraud_review_pending_at: 15.days.ago,
)
create(:profile, :fraud_review_pending, user: user)

expect(user.fraud_review_pending?).to eq true
end
Expand All @@ -589,10 +586,7 @@
describe '#fraud_rejection?' do
it 'returns true if fraud rejection' do
user = create(:user)
user.profiles.create(
active: false,
fraud_rejection_at: 15.days.ago,
)
create(:profile, :fraud_rejection, user: user)

expect(user.fraud_rejection?).to eq true
end
Expand All @@ -602,10 +596,7 @@
context 'with a fraud review pending profile' do
it 'returns the profile pending review' do
user = create(:user)
profile = user.profiles.create(
active: false,
fraud_review_pending_at: 15.days.ago,
)
profile = create(:profile, :fraud_review_pending, user: user)

expect(user.fraud_review_pending_profile).to eq(profile)
end
Expand All @@ -621,10 +612,7 @@
context 'with a fraud rejection profile' do
it 'returns the profile with rejection' do
user = create(:user)
profile = user.profiles.create(
active: false,
fraud_rejection_at: 15.days.ago,
)
profile = create(:profile, :fraud_rejection, user: user)

expect(user.fraud_rejection_profile).to eq(profile)
end
Expand Down