chore: one off SMS campaign APIs (#2589)

This commit is contained in:
Sojan Jose
2021-07-14 12:24:09 +05:30
committed by GitHub
parent cb44eb2964
commit dfddf9cacc
15 changed files with 337 additions and 23 deletions

View File

@@ -106,6 +106,28 @@ RSpec.describe 'Campaigns API', type: :request do
expect(response).to have_http_status(:success)
expect(JSON.parse(response.body, symbolize_names: true)[:title]).to eq('test')
end
it 'creates a new oneoff campaign' do
twilio_sms = create(:channel_twilio_sms, account: account)
twilio_inbox = create(:inbox, channel: twilio_sms)
label1 = create(:label, account: account)
label2 = create(:label, account: account)
post "/api/v1/accounts/#{account.id}/campaigns",
params: {
inbox_id: twilio_inbox.id, title: 'test', message: 'test message',
scheduled_at: 2.days.from_now,
audience: [{ type: 'Label', id: label1.id }, { type: 'Label', id: label2.id }]
},
headers: administrator.create_new_auth_token,
as: :json
expect(response).to have_http_status(:success)
response_data = JSON.parse(response.body, symbolize_names: true)
expect(response_data[:campaign_type]).to eq('one_off')
expect(response_data[:scheduled_at].present?).to eq true
expect(response_data[:audience].pluck(:id)).to include(label1.id, label2.id)
end
end
end