diff options
Diffstat (limited to 'spec/services/auto_merge')
-rw-r--r-- | spec/services/auto_merge/base_service_spec.rb | 4 | ||||
-rw-r--r-- | spec/services/auto_merge/merge_when_pipeline_succeeds_service_spec.rb | 16 |
2 files changed, 17 insertions, 3 deletions
diff --git a/spec/services/auto_merge/base_service_spec.rb b/spec/services/auto_merge/base_service_spec.rb index e08e1d670bf..98fa6012089 100644 --- a/spec/services/auto_merge/base_service_spec.rb +++ b/spec/services/auto_merge/base_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe AutoMerge::BaseService do +RSpec.describe AutoMerge::BaseService do let(:project) { create(:project) } let(:user) { create(:user) } let(:service) { described_class.new(project, user, params) } @@ -51,7 +51,7 @@ describe AutoMerge::BaseService do expect(merge_request.merge_params['commit_message']).to eq("Merge branch 'patch-12' into 'master'") expect(merge_request.merge_params['sha']).to eq('200fcc9c260f7219eaf0daba87d818f0922c5b18') expect(merge_request.merge_params['should_remove_source_branch']).to eq(false) - expect(merge_request.squash).to eq(false) + expect(merge_request.squash_on_merge?).to eq(false) expect(merge_request.merge_params['squash_commit_message']).to eq('Update README.md') end end diff --git a/spec/services/auto_merge/merge_when_pipeline_succeeds_service_spec.rb b/spec/services/auto_merge/merge_when_pipeline_succeeds_service_spec.rb index b6e8d3c636a..3bf59f6a2d1 100644 --- a/spec/services/auto_merge/merge_when_pipeline_succeeds_service_spec.rb +++ b/spec/services/auto_merge/merge_when_pipeline_succeeds_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe AutoMerge::MergeWhenPipelineSucceedsService do +RSpec.describe AutoMerge::MergeWhenPipelineSucceedsService do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :repository) } @@ -69,6 +69,7 @@ describe AutoMerge::MergeWhenPipelineSucceedsService do before do allow(merge_request) .to receive_messages(head_pipeline: pipeline, actual_head_pipeline: pipeline) + expect(MailScheduler::NotificationServiceWorker).to receive(:perform_async).with('merge_when_pipeline_succeeds', merge_request, user).once service.execute(merge_request) end @@ -90,6 +91,18 @@ describe AutoMerge::MergeWhenPipelineSucceedsService do end end + context 'without feature enabled' do + it 'does not send notification' do + stub_feature_flags(mwps_notification: false) + + allow(merge_request) + .to receive_messages(head_pipeline: pipeline, actual_head_pipeline: pipeline) + expect(MailScheduler::NotificationServiceWorker).not_to receive(:perform_async) + + service.execute(merge_request) + end + end + context 'already approved' do let(:service) { described_class.new(project, user, should_remove_source_branch: true) } let(:build) { create(:ci_build, ref: mr_merge_if_green_enabled.source_branch) } @@ -106,6 +119,7 @@ describe AutoMerge::MergeWhenPipelineSucceedsService do it 'updates the merge params' do expect(SystemNoteService).not_to receive(:merge_when_pipeline_succeeds) + expect(MailScheduler::NotificationServiceWorker).not_to receive(:perform_async).with('merge_when_pipeline_succeeds', any_args) service.execute(mr_merge_if_green_enabled) expect(mr_merge_if_green_enabled.merge_params).to have_key('should_remove_source_branch') |