diff options
author | Rémy Coutable <remy@rymai.me> | 2016-01-14 12:08:44 +0100 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-01-14 12:10:27 +0100 |
commit | 3183092ca94b14d6e61f5e8ba51069554646baf8 (patch) | |
tree | 05e7d558cbf946710db76f1597e05e1ff9100904 /spec | |
parent | 9f8c38bdac3d6f532b50ecab1d769652ffb5acc3 (diff) | |
download | gitlab-ce-3183092ca94b14d6e61f5e8ba51069554646baf8.tar.gz |
Add pagination headers to already paginated API resourcesadd-pagination-headers-to-api
Diffstat (limited to 'spec')
-rw-r--r-- | spec/requests/api/commit_status_spec.rb | 6 | ||||
-rw-r--r-- | spec/requests/api/notes_spec.rb | 4 | ||||
-rw-r--r-- | spec/support/api/pagination_shared_examples.rb | 20 |
3 files changed, 29 insertions, 1 deletions
diff --git a/spec/requests/api/commit_status_spec.rb b/spec/requests/api/commit_status_spec.rb index a28607bd240..21482fc1070 100644 --- a/spec/requests/api/commit_status_spec.rb +++ b/spec/requests/api/commit_status_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe API::API, api: true do +describe API::CommitStatus, api: true do include ApiHelpers let(:user) { create(:user) } let(:user2) { create(:user) } @@ -12,6 +12,10 @@ describe API::API, api: true do let(:commit_status) { create(:commit_status, commit: ci_commit) } describe "GET /projects/:id/repository/commits/:sha/statuses" do + it_behaves_like 'a paginated resources' do + let(:request) { get api("/projects/#{project.id}/repository/commits/#{commit.id}/statuses", user) } + end + context "reporter user" do let(:statuses_id) { json_response.map { |status| status['id'] } } diff --git a/spec/requests/api/notes_spec.rb b/spec/requests/api/notes_spec.rb index d8bbd107269..39f9a06fe1b 100644 --- a/spec/requests/api/notes_spec.rb +++ b/spec/requests/api/notes_spec.rb @@ -32,6 +32,10 @@ describe API::API, api: true do before { project.team << [user, :reporter] } describe "GET /projects/:id/noteable/:noteable_id/notes" do + it_behaves_like 'a paginated resources' do + let(:request) { get api("/projects/#{project.id}/issues/#{issue.id}/notes", user) } + end + context "when noteable is an Issue" do it "should return an array of issue notes" do get api("/projects/#{project.id}/issues/#{issue.id}/notes", user) 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 |