chore: Provider APIs for SMS Channel - Bandwidth (#3889)

fixes: #3888
This commit is contained in:
Sojan Jose
2022-02-03 15:22:13 -08:00
committed by GitHub
parent fba7f40bee
commit cf10f3d03b
40 changed files with 879 additions and 51 deletions

View File

@@ -78,6 +78,27 @@ RSpec.describe Campaign, type: :model do
end
end
context 'when SMS campaign' do
let!(:sms_channel) { create(:channel_sms) }
let!(:sms_inbox) { create(:inbox, channel: sms_channel) }
let(:campaign) { build(:campaign, inbox: sms_inbox) }
it 'only saves campaign type as oneoff and wont leave scheduled_at empty' do
campaign.campaign_type = 'ongoing'
campaign.save!
expect(campaign.reload.campaign_type).to eq 'one_off'
expect(campaign.scheduled_at.present?).to eq true
end
it 'calls sms service on trigger!' do
sms_service = double
expect(Sms::OneoffSmsCampaignService).to receive(:new).with(campaign: campaign).and_return(sms_service)
expect(sms_service).to receive(:perform)
campaign.save!
campaign.trigger!
end
end
context 'when Website campaign' do
let(:campaign) { build(:campaign) }