chore: reserve api_key_secret and update voice UI
This commit is contained in:
+8
-1
@@ -33,8 +33,15 @@ export default {
|
||||
hasApiKeySid() {
|
||||
return !!this.inbox.api_key_sid;
|
||||
},
|
||||
hasExistingCredentials() {
|
||||
return this.hasApiKeySid;
|
||||
},
|
||||
needsCredentials() {
|
||||
return this.voiceEnabled && !this.isVoiceConfigured;
|
||||
return (
|
||||
this.voiceEnabled &&
|
||||
!this.isVoiceConfigured &&
|
||||
!this.hasExistingCredentials
|
||||
);
|
||||
},
|
||||
needsApiKeySid() {
|
||||
return this.needsCredentials && !this.hasApiKeySid;
|
||||
|
||||
@@ -16,7 +16,7 @@ class Twilio::VoiceTeardownService
|
||||
end
|
||||
|
||||
def clear_voice_credentials
|
||||
channel.update!(twiml_app_sid: nil, api_key_secret: nil)
|
||||
channel.update!(twiml_app_sid: nil)
|
||||
end
|
||||
|
||||
def twilio_client
|
||||
|
||||
@@ -73,19 +73,19 @@ RSpec.describe Channel::TwilioSms do
|
||||
allow(app_context).to receive(:delete)
|
||||
end
|
||||
|
||||
it 'deletes the TwiML app and clears voice credentials' do
|
||||
it 'deletes the TwiML app and clears twiml_app_sid' do
|
||||
original_twiml_sid = channel.twiml_app_sid
|
||||
channel.update!(voice_enabled: false)
|
||||
|
||||
expect(twilio_client).to have_received(:applications).with(original_twiml_sid)
|
||||
expect(app_context).to have_received(:delete)
|
||||
expect(channel.reload.twiml_app_sid).to be_nil
|
||||
expect(channel.reload.api_key_secret).to be_nil
|
||||
end
|
||||
|
||||
it 'preserves api_key_sid' do
|
||||
it 'preserves api_key_sid and api_key_secret' do
|
||||
channel.update!(voice_enabled: false)
|
||||
expect(channel.reload.api_key_sid).to be_present
|
||||
expect(channel.reload.api_key_secret).to be_present
|
||||
end
|
||||
|
||||
it 'does not fail if Twilio API errors' do
|
||||
@@ -94,7 +94,6 @@ RSpec.describe Channel::TwilioSms do
|
||||
|
||||
expect { channel.update!(voice_enabled: false) }.not_to raise_error
|
||||
expect(channel.reload.twiml_app_sid).to be_nil
|
||||
expect(channel.reload.api_key_secret).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user