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:
Grzegorz Bizon 2017-06-13 12:48:47 +00:00
commit 1039f101c9
3 changed files with 17 additions and 2 deletions

View file

@ -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

View file

@ -0,0 +1,4 @@
---
title: Handle nameless legacy jobs
merge_request:
author:

View file

@ -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