Commit 93b555af authored by Z.J. van de Weg's avatar Z.J. van de Weg

Handle legacy jobs without name

Older pipelines can contain jobs without a name, in which case
'nameless' is used right now, so we can properly still handle other
actions on these jobs.

Fixes gitlab-org/gitlab-ce#33403
parent de20057c
...@@ -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