Update the pipeline cache when updating a pipeline-status
This commit is contained in:
parent
e36f444930
commit
4b249d522c
2 changed files with 19 additions and 0 deletions
|
@ -22,6 +22,7 @@ module Ci
|
|||
validate :valid_commit_sha, unless: :importing?
|
||||
|
||||
after_create :keep_around_commits, unless: :importing?
|
||||
after_create :refresh_build_status_cache
|
||||
|
||||
state_machine :status, initial: :created do
|
||||
event :enqueue do
|
||||
|
@ -328,6 +329,7 @@ module Ci
|
|||
when 'manual' then block
|
||||
end
|
||||
end
|
||||
refresh_build_status_cache
|
||||
end
|
||||
|
||||
def predefined_variables
|
||||
|
@ -369,6 +371,10 @@ module Ci
|
|||
.fabricate!
|
||||
end
|
||||
|
||||
def refresh_build_status_cache
|
||||
Ci::PipelineStatus.new(project, sha: sha, status: status).store_in_cache_if_needed
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def pipeline_data
|
||||
|
|
|
@ -1018,6 +1018,19 @@ describe Ci::Pipeline, models: true do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#update_status' do
|
||||
let(:pipeline) { create(:ci_pipeline, sha: '123456') }
|
||||
|
||||
it 'updates the cached status' do
|
||||
fake_status = double
|
||||
# after updating the status, the status is set to `skipped` for this pipeline's builds
|
||||
expect(Ci::PipelineStatus).to receive(:new).with(pipeline.project, sha: '123456', status: 'skipped').and_return(fake_status)
|
||||
expect(fake_status).to receive(:store_in_cache_if_needed)
|
||||
|
||||
pipeline.update_status
|
||||
end
|
||||
end
|
||||
|
||||
describe 'notifications when pipeline success or failed' do
|
||||
let(:project) { create(:project, :repository) }
|
||||
|
||||
|
|
Loading…
Reference in a new issue