Skip to content
Snippets Groups Projects
Commit 2fe8ebc1 authored by Lin Jen-Shin's avatar Lin Jen-Shin
Browse files

We need INNER JOIN to get the right pipeline,

also added a test for checking this.
parent 3925436a
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -431,7 +431,7 @@ class Project < ActiveRecord::Base
 
# ref can't be HEAD, can only be branch/tag name or SHA
def latest_successful_builds_for(ref = default_branch)
builds.where(pipeline: pipelines.latest_successful_for(ref)).
Ci::Build.joins(:pipeline).merge(pipelines.latest_successful_for(ref)).
latest_successful_with_artifacts
end
 
Loading
Loading
Loading
Loading
@@ -256,14 +256,17 @@ describe API::API, api: true do
 
context 'with latest pipeline' do
before do
pipelines = Array.new(3).map do # creating some old pipelines
old_pipelines = Array.new(3).map do # creating some old pipelines
create(:ci_pipeline, status: 'success')
end
 
pipelines.reverse_each do |pipe|
new_build = create(:ci_build, :success, pipeline: pipe)
new_build.update(artifacts_file: another_artifacts)
old_pipelines.reverse_each do |pipe|
old_build = create(:ci_build, :success, pipeline: pipe)
old_build.update(artifacts_file: another_artifacts)
end
wrong_build = create(:ci_build, :success, pipeline: pipeline)
wrong_build.update(artifacts_file: another_artifacts)
end
 
before do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment