dawarich/spec/swagger/api/v1/settings_controller_spec.rb

227 lines
8.2 KiB
Ruby
Raw Normal View History

2024-08-28 14:24:35 -04:00
# frozen_string_literal: true
require 'swagger_helper'
describe 'Settings API', type: :request do
path '/api/v1/settings' do
patch 'Updates user settings' do
request_body_example value: {
'settings': {
2025-07-02 17:50:32 -04:00
'route_opacity': 60,
'meters_between_routes': 500,
'minutes_between_routes': 30,
'fog_of_war_meters': 50,
'time_threshold_minutes': 30,
'merge_threshold_minutes': 15,
'preferred_map_layer': 'OpenStreetMap',
'speed_colored_routes': false,
'points_rendering_mode': 'raw',
'live_map_enabled': true,
'immich_url': 'https://immich.example.com',
'immich_api_key': 'your-immich-api-key',
'photoprism_url': 'https://photoprism.example.com',
'photoprism_api_key': 'your-photoprism-api-key',
'speed_color_scale': 'viridis',
'fog_of_war_threshold': 100
2024-08-28 14:24:35 -04:00
}
}
tags 'Settings'
consumes 'application/json'
parameter name: :settings, in: :body, schema: {
type: :object,
properties: {
2025-02-07 13:17:28 -05:00
route_opacity: {
type: :number,
2025-07-02 17:50:32 -04:00
example: 60,
description: 'Route opacity percentage (0-100)'
2025-02-07 13:17:28 -05:00
},
meters_between_routes: {
type: :number,
2025-07-02 17:50:32 -04:00
example: 500,
description: 'Minimum distance between routes in meters'
2025-02-07 13:17:28 -05:00
},
minutes_between_routes: {
type: :number,
2025-07-02 17:50:32 -04:00
example: 30,
description: 'Minimum time between routes in minutes'
2025-02-07 13:17:28 -05:00
},
fog_of_war_meters: {
type: :number,
2025-07-02 17:50:32 -04:00
example: 50,
description: 'Fog of war radius in meters'
},
time_threshold_minutes: {
type: :number,
example: 30,
description: 'Time threshold for grouping points in minutes'
},
merge_threshold_minutes: {
type: :number,
example: 15,
description: 'Threshold for merging nearby points in minutes'
},
preferred_map_layer: {
type: :string,
example: 'OpenStreetMap',
description: 'Preferred map layer/tile provider'
},
speed_colored_routes: {
type: :boolean,
example: false,
description: 'Whether to color routes based on speed'
},
points_rendering_mode: {
type: :string,
example: 'raw',
description: 'How to render points on the map (raw, heatmap, etc.)'
},
live_map_enabled: {
type: :boolean,
example: true,
description: 'Whether live map updates are enabled'
},
immich_url: {
type: :string,
example: 'https://immich.example.com',
description: 'Immich server URL for photo integration'
},
immich_api_key: {
type: :string,
example: 'your-immich-api-key',
description: 'API key for Immich photo service'
},
photoprism_url: {
type: :string,
example: 'https://photoprism.example.com',
description: 'PhotoPrism server URL for photo integration'
},
photoprism_api_key: {
type: :string,
example: 'your-photoprism-api-key',
description: 'API key for PhotoPrism photo service'
},
speed_color_scale: {
type: :string,
example: 'viridis',
description: 'Color scale for speed-colored routes'
2025-07-02 17:50:32 -04:00
},
fog_of_war_threshold: {
type: :number,
example: 100,
description: 'Fog of war threshold value'
2025-02-07 13:17:28 -05:00
}
2025-07-02 17:50:32 -04:00
}
2024-08-28 14:24:35 -04:00
}
parameter name: :api_key, in: :query, type: :string, required: true, description: 'API Key'
response '200', 'settings updated' do
2025-07-02 17:50:32 -04:00
let(:settings) { { settings: { route_opacity: 60 } } }
2024-08-28 14:24:35 -04:00
let(:api_key) { create(:user).api_key }
run_test!
end
end
get 'Retrieves user settings' do
tags 'Settings'
produces 'application/json'
parameter name: :api_key, in: :query, type: :string, required: true, description: 'API Key'
response '200', 'settings found' do
schema type: :object,
properties: {
settings: {
type: :object,
properties: {
2025-02-07 13:17:28 -05:00
route_opacity: {
type: :number,
example: 60,
2025-07-02 17:50:32 -04:00
description: 'Route opacity percentage (0-100)'
2025-02-07 13:17:28 -05:00
},
meters_between_routes: {
type: :number,
example: 500,
2025-07-02 17:50:32 -04:00
description: 'Minimum distance between routes in meters'
2025-02-07 13:17:28 -05:00
},
minutes_between_routes: {
type: :number,
example: 30,
2025-07-02 17:50:32 -04:00
description: 'Minimum time between routes in minutes'
2025-02-07 13:17:28 -05:00
},
fog_of_war_meters: {
type: :number,
example: 50,
2025-07-02 17:50:32 -04:00
description: 'Fog of war radius in meters'
},
time_threshold_minutes: {
type: :number,
example: 30,
2025-07-02 17:50:32 -04:00
description: 'Time threshold for grouping points in minutes'
},
merge_threshold_minutes: {
type: :number,
example: 15,
2025-07-02 17:50:32 -04:00
description: 'Threshold for merging nearby points in minutes'
},
preferred_map_layer: {
type: :string,
example: 'OpenStreetMap',
description: 'Preferred map layer/tile provider'
},
speed_colored_routes: {
type: :boolean,
example: false,
description: 'Whether to color routes based on speed'
},
points_rendering_mode: {
type: :string,
example: 'raw',
description: 'How to render points on the map (raw, heatmap, etc.)'
},
live_map_enabled: {
type: :boolean,
example: true,
description: 'Whether live map updates are enabled'
},
immich_url: {
type: :string,
example: 'https://immich.example.com',
description: 'Immich server URL for photo integration'
},
immich_api_key: {
type: :string,
example: 'your-immich-api-key',
description: 'API key for Immich photo service'
},
photoprism_url: {
type: :string,
example: 'https://photoprism.example.com',
description: 'PhotoPrism server URL for photo integration'
},
photoprism_api_key: {
type: :string,
example: 'your-photoprism-api-key',
description: 'API key for PhotoPrism photo service'
},
speed_color_scale: {
type: :string,
example: 'viridis',
description: 'Color scale for speed-colored routes'
2025-07-02 17:50:32 -04:00
},
fog_of_war_threshold: {
type: :number,
example: 100,
description: 'Fog of war threshold value'
2025-02-07 13:17:28 -05:00
}
2025-07-02 17:50:32 -04:00
}
2024-08-28 14:24:35 -04:00
}
}
let(:user) { create(:user) }
let(:settings) { { settings: user.settings } }
let(:api_key) { user.api_key }
run_test!
end
end
end
end