2020-02-14 17:49:17 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe WebhookJob, type: :job do
|
2022-06-23 13:47:46 +00:00
|
|
|
include ActiveJob::TestHelper
|
|
|
|
|
2020-02-14 17:49:17 +00:00
|
|
|
subject(:job) { described_class.perform_later(url, payload) }
|
|
|
|
|
2022-06-23 13:47:46 +00:00
|
|
|
let(:url) { 'https://test.chatwoot.com' }
|
2020-02-14 17:49:17 +00:00
|
|
|
let(:payload) { { name: 'test' } }
|
|
|
|
|
|
|
|
it 'queues the job' do
|
|
|
|
expect { job }.to have_enqueued_job(described_class)
|
|
|
|
.with(url, payload)
|
|
|
|
.on_queue('webhooks')
|
|
|
|
end
|
2022-06-23 13:47:46 +00:00
|
|
|
|
|
|
|
it 'executes perform' do
|
|
|
|
expect(Webhooks::Trigger).to receive(:execute).with(url, payload)
|
|
|
|
perform_enqueued_jobs { job }
|
|
|
|
end
|
2020-02-14 17:49:17 +00:00
|
|
|
end
|