Commit f59b8238 authored by Rémy Coutable's avatar Rémy Coutable 🏖

Make UpstreamMergeService handle the new UpstreamMerge::DownstreamAlreadyUpToDate error

Signed-off-by: Rémy Coutable's avatarRémy Coutable <remy@rymai.me>
parent 4b960ce5
......@@ -24,11 +24,13 @@ module Services
origin: Project::GitlabEe.remotes[:gitlab],
upstream: Project::GitlabCe.remotes[:gitlab],
merge_branch: upstream_merge_request.source_branch)
upstream_merge_request.conflicts = merge.execute
upstream_merge_request.conflicts = merge.execute!
upstream_merge_request.create unless dry_run
Result.new(true, { upstream_mr: upstream_merge_request })
rescue UpstreamMerge::DownstreamAlreadyUpToDate
Result.new(false, { already_up_to_date: true })
rescue UpstreamMergeInProgressError
return Result.new(false, { in_progress_mr: open_merge_requests.first })
end
......
......@@ -3,6 +3,8 @@ require 'spec_helper'
require 'services/upstream_merge_service'
describe Services::UpstreamMergeService do
let(:upstream_merge) { double(execute!: []) }
around do |example|
Timecop.freeze(2017, 11, 15) do
example.run
......@@ -19,7 +21,7 @@ describe Services::UpstreamMergeService do
origin: Project::GitlabEe.remotes[:gitlab],
upstream: Project::GitlabCe.remotes[:gitlab],
merge_branch: 'ce-to-ee-2017-11-15'
).and_return(double(execute: []))
).and_return(upstream_merge)
end
end
......@@ -107,6 +109,21 @@ describe Services::UpstreamMergeService do
it_behaves_like 'successful MR creation'
end
context 'when downstream is already up-to-date with upstream' do
include_context 'stub collaborators'
before do
expect(upstream_merge).to receive(:execute!).and_raise(UpstreamMerge::DownstreamAlreadyUpToDate)
end
it 'returns a non-successful result object' do
result = subject.perform
expect(result).not_to be_success
expect(result.payload[:already_up_to_date]).to be(true)
end
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