summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/ci/templates/templates_spec.rb
blob: def4d1b3bf6ab2221289362395fcc640e39252c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'CI YML Templates' do
  subject { Gitlab::Ci::YamlProcessor.new(content) }

  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
    end
  end

  context 'included in a CI YAML configuration' do
    using RSpec::Parameterized::TableSyntax

    where(:template_name) do
      all_templates - disabled_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 valid' do
        expect { subject }.not_to raise_error
      end

      it 'require default stages to be included' do
        expect(subject.stages).to include(*Gitlab::Ci::Config::Entry::Stages.default)
      end
    end
  end
end