From 3d63b29651fdd0b8e1c563bbdda5beda3ef765d7 Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Sat, 27 Jul 2024 13:57:01 +0200 Subject: [PATCH] Ensure that the service does not create duplicate visits --- spec/services/areas/visits/create_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/services/areas/visits/create_spec.rb b/spec/services/areas/visits/create_spec.rb index 655993c6..28d4aa48 100644 --- a/spec/services/areas/visits/create_spec.rb +++ b/spec/services/areas/visits/create_spec.rb @@ -96,6 +96,14 @@ RSpec.describe Areas::Visits::Create do expect(work_visit.points).to match_array([work_point1, work_point2, work_point3]) end end + + context 'running twice' do + it 'does not create duplicate visits' do + create_visits + + expect { create_visits }.not_to(change { Visit.count }) + end + end end end end