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
15 changes: 13 additions & 2 deletions app/controllers/idv/please_call_controller.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
module Idv
class PleaseCallController < ApplicationController
include FraudReviewConcern

before_action :confirm_two_factor_authenticated
before_action :handle_fraud_rejection
before_action :confirm_fraud_pending

FRAUD_REVIEW_CONTACT_WITHIN_DAYS = 14.days

def show
analytics.idv_please_call_visited
pending_at = current_user.fraud_review_pending_profile.fraud_review_pending_at ||
Time.zone.today
pending_at = current_user.fraud_review_pending_profile.fraud_review_pending_at
@call_by_date = pending_at + FRAUD_REVIEW_CONTACT_WITHIN_DAYS
end

private

def confirm_fraud_pending
if !fraud_review_pending?
redirect_to account_url
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.

Should we check if they're in the midst of IdV and redirect to idv_url? Or redirect there and let it check as needed?

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.

Do we have a reliable pattern for checking if a user is in the midst of IdV somewhere that I could use? I'm not sure this is the right place to introduce that pattern if not. A user should not be sent here if they are in the midst of IdV (and they aren't being sent here evidenced by the lack of 500s errors observed from this controller).

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.

As far as I can tell, only IdV controllers redirect to this controller with idv_please_call_url. There's now a user_please_call_url for suspended users that is used from application controller.

And, I looked at idv controller and it doesn't have a before action to redirect to account_url, so this seems fine. Good point about not seeing 500s.

end
end
end
end
29 changes: 21 additions & 8 deletions spec/controllers/idv/please_call_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,32 @@

RSpec.describe Idv::PleaseCallController do
let(:user) { create(:user) }
let(:fraud_review_pending_date) { 5.days.ago }
let(:verify_date) { 20.days.ago }
let(:fraud_review_pending_date) { profile.fraud_review_pending_at }
let(:verify_date) { profile.verified_at }
let!(:profile) { create(:profile, :verified, :fraud_review_pending, user: user) }

before do
user.profiles.create(
fraud_review_pending_at: fraud_review_pending_date,
verified_at: verify_date,
)
stub_sign_in(user)
end

render_views

it 'redirects a user who is not fraud review pending' do
profile.activate_after_fraud_review_unnecessary

get :show

expect(response).to redirect_to(account_url)
end

it 'redirects a user who has been fraud rejected' do
profile.reject_for_fraud(notify_user: false)

get :show

expect(response).to redirect_to(idv_not_verified_url)
end

it 'renders the show template' do
stub_analytics

Expand All @@ -26,8 +41,6 @@
expect(response).to render_template :show
end

render_views

it 'asks user to call 2 weeks from fraud_review_pending_date' do
get :show

Expand Down