summaryrefslogtreecommitdiff
path: root/spec/workers/deployments/success_worker_spec.rb
blob: ba7d45eca01f6a3150afdaa414d53be722551a20 (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
require 'spec_helper'

describe Deployments::SuccessWorker do
  subject { described_class.new.perform(deployment&.id) }

  context 'when successful deployment' do
    let(:deployment) { create(:deployment, :success) }

    it 'executes UpdateDeploymentService' do
      expect(UpdateDeploymentService)
        .to receive(:new).with(deployment).and_call_original

      subject
    end
  end

  context 'when canceled deployment' do
    let(:deployment) { create(:deployment, :canceled) }

    it 'does not execute UpdateDeploymentService' do
      expect(UpdateDeploymentService).not_to receive(:new)

      subject
    end
  end

  context 'when deploy record does not exist' do
    let(:deployment) { nil }

    it 'does not execute UpdateDeploymentService' do
      expect(UpdateDeploymentService).not_to receive(:new)

      subject
    end
  end
end