Skip to content

Bugfix: Clear in_person_verification_pending_at on fraud deactivation#10222

Merged
n1zyy merged 6 commits intomainfrom
mattw/fraud_deactivation_ipp
Mar 14, 2024
Merged

Bugfix: Clear in_person_verification_pending_at on fraud deactivation#10222
n1zyy merged 6 commits intomainfrom
mattw/fraud_deactivation_ipp

Conversation

@n1zyy
Copy link
Contributor

@n1zyy n1zyy commented Mar 8, 2024

🎫 Ticket

TK

🛠 Summary of changes

deactivate_for_fraud_review was not clearing in_person_verification_pending_at. This didn't affect anything on the site and thus went unnoticed until now.

But, Profile validation prevents activating an account that is in_person_verification_pending?, which means that anyone flagged for fraud could not have their account reinstated after a manual review. This fixes that.

(Someone please notice that my commit has the description perfectly fit the same length on each line. I am very proud of myself for this meaningless accomplishment.)

📜 Testing Plan

I made some small changes to the unit test for this method.

@JackRyan1989 identified this issue as part of his larger work on improved testing, so I stuck to a simple unit test change rather than steal his excellent work that will be pushed up soon.

n1zyy added 3 commits March 8, 2024 13:13
Jack found a sneaky bug, where the UX was correct, but the profile
would not be able to be reactivated because validation prevents an
in_person_verification_pending profile from activation. Now fixed!
expect(profile.fraud_review_pending?).to eq(true)
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
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.

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.in_person_verification_pending_at).not_to be_nil # to change
Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 or 👎 on this comment (and the one below on 1038)? I was following the pattern established on 1024, but am of half a mind to think that it could be misread as meaning that this behavior is subject to change in a future sprint, rather than that we test that this value has been changed.

(And is it bad that most of the test is devoted to assertions that don't change and we need comments to highlight what does?) 🤔

Copy link
Contributor

@gina-yamada gina-yamada Mar 8, 2024

Choose a reason for hiding this comment

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

I vote 👍 - I like when things like this are pointed out like this when there is a lot of data. Also, because it is in a test file- I did not interrupt the comment as a change in a future sprint.

Copy link
Contributor

@svalexander svalexander Mar 8, 2024

Choose a reason for hiding this comment

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

if we include this comment I would include when it should be changed so we have an indicator as to when the comment should be removed.
I lean toward not including the comment on line 1038

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can use RSpec to write specs that actually highlight what should change, and get better error messages too

expect { profile.deactivate_for_fraud_review }.to(
    change { profile.reload.in_person_verification_pending_at }.to(nil)
    .and(change { profile.reload.fraud_review_pending?).from(false).to_true)),
)

See https://stackoverflow.com/a/29389223

@n1zyy n1zyy requested a review from a team March 8, 2024 18:35
}.to(nil)

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

}.from(false).to(true).
and change {
profile.in_person_verification_pending_at
}.to(nil)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

rubocop -A made an absolute abomination of this formatting. I tried to clean it up by hand, but rubocop wasn't having it.

@zachmargolis You had provided an example that was considerably less ugly. Do you have any thoughts on how to make this look more like that without rubocop rejecting it?

Co-authored-by: Zach Margolis <zachmargolis@users.noreply.github.com>
@n1zyy n1zyy merged commit 8f74bcd into main Mar 14, 2024
@n1zyy n1zyy deleted the mattw/fraud_deactivation_ipp branch March 14, 2024 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants