summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZ.J. van de Weg <git@zjvandeweg.nl>2017-06-13 09:22:22 +0200
committerZ.J. van de Weg <git@zjvandeweg.nl>2017-06-13 11:19:45 +0200
commit93b555af85ff124820366855ed9b3a9fa719c272 (patch)
treeed23bb4b6c87656373c0bdab3941fe8a4bb935ad
parentde20057ccbd3b8c94d64ff5d8deb14cab232d08a (diff)
downloadgitlab-ce-zj-commit-status-sortable-name.tar.gz
Handle legacy jobs without namezj-commit-status-sortable-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
-rw-r--r--app/models/commit_status.rb4
-rw-r--r--changelogs/unreleased/zj-commit-status-sortable-name.yml4
-rw-r--r--spec/models/ci/legacy_stage_spec.rb11
3 files changed, 17 insertions, 2 deletions
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index cb425706a9e..07cec63b939 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -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
diff --git a/changelogs/unreleased/zj-commit-status-sortable-name.yml b/changelogs/unreleased/zj-commit-status-sortable-name.yml
new file mode 100644
index 00000000000..1be9ac6380f
--- /dev/null
+++ b/changelogs/unreleased/zj-commit-status-sortable-name.yml
@@ -0,0 +1,4 @@
+---
+title: Handle nameless legacy jobs
+merge_request:
+author:
diff --git a/spec/models/ci/legacy_stage_spec.rb b/spec/models/ci/legacy_stage_spec.rb
index 48116c7e701..d43c33d3807 100644
--- a/spec/models/ci/legacy_stage_spec.rb
+++ b/spec/models/ci/legacy_stage_spec.rb
@@ -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