Merge branch 'add-pagination-commit-diffs' into 'master'

Add missing pagination on the commit diff endpoint

Closes #43370

See merge request gitlab-org/gitlab-ce!17203
This commit is contained in:
Robert Speicher 2018-02-21 16:51:10 +00:00
commit 94ac29f66d
3 changed files with 10 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
title: Add missing pagination on the commit diff endpoint
merge_request: 17203
author: Maxime Roussin-Bélanger
type: fixed

View file

@ -97,13 +97,16 @@ module API
end
params do
requires :sha, type: String, desc: 'A commit sha, or the name of a branch or tag'
use :pagination
end
get ':id/repository/commits/:sha/diff', requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
commit = user_project.commit(params[:sha])
not_found! 'Commit' unless commit
present commit.raw_diffs.to_a, with: Entities::Diff
raw_diffs = ::Kaminari.paginate_array(commit.raw_diffs.to_a)
present paginate(raw_diffs), with: Entities::Diff
end
desc "Get a commit's comments" do

View file

@ -698,6 +698,7 @@ describe API::Commits do
get api(route, current_user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response.size).to be >= 1
expect(json_response.first.keys).to include 'diff'
end