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