Read about our upcoming Code of Conduct on this issue

Commit 170d081f authored by Alexis Reigel's avatar Alexis Reigel Committed by Alexis Reigel
Browse files

invoke SystemHooksService instead of direct model

parent ca5f0ec5b962
......@@ -975,9 +975,7 @@ def execute_hooks(data, hooks_scope = :push_hooks)
end
end
SystemHook.public_send(hooks_scope).each do |hook| # rubocop:disable GitlabSecurity/PublicSend
hook.async_execute(data, hooks_scope.to_s)
end
SystemHooksService.new.execute_hooks(data, hooks_scope)
end
def execute_services(data, hooks_scope = :push_hooks)
......
......@@ -3190,14 +3190,10 @@ def enable_lfs
end
it 'executes the system hooks with the specified scope' do
create :system_hook, merge_requests_events: true, tag_push_events: false
create :system_hook, merge_requests_events: false, tag_push_events: true
allow_any_instance_of(SystemHook).to receive(:async_execute).once
project = create :project
expect_any_instance_of(SystemHooksService).to receive(:execute_hooks).with({ data: 'data' }, :merge_request_hooks)
expect_any_instance_of(SystemHook).to receive(:async_execute).once
project.execute_hooks({}, :tag_push_hooks)
project = build(:project)
project.execute_hooks({ data: 'data' }, :merge_request_hooks)
end
end
end
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