summaryrefslogtreecommitdiff
path: root/spec/requests
diff options
context:
space:
mode:
authorChris Wilson <chris@chrisjwilson.com>2017-04-24 16:53:43 +1000
committerChris Wilson <chris@chrisjwilson.com>2017-04-24 20:51:05 +1000
commite670cb271ed61cde68a932ce911553d7c8e4a6d5 (patch)
treef18345c0787cadb8e72de528114b3a63c2d6688a /spec/requests
parentc768026474b9dff9f6f988372e4eefb85b1d8be9 (diff)
downloadgitlab-ce-e670cb271ed61cde68a932ce911553d7c8e4a6d5.tar.gz
Fix updating merge_when_build_succeeds via merge API endpointmrchrisw-22740-merge-api
When updating a merge request via the `/merge` endpoint we check the `mergeable` and `mergeable_state` status, these will return `false` if the application option only_allow_merge_if_pipeline_succeeds is enabled. We should skip CI checks if the request uses the merge_when_pipeline_succeeds param Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/22740
Diffstat (limited to 'spec/requests')
-rw-r--r--spec/requests/api/merge_requests_spec.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb
index 61d965e8974..41885659190 100644
--- a/spec/requests/api/merge_requests_spec.rb
+++ b/spec/requests/api/merge_requests_spec.rb
@@ -6,7 +6,7 @@ describe API::MergeRequests, api: true do
let(:user) { create(:user) }
let(:admin) { create(:user, :admin) }
let(:non_member) { create(:user) }
- let!(:project) { create(:project, :public, :repository, creator: user, namespace: user.namespace) }
+ let!(:project) { create(:project, :public, :repository, creator: user, namespace: user.namespace, only_allow_merge_if_pipeline_succeeds: false) }
let!(:merge_request) { create(:merge_request, :simple, author: user, assignee: user, source_project: project, title: "Test", created_at: base_time) }
let!(:merge_request_closed) { create(:merge_request, state: "closed", author: user, assignee: user, source_project: project, title: "Closed test", created_at: base_time + 1.second) }
let!(:merge_request_merged) { create(:merge_request, state: "merged", author: user, assignee: user, source_project: project, title: "Merged test", created_at: base_time + 2.seconds, merge_commit_sha: '9999999999999999999999999999999999999999') }
@@ -527,6 +527,18 @@ describe API::MergeRequests, api: true do
expect(json_response['merge_when_pipeline_succeeds']).to eq(true)
end
+ it "enables merge when pipeline succeeds if the pipeline is active and only_allow_merge_if_pipeline_succeeds is true" do
+ allow_any_instance_of(MergeRequest).to receive(:head_pipeline).and_return(pipeline)
+ allow(pipeline).to receive(:active?).and_return(true)
+ project.update_attribute(:only_allow_merge_if_pipeline_succeeds, true)
+
+ put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), merge_when_pipeline_succeeds: true
+
+ expect(response).to have_http_status(200)
+ expect(json_response['title']).to eq('Test')
+ expect(json_response['merge_when_pipeline_succeeds']).to eq(true)
+ end
+
it "returns 404 for an invalid merge request IID" do
put api("/projects/#{project.id}/merge_requests/12345/merge", user)