diff options
author | Shinya Maeda <shinya@gitlab.com> | 2019-05-27 19:21:36 +0700 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2019-06-04 10:51:32 +0700 |
commit | 197a3d053359e66535c41935eac065ee424cbb07 (patch) | |
tree | 65b2010d5446fe8c41a378c0f9c7f359ae1eab69 /spec/workers | |
parent | 9a9c947b145e6a43ae49687aa398d1154d07a25b (diff) | |
download | gitlab-ce-197a3d053359e66535c41935eac065ee424cbb07.tar.gz |
Introduce sidekiq worker for auto merge processintroduce-auto-merge-process-worker
As we have a central domain for auto merge process today,
we should use a single worker for any auto merge process.
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 |