diff options
author | Thong Kuah <tkuah@gitlab.com> | 2019-06-04 11:15:47 +0000 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2019-06-04 11:15:47 +0000 |
commit | aa6b8c8c227a3d5fc543bb3f681a9bbc1cf4f944 (patch) | |
tree | cdd0c4d943c693042fdd1c5f97dc7b007afc2184 /spec/workers | |
parent | cfc70fbe15c5a762afec98b751a8123e86dd7a6a (diff) | |
parent | 197a3d053359e66535c41935eac065ee424cbb07 (diff) | |
download | gitlab-ce-aa6b8c8c227a3d5fc543bb3f681a9bbc1cf4f944.tar.gz |
Merge branch 'introduce-auto-merge-process-worker' into 'master'
Introduce sidekiq worker for auto merge process
See merge request gitlab-org/gitlab-ce!28780
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/auto_merge_process_worker_spec.rb | 31 | ||||
-rw-r--r-- | spec/workers/pipeline_success_worker_spec.rb | 27 |
2 files changed, 31 insertions, 27 deletions
diff --git a/spec/workers/auto_merge_process_worker_spec.rb b/spec/workers/auto_merge_process_worker_spec.rb new file mode 100644 index 00000000000..616727ce5ca --- /dev/null +++ b/spec/workers/auto_merge_process_worker_spec.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe AutoMergeProcessWorker do + describe '#perform' do + subject { described_class.new.perform(merge_request&.id) } + + context 'when merge request is found' do + let(:merge_request) { create(:merge_request) } + + it 'executes AutoMergeService' do + expect_next_instance_of(AutoMergeService) do |auto_merge| + expect(auto_merge).to receive(:process) + end + + subject + end + end + + context 'when merge request is not found' do + let(:merge_request) { nil } + + it 'does not execute AutoMergeService' do + expect(AutoMergeService).not_to receive(:new) + + subject + end + end + end +end diff --git a/spec/workers/pipeline_success_worker_spec.rb b/spec/workers/pipeline_success_worker_spec.rb deleted file mode 100644 index b511edfa620..00000000000 --- a/spec/workers/pipeline_success_worker_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe PipelineSuccessWorker do - describe '#perform' do - context 'when pipeline exists' do - let(:pipeline) { create(:ci_pipeline, status: 'success', ref: merge_request.source_branch, project: merge_request.source_project) } - let(:merge_request) { create(:merge_request) } - - it 'performs "merge when pipeline succeeds"' do - expect_next_instance_of(AutoMergeService) do |auto_merge| - expect(auto_merge).to receive(:process) - end - - described_class.new.perform(pipeline.id) - end - end - - context 'when pipeline does not exist' do - it 'does not raise exception' do - expect { described_class.new.perform(123) } - .not_to raise_error - end - end - end -end |