blob: d935824e6cc508c0d6c9dc94dbef5f71519ed41b (
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
55
56
57
58
59
60
61
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectness,
feature_category: :continuous_integration do
describe '.pre/.post stages' do
let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { project.first_owner }
let(:source) { :push }
let(:service) { described_class.new(project, user, { ref: ref }) }
let(:pipeline) { service.execute(source).payload }
let(:config) do
<<~YAML
validate:
stage: .pre
script: echo Hello World
build:
stage: build
rules:
- if: $CI_COMMIT_BRANCH == "master"
script: echo Hello World
notify:
stage: .post
script: echo Hello World
YAML
end
before do
stub_ci_pipeline_yaml_file(config)
end
context 'when pipeline contains a build except .pre/.post' do
let(:ref) { 'refs/heads/master' }
it 'creates a pipeline' do
expect(pipeline).to be_persisted
expect(pipeline.stages.map(&:name)).to contain_exactly(
*%w(.pre build .post))
expect(pipeline.builds.map(&:name)).to contain_exactly(
*%w(validate build notify))
end
end
context 'when pipeline does not contain any other build except .pre/.post' do
let(:ref) { 'refs/heads/feature' }
it 'does not create a pipeline' do
expect(pipeline).not_to be_persisted
# we can validate a list of stages, as they are assigned
# but not persisted
expect(pipeline.stages.map(&:name)).to contain_exactly(
*%w(.pre .post))
end
end
end
end
|