summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-05-13 11:27:19 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-05-13 11:27:19 +0000
commit0c621708658da4b3cf88d805da5dbad920f3d27f (patch)
tree99ae5d61a368da3cc7f1470d135f5c1aa2a2751c /spec
parent17858d49f6b189c922c7a69e94b5d8aa96fb48ad (diff)
parent2d2b2da45a586bdf29e115dcb4b4f66f9a1feed0 (diff)
downloadgitlab-ce-0c621708658da4b3cf88d805da5dbad920f3d27f.tar.gz
Merge branch 'api-mr-merge' into 'master'
Accept merge request API This MR adds new endpoint `PUT /projects/:id/merge_request/:merge_request_id/merge`. After this change you can merge branches using API. Fixes internal issue #1166
Diffstat (limited to 'spec')
-rw-r--r--spec/requests/api/merge_requests_spec.rb30
1 files changed, 26 insertions, 4 deletions
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb
index db7c30e1ab8..2fb3684fdf0 100644
--- a/spec/requests/api/merge_requests_spec.rb
+++ b/spec/requests/api/merge_requests_spec.rb
@@ -183,11 +183,33 @@ describe API::API, api: true do
end
end
- describe "PUT /projects/:id/merge_request/:merge_request_id to merge MR" do
- it "should return merge_request" do
- put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), state_event: "merge"
+ describe "PUT /projects/:id/merge_request/:merge_request_id/merge" do
+ it "should return merge_request in case of success" do
+ MergeRequest.any_instance.stub(can_be_merged?: true, automerge!: true)
+ put api("/projects/#{project.id}/merge_request/#{merge_request.id}/merge", user)
response.status.should == 200
- json_response['state'].should == 'merged'
+ end
+
+ it "should return 405 if branch can't be merged" do
+ MergeRequest.any_instance.stub(can_be_merged?: false)
+ put api("/projects/#{project.id}/merge_request/#{merge_request.id}/merge", user)
+ response.status.should == 405
+ json_response['message'].should == 'Branch cannot be merged'
+ end
+
+ it "should return 405 if merge_request is not open" do
+ merge_request.close
+ put api("/projects/#{project.id}/merge_request/#{merge_request.id}/merge", user)
+ response.status.should == 405
+ json_response['message'].should == 'Method Not Allowed'
+ end
+
+ it "should return 401 if user has no permissions to merge" do
+ user2 = create(:user)
+ project.team << [user2, :reporter]
+ put api("/projects/#{project.id}/merge_request/#{merge_request.id}/merge", user2)
+ response.status.should == 401
+ json_response['message'].should == '401 Unauthorized'
end
end