diff options
author | Sean McGivern <sean@gitlab.com> | 2017-11-03 13:49:37 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2017-11-03 14:28:18 +0000 |
commit | 9d259c2232a7a6bab344b961ef8dc9561c380c29 (patch) | |
tree | c47b47d24eb4f3a378c99824b35f3a4d20c3ceb7 /spec/requests | |
parent | 8c01f3110c8d8601fc16b17850dfa778f1f3d877 (diff) | |
download | gitlab-ce-9d259c2232a7a6bab344b961ef8dc9561c380c29.tar.gz |
Add changes_count to the merge requests APIadd-changes-count-to-merge-requests-api
This returns the `real_size` of the MR's diff, which is a string indicating the
number of changes. If the diff overflows after _n_ files, the string will be
`$n+`.
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/merge_requests_spec.rb | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index 024cfe8b372..4bad14b4e75 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -435,17 +435,7 @@ describe API::MergeRequests do expect(json_response['merge_status']).to eq('can_be_merged') expect(json_response['should_close_merge_request']).to be_falsy expect(json_response['force_close_merge_request']).to be_falsy - end - - it "returns merge_request" do - get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user) - expect(response).to have_gitlab_http_status(200) - expect(json_response['title']).to eq(merge_request.title) - expect(json_response['iid']).to eq(merge_request.iid) - expect(json_response['work_in_progress']).to eq(false) - expect(json_response['merge_status']).to eq('can_be_merged') - expect(json_response['should_close_merge_request']).to be_falsy - expect(json_response['force_close_merge_request']).to be_falsy + expect(json_response['changes_count']).to eq(merge_request.merge_request_diff.real_size) end it "returns a 404 error if merge_request_iid not found" do @@ -462,12 +452,32 @@ describe API::MergeRequests do context 'Work in Progress' do let!(:merge_request_wip) { create(:merge_request, author: user, assignee: user, source_project: project, target_project: project, title: "WIP: Test", created_at: base_time + 1.second) } - it "returns merge_request" do + it "returns merge request" do get api("/projects/#{project.id}/merge_requests/#{merge_request_wip.iid}", user) + expect(response).to have_gitlab_http_status(200) expect(json_response['work_in_progress']).to eq(true) end end + + context 'when a merge request has more than the changes limit' do + it "returns a string indicating that more changes were made" do + stub_const('Commit::DIFF_HARD_LIMIT_FILES', 5) + + merge_request_overflow = create(:merge_request, :simple, + author: user, + assignee: user, + source_project: project, + source_branch: 'expand-collapse-files', + target_project: project, + target_branch: 'master') + + get api("/projects/#{project.id}/merge_requests/#{merge_request_overflow.iid}", user) + + expect(response).to have_gitlab_http_status(200) + expect(json_response['changes_count']).to eq('5+') + end + end end describe 'GET /projects/:id/merge_requests/:merge_request_iid/commits' do |