diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-19 14:01:45 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-19 14:01:45 +0300 |
commit | 9297025d0b7ddf095eb618dfaaab2ff8f2018d8b (patch) | |
tree | 865198c01d1824a9b098127baa3ab980c9cd2c06 /spec/models/merge_request_spec.rb | |
parent | 6372471f43ee03c05a7c1f8b0c6ac6b8a7431dbe (diff) |
Add latest changes from gitlab-org/gitlab@16-7-stable-eev16.7.0-rc42
Diffstat (limited to 'spec/models/merge_request_spec.rb')
-rw-r--r-- | spec/models/merge_request_spec.rb | 65 |
1 files changed, 27 insertions, 38 deletions
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 1c6a29f065f..2b5f4165d8c 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -404,7 +404,7 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev end end - context "with the skip_validations_during_transition_feature_flag" do + context "when transitioning between states" do let(:merge_request) { build(:merge_request, transitioning: transitioning) } where(:transitioning, :to_or_not_to) do @@ -6026,47 +6026,11 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev subject(:current_patch_id_sha) { merge_request.current_patch_id_sha } before do - allow(merge_request).to receive(:merge_request_diff).and_return(merge_request_diff) + allow(merge_request).to receive(:latest_merge_request_diff).and_return(merge_request_diff) allow(merge_request_diff).to receive(:patch_id_sha).and_return(patch_id) end it { is_expected.to eq(patch_id) } - - context 'when related merge_request_diff does not have a patch_id_sha' do - let(:diff_refs) { instance_double(Gitlab::Diff::DiffRefs, base_sha: base_sha, head_sha: head_sha) } - let(:base_sha) { 'abc123' } - let(:head_sha) { 'def456' } - - before do - allow(merge_request_diff).to receive(:patch_id_sha).and_return(nil) - allow(merge_request).to receive(:diff_refs).and_return(diff_refs) - - allow(merge_request.project.repository) - .to receive(:get_patch_id) - .with(diff_refs.base_sha, diff_refs.head_sha) - .and_return(patch_id) - end - - it { is_expected.to eq(patch_id) } - - context 'when base_sha is nil' do - let(:base_sha) { nil } - - it { is_expected.to be_nil } - end - - context 'when head_sha is nil' do - let(:head_sha) { nil } - - it { is_expected.to be_nil } - end - - context 'when base_sha and head_sha match' do - let(:head_sha) { base_sha } - - it { is_expected.to be_nil } - end - end end describe '#all_mergeability_checks_results' do @@ -6138,4 +6102,29 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev it { is_expected.to eq(false) } end end + + describe '#allow_merge_without_pipeline?' do + let(:merge_request) { build_stubbed(:merge_request) } + + subject(:result) { merge_request.allow_merge_without_pipeline? } + + before do + allow(merge_request.project) + .to receive(:allow_merge_without_pipeline?) + .with(inherit_group_setting: true) + .and_return(allow_merge_without_pipeline?) + end + + context 'when associated project allow_merge_without_pipeline? returns true' do + let(:allow_merge_without_pipeline?) { true } + + it { is_expected.to eq(true) } + end + + context 'when associated project allow_merge_without_pipeline? returns false' do + let(:allow_merge_without_pipeline?) { false } + + it { is_expected.to eq(false) } + end + end end |