2019-07-07 11:18:12 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe ProjectHook do
|
2017-09-10 17:25:29 +05:30
|
|
|
describe 'associations' do
|
2016-06-02 11:05:42 +05:30
|
|
|
it { is_expected.to belong_to :project }
|
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
describe 'validations' do
|
|
|
|
it { is_expected.to validate_presence_of(:project) }
|
|
|
|
end
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
it_behaves_like 'includes Limitable concern' do
|
|
|
|
subject { build(:project_hook, project: create(:project)) }
|
|
|
|
end
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
describe '.push_hooks' do
|
2016-09-13 17:45:13 +05:30
|
|
|
it 'returns hooks for push events only' do
|
2014-09-02 18:07:02 +05:30
|
|
|
hook = create(:project_hook, push_events: true)
|
2015-10-24 18:46:33 +05:30
|
|
|
create(:project_hook, push_events: false)
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(described_class.push_hooks).to eq([hook])
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.tag_push_hooks' do
|
2016-09-13 17:45:13 +05:30
|
|
|
it 'returns hooks for tag push events only' do
|
2014-09-02 18:07:02 +05:30
|
|
|
hook = create(:project_hook, tag_push_events: true)
|
2015-10-24 18:46:33 +05:30
|
|
|
create(:project_hook, tag_push_events: false)
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(described_class.tag_push_hooks).to eq([hook])
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|
2021-06-08 01:23:25 +05:30
|
|
|
|
|
|
|
describe '#rate_limit' do
|
|
|
|
let_it_be(:hook) { create(:project_hook) }
|
|
|
|
let_it_be(:plan_limits) { create(:plan_limits, :default_plan, web_hook_calls: 100) }
|
|
|
|
|
|
|
|
it 'returns the default limit' do
|
|
|
|
expect(hook.rate_limit).to be(100)
|
|
|
|
end
|
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|