2024-08-12 16:18:11 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2024-08-05 15:23:08 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
|
|
RSpec.describe VisitSuggestingJob, type: :job do
|
2025-01-09 08:47:21 -05:00
|
|
|
let!(:users) { [create(:user)] }
|
2024-08-12 16:18:11 -04:00
|
|
|
|
2025-01-09 08:47:21 -05:00
|
|
|
describe '#perform' do
|
2024-08-12 16:18:11 -04:00
|
|
|
subject { described_class.perform_now }
|
|
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
allow(Visits::Suggest).to receive(:new).and_call_original
|
|
|
|
|
allow_any_instance_of(Visits::Suggest).to receive(:call)
|
|
|
|
|
end
|
|
|
|
|
|
2025-01-09 08:47:21 -05:00
|
|
|
context 'when user has no tracked points' do
|
|
|
|
|
it 'does not suggest visits' do
|
|
|
|
|
subject
|
|
|
|
|
|
|
|
|
|
expect(Visits::Suggest).not_to have_received(:new)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'when user has tracked points' do
|
|
|
|
|
let!(:tracked_point) { create(:point, user: users.first) }
|
|
|
|
|
|
|
|
|
|
it 'suggests visits' do
|
|
|
|
|
subject
|
2024-08-12 16:18:11 -04:00
|
|
|
|
2025-01-09 08:47:21 -05:00
|
|
|
expect(Visits::Suggest).to have_received(:new)
|
|
|
|
|
end
|
2024-08-12 16:18:11 -04:00
|
|
|
end
|
|
|
|
|
end
|
2024-08-05 15:23:08 -04:00
|
|
|
end
|