Commit 179b8178 authored by James Lopez's avatar James Lopez

Fix arguments error on Import/Export fetch_ref method

Added unit test and updated integration spec to test for this as well.
parent 43388234
...@@ -26,7 +26,7 @@ module Gitlab ...@@ -26,7 +26,7 @@ module Gitlab
end end
def fetch_ref def fetch_ref
@project.repository.fetch_ref(@project.repository.path, @diff_head_sha, @merge_request.source_branch) @project.repository.fetch_ref(@project.repository.path, source_ref: @diff_head_sha, target_ref: @merge_request.source_branch)
end end
def branch_exists?(branch_name) def branch_exists?(branch_name)
......
...@@ -13,7 +13,7 @@ describe Gitlab::ImportExport::MergeRequestParser do ...@@ -13,7 +13,7 @@ describe Gitlab::ImportExport::MergeRequestParser do
let(:parsed_merge_request) do let(:parsed_merge_request) do
described_class.new(project, described_class.new(project,
merge_request.diff_head_sha, 'abcd',
merge_request, merge_request,
merge_request.as_json).parse! merge_request.as_json).parse!
end end
...@@ -29,4 +29,14 @@ describe Gitlab::ImportExport::MergeRequestParser do ...@@ -29,4 +29,14 @@ describe Gitlab::ImportExport::MergeRequestParser do
it 'has a target branch' do it 'has a target branch' do
expect(project.repository.branch_exists?(parsed_merge_request.target_branch)).to be true expect(project.repository.branch_exists?(parsed_merge_request.target_branch)).to be true
end end
it 'parses a MR that has no source branch' do
allow_any_instance_of(Gitlab::ImportExport::MergeRequestParser).to receive(:branch_exists?).and_call_original
allow_any_instance_of(Gitlab::ImportExport::MergeRequestParser).to receive(:branch_exists?).with(merge_request.source_branch).and_return(false)
allow_any_instance_of(Gitlab::ImportExport::MergeRequestParser).to receive(:fork_merge_request?).and_return(true)
allow(Gitlab::GitalyClient).to receive(:migrate).and_call_original
allow(Gitlab::GitalyClient).to receive(:migrate).with(:fetch_ref).and_return([nil, 0])
expect(parsed_merge_request).to eq(merge_request)
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