Skip to content

Commit 6b2f81f

Browse files
committed
Merge branch 'remove-get-builds-method' into 'master'
Remove get_build method for find_by_id See merge request gitlab-org/gitlab-ce!24271
2 parents 249607c + ab6b9a1 commit 6b2f81f

File tree

4 files changed

+2
-29
lines changed

4 files changed

+2
-29
lines changed

app/controllers/projects/artifacts_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def build
8686
end
8787

8888
def build_from_id
89-
project.get_build(params[:job_id]) if params[:job_id]
89+
project.builds.find_by_id(params[:job_id]) if params[:job_id]
9090
end
9191

9292
def build_from_ref

app/controllers/projects/build_artifacts_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def job
4545
end
4646

4747
def job_from_id
48-
project.get_build(params[:build_id]) if params[:build_id]
48+
project.builds.find_by_id(params[:build_id]) if params[:build_id]
4949
end
5050

5151
def job_from_ref

app/models/project.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -658,10 +658,6 @@ def latest_successful_build_for!(job_name, ref = default_branch)
658658
latest_successful_build_for(job_name, ref) || raise(ActiveRecord::RecordNotFound.new("Couldn't find job #{job_name}"))
659659
end
660660

661-
def get_build(id)
662-
builds.find_by(id: id)
663-
end
664-
665661
def merge_base_commit(first_commit_id, second_commit_id)
666662
sha = repository.merge_base(first_commit_id, second_commit_id)
667663
commit_by(oid: sha) if sha

spec/models/project_spec.rb

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,29 +2044,6 @@
20442044
end
20452045
end
20462046

2047-
describe '#get_build' do
2048-
let(:project) { create(:project, :repository) }
2049-
let(:ci_pipeline) { create(:ci_pipeline, project: project) }
2050-
2051-
context 'when build exists' do
2052-
context 'build is associated with project' do
2053-
let(:build) { create(:ci_build, :success, pipeline: ci_pipeline) }
2054-
2055-
it { expect(project.get_build(build.id)).to eq(build) }
2056-
end
2057-
2058-
context 'build is not associated with project' do
2059-
let(:build) { create(:ci_build, :success) }
2060-
2061-
it { expect(project.get_build(build.id)).to be_nil }
2062-
end
2063-
end
2064-
2065-
context 'build does not exists' do
2066-
it { expect(project.get_build(rand 100)).to be_nil }
2067-
end
2068-
end
2069-
20702047
describe '#import_status' do
20712048
context 'with import_state' do
20722049
it 'returns the right status' do

0 commit comments

Comments
 (0)