debian-mirror-gitlab/spec/models/hooks/service_hook_spec.rb

44 lines
956 B
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
require 'spec_helper'
2014-09-02 18:07:02 +05:30
2020-07-28 23:09:34 +05:30
RSpec.describe ServiceHook do
2017-09-10 17:25:29 +05:30
describe 'associations' do
2021-06-08 01:23:25 +05:30
it { is_expected.to belong_to :integration }
2014-09-02 18:07:02 +05:30
end
2015-09-11 14:41:01 +05:30
2017-09-10 17:25:29 +05:30
describe 'validations' do
2021-06-08 01:23:25 +05:30
it { is_expected.to validate_presence_of(:integration) }
2017-09-10 17:25:29 +05:30
end
2015-09-11 14:41:01 +05:30
2017-09-10 17:25:29 +05:30
describe 'execute' do
let(:hook) { build(:service_hook) }
let(:data) { { key: 'value' } }
2015-09-11 14:41:01 +05:30
2017-09-10 17:25:29 +05:30
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-09-11 14:41:01 +05:30
2017-09-10 17:25:29 +05:30
hook.execute(data)
2015-09-11 14:41:01 +05:30
end
end
2021-06-08 01:23:25 +05:30
describe '#rate_limit' do
let(:hook) { build(:service_hook) }
it 'returns nil' do
expect(hook.rate_limit).to be_nil
end
end
2021-09-04 01:27:46 +05:30
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
2014-09-02 18:07:02 +05:30
end