From 0dafea8685f0376d4c474f7670a97d0b8e449767 Mon Sep 17 00:00:00 2001 From: Maxime Roussin-Belanger Date: Sun, 18 Feb 2018 22:17:23 -0500 Subject: Add missing pagination on the commit diff endpoint --- .../unreleased/17203-add-missing-pagination-commit-diff-endpoint.yml | 5 +++++ lib/api/commits.rb | 5 ++++- spec/requests/api/commits_spec.rb | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/17203-add-missing-pagination-commit-diff-endpoint.yml diff --git a/changelogs/unreleased/17203-add-missing-pagination-commit-diff-endpoint.yml b/changelogs/unreleased/17203-add-missing-pagination-commit-diff-endpoint.yml new file mode 100644 index 00000000000..efd936ca104 --- /dev/null +++ b/changelogs/unreleased/17203-add-missing-pagination-commit-diff-endpoint.yml @@ -0,0 +1,5 @@ +--- + title: Add missing pagination on the commit diff endpoint + merge_request: 17203 + author: Maxime Roussin-BĂ©langer + type: fixed diff --git a/lib/api/commits.rb b/lib/api/commits.rb index d83c43ee49b..3d6e78d2d80 100644 --- a/lib/api/commits.rb +++ b/lib/api/commits.rb @@ -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 diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb index 31959d28fee..ad3eec88952 100644 --- a/spec/requests/api/commits_spec.rb +++ b/spec/requests/api/commits_spec.rb @@ -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 -- cgit v1.2.3