mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
Include id attribute in slim points response
This commit is contained in:
parent
ec793fe4aa
commit
d2aa1e9381
4 changed files with 13 additions and 8 deletions
|
|
@ -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
|
||||
|
||||
### Changed
|
||||
|
||||
- `GET /api/v1/points?slim=true` now returns `id` attribute for each point
|
||||
|
||||
# [0.14.5] - 2024-09-28
|
||||
|
||||
### Fixed
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class Api::V1::PointsController < ApiController
|
|||
.order(:timestamp)
|
||||
.page(params[:page])
|
||||
.per(params[:per_page] || 100)
|
||||
|
||||
|
||||
serialized_points = points.map { |point| point_serializer.new(point).call }
|
||||
|
||||
response.set_header('X-Current-Page', points.current_page.to_s)
|
||||
|
|
@ -30,6 +30,6 @@ class Api::V1::PointsController < ApiController
|
|||
private
|
||||
|
||||
def point_serializer
|
||||
params[:slim] ? SlimPointSerializer : PointSerializer
|
||||
params[:slim] == 'true' ? SlimPointSerializer : PointSerializer
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ class SlimPointSerializer
|
|||
|
||||
def call
|
||||
{
|
||||
latitude: point.latitude,
|
||||
id: point.id,
|
||||
latitude: point.latitude,
|
||||
longitude: point.longitude,
|
||||
timestamp: point.timestamp
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,13 +46,13 @@ RSpec.describe 'Api::V1::Points', type: :request do
|
|||
|
||||
context 'when slim version of points is requested' 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
|
||||
end
|
||||
|
||||
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)
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ RSpec.describe 'Api::V1::Points', type: :request do
|
|||
end
|
||||
|
||||
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)
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ RSpec.describe 'Api::V1::Points', type: :request do
|
|||
end
|
||||
|
||||
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)
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ RSpec.describe 'Api::V1::Points', type: :request do
|
|||
end
|
||||
|
||||
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)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue