mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 03:57:52 +00:00
chore: one off SMS campaign APIs (#2589)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user