From 5a16a5a0ee0303257fa565ead5d0ec4b7458af9f Mon Sep 17 00:00:00 2001 From: Muhsin <12408980+muhsin-k@users.noreply.github.com> Date: Tue, 14 Apr 2026 15:24:44 +0400 Subject: [PATCH 1/2] test: stub incoming_phone_numbers in voice teardown spec Teardown now also clears number-level voice_url/status_callback, so the Twilio client double needs incoming_phone_numbers.list stubbed. --- spec/enterprise/models/channel/twilio_sms_voice_spec.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/enterprise/models/channel/twilio_sms_voice_spec.rb b/spec/enterprise/models/channel/twilio_sms_voice_spec.rb index ae858993b..0b1b76077 100644 --- a/spec/enterprise/models/channel/twilio_sms_voice_spec.rb +++ b/spec/enterprise/models/channel/twilio_sms_voice_spec.rb @@ -69,11 +69,14 @@ RSpec.describe Channel::TwilioSms do let(:channel) { create(:channel_twilio_sms, :with_voice, account: account) } let(:app_context) { instance_double(Twilio::REST::Api::V2010::AccountContext::ApplicationContext) } let(:twilio_client) { instance_double(Twilio::REST::Client) } + let(:numbers_list) { instance_double(Twilio::REST::Api::V2010::AccountContext::IncomingPhoneNumberList) } before do allow(Twilio::REST::Client).to receive(:new).and_return(twilio_client) allow(twilio_client).to receive(:applications).with(channel.twiml_app_sid).and_return(app_context) allow(app_context).to receive(:delete) + allow(twilio_client).to receive(:incoming_phone_numbers).and_return(numbers_list) + allow(numbers_list).to receive(:list).with(phone_number: channel.phone_number).and_return([]) end it 'deletes the TwiML app and clears twiml_app_sid' do From 94766e12000a474c10e383343f2b33c1ac3da2e3 Mon Sep 17 00:00:00 2001 From: Muhsin <12408980+muhsin-k@users.noreply.github.com> Date: Tue, 14 Apr 2026 15:29:16 +0400 Subject: [PATCH 2/2] chore: rescue errors only in delete_twiml_app --- enterprise/app/services/twilio/voice_teardown_service.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/enterprise/app/services/twilio/voice_teardown_service.rb b/enterprise/app/services/twilio/voice_teardown_service.rb index 87e991f47..6cece3791 100644 --- a/enterprise/app/services/twilio/voice_teardown_service.rb +++ b/enterprise/app/services/twilio/voice_teardown_service.rb @@ -4,8 +4,6 @@ class Twilio::VoiceTeardownService def perform delete_twiml_app if channel.twiml_app_sid.present? clear_number_webhooks - rescue StandardError => e - Rails.logger.error("TWILIO_VOICE_TEARDOWN_ERROR: #{e.class} #{e.message} phone=#{channel.phone_number} account=#{channel.account_id}") ensure clear_voice_credentials end @@ -14,6 +12,8 @@ class Twilio::VoiceTeardownService def delete_twiml_app twilio_client.applications(channel.twiml_app_sid).delete + rescue StandardError => e + Rails.logger.error("TWILIO_VOICE_TEARDOWN_ERROR: #{e.class} #{e.message} phone=#{channel.phone_number} account=#{channel.account_id}") end def clear_number_webhooks