-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pagination to the /api/v1/points endpoint
- Loading branch information
Showing
4 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.11.0 | ||
0.11.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe 'Api::V1::Points', type: :request do | ||
let!(:user) { create(:user) } | ||
let!(:points) { create_list(:point, 150, user:) } | ||
|
||
describe 'GET /index' do | ||
it 'renders a successful response' do | ||
get api_v1_points_url(api_key: user.api_key) | ||
|
||
expect(response).to be_successful | ||
end | ||
|
||
it 'returns a list of points' do | ||
get api_v1_points_url(api_key: user.api_key) | ||
|
||
expect(response).to have_http_status(:ok) | ||
|
||
json_response = JSON.parse(response.body) | ||
|
||
expect(json_response.size).to eq(100) | ||
end | ||
|
||
it 'returns a list of points with pagination' do | ||
get api_v1_points_url(api_key: user.api_key, page: 2, per_page: 10) | ||
|
||
expect(response).to have_http_status(:ok) | ||
|
||
json_response = JSON.parse(response.body) | ||
|
||
expect(json_response.size).to eq(10) | ||
end | ||
end | ||
end |