Commit 086f0351 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Do not fire synrchonous hooks when creating a job

Fire asynchronous hooks instead.
parent 6509833c
...@@ -46,7 +46,10 @@ module Ci ...@@ -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 ...@@ -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) }
......
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