From a311325c828635a76ae1b53d02106b1446864f56 Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Mon, 20 Jan 2025 20:41:26 +0100 Subject: [PATCH] Fix failed tests --- app/jobs/points/create_job.rb | 14 ++------------ spec/services/points/params_spec.rb | 6 ++++-- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/app/jobs/points/create_job.rb b/app/jobs/points/create_job.rb index 148349fe..964c50f7 100644 --- a/app/jobs/points/create_job.rb +++ b/app/jobs/points/create_job.rb @@ -9,19 +9,9 @@ class Points::CreateJob < ApplicationJob data.each_slice(1000) do |location_batch| Point.upsert_all( location_batch, - unique_by: %i[latitude longitude timestamp user_id] + unique_by: %i[latitude longitude timestamp user_id], + returning: false ) end end - - private - - def point_exists?(params, user_id) - Point.exists?( - latitude: params[:latitude], - longitude: params[:longitude], - timestamp: params[:timestamp], - user_id: - ) - end end diff --git a/spec/services/points/params_spec.rb b/spec/services/points/params_spec.rb index 6fb3f486..62f9b82b 100644 --- a/spec/services/points/params_spec.rb +++ b/spec/services/points/params_spec.rb @@ -4,6 +4,7 @@ require 'rails_helper' RSpec.describe Points::Params do describe '#call' do + let(:user) { create(:user) } let(:file_path) { 'spec/fixtures/files/points/geojson_example.json' } let(:file) { File.open(file_path) } let(:json) { JSON.parse(file.read) } @@ -40,11 +41,12 @@ RSpec.describe Points::Params do timestamp: '2025-01-17T21:03:01Z', device_id: '8D5D4197-245B-4619-A88B-2049100ADE46' } - }.with_indifferent_access + }.with_indifferent_access, + user_id: user.id } end - subject(:params) { described_class.new(json).call } + subject(:params) { described_class.new(json, user.id).call } it 'returns an array of points' do expect(params).to be_an(Array)