diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-30 03:09:55 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-30 03:09:55 +0300 |
commit | 4362d376f3d810540408b22a17c5e314b2aee945 (patch) | |
tree | 0173bb8a2fe6a1c1e283ff6103ce149b7ea3ccaf /spec | |
parent | a4686f1a0ebf89649b2bb04a0b17bbe35beea5ed (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/finders/merge_requests/oldest_per_commit_finder_spec.rb | 21 | ||||
-rw-r--r-- | spec/models/merge_request_spec.rb | 27 |
2 files changed, 44 insertions, 4 deletions
diff --git a/spec/finders/merge_requests/oldest_per_commit_finder_spec.rb b/spec/finders/merge_requests/oldest_per_commit_finder_spec.rb index d26e653cf14..9832c74c6b8 100644 --- a/spec/finders/merge_requests/oldest_per_commit_finder_spec.rb +++ b/spec/finders/merge_requests/oldest_per_commit_finder_spec.rb @@ -117,6 +117,27 @@ RSpec.describe MergeRequests::OldestPerCommitFinder, feature_category: :code_rev .to eq(sha1 => mr, sha2 => mr) end + it 'includes a merge request for fast-forward merged MR' do + project = create(:project) + sha = Digest::SHA1.hexdigest('foo') + # When there is only a merged_commit_sha, then it means the MR was + # fast-forward merged without a squash, but possibly including a rebase. + mr = create( + :merge_request, + :merged, + target_project: project, + merged_commit_sha: sha + ) + + commits = [double(:commit1, id: sha)] + + expect(MergeRequestDiffCommit) + .not_to receive(:oldest_merge_request_id_per_commit) + + expect(described_class.new(project).execute(commits)) + .to eq(sha => mr) + end + it 'includes the oldest merge request when a merge commit is present in a newer merge request' do project = create(:project) sha = Digest::SHA1.hexdigest('foo') diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 7d96926fae8..a1787f5ea63 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -570,6 +570,16 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev end end + describe '.by_merged_commit_sha' do + it 'returns merge requests that match the given merged commit' do + mr = create(:merge_request, :merged, merged_commit_sha: '123abc') + + create(:merge_request, :merged, merged_commit_sha: '123def') + + expect(described_class.by_merged_commit_sha('123abc')).to eq([mr]) + end + end + describe '.by_merge_commit_sha' do it 'returns merge requests that match the given merge commit' do mr = create(:merge_request, :merged, merge_commit_sha: '123abc') @@ -591,16 +601,18 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev end end - describe '.by_merge_or_squash_commit_sha' do - subject { described_class.by_merge_or_squash_commit_sha([sha1, sha2]) } + describe '.by_merged_or_merge_or_squash_commit_sha' do + subject { described_class.by_merged_or_merge_or_squash_commit_sha([sha1, sha2, sha3]) } let(:sha1) { '123abc' } let(:sha2) { '456abc' } + let(:sha3) { '111111' } let(:mr1) { create(:merge_request, :merged, squash_commit_sha: sha1) } let(:mr2) { create(:merge_request, :merged, merge_commit_sha: sha2) } + let(:mr3) { create(:merge_request, :merged, merged_commit_sha: sha3) } - it 'returns merge requests that match the given squash and merge commits' do - is_expected.to include(mr1, mr2) + it 'returns merge requests that match the given squash, merge and merged commits' do + is_expected.to include(mr1, mr2, mr3) end end @@ -644,6 +656,13 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev it { is_expected.to eq([merge_request]) } end + context 'when commit is a rebased fast-forward commit' do + let!(:merge_request) { create(:merge_request, :merged, merged_commit_sha: sha) } + let(:sha) { '123abc' } + + it { is_expected.to eq([merge_request]) } + end + context 'when commit is not found' do let(:sha) { '0000' } |