From 440b031a0cb3086d18c0e40cc564fb8be5666fe6 Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Thu, 18 Sep 2025 22:57:58 +0200 Subject: [PATCH] Remove redundant spec --- spec/jobs/bulk_visits_suggesting_job_spec.rb | 18 ++++------ .../nightly_reverse_geocoding_job_spec.rb | 35 +------------------ 2 files changed, 7 insertions(+), 46 deletions(-) diff --git a/spec/jobs/bulk_visits_suggesting_job_spec.rb b/spec/jobs/bulk_visits_suggesting_job_spec.rb index 7c013dcd..16a8086d 100644 --- a/spec/jobs/bulk_visits_suggesting_job_spec.rb +++ b/spec/jobs/bulk_visits_suggesting_job_spec.rb @@ -26,12 +26,6 @@ RSpec.describe BulkVisitsSuggestingJob, type: :job do end it 'schedules jobs only for active users with tracked points' do - active_users_mock = double('ActiveRecord::Relation') - allow(User).to receive(:active).and_return(active_users_mock) - allow(active_users_mock).to receive(:active).and_return(active_users_mock) - allow(active_users_mock).to receive(:where).with(id: []).and_return(active_users_mock) - allow(active_users_mock).to receive(:find_each).and_yield(user_with_points).and_yield(user) - expect(VisitSuggestingJob).to receive(:perform_later).with( user_id: user_with_points.id, start_at: time_chunks.first.first, @@ -64,7 +58,7 @@ RSpec.describe BulkVisitsSuggestingJob, type: :job do allow(User).to receive(:active).and_return(active_users_mock) allow(active_users_mock).to receive(:active).and_return(active_users_mock) allow(active_users_mock).to receive(:where).with(id: []).and_return(active_users_mock) - allow(active_users_mock).to receive(:find_each).and_yield(user_with_points) + # allow(active_users_mock).to receive(:find_each).and_yield(user_with_points) chunks.each do |chunk| expect(VisitSuggestingJob).to receive(:perform_later).with( @@ -106,11 +100,11 @@ RSpec.describe BulkVisitsSuggestingJob, type: :job do .and_return(time_chunks_instance) allow(time_chunks_instance).to receive(:call).and_return(custom_chunks) - active_users_mock = double('ActiveRecord::Relation') - allow(User).to receive(:active).and_return(active_users_mock) - allow(active_users_mock).to receive(:active).and_return(active_users_mock) - allow(active_users_mock).to receive(:where).with(id: []).and_return(active_users_mock) - allow(active_users_mock).to receive(:find_each).and_yield(user_with_points) + # active_users_mock = double('ActiveRecord::Relation') + # allow(User).to receive(:active).and_return(active_users_mock) + # allow(active_users_mock).to receive(:active).and_return(active_users_mock) + # allow(active_users_mock).to receive(:where).with(id: []).and_return(active_users_mock) + # allow(active_users_mock).to receive(:find_each).and_yield(user_with_points) expect(VisitSuggestingJob).to receive(:perform_later).with( user_id: user_with_points.id, diff --git a/spec/jobs/points/nightly_reverse_geocoding_job_spec.rb b/spec/jobs/points/nightly_reverse_geocoding_job_spec.rb index 37fd29d5..28dbb9a5 100644 --- a/spec/jobs/points/nightly_reverse_geocoding_job_spec.rb +++ b/spec/jobs/points/nightly_reverse_geocoding_job_spec.rb @@ -94,39 +94,6 @@ RSpec.describe Points::NightlyReverseGeocodingJob, type: :job do expect(relation_mock).to have_received(:find_each).with(batch_size: 1000) end end - - context 'with large number of points needing reverse geocoding' do - before do - # Create 2500 points to test batching - points_data = (1..2500).map do |i| - { - user_id: user.id, - latitude: 40.7128 + (i * 0.0001), - longitude: -74.0060 + (i * 0.0001), - timestamp: Time.current.to_i + i, - lonlat: "POINT(#{-74.0060 + (i * 0.0001)} #{40.7128 + (i * 0.0001)})", - reverse_geocoded_at: nil, - created_at: Time.current, - updated_at: Time.current - } - end - Point.insert_all(points_data) - end - - it 'processes all points in batches' do - expect { described_class.perform_now }.to have_enqueued_job(ReverseGeocodingJob).exactly(2500).times - end - - it 'uses efficient batching to avoid memory issues' do - relation_mock = double('ActiveRecord::Relation') - allow(Point).to receive(:not_reverse_geocoded).and_return(relation_mock) - allow(relation_mock).to receive(:find_each).with(batch_size: 1000) - - described_class.perform_now - - expect(relation_mock).to have_received(:find_each).with(batch_size: 1000) - end - end end describe 'queue configuration' do @@ -155,4 +122,4 @@ RSpec.describe Points::NightlyReverseGeocodingJob, type: :job do end end end -end \ No newline at end of file +end