summaryrefslogtreecommitdiff
path: root/spec/models/commit_status_spec.rb
diff options
context:
space:
mode:
authorMike Greiling <mike@pixelcog.com>2017-01-02 11:42:08 -0600
committerMike Greiling <mike@pixelcog.com>2017-01-02 11:44:08 -0600
commitdc3d40ff28e4087120d48a94db5bd3d3b32f164d (patch)
tree450f95bca32530bcdb53b6ae38ea9e3ca3987fda /spec/models/commit_status_spec.rb
parent1c5a506588342bdb2a6390f14d333d41a5482f58 (diff)
downloadgitlab-ce-dc3d40ff28e4087120d48a94db5bd3d3b32f164d.tar.gz
prefer unit test on model over view testfix-build-sort-order
Diffstat (limited to 'spec/models/commit_status_spec.rb')
-rw-r--r--spec/models/commit_status_spec.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb
index 701f3323c0f..daabc804d16 100644
--- a/spec/models/commit_status_spec.rb
+++ b/spec/models/commit_status_spec.rb
@@ -243,4 +243,26 @@ describe CommitStatus, models: true do
.to be_a Gitlab::Ci::Status::Success
end
end
+
+ describe '#sortable_name' do
+ subject { commit_status.sortable_name }
+
+ tests = {
+ 'karma' => ['karma'],
+ 'karma 0 20' => ['karma ', 0, ' ', 20],
+ 'karma 10 20' => ['karma ', 10, ' ', 20],
+ 'karma 50:100' => ['karma ', 50, ':', 100],
+ 'karma 1.10' => ['karma ', 1, '.', 10],
+ 'karma 1.5.1' => ['karma ', 1, '.', 5, '.', 1],
+ 'karma 1 a' => ['karma ', 1, ' a']
+ }
+
+ tests.each do |name, sortable_name|
+ it "'#{name}' sorts as '#{sortable_name}'" do
+ commit_status.name = name
+
+ is_expected.to eq(sortable_name)
+ end
+ end
+ end
end