diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-01-14 15:20:16 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-01-14 15:20:16 +0000 |
commit | 0eef82761fe3a100c4f22c7a1abea3a34dc76edf (patch) | |
tree | b68717b4dcf92243adef44ac26e8a027d58071a3 /spec/support | |
parent | 0430c00cf02cc62a376545ae7333a06f78913aca (diff) | |
parent | 1b08cd811abeed18c3601e1b997b0566a243662c (diff) | |
download | gitlab-ce-0eef82761fe3a100c4f22c7a1abea3a34dc76edf.tar.gz |
Merge branch 'add-pagination-headers-to-api' into 'master'
Add pagination headers to already paginated API resources
Following #3045, I've added pagination headers using already available Kaminari methods.
## Pagination headers in action
![Screen_Shot_2016-01-14_at_12.14.53](/uploads/88807f754dd9aafbb24da85f6bdf9521/Screen_Shot_2016-01-14_at_12.14.53.png)
---
I've also added a shared example to test paginated API resources.
A possible next step would be to paginate all the API resources that return an array.
See merge request !2426
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/api/pagination_shared_examples.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/support/api/pagination_shared_examples.rb b/spec/support/api/pagination_shared_examples.rb new file mode 100644 index 00000000000..352a6eeec79 --- /dev/null +++ b/spec/support/api/pagination_shared_examples.rb @@ -0,0 +1,20 @@ +# Specs for paginated resources. +# +# Requires an API request: +# let(:request) { get api("/projects/#{project.id}/repository/branches", user) } +shared_examples 'a paginated resources' do + before do + # Fires the request + request + end + + it 'has pagination headers' do + expect(response.headers).to include('X-Total') + expect(response.headers).to include('X-Total-Pages') + expect(response.headers).to include('X-Per-Page') + expect(response.headers).to include('X-Page') + expect(response.headers).to include('X-Next-Page') + expect(response.headers).to include('X-Prev-Page') + expect(response.headers).to include('Link') + end +end |