Do not fire synrchonous hooks when creating a job

Fire asynchronous hooks instead.
This commit is contained in:
Grzegorz Bizon 2017-08-22 10:57:52 +02:00
parent 6509833cfa
commit 086f0351df
2 changed files with 14 additions and 1 deletions

View File

@ -46,7 +46,10 @@ module Ci
before_save :ensure_token
before_destroy { unscoped_project }
after_create :execute_hooks
after_create do |build|
BuildHooksWorker.perform_async(build.id)
end
after_commit :update_project_statistics_after_save, on: [:create, :update]
after_commit :update_project_statistics, on: :destroy

View File

@ -21,6 +21,16 @@ describe Ci::Build do
it { is_expected.to respond_to(:has_trace?) }
it { is_expected.to respond_to(:trace) }
describe 'callbacks' do
context 'when running after_create callback' do
it 'triggers asynchronous build hooks worker' do
expect(BuildHooksWorker).to receive(:perform_async)
create(:ci_build)
end
end
end
describe '.manual_actions' do
let!(:manual_but_created) { create(:ci_build, :manual, status: :created, pipeline: pipeline) }
let!(:manual_but_succeeded) { create(:ci_build, :manual, status: :success, pipeline: pipeline) }