summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis Reigel <alexis.reigel.ext@siemens.com>2017-12-04 15:29:13 +0100
committerAlexis Reigel <alexis.reigel.ext@siemens.com>2018-01-17 09:55:00 +0100
commita63792b7249d8b49ef9e20ee3bbabd41c22b1ccf (patch)
treea55194443546f16d5713518d377c75b663513b86
parenta78abf3a0071d1705adc562f23be1f3a347c6db5 (diff)
downloadgitlab-ce-a63792b7249d8b49ef9e20ee3bbabd41c22b1ccf.tar.gz
accepts `.all` as a hook scope as well
-rw-r--r--app/models/concerns/triggerable_hooks.rb3
-rw-r--r--spec/models/concerns/triggerable_hooks_spec.rb10
2 files changed, 11 insertions, 2 deletions
diff --git a/app/models/concerns/triggerable_hooks.rb b/app/models/concerns/triggerable_hooks.rb
index 42f40c52d29..4f2c8102204 100644
--- a/app/models/concerns/triggerable_hooks.rb
+++ b/app/models/concerns/triggerable_hooks.rb
@@ -18,7 +18,8 @@ module TriggerableHooks
attr_reader :triggerable_hooks
def hooks_for(trigger)
- return none unless self::TRIGGERS.keys.include?(trigger)
+ callable_scopes = self::TRIGGERS.keys + [:all]
+ return none unless callable_scopes.include?(trigger)
public_send(trigger) # rubocop:disable GitlabSecurity/PublicSend
end
diff --git a/spec/models/concerns/triggerable_hooks_spec.rb b/spec/models/concerns/triggerable_hooks_spec.rb
index 3ddf477e41e..bea846454de 100644
--- a/spec/models/concerns/triggerable_hooks_spec.rb
+++ b/spec/models/concerns/triggerable_hooks_spec.rb
@@ -26,10 +26,18 @@ RSpec.describe TriggerableHooks do
context 'the model does not have the required trigger scope' do
it 'returns an empty relation' do
- TestableHook.create!(url: 'http://example.com', push_events: true)
+ TestableHook.create!(url: 'http://example.com')
expect(TestableHook.hooks_for(:tag_push_hooks)).to eq []
end
end
+
+ context 'the stock scope ".all" is accepted' do
+ it 'returns the record' do
+ hook = TestableHook.create!(url: 'http://example.com')
+
+ expect(TestableHook.hooks_for(:all)).to eq [hook]
+ end
+ end
end
end