Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuana Saskia <starkcoffee@users.noreply.github.com>2018-06-07 10:35:17 +0300
committerDuana Saskia <starkcoffee@users.noreply.github.com>2018-08-13 14:20:58 +0300
commitece6a1ea6ecffdbde5ff7d663f1ad1eb74f78aa6 (patch)
tree288e34ff932b6c84e1a1c5ead26cbd8f80ea12f5 /spec/models/project_spec.rb
parent07356866b2ce85f4d724c96f14e129fbe6a56963 (diff)
Filter project hooks by branch
Allow specificying a branch filter for a project hook and only trigger a project hook if either the branch filter is blank or the branch matches. Only supported for push_events for now.
Diffstat (limited to 'spec/models/project_spec.rb')
-rw-r--r--spec/models/project_spec.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 2ec030daa67..cea7fa31b16 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -3671,7 +3671,10 @@ describe Project do
describe '#execute_hooks' do
let(:data) { { ref: 'refs/heads/master', data: 'data' } }
- it 'executes the projects hooks with the specified scope' do
+ it 'executes active projects hooks with the specified scope' do
+ expect_any_instance_of(ActiveHookFilter).to receive(:matches?)
+ .with(:tag_push_hooks, data)
+ .and_return(true)
hook = create(:project_hook, merge_requests_events: false, tag_push_events: true)
project = create(:project, hooks: [hook])
@@ -3689,6 +3692,18 @@ describe Project do
project.execute_hooks(data, :tag_push_hooks)
end
+ it 'does not execute project hooks which are not active' do
+ expect_any_instance_of(ActiveHookFilter).to receive(:matches?)
+ .with(:tag_push_hooks, data)
+ .and_return(false)
+ hook = create(:project_hook, tag_push_events: true)
+ project = create(:project, hooks: [hook])
+
+ expect_any_instance_of(ProjectHook).not_to receive(:async_execute).once
+
+ project.execute_hooks(data, :tag_push_hooks)
+ end
+
it 'executes the system hooks with the specified scope' do
expect_any_instance_of(SystemHooksService).to receive(:execute_hooks).with(data, :merge_request_hooks)