From 9af9e1a25375a91f07baf5e6aa571a4c92627302 Mon Sep 17 00:00:00 2001 From: Paul Hirsch Date: Thu, 16 Mar 2023 10:18:46 -0500 Subject: [PATCH] Add additional prompts to UUID lookup and review rake tasks changelog: Internal, utilities, Reuqest more information from users when calling investigative rake tasks --- lib/tasks/review_profile.rake | 23 ++++++++++++++++++++--- lib/tasks/users_lookup.rake | 9 ++++++++- spec/lib/tasks/review_profile_spec.rb | 6 +++++- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/lib/tasks/review_profile.rake b/lib/tasks/review_profile.rake index 11dd01f2c72..66f92778099 100644 --- a/lib/tasks/review_profile.rake +++ b/lib/tasks/review_profile.rake @@ -4,7 +4,16 @@ namespace :users do namespace :review do desc 'Pass a user that has a pending review' task pass: :environment do |_task, args| - user_uuid = STDIN.getpass('Enter the User UUID to pass (input will be hidden):') + STDOUT.sync = true + print 'Enter the name of the investigator: ' + investigator_name = STDIN.gets.chomp + print 'Enter the issue/ticket/reason for the investigation: ' + investigation_number = STDIN.gets.chomp + print 'Enter the User UUID to pass: ' + user_uuid = STDIN.gets.chomp + puts "investigator name: #{investigator_name}" + puts "investigation reason: #{investigation_number}" + puts "uuid: #{user_uuid}" user = User.find_by(uuid: user_uuid) if user.fraud_review_pending? && user.proofing_component.review_eligible? @@ -35,14 +44,22 @@ namespace :users do desc 'Reject a user that has a pending review' task reject: :environment do |_task, args| - user_uuid = STDIN.getpass('Enter the User UUID to reject (input will be hidden):') + STDOUT.sync = true + print 'Enter the name of the investigator: ' + investigator_name = STDIN.gets.chomp + print 'Enter the issue/ticket/reason for the investigation: ' + investigation_number = STDIN.gets.chomp + print 'Enter the User UUID to reject: ' + user_uuid = STDIN.gets.chomp + puts "investigator name: #{investigator_name}" + puts "investigation reason: #{investigation_number}" + puts "uuid: #{user_uuid}" user = User.find_by(uuid: user_uuid) if user.fraud_review_pending? && user.proofing_component.review_eligible? profile = user.fraud_review_pending_profile profile.reject_for_fraud(notify_user: true) - puts "User's profile has been deactivated due to fraud rejection." elsif !user.proofing_component.review_eligible? puts 'User is past the 30 day review eligibility' diff --git a/lib/tasks/users_lookup.rake b/lib/tasks/users_lookup.rake index 5e67bef6d42..a80cf82a8fa 100644 --- a/lib/tasks/users_lookup.rake +++ b/lib/tasks/users_lookup.rake @@ -2,12 +2,19 @@ namespace :users do desc 'Look up a user by email address' task lookup_by_email: :environment do |_task, args| require 'io/console' + STDOUT.sync = true + print 'Enter the name of the investigator: ' + investigator_name = STDIN.gets.chomp + print 'Enter the issue/ticket/reason for the investigation: ' + investigation_number = STDIN.gets.chomp email = STDIN.getpass('Enter the email address to look up (input will be hidden): ') + puts "investigator name: #{investigator_name}" + puts "investigation reason: #{investigation_number}" user = User.find_with_email(email) if user.present? puts "uuid: #{user.uuid}" else - puts 'No user found' + puts 'uuid: Not Found' end end end diff --git a/spec/lib/tasks/review_profile_spec.rb b/spec/lib/tasks/review_profile_spec.rb index 39be1a9b826..b12b5d98c2f 100644 --- a/spec/lib/tasks/review_profile_spec.rb +++ b/spec/lib/tasks/review_profile_spec.rb @@ -13,7 +13,11 @@ before do Rake.application.rake_require('lib/tasks/review_profile', [Rails.root.to_s]) Rake::Task.define_task(:environment) - allow(STDIN).to receive(:getpass) { user.uuid } + allow(STDIN).to receive(:gets).and_return( + "John Doe\n", + "Rspec Test\n", + user.uuid, + ) end describe 'users:review:pass' do