Commit 1039f101 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'zj-commit-status-sortable-name' into 'master'

Handle legacy jobs without name

Closes #33403

See merge request !12118
parents e44502f6 93b555af
...@@ -112,7 +112,7 @@ class CommitStatus < ActiveRecord::Base ...@@ -112,7 +112,7 @@ class CommitStatus < ActiveRecord::Base
end end
def group_name def group_name
name.gsub(/\d+[\s:\/\\]+\d+\s*/, '').strip name.to_s.gsub(/\d+[\s:\/\\]+\d+\s*/, '').strip
end end
def failed_but_allowed? def failed_but_allowed?
...@@ -156,7 +156,7 @@ class CommitStatus < ActiveRecord::Base ...@@ -156,7 +156,7 @@ class CommitStatus < ActiveRecord::Base
end end
def sortable_name def sortable_name
name.split(/(\d+)/).map do |v| name.to_s.split(/(\d+)/).map do |v|
v =~ /\d+/ ? v.to_i : v v =~ /\d+/ ? v.to_i : v
end end
end end
......
---
title: Handle nameless legacy jobs
merge_request:
author:
...@@ -55,6 +55,17 @@ describe Ci::LegacyStage, :models do ...@@ -55,6 +55,17 @@ describe Ci::LegacyStage, :models do
expect(stage.groups.map(&:name)) expect(stage.groups.map(&:name))
.to eq %w[aaaaa rspec spinach] .to eq %w[aaaaa rspec spinach]
end end
context 'when a name is nil on legacy pipelines' do
before do
pipeline.builds.first.update_attribute(:name, nil)
end
it 'returns an array of three groups' do
expect(stage.groups.map(&:name))
.to eq ['', 'aaaaa', 'rspec', 'spinach']
end
end
end end
describe '#statuses_count' do describe '#statuses_count' do
......
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