Merge branch 'fix-latest-pipeine-ordering-again' into 'master'
Order only for latest_successful_for See merge request !8301
This commit is contained in:
commit
796b5b575f
3 changed files with 20 additions and 6 deletions
|
@ -93,11 +93,8 @@ module Ci
|
|||
.select("max(#{quoted_table_name}.id)")
|
||||
.group(:ref, :sha)
|
||||
|
||||
if ref
|
||||
where(id: max_id, ref: ref)
|
||||
else
|
||||
where(id: max_id)
|
||||
end
|
||||
relation = ref ? where(ref: ref) : self
|
||||
relation.where(id: max_id)
|
||||
end
|
||||
|
||||
def self.latest_status(ref = nil)
|
||||
|
@ -105,7 +102,7 @@ module Ci
|
|||
end
|
||||
|
||||
def self.latest_successful_for(ref)
|
||||
success.latest(ref).first
|
||||
success.latest(ref).order(id: :desc).first
|
||||
end
|
||||
|
||||
def self.truncate_sha(sha)
|
||||
|
|
4
changelogs/unreleased/fix-latest-pipeine-ordering.yml
Normal file
4
changelogs/unreleased/fix-latest-pipeine-ordering.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
title: Fix finding the latest pipeline
|
||||
merge_request: 8301
|
||||
author:
|
|
@ -464,6 +464,19 @@ describe Ci::Pipeline, models: true do
|
|||
end
|
||||
end
|
||||
|
||||
describe '.latest_successful_for' do
|
||||
include_context 'with some outdated pipelines'
|
||||
|
||||
let!(:latest_successful_pipeline) do
|
||||
create_pipeline(:success, 'ref', 'D')
|
||||
end
|
||||
|
||||
it 'returns the latest successful pipeline' do
|
||||
expect(described_class.latest_successful_for('ref')).
|
||||
to eq(latest_successful_pipeline)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#status' do
|
||||
let!(:build) { create(:ci_build, :created, pipeline: pipeline, name: 'test') }
|
||||
|
||||
|
|
Loading…
Reference in a new issue