Include id attribute in slim points response

This commit is contained in:
Eugene Burmakin 2024-09-30 23:38:32 +02:00
parent ec793fe4aa
commit d2aa1e9381
4 changed files with 13 additions and 8 deletions

View file

@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Points imported from Google Location History (mobile devise) now have correct timestamps - Points imported from Google Location History (mobile devise) now have correct timestamps
### Changed
- `GET /api/v1/points?slim=true` now returns `id` attribute for each point
# [0.14.5] - 2024-09-28 # [0.14.5] - 2024-09-28
### Fixed ### Fixed

View file

@ -30,6 +30,6 @@ class Api::V1::PointsController < ApiController
private private
def point_serializer def point_serializer
params[:slim] ? SlimPointSerializer : PointSerializer params[:slim] == 'true' ? SlimPointSerializer : PointSerializer
end end
end end

View file

@ -7,7 +7,8 @@ class SlimPointSerializer
def call def call
{ {
latitude: point.latitude, id: point.id,
latitude: point.latitude,
longitude: point.longitude, longitude: point.longitude,
timestamp: point.timestamp timestamp: point.timestamp
} }

View file

@ -46,13 +46,13 @@ RSpec.describe 'Api::V1::Points', type: :request do
context 'when slim version of points is requested' do context 'when slim version of points is requested' do
it 'renders a successful response' do it 'renders a successful response' do
get api_v1_points_url(api_key: user.api_key, slim: true) get api_v1_points_url(api_key: user.api_key, slim: 'true')
expect(response).to be_successful expect(response).to be_successful
end end
it 'returns a list of points' do it 'returns a list of points' do
get api_v1_points_url(api_key: user.api_key, slim: true) get api_v1_points_url(api_key: user.api_key, slim: 'true')
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
@ -62,7 +62,7 @@ RSpec.describe 'Api::V1::Points', type: :request do
end end
it 'returns a list of points with pagination' do it 'returns a list of points with pagination' do
get api_v1_points_url(api_key: user.api_key, slim: true, page: 2, per_page: 10) get api_v1_points_url(api_key: user.api_key, slim: 'true', page: 2, per_page: 10)
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
@ -72,7 +72,7 @@ RSpec.describe 'Api::V1::Points', type: :request do
end end
it 'returns a list of points with pagination headers' do it 'returns a list of points with pagination headers' do
get api_v1_points_url(api_key: user.api_key, slim: true, page: 2, per_page: 10) get api_v1_points_url(api_key: user.api_key, slim: 'true', page: 2, per_page: 10)
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
@ -81,7 +81,7 @@ RSpec.describe 'Api::V1::Points', type: :request do
end end
it 'returns a list of points with slim attributes' do it 'returns a list of points with slim attributes' do
get api_v1_points_url(api_key: user.api_key, slim: true) get api_v1_points_url(api_key: user.api_key, slim: 'true')
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)