Welcome to mirror list, hosted at ThFree Co, Russian Federation.

parameter_content_spec.rb « create_pipeline_service « ci « services « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f593707f460f7f2d23075082b297f2476c944f84 (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
45
46
47
48
49
50
51
52
53
54
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Ci::CreatePipelineService do
  let_it_be(:project) { create(:project, :repository) }
  let_it_be(:user) { project.first_owner }

  let(:service) { described_class.new(project, user, { ref: 'refs/heads/master' }) }
  let(:content) do
    <<~EOY
      ---
      stages:
        - dast

      variables:
        DAST_VERSION: 1
        SECURE_ANALYZERS_PREFIX: "registry.gitlab.com/security-products"

      dast:
        stage: dast
        image:
          name: "$SECURE_ANALYZERS_PREFIX/dast:$DAST_VERSION"
        variables:
          GIT_STRATEGY: none
        script:
          - /analyze
    EOY
  end

  describe '#execute' do
    context 'when source is a dangling build' do
      subject { service.execute(:ondemand_dast_scan, content: content).payload }

      context 'parameter config content' do
        it 'creates a pipeline' do
          expect(subject).to be_persisted
        end

        it 'creates builds with the correct names' do
          expect(subject.builds.pluck(:name)).to match_array %w[dast]
        end

        it 'creates stages with the correct names' do
          expect(subject.stages.pluck(:name)).to match_array %w[dast]
        end

        it 'sets the correct config source' do
          expect(subject.config_source).to eq 'parameter_source'
        end
      end
    end
  end
end