Commit a654e92b authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch '7816-commits-diff-total-api' into 'master'

Show correct total number of commit diff's changes

See merge request gitlab-org/gitlab!19424
parents fd86f88d 4a3a5fe6
---
title: Show correct total number of commit diff's changes
merge_request: 19424
author:
type: fixed
......@@ -169,7 +169,7 @@ module API
not_found! 'Commit' unless commit
raw_diffs = ::Kaminari.paginate_array(commit.raw_diffs.to_a)
raw_diffs = ::Kaminari.paginate_array(commit.diffs(expanded: true).diffs.to_a)
present paginate(raw_diffs), with: Entities::Diff
end
......
......@@ -1089,6 +1089,20 @@ describe API::Commits do
expect(json_response.first.keys).to include 'diff'
end
context 'when hard limits are lower than the number of files' do
before do
allow(Commit).to receive(:max_diff_options).and_return(max_files: 1)
end
it 'respects the limit' 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
end
end
context 'when ref does not exist' do
let(:commit_id) { 'unknown' }
......
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