2019-03-30 03:23:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-27 06:08:57 -04:00
|
|
|
require 'spec_helper'
|
2012-11-19 13:14:05 -05:00
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe ServiceHook do
|
2017-04-27 06:08:57 -04:00
|
|
|
describe 'associations' do
|
2021-05-12 08:10:24 -04:00
|
|
|
it { is_expected.to belong_to :integration }
|
2012-11-19 13:14:05 -05:00
|
|
|
end
|
2015-01-23 19:10:43 -05:00
|
|
|
|
2017-07-20 11:12:06 -04:00
|
|
|
describe 'validations' do
|
2021-05-12 08:10:24 -04:00
|
|
|
it { is_expected.to validate_presence_of(:integration) }
|
2017-07-20 11:12:06 -04:00
|
|
|
end
|
|
|
|
|
2017-04-27 06:08:57 -04:00
|
|
|
describe 'execute' do
|
|
|
|
let(:hook) { build(:service_hook) }
|
|
|
|
let(:data) { { key: 'value' } }
|
2015-01-23 19:10:43 -05:00
|
|
|
|
2017-04-27 06:08:57 -04:00
|
|
|
it '#execute' do
|
|
|
|
expect(WebHookService).to receive(:new).with(hook, data, 'service_hook').and_call_original
|
|
|
|
expect_any_instance_of(WebHookService).to receive(:execute)
|
2015-01-23 19:10:43 -05:00
|
|
|
|
2017-04-27 06:08:57 -04:00
|
|
|
hook.execute(data)
|
2015-01-23 19:10:43 -05:00
|
|
|
end
|
|
|
|
end
|
2021-05-14 05:10:24 -04:00
|
|
|
|
|
|
|
describe '#rate_limit' do
|
|
|
|
let(:hook) { build(:service_hook) }
|
|
|
|
|
|
|
|
it 'returns nil' do
|
|
|
|
expect(hook.rate_limit).to be_nil
|
|
|
|
end
|
|
|
|
end
|
2021-05-20 08:10:26 -04:00
|
|
|
|
|
|
|
describe '#application_context' do
|
|
|
|
let(:hook) { build(:service_hook) }
|
|
|
|
|
|
|
|
it 'includes the type' do
|
|
|
|
expect(hook.application_context).to eq(
|
|
|
|
related_class: 'ServiceHook'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2012-11-19 13:14:05 -05:00
|
|
|
end
|