diff options
author | Sean McGivern <sean@gitlab.com> | 2019-08-06 19:27:46 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-08-08 19:10:41 +0300 |
commit | e6dc5168b86d613e3334fa55618e394308bf55bf (patch) | |
tree | 6ad67848dfbe81949474e20f5224edf055c273cb /spec/requests/api/group_labels_spec.rb | |
parent | 26087322713e2949f2bf207798512374757a484c (diff) |
Remove label issue and MR counts from default API responses
These counts significantly increase the load time for these
requests. Users can now opt in to receiving the counts by setting
`with_counts=true` in requests. This is a breaking change, but hopefully
a fairly minor one.
Diffstat (limited to 'spec/requests/api/group_labels_spec.rb')
-rw-r--r-- | spec/requests/api/group_labels_spec.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/spec/requests/api/group_labels_spec.rb b/spec/requests/api/group_labels_spec.rb index fcea57d9df7..0be4e2e9121 100644 --- a/spec/requests/api/group_labels_spec.rb +++ b/spec/requests/api/group_labels_spec.rb @@ -14,12 +14,25 @@ describe API::GroupLabels do get api("/groups/#{group.id}/labels", user) expect(response).to have_gitlab_http_status(200) - expect(response).to match_response_schema('public_api/v4/group_labels') expect(response).to include_pagination_headers expect(json_response).to be_an Array + expect(json_response).to all(match_schema('public_api/v4/labels/label')) expect(json_response.size).to eq(2) expect(json_response.map {|r| r['name'] }).to contain_exactly('feature', 'bug') end + + context 'when the with_counts parameter is set' do + it 'includes counts in the response' do + get api("/groups/#{group.id}/labels", user), params: { with_counts: true } + + expect(response).to have_gitlab_http_status(200) + expect(response).to include_pagination_headers + expect(json_response).to be_an Array + expect(json_response).to all(match_schema('public_api/v4/labels/label_with_counts')) + expect(json_response.size).to eq(2) + expect(json_response.map { |r| r['open_issues_count'] }).to contain_exactly(0, 0) + end + end end describe 'POST /groups/:id/labels' do |