Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: LG-14503 Update USPS Proofing Job To Not Override Deactivation Codes on Profile #11261

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

gina-yamada
Copy link
Contributor

@gina-yamada gina-yamada commented Sep 18, 2024

🎫 Ticket

LG-14503 Update USPS Proofing Results Job exclude overwriting profile deactivation reason

🛠 Summary of changes

  • Update method deactivate_due_to_in_person_verification_cancelled to only update profile with a deactivation reason when it does not already exist. We do not want to override password_reset or encryption_error to preserves the history.

📜 Testing Plan

  • Step 1 It is helpful to add get_usps_proofing_results_job_cron: '0/59 * * * *' or some version to config/application.yml to delay the job from running so you have time to test. (The job will run on the 59 min of the hour.)

Check that there is not a regression. (A profile that has an enrollment that either expired, was cancelled, or failed gets verification_cancelled assigned as the deactivation reason.)

  • Step 2 Starting in Sinatra, create an account go through ID-IPP flow to create an enrollment- get to Ready to Verify (barcode page). In a different terminal open the rails console
  • Step 3 Run the job using the following commands
e = InPersonEnrollment.last
res = JSON.parse(UspsInPersonProofing::Mock::Fixtures.request_failed_proofing_results_response)
job = GetUspsProofingResultsJob.new
job.instance_variable_set('@enrollment_outcomes', { enrollments_passed: 0, enrollments_failed: 0, enrollments_errored: 0, enrollments_expired: 0, enrollments_checked: 0 })
job.send(:process_enrollment_response, e, res)
  • Step 4 Verify the data. (1. Enrollment status is failed 2. Profile is not active 3. Profile deactivation reason is verification_cancelled)
  • Step 5 Optional: Repeat steps 2-4 for each- cancelled and expired enrollments

Check new functionality

  • Step 6 - [ ] Step 2 Starting in Sinatra, create an account (use [email protected] so you can get an email delivered to reset your PW), go through ID-IPP flow to create an enrollment- get to Ready to Verify (barcode page). In a different terminal open the rails console
  • Step 7 Verify the data. (1. Enrollment status is pending 2. Profile is not active 3. Profile deactivation reason is nil)
  • Step 8 Sign out. Perform a password reset via Forgot you password on the sign in page of Login.
  • Step 9 Sign in. Verify the data. (1. Enrollment status is pending 2. Profile is not active 3. Profile deactivation reason is encyption_error).
  • Step 10 Run the job using the following commands
e = InPersonEnrollment.last
res = JSON.parse(UspsInPersonProofing::Mock::Fixtures.request_failed_proofing_results_response)
job = GetUspsProofingResultsJob.new
job.instance_variable_set('@enrollment_outcomes', { enrollments_passed: 0, enrollments_failed: 0, enrollments_errored: 0, enrollments_expired: 0, enrollments_checked: 0 })
job.send(:process_enrollment_response, e, res)
  • Step 11 Verify the data. (1. Enrollment status is cancelled 2. Profile is not active 3. Profile deactivation reason is encryption_error).

  • Step 12

@gina-yamada gina-yamada changed the title LG-14503 Update USPS Proofing Job To Not Override Deactivation Codes on Profile WIP: LG-14503 Update USPS Proofing Job To Not Override Deactivation Codes on Profile Sep 18, 2024
Comment on lines 200 to 201
update!(active: false, in_person_verification_pending_at: nil)
update!(deactivation_reason: :verification_cancelled) if !deactivation_reason.present?
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to combine this into one UPDATE to avoid the extra database call?

Copy link
Contributor

@zachmargolis zachmargolis Sep 18, 2024

Choose a reason for hiding this comment

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

maybe like this?

Suggested change
update!(active: false, in_person_verification_pending_at: nil)
update!(deactivation_reason: :verification_cancelled) if !deactivation_reason.present?
to_update = {
active: false,
in_person_verification_pending_at: nil
}.tap do |attrs|
attrs[:deactivation_reason] = :verification_cancelled if deactivation_reason.blank?
end
update!(to_update)

Copy link
Contributor

@zachmargolis zachmargolis Sep 18, 2024

Choose a reason for hiding this comment

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

or maybe something like this:

Suggested change
update!(active: false, in_person_verification_pending_at: nil)
update!(deactivation_reason: :verification_cancelled) if !deactivation_reason.present?
update!(
active: false,
in_person_verification_pending_at: nil,
deactivation_reason: deactivation_reason.presence || :verification_cancelled,
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had never seen tap before- helpful method. Ultimately, I went went suggestion 2. Resolved with commit d0b5cb4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants