Commit 4bcd900f authored by gpongelli's avatar gpongelli Committed by Sean McGivern

Moved call of SystemHooksService from UpdateMergeRequestsWorker to GitPushServic…

parent ac9d7929
......@@ -99,6 +99,8 @@ class GitPushService < BaseService
UpdateMergeRequestsWorker
.perform_async(@project.id, current_user.id, params[:oldrev], params[:newrev], params[:ref])
SystemHookPushWorker.perform_async(build_push_data.dup, :push_hooks)
EventCreateService.new.push(@project, current_user, build_push_data)
@project.execute_hooks(build_push_data.dup, :push_hooks)
@project.execute_services(build_push_data.dup, :push_hooks)
......
class SystemHookPushWorker
include Sidekiq::Worker
include DedicatedSidekiqQueue
def perform(push_data, hook_id)
SystemHooksService.new.execute_hooks(push_data, hook_id)
end
end
......@@ -10,8 +10,5 @@ class UpdateMergeRequestsWorker
return unless user
MergeRequests::RefreshService.new(project, user).execute(oldrev, newrev, ref)
push_data = Gitlab::DataBuilder::Push.build(project, user, oldrev, newrev, ref, [])
SystemHooksService.new.execute_hooks(push_data, :push_hooks)
end
end
---
title: Added commit array to Syshook json
merge_request: 9685
author: Gabriele Pongelli
......@@ -52,3 +52,4 @@
- [cronjob, 1]
- [default, 1]
- [pages, 1]
- [system_hook_push, 1]
......@@ -150,6 +150,13 @@ describe GitPushService, services: true do
execute_service(project, user, @blankrev, 'newrev', 'refs/heads/master' )
end
end
context "Sends System Push data" do
it "when pushing on a branch" do
expect(SystemHookPushWorker).to receive(:perform_async).with(@push_data, :push_hooks)
execute_service(project, user, @oldrev, @newrev, @ref )
end
end
end
describe "Updates git attributes" do
......
require 'spec_helper'
describe SystemHookPushWorker do
include RepoHelpers
subject { described_class.new }
describe '#perform' do
it 'executes SystemHooksService with expected values' do
push_data = double('push_data')
system_hook_service = double('system_hook_service')
expect(SystemHooksService).to receive(:new).and_return(system_hook_service)
expect(system_hook_service).to receive(:execute_hooks).with(push_data, :push_hooks)
subject.perform(push_data, :push_hooks)
end
end
end
......@@ -23,16 +23,5 @@ describe UpdateMergeRequestsWorker do
perform
end
it 'executes SystemHooksService with expected values' do
push_data = double('push_data')
expect(Gitlab::DataBuilder::Push).to receive(:build).with(project, user, oldrev, newrev, ref, []).and_return(push_data)
system_hook_service = double('system_hook_service')
expect(SystemHooksService).to receive(:new).and_return(system_hook_service)
expect(system_hook_service).to receive(:execute_hooks).with(push_data, :push_hooks)
perform
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