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
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@
end

context 'when loaded while adding a new phone' do
render_views

let(:user) { create(:user) }
let(:phone) { Faker::PhoneNumber.cell_phone_in_e164 }
let(:opt_out_uuid) { PhoneNumberOptOut.create_or_find_with_phone(phone).uuid }
Expand Down
29 changes: 29 additions & 0 deletions spec/features/two_factor_authentication/sign_in_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,35 @@
end
end

context 'with a number that has opted out of SMS delivery' do
let(:user) { create(:user, :with_phone) }
let(:phone_configuration) { user.phone_configurations.first }

before do
PhoneNumberOptOut.create_or_find_with_phone(phone_configuration.phone)
opt_out_manager = instance_double('Telephony::Pinpoint::OptOutManager')
allow(opt_out_manager).
to receive(:opt_in_phone_number).
with(phone_configuration.formatted_phone).
and_return(FormResponse.new(success: true))
allow_any_instance_of(TwoFactorAuthentication::SmsOptInController).
to receive(:opt_out_manager).and_return(opt_out_manager)
end

scenario 'renders the sms opt-out error screen when signing in' do
sign_in_before_2fa(user)

expect(page).to have_content(t('two_factor_authentication.opt_in.title'))

click_button t('forms.buttons.send_one_time_code')

fill_in_code_with_last_phone_otp
click_submit_default

expect(page).to have_current_path(account_path)
end
end

context 'with international phone that does not support voice delivery' do
scenario 'updates international code as user types', :js do
sign_in_before_2fa
Expand Down