diff options
author | Mike Greiling <mike@pixelcog.com> | 2017-01-02 11:42:08 -0600 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2017-01-02 11:44:08 -0600 |
commit | dc3d40ff28e4087120d48a94db5bd3d3b32f164d (patch) | |
tree | 450f95bca32530bcdb53b6ae38ea9e3ca3987fda /spec/models/commit_status_spec.rb | |
parent | 1c5a506588342bdb2a6390f14d333d41a5482f58 (diff) | |
download | gitlab-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.rb | 22 |
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 |