feat: Support Twilio Messaging Services (#4242)
This allows sending and receiving from multiple phone numbers using Twilio messaging services Fixes: #4204
This commit is contained in:
@@ -3,7 +3,7 @@ require 'rails_helper'
|
||||
describe Twilio::IncomingMessageService do
|
||||
let!(:account) { create(:account) }
|
||||
let!(:twilio_sms) do
|
||||
create(:channel_twilio_sms, account: account, phone_number: '+1234567890', account_sid: 'ACxxx',
|
||||
create(:channel_twilio_sms, account: account, account_sid: 'ACxxx',
|
||||
inbox: create(:inbox, account: account, greeting_enabled: false))
|
||||
end
|
||||
let!(:contact) { create(:contact, account: account, phone_number: '+12345') }
|
||||
@@ -16,7 +16,7 @@ describe Twilio::IncomingMessageService do
|
||||
SmsSid: 'SMxx',
|
||||
From: '+12345',
|
||||
AccountSid: 'ACxxx',
|
||||
To: '+1234567890',
|
||||
MessagingServiceSid: twilio_sms.messaging_service_sid,
|
||||
Body: 'testing3'
|
||||
}
|
||||
|
||||
@@ -29,12 +29,45 @@ describe Twilio::IncomingMessageService do
|
||||
SmsSid: 'SMxx',
|
||||
From: '+123456',
|
||||
AccountSid: 'ACxxx',
|
||||
To: '+1234567890',
|
||||
MessagingServiceSid: twilio_sms.messaging_service_sid,
|
||||
Body: 'new conversation'
|
||||
}
|
||||
|
||||
described_class.new(params: params).perform
|
||||
expect(Conversation.count).to eq(2)
|
||||
end
|
||||
|
||||
context 'with a phone number' do
|
||||
let!(:twilio_sms) do
|
||||
create(:channel_twilio_sms, :with_phone_number, account: account, account_sid: 'ACxxx',
|
||||
inbox: create(:inbox, account: account, greeting_enabled: false))
|
||||
end
|
||||
|
||||
it 'creates a new message in existing conversation' do
|
||||
params = {
|
||||
SmsSid: 'SMxx',
|
||||
From: '+12345',
|
||||
AccountSid: 'ACxxx',
|
||||
To: twilio_sms.phone_number,
|
||||
Body: 'testing3'
|
||||
}
|
||||
|
||||
described_class.new(params: params).perform
|
||||
expect(conversation.reload.messages.last.content).to eq('testing3')
|
||||
end
|
||||
|
||||
it 'creates a new conversation' do
|
||||
params = {
|
||||
SmsSid: 'SMxx',
|
||||
From: '+123456',
|
||||
AccountSid: 'ACxxx',
|
||||
To: twilio_sms.phone_number,
|
||||
Body: 'new conversation'
|
||||
}
|
||||
|
||||
described_class.new(params: params).perform
|
||||
expect(Conversation.count).to eq(2)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user