diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /spec/lib/gitlab/template | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/lib/gitlab/template')
-rw-r--r-- | spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb | 42 | ||||
-rw-r--r-- | spec/lib/gitlab/template/metrics_dashboard_template_spec.rb | 26 |
2 files changed, 27 insertions, 41 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 3004de6fe08..55444114d39 100644 --- a/spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb +++ b/spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb @@ -6,10 +6,6 @@ RSpec.describe Gitlab::Template::GitlabCiYmlTemplate do subject { described_class } describe '.all' do - it 'strips the gitlab-ci suffix' do - expect(subject.all.first.name).not_to end_with('.gitlab-ci.yml') - end - it 'combines the globals and rest' do all = subject.all.map(&:name) @@ -17,34 +13,6 @@ RSpec.describe Gitlab::Template::GitlabCiYmlTemplate do expect(all).to include('Docker') expect(all).to include('Ruby') end - - it 'ensure that the template name is used exactly once' do - all = subject.all.group_by(&:name) - duplicates = all.select { |_, templates| templates.length > 1 } - - expect(duplicates).to be_empty - end - end - - describe '.find' do - it 'returns nil if the file does not exist' do - expect(subject.find('mepmep-yadida')).to be nil - end - - it 'returns the GitlabCiYml object of a valid file' do - ruby = subject.find('Ruby') - - expect(ruby).to be_a described_class - expect(ruby.name).to eq('Ruby') - 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 @@ -56,13 +24,5 @@ RSpec.describe Gitlab::Template::GitlabCiYmlTemplate do 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 + it_behaves_like 'file template shared examples', 'Ruby', '.gitlab-ci.yml' end diff --git a/spec/lib/gitlab/template/metrics_dashboard_template_spec.rb b/spec/lib/gitlab/template/metrics_dashboard_template_spec.rb new file mode 100644 index 00000000000..4c2b3dea600 --- /dev/null +++ b/spec/lib/gitlab/template/metrics_dashboard_template_spec.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Template::MetricsDashboardTemplate do + subject { described_class } + + describe '.all' do + it 'combines the globals and rest' do + all = subject.all.map(&:name) + + expect(all).to include('Default') + end + end + + describe '#content' do + it 'loads the full file' do + example_dashboard = subject.new(Rails.root.join('lib/gitlab/metrics/templates/Default.metrics-dashboard.yml')) + + expect(example_dashboard.name).to eq 'Default' + expect(example_dashboard.content).to start_with('#') + end + end + + it_behaves_like 'file template shared examples', 'Default', '.metrics-dashboard.yml' +end |