From 996f84288243e7299e8ec5c9868d3b912580e02f Mon Sep 17 00:00:00 2001 From: Jordan Brough Date: Wed, 16 Aug 2023 16:00:02 -0600 Subject: [PATCH] feat: Allow Twilio::REST::TwilioError errors to raise and prevent Inbox creation (#7379) This update will mean that errors will roll back the current transaction and the error will be sent back to the frontend and the user will know that the Inbox did not finish setting up successfully. --- app/services/twilio/webhook_setup_service.rb | 2 -- .../twilio/webhook_setup_service_spec.rb | 17 ----------------- 2 files changed, 19 deletions(-) diff --git a/app/services/twilio/webhook_setup_service.rb b/app/services/twilio/webhook_setup_service.rb index 565cd4edf..b949bf37c 100644 --- a/app/services/twilio/webhook_setup_service.rb +++ b/app/services/twilio/webhook_setup_service.rb @@ -9,8 +9,6 @@ class Twilio::WebhookSetupService else update_phone_number end - rescue Twilio::REST::TwilioError => e - Rails.logger.error "TWILIO_FAILURE: #{e.message}" end private diff --git a/spec/services/twilio/webhook_setup_service_spec.rb b/spec/services/twilio/webhook_setup_service_spec.rb index b45a8a895..fbbc11a60 100644 --- a/spec/services/twilio/webhook_setup_service_spec.rb +++ b/spec/services/twilio/webhook_setup_service_spec.rb @@ -27,14 +27,6 @@ describe Twilio::WebhookSetupService do expect(services).to have_received(:update) end - - it 'does not raise if TwilioError is thrown' do - expect(services).to receive(:update).and_raise(Twilio::REST::TwilioError) - - expect do - described_class.new(inbox: channel_twilio_sms.inbox).perform - end.not_to raise_error - end end context 'with a phone number' do @@ -68,15 +60,6 @@ describe Twilio::WebhookSetupService do sms_url: twilio_callback_index_url ) end - - it 'does not call update if TwilioError is thrown' do - allow(twilio_client).to receive(:incoming_phone_numbers).and_return(phone_double) - allow(phone_double).to receive(:list).and_raise(Twilio::REST::TwilioError) - - described_class.new(inbox: channel_twilio_sms.inbox).perform - - expect(phone_double).not_to have_received(:update) - end end end end