Commit 4dddd904 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch '218536-removing-legacy-methods-of-pipeline' into 'master'

Remove legacy methods of ci pipeline

See merge request gitlab-org/gitlab!39211
parents 935a335c 111f9dff
...@@ -733,10 +733,6 @@ module Ci ...@@ -733,10 +733,6 @@ module Ci
end end
end end
def update_legacy_status
set_status(latest_builds_status.to_s)
end
def protected_ref? def protected_ref?
strong_memoize(:protected_ref) { project.protected_for?(git_ref) } strong_memoize(:protected_ref) { project.protected_for?(git_ref) }
end end
...@@ -1089,12 +1085,6 @@ module Ci ...@@ -1089,12 +1085,6 @@ module Ci
end end
end end
def latest_builds_status
return 'failed' unless yaml_errors.blank?
statuses.latest.slow_composite_status(project: project) || 'skipped'
end
def keep_around_commits def keep_around_commits
return unless project return unless project
......
...@@ -57,7 +57,7 @@ class Gitlab::Seeder::Pipelines ...@@ -57,7 +57,7 @@ class Gitlab::Seeder::Pipelines
BUILDS.each { |opts| build_create!(pipeline, opts) } BUILDS.each { |opts| build_create!(pipeline, opts) }
EXTERNAL_JOBS.each { |opts| commit_status_create!(pipeline, opts) } EXTERNAL_JOBS.each { |opts| commit_status_create!(pipeline, opts) }
pipeline.update_duration pipeline.update_duration
pipeline.update_legacy_status ::Ci::ProcessPipelineService.new(pipeline).execute
end end
end end
......
...@@ -63,7 +63,7 @@ RSpec.describe 'test coverage badge' do ...@@ -63,7 +63,7 @@ RSpec.describe 'test coverage badge' do
create(:ci_pipeline, opts).tap do |pipeline| create(:ci_pipeline, opts).tap do |pipeline|
yield pipeline yield pipeline
pipeline.update_legacy_status ::Ci::ProcessPipelineService.new(pipeline).execute
end end
end end
......
...@@ -102,7 +102,7 @@ RSpec.describe Gitlab::Badge::Coverage::Report do ...@@ -102,7 +102,7 @@ RSpec.describe Gitlab::Badge::Coverage::Report do
create(:ci_pipeline, opts).tap do |pipeline| create(:ci_pipeline, opts).tap do |pipeline|
yield pipeline yield pipeline
pipeline.update_legacy_status ::Ci::ProcessPipelineService.new(pipeline).execute
end end
end end
end end
...@@ -2096,58 +2096,6 @@ RSpec.describe Ci::Pipeline, :mailer do ...@@ -2096,58 +2096,6 @@ RSpec.describe Ci::Pipeline, :mailer do
end end
end end
describe '#update_status' do
context 'when pipeline is empty' do
it 'updates does not change pipeline status' do
expect(pipeline.statuses.latest.slow_composite_status(project: project)).to be_nil
expect { pipeline.update_legacy_status }
.to change { pipeline.reload.status }
.from('created')
.to('skipped')
end
end
context 'when updating status to pending' do
before do
create(:ci_build, pipeline: pipeline, status: :running)
end
it 'updates pipeline status to running' do
expect { pipeline.update_legacy_status }
.to change { pipeline.reload.status }
.from('created')
.to('running')
end
end
context 'when updating status to scheduled' do
before do
create(:ci_build, pipeline: pipeline, status: :scheduled)
end
it 'updates pipeline status to scheduled' do
expect { pipeline.update_legacy_status }
.to change { pipeline.reload.status }
.from('created')
.to('scheduled')
end
end
context 'when statuses status was not recognized' do
before do
allow(pipeline)
.to receive(:latest_builds_status)
.and_return(:unknown)
end
it 'raises an exception' do
expect { pipeline.update_legacy_status }
.to raise_error(Ci::HasStatus::UnknownStatusError)
end
end
end
describe '#detailed_status' do describe '#detailed_status' do
subject { pipeline.detailed_status(user) } subject { pipeline.detailed_status(user) }
......
...@@ -364,7 +364,7 @@ RSpec.describe Ci::RetryPipelineService, '#execute' do ...@@ -364,7 +364,7 @@ RSpec.describe Ci::RetryPipelineService, '#execute' do
stage: "stage_#{stage_num}", stage: "stage_#{stage_num}",
stage_idx: stage_num, stage_idx: stage_num,
pipeline: pipeline, **opts) do |build| pipeline: pipeline, **opts) do |build|
pipeline.update_legacy_status ::Ci::ProcessPipelineService.new(pipeline).execute
end end
end 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