diff --git a/.reek b/.reek index 300a18b49a2..d83f1dc79b1 100644 --- a/.reek +++ b/.reek @@ -132,6 +132,7 @@ UncommunicativeModuleName: UnusedParameters: exclude: - SmsOtpSenderJob#perform + - VoiceOtpSenderJob#perform UnusedPrivateMethod: exclude: - ApplicationController diff --git a/app/jobs/voice_otp_sender_job.rb b/app/jobs/voice_otp_sender_job.rb index eb451232802..b9d17f696cb 100644 --- a/app/jobs/voice_otp_sender_job.rb +++ b/app/jobs/voice_otp_sender_job.rb @@ -4,9 +4,15 @@ class VoiceOtpSenderJob < ApplicationJob queue_as :voice - def perform(code:, phone:, otp_created_at:) + # rubocop:disable Lint/UnusedMethodArgument + # locale is an argument used for the Twilio/Authy Verify service, which uses + # a localized message for delivering OTPs via SMS and Voice. As of this + # writing, we are only using Verify for non-US SMS, but we might expand + # to Voice later. + def perform(code:, phone:, otp_created_at:, locale: nil) send_otp(TwilioService.new, code, phone) if otp_valid?(otp_created_at) end + # rubocop:enable Lint/UnusedMethodArgument private diff --git a/spec/features/two_factor_authentication/sign_in_spec.rb b/spec/features/two_factor_authentication/sign_in_spec.rb index 535970ad3ac..61cf0da6b8a 100644 --- a/spec/features/two_factor_authentication/sign_in_spec.rb +++ b/spec/features/two_factor_authentication/sign_in_spec.rb @@ -125,6 +125,17 @@ expect(current_path).to eq login_two_factor_path(otp_delivery_preference: 'sms') end end + + context 'with voice option and US number' do + it 'sends the code via VoiceOtpSenderJob and redirects to prompt for the code' do + sign_in_before_2fa + select_2fa_option('voice') + fill_in 'user_phone_form_phone', with: '7035551212' + click_send_security_code + + expect(current_path).to eq login_two_factor_path(otp_delivery_preference: 'voice') + end + end end def phone_field