Commit ab032256 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add some tests for merge API

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 5880d7df
......@@ -14,6 +14,7 @@ v 6.9.0
- Fix wiki backup skip bug
- Two Step MR creation process
- Remove unwanted files from satellite working directory with git clean -fdx
- Accept merge request via API (sponsored by O'Reilly Media)
v 6.8.0
- Ability to at mention users that are participating in issue and merge req. discussion
......
......@@ -34,7 +34,7 @@ module API
when "closed" then user_project.merge_requests.closed
when "merged" then user_project.merge_requests.merged
else user_project.merge_requests
end
end
present paginate(mrs), with: Entities::MergeRequest
end
......@@ -129,7 +129,7 @@ module API
:push_code
end
if can?(current_user, action, project)
if can?(current_user, action, user_project)
if merge_request.unchecked?
merge_request.check_if_can_be_merged
end
......
......@@ -183,11 +183,18 @@ 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
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