Commit f9f76690 authored by Shinya Maeda's avatar Shinya Maeda Committed by Fabio Pitino

Ensure the controller passes Ci::Build to RetryBuildService

parent b2a333b7
......@@ -44,7 +44,7 @@ class Projects::JobsController < Projects::ApplicationController
render json: BuildSerializer
.new(project: @project, current_user: @current_user)
.represent(@build, {}, BuildDetailsEntity)
.represent(@build.present(current_user: current_user), {}, BuildDetailsEntity)
end
end
end
......@@ -120,7 +120,7 @@ class Projects::JobsController < Projects::ApplicationController
def status
render json: BuildSerializer
.new(project: @project, current_user: @current_user)
.represent_status(@build)
.represent_status(@build.present(current_user: current_user))
end
def erase
......@@ -225,7 +225,6 @@ class Projects::JobsController < Projects::ApplicationController
def find_job_as_build
@build = project.builds.find(params[:id])
.present(current_user: current_user)
end
def find_job_as_processable
......
......@@ -32,6 +32,11 @@ module Ci
# rubocop: disable CodeReuse/ActiveRecord
def reprocess!(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.
raise TypeError unless build.instance_of?(Ci::Build)
check_access!(build)
new_build = clone_build(build)
......
......@@ -283,6 +283,10 @@ RSpec.describe Ci::RetryBuildService do
end
end
it 'raises an error when an unexpected class is passed' do
expect { service.reprocess!(create(:ci_build).present) }.to raise_error(TypeError)
end
context 'when user has ability to execute build' do
before do
stub_not_protect_default_branch
......
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