diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /spec/workers/merge_requests/create_pipeline_worker_spec.rb | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'spec/workers/merge_requests/create_pipeline_worker_spec.rb')
-rw-r--r-- | spec/workers/merge_requests/create_pipeline_worker_spec.rb | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/spec/workers/merge_requests/create_pipeline_worker_spec.rb b/spec/workers/merge_requests/create_pipeline_worker_spec.rb index 06d44c45706..441d7652219 100644 --- a/spec/workers/merge_requests/create_pipeline_worker_spec.rb +++ b/spec/workers/merge_requests/create_pipeline_worker_spec.rb @@ -3,24 +3,50 @@ require 'spec_helper' RSpec.describe MergeRequests::CreatePipelineWorker do - subject(:worker) { described_class.new } - describe '#perform' do let(:user) { create(:user) } let(:project) { create(:project) } let(:merge_request) { create(:merge_request) } + let(:worker) { described_class.new } + + subject { worker.perform(project.id, user.id, merge_request.id) } context 'when the objects exist' do it 'calls the merge request create pipeline service and calls update head pipeline' do aggregate_failures do - expect_next_instance_of(MergeRequests::CreatePipelineService, project: project, current_user: user) do |service| + expect_next_instance_of(MergeRequests::CreatePipelineService, + project: project, + current_user: user, + params: { push_options: nil }) do |service| expect(service).to receive(:execute).with(merge_request) end expect(MergeRequest).to receive(:find_by_id).with(merge_request.id).and_return(merge_request) expect(merge_request).to receive(:update_head_pipeline) - subject.perform(project.id, user.id, merge_request.id) + subject + end + end + + context 'when push options are passed as Hash to the worker' do + let(:extra_params) { { 'push_options' => { 'ci' => { 'skip' => true } } } } + + subject { worker.perform(project.id, user.id, merge_request.id, extra_params) } + + it 'calls the merge request create pipeline service and calls update head pipeline' do + aggregate_failures do + expect_next_instance_of(MergeRequests::CreatePipelineService, + project: project, + current_user: user, + params: { push_options: { ci: { skip: true } } }) do |service| + expect(service).to receive(:execute).with(merge_request) + end + + expect(MergeRequest).to receive(:find_by_id).with(merge_request.id).and_return(merge_request) + expect(merge_request).to receive(:update_head_pipeline) + + subject + end end end end @@ -29,8 +55,7 @@ RSpec.describe MergeRequests::CreatePipelineWorker do it 'does not call the create pipeline service' do expect(MergeRequests::CreatePipelineService).not_to receive(:new) - expect { subject.perform(project.id, user.id, merge_request.id) } - .not_to raise_exception + expect { subject }.not_to raise_exception end end |