Add basic test for Geojson::ImportParser

This commit is contained in:
Eugene Burmakin 2024-09-02 22:42:29 +02:00
parent 8bb6a9afb5
commit 1ae3f4ad96
5 changed files with 28 additions and 3 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -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

View file

@ -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

View 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