Do not fire synrchonous hooks when creating a job
Fire asynchronous hooks instead.
This commit is contained in:
parent
6509833cfa
commit
086f0351df
|
@ -46,7 +46,10 @@ module Ci
|
||||||
before_save :ensure_token
|
before_save :ensure_token
|
||||||
before_destroy { unscoped_project }
|
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_after_save, on: [:create, :update]
|
||||||
after_commit :update_project_statistics, on: :destroy
|
after_commit :update_project_statistics, on: :destroy
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,16 @@ describe Ci::Build do
|
||||||
it { is_expected.to respond_to(:has_trace?) }
|
it { is_expected.to respond_to(:has_trace?) }
|
||||||
it { is_expected.to respond_to(: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
|
describe '.manual_actions' do
|
||||||
let!(:manual_but_created) { create(:ci_build, :manual, status: :created, pipeline: pipeline) }
|
let!(:manual_but_created) { create(:ci_build, :manual, status: :created, pipeline: pipeline) }
|
||||||
let!(:manual_but_succeeded) { create(:ci_build, :manual, status: :success, pipeline: pipeline) }
|
let!(:manual_but_succeeded) { create(:ci_build, :manual, status: :success, pipeline: pipeline) }
|
||||||
|
|
Loading…
Reference in New Issue