diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-17 21:10:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-17 21:10:42 +0300 |
commit | 49bb78aac34a111c0fb13aae3a83b078be351fd3 (patch) | |
tree | 510df08e78b39ef88631f8f25bdc371a4661caa9 /spec/workers/ci | |
parent | 68c476dbd8a2c670aeeebffce8b63b554a3ac7f0 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers/ci')
-rw-r--r-- | spec/workers/ci/retry_pipeline_worker_spec.rb | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/workers/ci/retry_pipeline_worker_spec.rb b/spec/workers/ci/retry_pipeline_worker_spec.rb new file mode 100644 index 00000000000..c7600a24280 --- /dev/null +++ b/spec/workers/ci/retry_pipeline_worker_spec.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Ci::RetryPipelineWorker do + describe '#perform' do + subject(:perform) { described_class.new.perform(pipeline_id, user_id) } + + let(:pipeline) { create(:ci_pipeline) } + + context 'when pipeline exists' do + let(:pipeline_id) { pipeline.id } + + context 'when user exists' do + let(:user) { create(:user) } + let(:user_id) { user.id } + + before do + pipeline.project.add_maintainer(user) + end + + it 'retries the pipeline' do + expect(::Ci::Pipeline).to receive(:find_by_id).with(pipeline.id).and_return(pipeline) + expect(pipeline).to receive(:retry_failed).with(having_attributes(id: user_id)) + + perform + end + end + + context 'when user does not exist' do + let(:user_id) { 1234 } + + it 'does not retry the pipeline' do + expect(::Ci::Pipeline).to receive(:find_by_id).with(pipeline_id).and_return(pipeline) + expect(pipeline).not_to receive(:retry_failed).with(having_attributes(id: user_id)) + + perform + end + end + end + + context 'when pipeline does not exist' do + let(:pipeline_id) { 1234 } + let(:user_id) { 1234 } + + it 'returns nil' do + expect(perform).to be_nil + end + end + end +end |