Commit bf717b67 authored by Kerri Miller's avatar Kerri Miller

Merge branch 'fix_commitsWithoutMergeCommits' into 'master'

merge_request_diff.rb: Populate CommitCollection from target project/branch

See merge request gitlab-org/gitlab!67016
parents eb51df96 8fcd3dae
......@@ -710,7 +710,7 @@ class MergeRequestDiff < ApplicationRecord
end
CommitCollection
.new(merge_request.source_project, commits, merge_request.source_branch)
.new(merge_request.target_project, commits, merge_request.target_branch)
end
def save_diffs
......
......@@ -1080,6 +1080,22 @@ RSpec.describe MergeRequestDiff do
end
end
describe '#commits' do
include ProjectForksHelper
let_it_be(:target) { create(:project, :test_repo) }
let_it_be(:forked) { fork_project(target, nil, repository: true) }
let_it_be(:mr) { create(:merge_request, source_project: forked, target_project: target) }
it 'returns a CommitCollection whose container points to the target project' do
expect(mr.merge_request_diff.commits.container).to eq(target)
end
it 'returns a non-empty CommitCollection' do
expect(mr.merge_request_diff.commits.commits.size).to be > 0
end
end
describe '.latest_diff_for_merge_requests' do
let_it_be(:merge_request_1) { create(:merge_request_without_merge_request_diff) }
let_it_be(:merge_request_1_diff_1) { create(:merge_request_diff, merge_request: merge_request_1, created_at: 3.days.ago) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment