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/hooks/web_hook_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/hooks/web_hook_spec.rb')
-rw-r--r--spec/models/hooks/web_hook_spec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/models/hooks/web_hook_spec.rb b/spec/models/hooks/web_hook_spec.rb
index ea6d6e53ef5..a4181631f01 100644
--- a/spec/models/hooks/web_hook_spec.rb
+++ b/spec/models/hooks/web_hook_spec.rb
@@ -35,6 +35,26 @@ describe WebHook do
it { is_expected.not_to allow_values("foo\nbar", "foo\r\nbar").for(:token) }
end
+
+ describe 'push_events_branch_filter' do
+ it { is_expected.to allow_values("good_branch_name", "another/good-branch_name").for(:push_events_branch_filter) }
+ it { is_expected.to allow_values("").for(:push_events_branch_filter) }
+ it { is_expected.not_to allow_values("bad branch name", "bad~branchname").for(:push_events_branch_filter) }
+
+ it 'gets rid of whitespace' do
+ hook.push_events_branch_filter = ' branch '
+ hook.save
+
+ expect(hook.push_events_branch_filter).to eq('branch')
+ end
+
+ it 'stores whitespace only as empty' do
+ hook.push_events_branch_filter = ' '
+ hook.save
+
+ expect(hook.push_events_branch_filter).to eq('')
+ end
+ end
end
describe 'execute' do