Some checks failed
Lock Threads / action (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot EE docker images / merge (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot CE docker images / merge (push) Has been cancelled
Run Chatwoot CE spec / lint-backend (push) Has been cancelled
Run Chatwoot CE spec / lint-frontend (push) Has been cancelled
Run Chatwoot CE spec / frontend-tests (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (0, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (1, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (10, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (11, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (12, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (13, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (14, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (15, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (2, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (3, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (4, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (5, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (6, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (7, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (8, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (9, 16) (push) Has been cancelled
Run Linux nightly installer / nightly (push) Has been cancelled
- Add Logistics component with progress tracking - Add OrderDetail component for order information - Support data-driven steps and actions - Add blue color scale to widget SCSS - Fix node overflow and progress bar rendering issues - Add English translations for dashboard components Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
86 lines
3.2 KiB
Ruby
86 lines
3.2 KiB
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe Webhooks::SmsEventsJob do
|
|
subject(:job) { described_class.perform_later(params) }
|
|
|
|
let!(:sms_channel) { create(:channel_sms) }
|
|
let!(:params) do
|
|
{
|
|
time: '2022-02-02T23:14:05.309Z',
|
|
type: 'message-received',
|
|
to: sms_channel.phone_number,
|
|
description: 'Incoming message received',
|
|
message: {
|
|
'id': '3232420-2323-234324',
|
|
'owner': sms_channel.phone_number,
|
|
'applicationId': '2342349-324234d-32432432',
|
|
'time': '2022-02-02T23:14:05.262Z',
|
|
'segmentCount': 1,
|
|
'direction': 'in',
|
|
'to': [
|
|
sms_channel.phone_number
|
|
],
|
|
'from': '+14234234234',
|
|
'text': 'test message'
|
|
}
|
|
}
|
|
end
|
|
|
|
it 'enqueues the job' do
|
|
expect { job }.to have_enqueued_job(described_class)
|
|
.with(params)
|
|
.on_queue('default')
|
|
end
|
|
|
|
context 'when invalid params' do
|
|
it 'returns nil when no bot_token' do
|
|
expect(described_class.perform_now({})).to be_nil
|
|
end
|
|
|
|
it 'returns nil when invalid type' do
|
|
expect(described_class.perform_now({ type: 'invalid' })).to be_nil
|
|
end
|
|
end
|
|
|
|
context 'when valid params' do
|
|
it 'calls Sms::IncomingMessageService if the message type is message-received' do
|
|
process_service = double
|
|
allow(Sms::IncomingMessageService).to receive(:new).and_return(process_service)
|
|
allow(process_service).to receive(:perform)
|
|
expect(Sms::IncomingMessageService).to receive(:new).with(inbox: sms_channel.inbox,
|
|
params: params[:message].with_indifferent_access)
|
|
expect(process_service).to receive(:perform)
|
|
described_class.perform_now(params)
|
|
end
|
|
|
|
it 'calls Sms::DeliveryStatusService if the message type is message-delivered' do
|
|
params[:type] = 'message-delivered'
|
|
process_service = double
|
|
allow(Sms::DeliveryStatusService).to receive(:new).and_return(process_service)
|
|
allow(process_service).to receive(:perform)
|
|
expect(Sms::DeliveryStatusService).to receive(:new).with(channel: sms_channel,
|
|
params: params[:message].with_indifferent_access)
|
|
expect(process_service).to receive(:perform)
|
|
described_class.perform_now(params)
|
|
end
|
|
|
|
it 'calls Sms::DeliveryStatusService if the message type is message-failed' do
|
|
params[:type] = 'message-failed'
|
|
process_service = double
|
|
allow(Sms::DeliveryStatusService).to receive(:new).and_return(process_service)
|
|
allow(process_service).to receive(:perform)
|
|
expect(Sms::DeliveryStatusService).to receive(:new).with(channel: sms_channel,
|
|
params: params[:message].with_indifferent_access)
|
|
expect(process_service).to receive(:perform)
|
|
described_class.perform_now(params)
|
|
end
|
|
|
|
it 'does not call any service if the message type is not supported' do
|
|
params[:type] = 'message-sent'
|
|
expect(Sms::IncomingMessageService).not_to receive(:new)
|
|
expect(Sms::DeliveryStatusService).not_to receive(:new)
|
|
described_class.perform_now(params)
|
|
end
|
|
end
|
|
end
|