diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2017-08-30 09:05:13 +0300 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2017-08-31 16:45:48 +0300 |
commit | ed8f7ed671a5fb6197c9e4759bf13742cf967f50 (patch) | |
tree | 9b557b7dabc264cca65d7e50a18e2f7cc5111c8a /spec/lib/gitlab/template | |
parent | 9e7e0496ff639d1eec65dcbf1b51edb2262456e2 (diff) |
Sort templates when fetching them
Used to rely on the underlying filesystem to sort the entries, now its
forced to be sorted on the name of the template.
Diffstat (limited to 'spec/lib/gitlab/template')
-rw-r--r-- | spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb b/spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb index 6541326d1de..e2fa76522bc 100644 --- a/spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb +++ b/spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb @@ -30,6 +30,14 @@ describe Gitlab::Template::GitlabCiYmlTemplate do end end + describe '.by_category' do + it 'returns sorted results' do + result = described_class.by_category('General') + + expect(result).to eq(result.sort) + end + end + describe '#content' do it 'loads the full file' do gitignore = subject.new(Rails.root.join('vendor/gitlab-ci-yml/Ruby.gitlab-ci.yml')) @@ -38,4 +46,14 @@ describe Gitlab::Template::GitlabCiYmlTemplate do expect(gitignore.content).to start_with('#') end end + + describe '#<=>' do + it 'sorts lexicographically' do + one = described_class.new('a.gitlab-ci.yml') + other = described_class.new('z.gitlab-ci.yml') + + expect(one.<=>(other)).to be(-1) + expect([other, one].sort).to eq([one, other]) + end + end end |