summaryrefslogtreecommitdiff
path: root/spec/services/ci/create_builds_service_spec.rb
blob: 8b0becd83d3805ceb6a47ae87cea2c26fb576455 (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
require 'spec_helper'

describe Ci::CreateBuildsService, services: true do
  let(:pipeline) { create(:ci_pipeline, ref: 'master') }
  let(:user) { create(:user) }

  describe '#execute' do
    # Using stubbed .gitlab-ci.yml created in commit factory
    #

    subject do
      described_class.new(pipeline).execute('test', user, status, nil)
    end

    context 'next builds available' do
      let(:status) { 'success' }

      it { is_expected.to be_an_instance_of Array }
      it { is_expected.to all(be_an_instance_of Ci::Build) }

      it 'does not persist created builds' do
        expect(subject.first).not_to be_persisted
      end
    end

    context 'builds skipped' do
      let(:status) { 'skipped' }

      it { is_expected.to be_empty }
    end
  end
end