Merge branch 'zj-commit-status-sortable-name' into 'master'
Handle legacy jobs without name Closes #33403 See merge request !12118
This commit is contained in:
commit
1039f101c9
3 changed files with 17 additions and 2 deletions
|
@ -112,7 +112,7 @@ class CommitStatus < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def group_name
|
||||
name.gsub(/\d+[\s:\/\\]+\d+\s*/, '').strip
|
||||
name.to_s.gsub(/\d+[\s:\/\\]+\d+\s*/, '').strip
|
||||
end
|
||||
|
||||
def failed_but_allowed?
|
||||
|
@ -156,7 +156,7 @@ class CommitStatus < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def sortable_name
|
||||
name.split(/(\d+)/).map do |v|
|
||||
name.to_s.split(/(\d+)/).map do |v|
|
||||
v =~ /\d+/ ? v.to_i : v
|
||||
end
|
||||
end
|
||||
|
|
4
changelogs/unreleased/zj-commit-status-sortable-name.yml
Normal file
4
changelogs/unreleased/zj-commit-status-sortable-name.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
title: Handle nameless legacy jobs
|
||||
merge_request:
|
||||
author:
|
|
@ -55,6 +55,17 @@ describe Ci::LegacyStage, :models do
|
|||
expect(stage.groups.map(&:name))
|
||||
.to eq %w[aaaaa rspec spinach]
|
||||
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
|
||||
|
||||
describe '#statuses_count' do
|
||||
|
|
Loading…
Reference in a new issue