Commit 81f95d89 authored by Balasankar "Balu" C's avatar Balasankar "Balu" C

Add test for accept_merge_request

parent 6334a2cf
......@@ -42,6 +42,53 @@ describe GitlabClient do
end
end
describe '.accept_merge_request' do
before do
allow(described_class).to receive(:current_user).and_return(double(id: 42))
end
let(:merge_request) do
double(
project: double(path: 'gitlab-org/gitlab-ce'),
title: 'Upstream MR',
iid: '12345',
description: 'Hello world',
labels: 'CE upstream',
source_branch: 'feature',
target_branch: 'master',
milestone: nil)
end
let(:default_params) do
{
merge_when_pipeline_succeeds: true
}
end
it 'accepts a merge request against master on the GitLab CE project' do
expect(described_class.__send__(:client))
.to receive(:accept_merge_request).with(
Project::GitlabCe.path,
merge_request.iid,
default_params)
described_class.accept_merge_request(merge_request)
end
context 'when passing a project' do
it 'accepts a merge request in the given project' do
expect(described_class.__send__(:client))
.to receive(:accept_merge_request).with(
Project::GitlabEe.path,
merge_request.iid,
default_params)
described_class.accept_merge_request(merge_request, Project::GitlabEe)
end
end
end
describe '.create_merge_request' do
before do
allow(described_class).to receive(:current_user).and_return(double(id: 42))
......
......@@ -25,13 +25,13 @@ describe Services::UpstreamMergeService do
shared_context 'without conflicts' do
before do
allow(subject.upstream_merge_request).to receive(:conflicts?).and_return(false)
allow(subject.upstream_merge_request).to receive(:conflicts?).and_return(false)
end
end
shared_context 'with conflicts' do
before do
allow(subject.upstream_merge_request).to receive(:conflicts?).and_return(true)
allow(subject.upstream_merge_request).to receive(:conflicts?).and_return(true)
end
end
......@@ -40,7 +40,6 @@ describe Services::UpstreamMergeService do
include_context 'with conflicts'
it 'returns a successful result object' do
expect(subject.upstream_merge_request).to receive(:create)
expect(subject.upstream_merge_request).not_to receive(:accept)
......@@ -103,8 +102,8 @@ describe Services::UpstreamMergeService do
end
context 'when real run (default)' do
it_behaves_like 'successful MR creation and automatic acceptance'
it_behaves_like 'successful MR creation without automatic acceptance'
it_behaves_like 'successful MR creation and automatic acceptance'
it_behaves_like 'successful MR creation without automatic acceptance'
end
context 'when dry run' do
......
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