blob: df0acf46bd9f354d2d6306bacd35821caabbf0f9 (
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 Environments::StopJobSuccessWorker, feature_category: :continuous_delivery do
describe '#perform' do
let_it_be_with_refind(:environment) { create(:environment, state: :available) }
subject { described_class.new.perform(job.id) }
shared_examples_for 'stopping an associated environment' do
it 'stops the environment' do
expect(environment).to be_available
subject
expect(environment.reload).to be_stopped
end
context 'when the job fails' do
before do
job.update!(status: :failed)
environment.update!(state: :available)
end
it 'does not stop the environment' do
expect(environment).to be_available
subject
expect(environment.reload).not_to be_stopped
end
end
end
context 'with build job' do
let!(:job) do
create(:ci_build, :stop_review_app, environment: environment.name, project: environment.project,
status: :success)
end
it_behaves_like 'stopping an associated environment'
end
context 'with bridge job' do
let!(:job) do
create(:ci_bridge, :stop_review_app, environment: environment.name, project: environment.project,
status: :success)
end
it_behaves_like 'stopping an associated environment'
end
context 'when job does not exist' do
it 'does not raise exception' do
expect { described_class.new.perform(123) }
.not_to raise_error
end
end
end
end
|