Commit a0ddad33 authored by Jarka Košanová's avatar Jarka Košanová

Merge branch 'fix-method-name-in-retry-ci-build-service' into 'master'

Fix method name in RetryBuildService

See merge request gitlab-org/gitlab!71027
parents 16254e21 0b1a3e11
...@@ -17,7 +17,7 @@ module Ci ...@@ -17,7 +17,7 @@ module Ci
def execute(build) def execute(build)
build.ensure_scheduling_type! build.ensure_scheduling_type!
reprocess!(build).tap do |new_build| clone!(build).tap do |new_build|
check_assignable_runners!(new_build) check_assignable_runners!(new_build)
next if new_build.failed? next if new_build.failed?
...@@ -31,7 +31,7 @@ module Ci ...@@ -31,7 +31,7 @@ module Ci
end end
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def reprocess!(build) def clone!(build)
# Cloning a build requires a strict type check to ensure # Cloning a build requires a strict type check to ensure
# the attributes being used for the clone are taken straight # the attributes being used for the clone are taken straight
# from the model and not overridden by other abstractions. # from the model and not overridden by other abstractions.
......
...@@ -9,17 +9,12 @@ module Ci ...@@ -9,17 +9,12 @@ module Ci
raise Gitlab::Access::AccessDeniedError raise Gitlab::Access::AccessDeniedError
end end
needs = Set.new
pipeline.ensure_scheduling_type! pipeline.ensure_scheduling_type!
builds_relation(pipeline).find_each do |build| builds_relation(pipeline).find_each do |build|
next unless can_be_retried?(build) next unless can_be_retried?(build)
Ci::RetryBuildService.new(project, current_user) Ci::RetryBuildService.new(project, current_user).clone!(build)
.reprocess!(build)
needs += build.needs.map(&:name)
end end
pipeline.builds.latest.skipped.find_each do |skipped| pipeline.builds.latest.skipped.find_each do |skipped|
......
...@@ -17,7 +17,7 @@ RSpec.describe Ci::RetryBuildService do ...@@ -17,7 +17,7 @@ RSpec.describe Ci::RetryBuildService do
it_behaves_like 'restricts access to protected environments' it_behaves_like 'restricts access to protected environments'
describe '#reprocess' do describe '#clone!' do
context 'when user has ability to execute build' do context 'when user has ability to execute build' do
let_it_be(:namespace) { create(:namespace) } let_it_be(:namespace) { create(:namespace) }
let_it_be(:ultimate_plan) { create(:ultimate_plan) } let_it_be(:ultimate_plan) { create(:ultimate_plan) }
...@@ -27,7 +27,7 @@ RSpec.describe Ci::RetryBuildService do ...@@ -27,7 +27,7 @@ RSpec.describe Ci::RetryBuildService do
let(:new_build) do let(:new_build) do
travel_to(1.second.from_now) do travel_to(1.second.from_now) do
service.reprocess!(build) service.clone!(build)
end end
end end
......
...@@ -277,15 +277,15 @@ RSpec.describe Ci::RetryBuildService do ...@@ -277,15 +277,15 @@ RSpec.describe Ci::RetryBuildService do
end end
end end
describe '#reprocess' do describe '#clone!' do
let(:new_build) do let(:new_build) do
travel_to(1.second.from_now) do travel_to(1.second.from_now) do
service.reprocess!(build) service.clone!(build)
end end
end end
it 'raises an error when an unexpected class is passed' do it 'raises an error when an unexpected class is passed' do
expect { service.reprocess!(create(:ci_build).present) }.to raise_error(TypeError) expect { service.clone!(create(:ci_build).present) }.to raise_error(TypeError)
end end
context 'when user has ability to execute build' do context 'when user has ability to execute build' do
...@@ -343,7 +343,7 @@ RSpec.describe Ci::RetryBuildService do ...@@ -343,7 +343,7 @@ RSpec.describe Ci::RetryBuildService do
let(:user) { reporter } let(:user) { reporter }
it 'raises an error' do it 'raises an error' do
expect { service.reprocess!(build) } expect { service.clone!(build) }
.to raise_error Gitlab::Access::AccessDeniedError .to raise_error Gitlab::Access::AccessDeniedError
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