From c048a5a7e5295b7a84d87ed4e850affe598d5588 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Mon, 14 May 2018 12:58:56 +0200 Subject: CleanUp#destroy_routes_outside_referential: Test cascade Ensure that `JourneyPattern`s and `VehicleJourney`s associated with orphaned routes get deleted in cascade. Refs #6854 --- spec/models/clean_up_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'spec/models/clean_up_spec.rb') diff --git a/spec/models/clean_up_spec.rb b/spec/models/clean_up_spec.rb index cf15ab934..be169abbb 100644 --- a/spec/models/clean_up_spec.rb +++ b/spec/models/clean_up_spec.rb @@ -283,5 +283,17 @@ RSpec.describe CleanUp, :type => :model do expect(route).not_to be_destroyed end end + + it "cascades destruction of vehicle journeys and journey patterns" do + vehicle_journey = create(:vehicle_journey) + + cleaner.destroy_routes_outside_referential + + expect(Chouette::Route.exists?(vehicle_journey.route.id)).to be false + expect( + Chouette::JourneyPattern.exists?(vehicle_journey.journey_pattern) + ).to be false + expect(Chouette::VehicleJourney.exists?(vehicle_journey)).to be false + end end end -- cgit v1.2.3