2023-03-04 16:56:09 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe Webhooks::DeliveryWorker do
|
|
|
|
let(:worker) { described_class.new }
|
|
|
|
|
2023-11-16 15:36:59 +01:00
|
|
|
describe '#perform' do
|
|
|
|
let(:webhook) { Fabricate(:webhook) }
|
|
|
|
|
|
|
|
it 'reprocesses and updates the webhook' do
|
|
|
|
stub_request(:post, webhook.url).to_return(status: 200, body: '')
|
|
|
|
|
|
|
|
worker.perform(webhook.id, 'body')
|
|
|
|
|
|
|
|
expect(a_request(:post, webhook.url)).to have_been_made.at_least_once
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns true for non-existent record' do
|
|
|
|
result = worker.perform(123_123_123, '')
|
|
|
|
|
|
|
|
expect(result).to be(true)
|
2023-03-04 16:56:09 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|