diff options
Diffstat (limited to 'spec/lib/gitlab/ci')
-rw-r--r-- | spec/lib/gitlab/ci/templates/templates_spec.rb | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/spec/lib/gitlab/ci/templates/templates_spec.rb b/spec/lib/gitlab/ci/templates/templates_spec.rb index 685243d6315..768256ee6b3 100644 --- a/spec/lib/gitlab/ci/templates/templates_spec.rb +++ b/spec/lib/gitlab/ci/templates/templates_spec.rb @@ -7,17 +7,17 @@ RSpec.describe 'CI YML Templates' do let(:all_templates) { Gitlab::Template::GitlabCiYmlTemplate.all.map(&:full_name) } - let(:disabled_templates) do - Gitlab::Template::GitlabCiYmlTemplate.disabled_templates.map do |template| - template + Gitlab::Template::GitlabCiYmlTemplate.extension + let(:excluded_templates) do + all_templates.select do |name| + Gitlab::Template::GitlabCiYmlTemplate.excluded_patterns.any? { |pattern| pattern.match?(name) } end end - context 'included in a CI YAML configuration' do + context 'when including available templates in a CI YAML configuration' do using RSpec::Parameterized::TableSyntax where(:template_name) do - all_templates - disabled_templates + all_templates - excluded_templates end with_them do @@ -41,4 +41,29 @@ RSpec.describe 'CI YML Templates' do end end end + + context 'when including unavailable templates in a CI YAML configuration' do + using RSpec::Parameterized::TableSyntax + + where(:template_name) do + excluded_templates + end + + with_them do + let(:content) do + <<~EOS + include: + - template: #{template_name} + + concrete_build_implemented_by_a_user: + stage: test + script: do something + EOS + end + + it 'is not valid' do + expect(subject).not_to be_valid + end + end + end end |