2024-09-02 15:56:48 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
|
|
RSpec.describe PointSerializer do
|
|
|
|
|
describe '#call' do
|
|
|
|
|
subject(:serializer) { described_class.new(point).call }
|
|
|
|
|
|
|
|
|
|
let(:point) { create(:point) }
|
|
|
|
|
let(:expected_json) do
|
2025-02-21 18:32:30 -05:00
|
|
|
{
|
|
|
|
|
'battery_status' => point.battery_status,
|
|
|
|
|
'ping' => point.ping,
|
|
|
|
|
'battery' => point.battery,
|
|
|
|
|
'tracker_id' => point.tracker_id,
|
|
|
|
|
'topic' => point.topic,
|
|
|
|
|
'altitude' => point.altitude,
|
2025-02-22 17:14:23 -05:00
|
|
|
'longitude' => point.lon.to_s,
|
2025-02-21 18:32:30 -05:00
|
|
|
'velocity' => point.velocity,
|
|
|
|
|
'trigger' => point.trigger,
|
|
|
|
|
'bssid' => point.bssid,
|
|
|
|
|
'ssid' => point.ssid,
|
|
|
|
|
'connection' => point.connection,
|
|
|
|
|
'vertical_accuracy' => point.vertical_accuracy,
|
|
|
|
|
'accuracy' => point.accuracy,
|
|
|
|
|
'timestamp' => point.timestamp,
|
2025-02-22 17:14:23 -05:00
|
|
|
'latitude' => point.lat.to_s,
|
2025-02-21 18:32:30 -05:00
|
|
|
'mode' => point.mode,
|
|
|
|
|
'inrids' => point.inrids,
|
|
|
|
|
'in_regions' => point.in_regions,
|
|
|
|
|
'city' => point.city,
|
2025-07-12 07:43:15 -04:00
|
|
|
'country' => point.read_attribute(:country),
|
2025-02-21 18:32:30 -05:00
|
|
|
'geodata' => point.geodata,
|
|
|
|
|
'course' => point.course,
|
|
|
|
|
'course_accuracy' => point.course_accuracy,
|
2025-07-04 14:55:05 -04:00
|
|
|
'external_track_id' => point.external_track_id,
|
2025-07-29 14:14:24 -04:00
|
|
|
'track_id' => point.track_id,
|
2025-12-14 06:05:59 -05:00
|
|
|
'country_name' => point.read_attribute(:country_name),
|
|
|
|
|
'raw_data_archived' => point.raw_data_archived,
|
|
|
|
|
'raw_data_archive_id' => point.raw_data_archive_id
|
2025-02-21 18:32:30 -05:00
|
|
|
}
|
2024-09-02 15:56:48 -04:00
|
|
|
end
|
|
|
|
|
|
2025-02-21 18:32:30 -05:00
|
|
|
it 'returns JSON with correct attributes' do
|
2024-09-02 15:56:48 -04:00
|
|
|
expect(serializer.to_json).to eq(expected_json.to_json)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|