update_pages_service_spec.rb 1.01 KB
Newer Older
Kamil Trzcinski's avatar
Kamil Trzcinski committed
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
require 'spec_helper'

describe UpdatePagesService, services: true do
  let(:build) { create(:ci_build) }
  let(:data) { Gitlab::BuildDataBuilder.build(build) }
  let(:service) { UpdatePagesService.new(data) }

  context 'execute asynchronously for pages job' do
    before { build.name = 'pages' }

    context 'on success' do
      before { build.success }

      it 'should execute worker' do
        expect(PagesWorker).to receive(:perform_async)
        service.execute
      end
    end

    %w(pending running failed canceled).each do |status|
      context "on #{status}" do
        before { build.status = status }

        it 'should not execute worker' do
          expect(PagesWorker).to_not receive(:perform_async)
          service.execute
        end
      end
    end
  end

  context 'for other jobs' do
    before do
      build.name = 'other job'
      build.success
    end

    it 'should not execute worker' do
      expect(PagesWorker).to_not receive(:perform_async)
      service.execute
    end
  end
end