mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-13 02:31:39 -05:00
Add basic test for Geojson::ImportParser
This commit is contained in:
parent
8bb6a9afb5
commit
1ae3f4ad96
5 changed files with 28 additions and 3 deletions
2
spec/fixtures/files/geojson/export.json
vendored
2
spec/fixtures/files/geojson/export.json
vendored
File diff suppressed because one or more lines are too long
1
spec/fixtures/files/geojson/export_same_points.json
vendored
Normal file
1
spec/fixtures/files/geojson/export_same_points.json
vendored
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -16,7 +16,8 @@ RSpec.describe Import, type: :model do
|
|||
google_records: 2,
|
||||
google_phone_takeout: 3,
|
||||
gpx: 4,
|
||||
immich_api: 5
|
||||
immich_api: 5,
|
||||
geojson: 6
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ RSpec.describe Exports::Create do
|
|||
it 'writes the data to a file' do
|
||||
create_export
|
||||
|
||||
file_path = Rails.root.join('spec/fixtures/files/geojson/export.json')
|
||||
file_path = Rails.root.join('spec/fixtures/files/geojson/export_same_points.json')
|
||||
|
||||
expect(File.read(file_path)).to eq(export_content)
|
||||
end
|
||||
|
|
|
|||
23
spec/services/geojson/import_parser_spec.rb
Normal file
23
spec/services/geojson/import_parser_spec.rb
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Geojson::ImportParser do
|
||||
describe '#call' do
|
||||
subject(:service) { described_class.new(import, user.id).call }
|
||||
|
||||
let(:user) { create(:user) }
|
||||
|
||||
let(:user) { create(:user) }
|
||||
|
||||
context 'when file content is an object' do
|
||||
let(:file_path) { Rails.root.join('spec/fixtures/files/geojson/export.json') }
|
||||
let(:raw_data) { JSON.parse(File.read(file_path)) }
|
||||
let(:import) { create(:import, user:, name: 'geojson.json', raw_data:) }
|
||||
|
||||
it 'creates new points' do
|
||||
expect { service }.to change { Point.count }.by(10)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue