diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-28 09:10:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-28 09:10:35 +0300 |
commit | 787981be19177a149a901e873f199331ecb873d4 (patch) | |
tree | 163ab57eb1883827dd76a029fabb98a4d7b620c1 /spec/requests/api | |
parent | 583699499eb9f56c83563045fdd83f7ae896c082 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/api')
-rw-r--r-- | spec/requests/api/merge_requests_spec.rb | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index eea223485ce..18d3fdb2d50 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -1788,6 +1788,58 @@ RSpec.describe API::MergeRequests do end end + describe 'GET /projects/:id/merge_requests/:merge_request_iid/diffs' do + let_it_be(:merge_request) do + create( + :merge_request, + :simple, + author: user, + assignees: [user], + source_project: project, + target_project: project, + source_branch: 'markdown', + title: "Test", + created_at: base_time + ) + end + + it 'returns a 404 when merge_request_iid not found' do + get api("/projects/#{project.id}/merge_requests/0/diffs", user) + expect(response).to have_gitlab_http_status(:not_found) + end + + it 'returns a 404 when merge_request id is used instead of iid' do + get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/diffs", user) + + expect(response).to have_gitlab_http_status(:not_found) + end + + context 'when merge request author has only guest access' do + it_behaves_like 'rejects user from accessing merge request info' do + let(:url) { "/projects/#{project.id}/merge_requests/#{merge_request.iid}/diffs" } + end + end + + it 'returns the diffs of the merge_request' do + get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/diffs", user) + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response.size).to eq(merge_request.diffs.size) + end + + context 'when pagination params are present' do + it 'returns limited diffs' do + get( + api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/diffs", user), + params: { page: 1, per_page: 1 } + ) + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response.size).to eq(1) + end + end + end + describe 'GET /projects/:id/merge_requests/:merge_request_iid/pipelines' do let_it_be(:merge_request) { create(:merge_request, :simple, author: user, assignees: [user], source_project: project, target_project: project, source_branch: 'markdown', title: "Test", created_at: base_time) } |