mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 01:31:39 -05:00
Add a test for GoogleMaps::RecordsParser
This commit is contained in:
parent
2d26418337
commit
17b1980ceb
1 changed files with 29 additions and 0 deletions
|
|
@ -4,5 +4,34 @@ require 'rails_helper'
|
|||
|
||||
RSpec.describe GoogleMaps::RecordsParser do
|
||||
describe '#call' do
|
||||
subject(:parser) { described_class.new(import).call(json) }
|
||||
|
||||
let(:import) { create(:import) }
|
||||
let(:json) do
|
||||
{
|
||||
'latitudeE7' => 123_456_789,
|
||||
'longitudeE7' => 123_456_789,
|
||||
'timestamp' => Time.zone.now.to_s,
|
||||
'altitude' => 0,
|
||||
'velocity' => 0
|
||||
}
|
||||
end
|
||||
|
||||
it 'creates a point' do
|
||||
expect { parser }.to change(Point, :count).by(1)
|
||||
end
|
||||
|
||||
context 'when point already exists' do
|
||||
before do
|
||||
create(
|
||||
:point, user: import.user, import:, latitude: 12.3456789, longitude: 12.3456789,
|
||||
timestamp: Time.zone.now.to_i
|
||||
)
|
||||
end
|
||||
|
||||
it 'does not create a point' do
|
||||
expect { parser }.not_to change(Point, :count)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue