diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index 9a0997e92ee93b30724417256a61dae1203e8e62..2ef18d900f24babfefd3edcec3e65e50e038e449 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -86,7 +86,7 @@ def build end def build_from_id - project.get_build(params[:job_id]) if params[:job_id] + project.builds.find_by_id(params[:job_id]) if params[:job_id] end def build_from_ref diff --git a/app/controllers/projects/build_artifacts_controller.rb b/app/controllers/projects/build_artifacts_controller.rb index d3d5ba5c75db636aca41ff40b7fed5a8022d03f0..4274c3562272377870fa144ea9277cae833ac966 100644 --- a/app/controllers/projects/build_artifacts_controller.rb +++ b/app/controllers/projects/build_artifacts_controller.rb @@ -45,7 +45,7 @@ def job end def job_from_id - project.get_build(params[:build_id]) if params[:build_id] + project.builds.find_by_id(params[:build_id]) if params[:build_id] end def job_from_ref diff --git a/app/models/project.rb b/app/models/project.rb index a66ed6736caf99078ce71dfc47e183b567e68364..9d28ff81cdae67c85245dfad6186957642702263 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -658,10 +658,6 @@ def latest_successful_build_for!(job_name, ref = default_branch) latest_successful_build_for(job_name, ref) || raise(ActiveRecord::RecordNotFound.new("Couldn't find job #{job_name}")) end - def get_build(id) - builds.find_by(id: id) - end - def merge_base_commit(first_commit_id, second_commit_id) sha = repository.merge_base(first_commit_id, second_commit_id) commit_by(oid: sha) if sha diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 3044150bca8ed1de7bc4f71e37159c0c966aec1b..eee7fef17de1c3ba9a816e1ac666bbfcda204615 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -2026,29 +2026,6 @@ end end - describe '#get_build' do - let(:project) { create(:project, :repository) } - let(:ci_pipeline) { create(:ci_pipeline, project: project) } - - context 'when build exists' do - context 'build is associated with project' do - let(:build) { create(:ci_build, :success, pipeline: ci_pipeline) } - - it { expect(project.get_build(build.id)).to eq(build) } - end - - context 'build is not associated with project' do - let(:build) { create(:ci_build, :success) } - - it { expect(project.get_build(build.id)).to be_nil } - end - end - - context 'build does not exists' do - it { expect(project.get_build(rand 100)).to be_nil } - end - end - describe '#import_status' do context 'with import_state' do it 'returns the right status' do