Commit 893c824e authored by Nick Thomas's avatar Nick Thomas

Merge branch 'pr-importer-io-extra-error-handling' into 'master'

Ensure MR diffs always exist in the PR importer

Closes #47312

See merge request gitlab-org/gitlab-ce!19704
parents 8b0d2283 e4612df0
---
title: Ensure MR diffs always exist in the PR importer
merge_request:
author:
type: fixed
......@@ -104,7 +104,8 @@ module Gitlab
# first save the diff, then populate it.
diff =
if already_exists
merge_request.merge_request_diffs.take
merge_request.merge_request_diffs.take ||
merge_request.merge_request_diffs.build
else
merge_request.merge_request_diffs.build
end
......
......@@ -276,5 +276,17 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi
expect(diff.merge_request_diff_commits.exists?).to eq(true)
end
context 'when the merge request exists' do
it 'creates the merge request diffs if they do not yet exist' do
mr, _ = importer.create_merge_request
mr.merge_request_diffs.delete_all
importer.insert_git_data(mr, true)
expect(mr.merge_request_diffs.exists?).to eq(true)
end
end
end
end
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