From fafa152b58bcfd50f4b1b9e2524c0c359ad2b648 Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Sat, 6 Dec 2025 12:13:22 +0100 Subject: [PATCH] Fix specs --- app/controllers/api/v1/settings_controller.rb | 2 +- spec/serializers/api/point_serializer_spec.rb | 1 + spec/services/users/export_data_spec.rb | 2 +- .../api/v1/settings_controller_spec.rb | 56 +++++++++++++++---- swagger/v1/swagger.yaml | 45 +++++++++++---- 5 files changed, 82 insertions(+), 24 deletions(-) diff --git a/app/controllers/api/v1/settings_controller.rb b/app/controllers/api/v1/settings_controller.rb index 650d0d50..f06a04fe 100644 --- a/app/controllers/api/v1/settings_controller.rb +++ b/app/controllers/api/v1/settings_controller.rb @@ -14,7 +14,7 @@ class Api::V1::SettingsController < ApiController settings_params.each { |key, value| current_api_user.settings[key] = value } if current_api_user.save - render json: { message: 'Settings updated', settings: current_api_user.settings, status: 'success' }, + render json: { message: 'Settings updated', settings: current_api_user.safe_settings.config, status: 'success' }, status: :ok else render json: { message: 'Something went wrong', errors: current_api_user.errors.full_messages }, diff --git a/spec/serializers/api/point_serializer_spec.rb b/spec/serializers/api/point_serializer_spec.rb index d897ed92..16f83bd6 100644 --- a/spec/serializers/api/point_serializer_spec.rb +++ b/spec/serializers/api/point_serializer_spec.rb @@ -12,6 +12,7 @@ RSpec.describe Api::PointSerializer do point.attributes.except(*all_excluded).tap do |attributes| attributes['latitude'] = point.lat.to_s attributes['longitude'] = point.lon.to_s + attributes['country_name'] = point.country_name end end diff --git a/spec/services/users/export_data_spec.rb b/spec/services/users/export_data_spec.rb index 0953192d..a8dfa98d 100644 --- a/spec/services/users/export_data_spec.rb +++ b/spec/services/users/export_data_spec.rb @@ -100,7 +100,7 @@ RSpec.describe Users::ExportData, type: :service do expect(Users::ExportData::Trips).to receive(:new).with(user) expect(Users::ExportData::Stats).to receive(:new).with(user) expect(Users::ExportData::Notifications).to receive(:new).with(user) - expect(Users::ExportData::Points).to receive(:new).with(user) + expect(Users::ExportData::Points).to receive(:new).with(user, an_instance_of(StringIO)) expect(Users::ExportData::Visits).to receive(:new).with(user) expect(Users::ExportData::Places).to receive(:new).with(user) diff --git a/spec/swagger/api/v1/settings_controller_spec.rb b/spec/swagger/api/v1/settings_controller_spec.rb index 0f440b51..b5dfc137 100644 --- a/spec/swagger/api/v1/settings_controller_spec.rb +++ b/spec/swagger/api/v1/settings_controller_spec.rb @@ -137,27 +137,42 @@ describe 'Settings API', type: :request do description: 'Route opacity percentage (0-100)' }, meters_between_routes: { - type: :number, + oneOf: [ + { type: :number }, + { type: :string } + ], example: 500, description: 'Minimum distance between routes in meters' }, minutes_between_routes: { - type: :number, + oneOf: [ + { type: :number }, + { type: :string } + ], example: 30, description: 'Minimum time between routes in minutes' }, fog_of_war_meters: { - type: :number, + oneOf: [ + { type: :number }, + { type: :string } + ], example: 50, description: 'Fog of war radius in meters' }, time_threshold_minutes: { - type: :number, + oneOf: [ + { type: :number }, + { type: :string } + ], example: 30, description: 'Time threshold for grouping points in minutes' }, merge_threshold_minutes: { - type: :number, + oneOf: [ + { type: :number }, + { type: :string } + ], example: 15, description: 'Threshold for merging nearby points in minutes' }, @@ -182,32 +197,51 @@ describe 'Settings API', type: :request do description: 'Whether live map updates are enabled' }, immich_url: { - type: :string, + oneOf: [ + { type: :string }, + { type: :null } + ], example: 'https://immich.example.com', description: 'Immich server URL for photo integration' }, immich_api_key: { - type: :string, + oneOf: [ + { type: :string }, + { type: :null } + ], example: 'your-immich-api-key', description: 'API key for Immich photo service' }, photoprism_url: { - type: :string, + oneOf: [ + { type: :string }, + { type: :null } + ], example: 'https://photoprism.example.com', description: 'PhotoPrism server URL for photo integration' }, photoprism_api_key: { - type: :string, + oneOf: [ + { type: :string }, + { type: :null } + ], example: 'your-photoprism-api-key', description: 'API key for PhotoPrism photo service' }, speed_color_scale: { - type: :string, + oneOf: [ + { type: :string }, + { type: :null } + ], example: 'viridis', description: 'Color scale for speed-colored routes' }, fog_of_war_threshold: { - type: :number, + oneOf: [ + { type: :number }, + { type: :string }, + { type: :null } + ], example: 100, description: 'Fog of war threshold value' } diff --git a/swagger/v1/swagger.yaml b/swagger/v1/swagger.yaml index a59dffbf..a16602d6 100644 --- a/swagger/v1/swagger.yaml +++ b/swagger/v1/swagger.yaml @@ -1456,23 +1456,33 @@ paths: example: 60 description: Route opacity percentage (0-100) meters_between_routes: - type: number + oneOf: + - type: number + - type: string example: 500 description: Minimum distance between routes in meters minutes_between_routes: - type: number + oneOf: + - type: number + - type: string example: 30 description: Minimum time between routes in minutes fog_of_war_meters: - type: number + oneOf: + - type: number + - type: string example: 50 description: Fog of war radius in meters time_threshold_minutes: - type: number + oneOf: + - type: number + - type: string example: 30 description: Time threshold for grouping points in minutes merge_threshold_minutes: - type: number + oneOf: + - type: number + - type: string example: 15 description: Threshold for merging nearby points in minutes preferred_map_layer: @@ -1493,27 +1503,40 @@ paths: example: true description: Whether live map updates are enabled immich_url: - type: string + oneOf: + - type: string + - type: 'null' example: https://immich.example.com description: Immich server URL for photo integration immich_api_key: - type: string + oneOf: + - type: string + - type: 'null' example: your-immich-api-key description: API key for Immich photo service photoprism_url: - type: string + oneOf: + - type: string + - type: 'null' example: https://photoprism.example.com description: PhotoPrism server URL for photo integration photoprism_api_key: - type: string + oneOf: + - type: string + - type: 'null' example: your-photoprism-api-key description: API key for PhotoPrism photo service speed_color_scale: - type: string + oneOf: + - type: string + - type: 'null' example: viridis description: Color scale for speed-colored routes fog_of_war_threshold: - type: number + oneOf: + - type: number + - type: string + - type: 'null' example: 100 description: Fog of war threshold value "/api/v1/stats":