feat: Add native support for CSML in agent_bot API (#4913)
This commit is contained in:
19
spec/jobs/agent_bots/csml_job_spec.rb
Normal file
19
spec/jobs/agent_bots/csml_job_spec.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AgentBots::CsmlJob, type: :job do
|
||||
it 'runs csml processor service' do
|
||||
event = 'message.created'
|
||||
message = create(:message)
|
||||
agent_bot = create(:agent_bot)
|
||||
processor = double
|
||||
|
||||
allow(Integrations::Csml::ProcessorService).to receive(:new).and_return(processor)
|
||||
allow(processor).to receive(:perform)
|
||||
|
||||
described_class.perform_now(event, agent_bot, message)
|
||||
|
||||
expect(Integrations::Csml::ProcessorService)
|
||||
.to have_received(:new)
|
||||
.with(event_name: event, agent_bot: agent_bot, event_data: { message: message })
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,8 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AgentBotJob, type: :job do
|
||||
RSpec.describe AgentBots::WebhookJob, type: :job do
|
||||
include ActiveJob::TestHelper
|
||||
|
||||
subject(:job) { described_class.perform_later(url, payload) }
|
||||
|
||||
let(:url) { 'https://test.com' }
|
||||
@@ -11,4 +13,9 @@ RSpec.describe AgentBotJob, type: :job do
|
||||
.with(url, payload)
|
||||
.on_queue('bots')
|
||||
end
|
||||
|
||||
it 'executes perform' do
|
||||
expect(Webhooks::Trigger).to receive(:execute).with(url, payload)
|
||||
perform_enqueued_jobs { job }
|
||||
end
|
||||
end
|
||||
@@ -1,9 +1,11 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe WebhookJob, type: :job do
|
||||
include ActiveJob::TestHelper
|
||||
|
||||
subject(:job) { described_class.perform_later(url, payload) }
|
||||
|
||||
let(:url) { 'https://test.com' }
|
||||
let(:url) { 'https://test.chatwoot.com' }
|
||||
let(:payload) { { name: 'test' } }
|
||||
|
||||
it 'queues the job' do
|
||||
@@ -11,4 +13,9 @@ RSpec.describe WebhookJob, type: :job do
|
||||
.with(url, payload)
|
||||
.on_queue('webhooks')
|
||||
end
|
||||
|
||||
it 'executes perform' do
|
||||
expect(Webhooks::Trigger).to receive(:execute).with(url, payload)
|
||||
perform_enqueued_jobs { job }
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user