Commit b817ce2d authored by Kamil Trzcinski's avatar Kamil Trzcinski

Sort builds in stage dropdown

Order: failed pending running manual canceled success skipped created
parent db2617fd
...@@ -7,7 +7,7 @@ module HasStatus ...@@ -7,7 +7,7 @@ module HasStatus
STARTED_STATUSES = %w[running success failed skipped manual].freeze STARTED_STATUSES = %w[running success failed skipped manual].freeze
ACTIVE_STATUSES = %w[pending running].freeze ACTIVE_STATUSES = %w[pending running].freeze
COMPLETED_STATUSES = %w[success failed canceled skipped].freeze COMPLETED_STATUSES = %w[success failed canceled skipped].freeze
ORDERED_STATUSES = %w[manual failed pending running canceled success skipped].freeze ORDERED_STATUSES = %w[failed pending running manual canceled success skipped created].freeze
class_methods do class_methods do
def status_sql def status_sql
......
- @stage.statuses.latest.each do |status| - grouped_statuses = @stage.statuses.latest_ordered.group_by(&:status)
- HasStatus::ORDERED_STATUSES.each do |ordered_status|
- grouped_statuses.fetch(ordered_status, []).each do |status|
%li %li
= render 'ci/status/dropdown_graph_badge', subject: status = render 'ci/status/dropdown_graph_badge', subject: status
---
title: Sort builds in stage dropdown
merge_request:
author:
...@@ -50,4 +50,23 @@ describe 'projects/pipelines/_stage', :view do ...@@ -50,4 +50,23 @@ describe 'projects/pipelines/_stage', :view do
expect(rendered).to have_text 'test:build', count: 1 expect(rendered).to have_text 'test:build', count: 1
end end
end end
context 'when there are multiple builds' do
before do
HasStatus::AVAILABLE_STATUSES.each do |status|
create_build(status)
end
end
it 'shows them in order' do
render
expect(rendered).to have_text(HasStatus::ORDERED_STATUSES.join(" "))
end
def create_build(status)
create(:ci_build, name: status, status: status,
pipeline: pipeline, stage: stage.name)
end
end
end end
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