Commit ec3b0929 authored by Alex Kalderimis's avatar Alex Kalderimis

Add executable filtering to group hooks

parent c6df195e
......@@ -461,7 +461,7 @@ module EE
return unless feature_available?(:group_webhooks)
self_and_ancestor_hooks = GroupHook.where(group_id: self_and_ancestors)
self_and_ancestor_hooks.hooks_for(hooks_scope).each do |hook|
self_and_ancestor_hooks.executable.hooks_for(hooks_scope).each do |hook|
hook.async_execute(data, hooks_scope.to_s)
end
end
......
......@@ -986,6 +986,19 @@ RSpec.describe Group do
group.execute_hooks(data, :member_hooks)
end
end
context 'when a hook is not executable' do
before do
group_hook.update!(recent_failures: 4)
end
it 'does not execute the disabled hook' do
expect(WebHookService).to receive(:new).with(parent_group_hook, anything, anything).and_call_original
expect(WebHookService).not_to receive(:new).with(group_hook, anything, anything)
group.execute_hooks(data, :member_hooks)
end
end
end
context 'when group_webhooks feature is disabled' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment