diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 12:45:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 12:45:46 +0300 |
commit | a7b3560714b4d9cc4ab32dffcd1f74a284b93580 (patch) | |
tree | 7452bd5c3545c2fa67a28aa013835fb4fa071baf /spec/services/merge_requests | |
parent | ee9173579ae56a3dbfe5afe9f9410c65bb327ca7 (diff) |
Add latest changes from gitlab-org/gitlab@14-8-stable-eev14.8.0-rc42
Diffstat (limited to 'spec/services/merge_requests')
8 files changed, 26 insertions, 54 deletions
diff --git a/spec/services/merge_requests/after_create_service_spec.rb b/spec/services/merge_requests/after_create_service_spec.rb index 781be57d709..2155b4ffad1 100644 --- a/spec/services/merge_requests/after_create_service_spec.rb +++ b/spec/services/merge_requests/after_create_service_spec.rb @@ -89,10 +89,10 @@ RSpec.describe MergeRequests::AfterCreateService do merge_request.mark_as_preparing! end - it 'marks the merge request as unchecked' do - execute_service + it 'checks for mergeability' do + expect(merge_request).to receive(:check_mergeability).with(async: true) - expect(merge_request.reload).to be_unchecked + execute_service end context 'when preparing for mergeability fails' do @@ -108,17 +108,6 @@ RSpec.describe MergeRequests::AfterCreateService do expect { execute_service }.to raise_error(StandardError) expect(merge_request.reload).to be_preparing end - - context 'when early_prepare_for_mergeability feature flag is disabled' do - before do - stub_feature_flags(early_prepare_for_mergeability: false) - end - - it 'does not mark the merge request as unchecked' do - expect { execute_service }.to raise_error(StandardError) - expect(merge_request.reload).to be_preparing - end - end end context 'when preparing merge request fails' do @@ -130,20 +119,9 @@ RSpec.describe MergeRequests::AfterCreateService do .and_raise(StandardError) end - it 'still marks the merge request as unchecked' do + it 'still checks for mergeability' do + expect(merge_request).to receive(:check_mergeability).with(async: true) expect { execute_service }.to raise_error(StandardError) - expect(merge_request.reload).to be_unchecked - end - - context 'when early_prepare_for_mergeability feature flag is disabled' do - before do - stub_feature_flags(early_prepare_for_mergeability: false) - end - - it 'does not mark the merge request as unchecked' do - expect { execute_service }.to raise_error(StandardError) - expect(merge_request.reload).to be_preparing - end end end end diff --git a/spec/services/merge_requests/bulk_remove_attention_requested_service_spec.rb b/spec/services/merge_requests/bulk_remove_attention_requested_service_spec.rb index fe4ce0dab5e..ae8846974ce 100644 --- a/spec/services/merge_requests/bulk_remove_attention_requested_service_spec.rb +++ b/spec/services/merge_requests/bulk_remove_attention_requested_service_spec.rb @@ -10,7 +10,7 @@ RSpec.describe MergeRequests::BulkRemoveAttentionRequestedService do let(:reviewer) { merge_request.find_reviewer(user) } let(:assignee) { merge_request.find_assignee(assignee_user) } let(:project) { merge_request.project } - let(:service) { described_class.new(project: project, current_user: current_user, merge_request: merge_request) } + let(:service) { described_class.new(project: project, current_user: current_user, merge_request: merge_request, users: [user, assignee_user]) } let(:result) { service.execute } before do @@ -20,7 +20,7 @@ RSpec.describe MergeRequests::BulkRemoveAttentionRequestedService do describe '#execute' do context 'invalid permissions' do - let(:service) { described_class.new(project: project, current_user: create(:user), merge_request: merge_request) } + let(:service) { described_class.new(project: project, current_user: create(:user), merge_request: merge_request, users: [user]) } it 'returns an error' do expect(result[:status]).to eq :error diff --git a/spec/services/merge_requests/create_service_spec.rb b/spec/services/merge_requests/create_service_spec.rb index da547716e1e..a196c944eda 100644 --- a/spec/services/merge_requests/create_service_spec.rb +++ b/spec/services/merge_requests/create_service_spec.rb @@ -61,19 +61,19 @@ RSpec.describe MergeRequests::CreateService, :clean_gitlab_redis_shared_state do expect(merge_request.reload).to be_preparing end - describe 'when marked with /wip' do + describe 'when marked with /draft' do context 'in title and in description' do let(:opts) do { - title: 'WIP: Awesome merge_request', - description: "well this is not done yet\n/wip", + title: 'Draft: Awesome merge_request', + description: "well this is not done yet\n/draft", source_branch: 'feature', target_branch: 'master', assignees: [user2] } end - it 'sets MR to WIP' do + it 'sets MR to draft' do expect(merge_request.work_in_progress?).to be(true) end end @@ -89,7 +89,7 @@ RSpec.describe MergeRequests::CreateService, :clean_gitlab_redis_shared_state do } end - it 'sets MR to WIP' do + it 'sets MR to draft' do expect(merge_request.work_in_progress?).to be(true) end end diff --git a/spec/services/merge_requests/merge_service_spec.rb b/spec/services/merge_requests/merge_service_spec.rb index 127c94763d9..ecb856bd1a4 100644 --- a/spec/services/merge_requests/merge_service_spec.rb +++ b/spec/services/merge_requests/merge_service_spec.rb @@ -388,7 +388,7 @@ RSpec.describe MergeRequests::MergeService do end it 'logs and saves error if there is an error when squashing' do - error_message = 'Failed to squash. Should be done manually' + error_message = 'Squashing failed: Squash the commits locally, resolve any conflicts, then push the branch.' allow_any_instance_of(MergeRequests::SquashService).to receive(:squash!).and_return(nil) merge_request.update!(squash: true) diff --git a/spec/services/merge_requests/mergeability_check_service_spec.rb b/spec/services/merge_requests/mergeability_check_service_spec.rb index 65599b7e046..c24b83e21a6 100644 --- a/spec/services/merge_requests/mergeability_check_service_spec.rb +++ b/spec/services/merge_requests/mergeability_check_service_spec.rb @@ -73,12 +73,10 @@ RSpec.describe MergeRequests::MergeabilityCheckService, :clean_gitlab_redis_shar let(:merge_request) { create(:merge_request, merge_status: :unchecked, source_project: project, target_project: project) } describe '#async_execute' do - shared_examples_for 'no job is enqueued' do - it 'does not enqueue MergeRequestMergeabilityCheckWorker' do - expect(MergeRequestMergeabilityCheckWorker).not_to receive(:perform_async) + it 'updates merge status to checking' do + described_class.new(merge_request).async_execute - described_class.new(merge_request).async_execute - end + expect(merge_request).to be_checking end it 'enqueues MergeRequestMergeabilityCheckWorker' do @@ -92,15 +90,11 @@ RSpec.describe MergeRequests::MergeabilityCheckService, :clean_gitlab_redis_shar allow(Gitlab::Database).to receive(:read_only?) { true } end - it_behaves_like 'no job is enqueued' - end + it 'does not enqueue MergeRequestMergeabilityCheckWorker' do + expect(MergeRequestMergeabilityCheckWorker).not_to receive(:perform_async) - context 'when merge_status is already checking' do - before do - merge_request.mark_as_checking + described_class.new(merge_request).async_execute end - - it_behaves_like 'no job is enqueued' end end diff --git a/spec/services/merge_requests/rebase_service_spec.rb b/spec/services/merge_requests/rebase_service_spec.rb index e671bbf2cd6..a47e626666b 100644 --- a/spec/services/merge_requests/rebase_service_spec.rb +++ b/spec/services/merge_requests/rebase_service_spec.rb @@ -82,7 +82,7 @@ RSpec.describe MergeRequests::RebaseService do context 'with a pre-receive failure' do let(:pre_receive_error) { "Commit message does not follow the pattern 'ACME'" } - let(:merge_error) { "Something went wrong during the rebase pre-receive hook: #{pre_receive_error}." } + let(:merge_error) { "The rebase pre-receive hook failed: #{pre_receive_error}." } before do allow(repository).to receive(:gitaly_operation_client).and_raise(Gitlab::Git::PreReceiveError, "GitLab: #{pre_receive_error}") diff --git a/spec/services/merge_requests/squash_service_spec.rb b/spec/services/merge_requests/squash_service_spec.rb index e5bea0e7b14..387be8471b5 100644 --- a/spec/services/merge_requests/squash_service_spec.rb +++ b/spec/services/merge_requests/squash_service_spec.rb @@ -168,7 +168,7 @@ RSpec.describe MergeRequests::SquashService do it 'raises a squash error' do expect(service.execute).to match( status: :error, - message: a_string_including('does not allow squashing commits when merge requests are accepted')) + message: a_string_including('allow you to squash commits when merging')) end end @@ -205,7 +205,7 @@ RSpec.describe MergeRequests::SquashService do end it 'returns an error' do - expect(service.execute).to match(status: :error, message: a_string_including('squash')) + expect(service.execute).to match(status: :error, message: a_string_including('Squash')) end end end @@ -232,7 +232,7 @@ RSpec.describe MergeRequests::SquashService do end it 'returns an error' do - expect(service.execute).to match(status: :error, message: a_string_including('squash')) + expect(service.execute).to match(status: :error, message: a_string_including('Squash')) end it 'cleans up the temporary directory' do diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb index 2925dad7f6b..48d9f019274 100644 --- a/spec/services/merge_requests/update_service_spec.rb +++ b/spec/services/merge_requests/update_service_spec.rb @@ -102,16 +102,16 @@ RSpec.describe MergeRequests::UpdateService, :mailer do MergeRequests::UpdateService.new(project: project, current_user: user, params: opts).execute(merge_request2) end - it 'tracks Draft/WIP marking' do + it 'tracks Draft marking' do expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter) .to receive(:track_marked_as_draft_action).once.with(user: user) - opts[:title] = "WIP: #{opts[:title]}" + opts[:title] = "Draft: #{opts[:title]}" MergeRequests::UpdateService.new(project: project, current_user: user, params: opts).execute(merge_request2) end - it 'tracks Draft/WIP un-marking' do + it 'tracks Draft un-marking' do expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter) .to receive(:track_unmarked_as_draft_action).once.with(user: user) |