summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-09-14 15:04:12 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2016-09-14 15:04:12 +0200
commitb964c6c579f57f1ff83eb27caf8ff7f7be6d7671 (patch)
tree474c1c80acc8b0d5759cf895f612404e0cd01edc
parent8759770c962f7b6fe509a2d650dd420f75864de6 (diff)
downloadgitlab-ce-b964c6c579f57f1ff83eb27caf8ff7f7be6d7671.tar.gz
Add grouping tests
-rw-r--r--app/models/commit_status.rb6
-rw-r--r--spec/models/commit_status_spec.rb27
2 files changed, 32 insertions, 1 deletions
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index af739342256..1ae1a24c168 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -96,7 +96,7 @@ class CommitStatus < ActiveRecord::Base
end
def group_name
- name.gsub(/\d+[\s:]+\d+\s*/, '')
+ name.gsub(/\d+[\s:\/\\]+\d+\s*/, '').strip
end
def self.stages
@@ -117,6 +117,10 @@ class CommitStatus < ActiveRecord::Base
allow_failure? && (failed? || canceled?)
end
+ def playable?
+ false
+ end
+
def duration
calculate_duration
end
diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb
index fcfa3138ce5..ea3b8295364 100644
--- a/spec/models/commit_status_spec.rb
+++ b/spec/models/commit_status_spec.rb
@@ -223,4 +223,31 @@ describe CommitStatus, models: true do
expect(commit_status.commit).to eq project.commit
end
end
+
+ describe '#group_name' do
+ subject { commit_status.group_name }
+
+ tests = {
+ 'rspec:windows' => 'rspec:windows',
+ 'rspec:windows 0' => 'rspec:windows 0',
+ 'rspec:windows 0 test' => 'rspec:windows 0 test',
+ 'rspec:windows 0 1' => 'rspec:windows',
+ 'rspec:windows 0 1 name' => 'rspec:windows name',
+ 'rspec:windows 0/1' => 'rspec:windows',
+ 'rspec:windows 0/1 name' => 'rspec:windows name',
+ 'rspec:windows 0:1' => 'rspec:windows',
+ 'rspec:windows 0:1 name' => 'rspec:windows name',
+ 'rspec:windows 10000 20000' => 'rspec:windows',
+ 'rspec:windows 0 : / 1' => 'rspec:windows',
+ 'rspec:windows 0 : / 1 name' => 'rspec:windows name',
+ }
+
+ tests.each do |name, group_name|
+ it "'#{name}' puts in '#{group_name}'" do
+ commit_status.name = name
+
+ is_expected.to eq(group_name)
+ end
+ end
+ end
end