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.
This commit is contained in:
Jordan Brough
2023-08-16 16:00:02 -06:00
committed by GitHub
parent 616f702871
commit 996f842882
2 changed files with 0 additions and 19 deletions

View File

@@ -9,8 +9,6 @@ class Twilio::WebhookSetupService
else else
update_phone_number update_phone_number
end end
rescue Twilio::REST::TwilioError => e
Rails.logger.error "TWILIO_FAILURE: #{e.message}"
end end
private private

View File

@@ -27,14 +27,6 @@ describe Twilio::WebhookSetupService do
expect(services).to have_received(:update) expect(services).to have_received(:update)
end 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 end
context 'with a phone number' do context 'with a phone number' do
@@ -68,15 +60,6 @@ describe Twilio::WebhookSetupService do
sms_url: twilio_callback_index_url sms_url: twilio_callback_index_url
) )
end 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 end
end end