2019-03-30 07:15:48 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-07-31 10:07:05 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe StageUpdateWorker do
|
|
|
|
describe '#perform' do
|
|
|
|
context 'when stage exists' do
|
|
|
|
let(:stage) { create(:ci_stage_entity) }
|
|
|
|
|
|
|
|
it 'updates stage status' do
|
2020-01-17 15:08:37 +00:00
|
|
|
expect_any_instance_of(Ci::Stage).to receive(:set_status).with('skipped')
|
2017-07-31 10:07:05 +00:00
|
|
|
|
|
|
|
described_class.new.perform(stage.id)
|
|
|
|
end
|
2020-04-21 15:21:10 +00:00
|
|
|
|
|
|
|
it_behaves_like 'an idempotent worker' do
|
|
|
|
let(:job_args) { [stage.id] }
|
|
|
|
|
|
|
|
it 'results in the stage getting the skipped status' do
|
|
|
|
expect { subject }.to change { stage.reload.status }.from('pending').to('skipped')
|
|
|
|
expect { subject }.not_to change { stage.reload.status }
|
|
|
|
end
|
|
|
|
end
|
2017-07-31 10:07:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when stage does not exist' do
|
|
|
|
it 'does not raise exception' do
|
|
|
|
expect { described_class.new.perform(123) }
|
|
|
|
.not_to raise_error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|