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
1 change: 1 addition & 0 deletions app/models/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def deactivate_for_fraud_review
active: false,
fraud_review_pending_at: Time.zone.now,
fraud_rejection_at: nil,
in_person_verification_pending_at: nil,
)
end

Expand Down
27 changes: 6 additions & 21 deletions spec/models/profile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1016,33 +1016,18 @@
# TODO: related: should we test against an active profile here?
describe '#deactivate_for_fraud_review' do
it 'sets fraud_review_pending to true and sets fraud_pending_reason' do
profile = create(:profile, user: user)

expect(profile.activated_at).to be_nil
expect(profile.active).to eq(false) # ???
expect(profile.deactivation_reason).to be_nil
expect(profile.fraud_review_pending?).to eq(false) # to change
expect(profile.gpo_verification_pending_at).to be_nil
expect(profile.in_person_verification_pending_at).to be_nil
expect(profile.initiating_service_provider).to be_nil
expect(profile.verified_at).to be_nil
profile = create(:profile, :in_person_verification_pending, user: user)

profile.fraud_pending_reason = 'threatmetrix_review'
profile.deactivate_for_fraud_review

expect(profile.activated_at).to be_nil
expect(profile.active).to eq(false)
expect(profile.deactivation_reason).to be_nil
expect(profile.fraud_review_pending?).to eq(true) # changed
expect(profile.gpo_verification_pending_at).to be_nil
expect(profile.in_person_verification_pending_at).to be_nil
expect(profile.initiating_service_provider).to be_nil
expect(profile.verified_at).to be_nil
expect { profile.deactivate_for_fraud_review }.to(
change { profile.fraud_review_pending? }.from(false).to(true).
and(change { profile.in_person_verification_pending_at }.to(nil)),
)

expect(profile).to_not be_active
expect(profile.fraud_review_pending?).to eq(true)
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.

It appears that this line has always been redundant; it was tested before and after above already.

expect(profile.fraud_rejection?).to eq(false)
expect(profile.fraud_pending_reason).to eq('threatmetrix_review')
expect(profile.pending_reasons).to eq([:fraud_check_pending])
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.

Interesting aside: this is what was previously returning [:in_person_verification_pending] causing the problem. I set out to assert that this was an empty array, but it is not.

The action-account code handles this, and it's correct behavior, but it wasn't entirely intuitive in the moment.

end
end

Expand Down