debian-mirror-gitlab/spec/workers/build_success_worker_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

47 lines
1.2 KiB
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
2016-11-03 12:29:30 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe BuildSuccessWorker do
2016-11-03 12:29:30 +05:30
describe '#perform' do
2018-12-13 13:39:08 +05:30
subject { described_class.new.perform(build.id) }
2016-11-03 12:29:30 +05:30
context 'when build exists' do
2018-12-13 13:39:08 +05:30
context 'when the build will stop an environment' do
2022-07-23 23:45:48 +05:30
let!(:build) { create(:ci_build, :stop_review_app, environment: environment.name, project: environment.project, status: :success) }
2018-12-13 13:39:08 +05:30
let(:environment) { create(:environment, state: :available) }
it 'stops the environment' do
expect(environment).to be_available
subject
2016-11-03 12:29:30 +05:30
2018-12-13 13:39:08 +05:30
expect(environment.reload).to be_stopped
2016-11-03 12:29:30 +05:30
end
2022-07-23 23:45:48 +05:30
context 'when the build fails' do
before do
build.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
2016-11-03 12:29:30 +05:30
end
end
context 'when build does not exist' do
it 'does not raise exception' do
expect { described_class.new.perform(123) }
.not_to raise_error
end
end
end
end