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
11 changes: 7 additions & 4 deletions app/controllers/idv/otp_delivery_method_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def new
def create
result = otp_delivery_selection_form.submit(otp_delivery_selection_params)
analytics.track_event(Analytics::IDV_PHONE_OTP_DELIVERY_SELECTION_SUBMITTED, result.to_h)
return render(:new) unless result.success?
return render_new_with_error_message unless result.success?
send_phone_confirmation_otp_and_handle_result
rescue Twilio::REST::RestError, PhoneVerification::VerifyError => exception
invalid_phone_number(exception)
Expand All @@ -38,9 +38,12 @@ def set_idv_phone
end

def otp_delivery_selection_params
params.require(:otp_delivery_selection_form).permit(
:otp_delivery_preference
)
params.permit(:otp_delivery_preference)
end

def render_new_with_error_message
flash[:error] = t('idv.errors.unsupported_otp_delivery_method')
render :new
end

def send_phone_confirmation_otp_and_handle_result
Expand Down
5 changes: 3 additions & 2 deletions app/views/idv/otp_delivery_method/new.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ p.mt1 = t('idv.messages.otp_delivery_method.phone_number_html',
fieldset.mb3.p0.border-none
label.btn-border.col-12.mb1
.radio
= radio_button_tag 'otp_delivery_selection_form[otp_delivery_preference]', :sms, true,
= radio_button_tag 'otp_delivery_preference',
:sms, false,
class: :otp_delivery_preference_sms
span.indicator.mt-tiny
span.blue.bold.fs-20p
Expand All @@ -15,7 +16,7 @@ p.mt1 = t('idv.messages.otp_delivery_method.phone_number_html',
= t('two_factor_authentication.two_factor_choice_options.sms_info')
label.btn-border.col-12.mb0
.radio
= radio_button_tag 'otp_delivery_selection_form[otp_delivery_preference]',
= radio_button_tag 'otp_delivery_preference',
:voice, false,
class: :otp_delivery_preference_voice
span.indicator.mt-tiny
Expand Down
1 change: 1 addition & 0 deletions config/locales/idv/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ en:
zipcode: 'Your zipcode must be entered in as #####-####'
unsupported_jurisdiction: Sorry, we can't verify people from this state.
unsupported_jurisdiction_sp: Please visit %{sp_name} to access your account.
unsupported_otp_delivery_method: Select a method to receive a code.
failure:
attempts:
one: You have <strong>1 attempt remaining.</strong>
Expand Down
1 change: 1 addition & 0 deletions config/locales/idv/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ es:
unsupported_jurisdiction: Lo sentimos, no podemos verificar personas de este
estado.
unsupported_jurisdiction_sp: Visita %{sp_name} para acceder a tu cuenta.
unsupported_otp_delivery_method: Seleccione una manera de recibir un código.
failure:
attempts:
one: Tiene usted <strong> 1 intento restante.</ strong>
Expand Down
1 change: 1 addition & 0 deletions config/locales/idv/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ fr:
de cet état.
unsupported_jurisdiction_sp: Veuillez visiter %{sp_name} pour accéder à votre
compte.
unsupported_otp_delivery_method: Sélectionnez une méthode pour recevoir un code
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.

Minor issue: this is missing a period at the end compared to the other languages.

failure:
attempts:
one: Il ne vous reste qu' strongune tentative./strong
Expand Down
24 changes: 3 additions & 21 deletions spec/controllers/idv/otp_delivery_method_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,7 @@
end

describe '#create' do
let(:params) do
{
otp_delivery_selection_form: {
otp_delivery_preference: :sms,
},
}
end
let(:params) { { otp_delivery_preference: :sms } }

context 'user has not selected phone verification method' do
before do
Expand Down Expand Up @@ -130,13 +124,7 @@
end

context 'user has selected voice' do
let(:params) do
{
otp_delivery_selection_form: {
otp_delivery_preference: :voice,
},
}
end
let(:params) { { otp_delivery_preference: :voice } }

it 'redirects to the otp send path for voice' do
post :create, params: params
Expand All @@ -162,13 +150,7 @@
end

context 'form is invalid' do
let(:params) do
{
otp_delivery_selection_form: {
otp_delivery_preference: :🎷,
},
}
end
let(:params) { { otp_delivery_preference: :🎷 } }

it 'renders the new template' do
post :create, params: params
Expand Down
14 changes: 14 additions & 0 deletions spec/features/idv/steps/phone_otp_delivery_selection_step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@
end
end

context 'the user does not make a selection' do
it 'does not send a voice call or sms and renders an error' do
expect(VoiceOtpSenderJob).to_not receive(:perform_later)
expect(SmsOtpSenderJob).to_not receive(:perform_later)

start_idv_from_sp
complete_idv_steps_before_phone_otp_delivery_selection_step
click_on t('idv.buttons.send_confirmation_code')

expect(page).to have_content(t('idv.errors.unsupported_otp_delivery_method'))
expect(current_path).to eq(idv_otp_delivery_method_path)
end
end

context 'with a non-US number' do
let(:bahamas_phone) { '+12423270143' }

Expand Down
8 changes: 5 additions & 3 deletions spec/support/features/idv_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ def click_idv_continue
end

def choose_idv_otp_delivery_method_sms
using_wait_time(5) do
click_on t('idv.buttons.send_confirmation_code')
end
page.find(
'label',
text: t('two_factor_authentication.otp_delivery_preference.sms')
).click
click_on t('idv.buttons.send_confirmation_code')
end

def choose_idv_otp_delivery_method_voice
Expand Down