2020-02-14 17:49:17 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe Webhooks::Trigger do
|
|
|
|
subject(:trigger) { described_class }
|
|
|
|
|
|
|
|
describe '#execute' do
|
|
|
|
it 'triggers webhook' do
|
2021-03-31 11:09:57 +00:00
|
|
|
payload = { hello: :hello }
|
2020-07-21 06:45:24 +00:00
|
|
|
url = 'https://test.com'
|
2020-02-14 17:49:17 +00:00
|
|
|
|
2021-03-31 11:09:57 +00:00
|
|
|
expect(RestClient::Request).to receive(:execute)
|
|
|
|
.with(
|
|
|
|
method: :post,
|
|
|
|
url: url,
|
|
|
|
payload: payload.to_json,
|
|
|
|
headers: { content_type: :json, accept: :json },
|
|
|
|
timeout: 5
|
|
|
|
).once
|
|
|
|
trigger.execute(url, payload)
|
2020-02-14 17:49:17 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|