Commit 729f105e authored by Siddharth Asthana's avatar Siddharth Asthana

Changed the chronological order of Job history sequence on CI Job

Changelog: other
parent b79e15b3
...@@ -48,7 +48,7 @@ class CommitStatus < Ci::ApplicationRecord ...@@ -48,7 +48,7 @@ class CommitStatus < Ci::ApplicationRecord
scope :ordered, -> { order(:name) } scope :ordered, -> { order(:name) }
scope :ordered_by_stage, -> { order(stage_idx: :asc) } scope :ordered_by_stage, -> { order(stage_idx: :asc) }
scope :latest_ordered, -> { latest.ordered.includes(project: :namespace) } scope :latest_ordered, -> { latest.ordered.includes(project: :namespace) }
scope :retried_ordered, -> { retried.ordered.includes(project: :namespace) } scope :retried_ordered, -> { retried.order(name: :asc, id: :desc).includes(project: :namespace) }
scope :ordered_by_pipeline, -> { order(pipeline_id: :asc) } scope :ordered_by_pipeline, -> { order(pipeline_id: :asc) }
scope :before_stage, -> (index) { where('stage_idx < ?', index) } scope :before_stage, -> (index) { where('stage_idx < ?', index) }
scope :for_stage, -> (index) { where(stage_idx: index) } scope :for_stage, -> (index) { where(stage_idx: index) }
......
...@@ -379,6 +379,22 @@ RSpec.describe CommitStatus do ...@@ -379,6 +379,22 @@ RSpec.describe CommitStatus do
end end
end end
describe '.retried_ordered' do
subject { described_class.retried_ordered.to_a }
let!(:statuses) do
[create_status(name: 'aa', ref: 'bb', status: 'running', retried: true),
create_status(name: 'cc', ref: 'cc', status: 'pending', retried: true),
create_status(name: 'aa', ref: 'cc', status: 'success', retried: true),
create_status(name: 'cc', ref: 'bb', status: 'success'),
create_status(name: 'aa', ref: 'bb', status: 'success')]
end
it 'returns retried statuses in order' do
is_expected.to eq(statuses.values_at(2, 0, 1))
end
end
describe '.running_or_pending' do describe '.running_or_pending' do
subject { described_class.running_or_pending.order(:id) } subject { described_class.running_or_pending.order(:id) }
......
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