From ceec2e53425f8a1c726f4903d03e268386cb598e Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 15 May 2018 15:24:29 +0200 Subject: CleanUp: Add `#destroy_empty` Gives us a single call site to trigger the destruction of vehicle journeys, journey patterns, and routes without content. This was previously done directly in the `#clean` method, but since it's not needed during referential duplication (only during merges), we don't want to enable it by default. Thus now to activate the same old functionality, you would create a `CleanUp` like this: CleanUp.new(methods: [:destroy_empty]) 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 f0c3a3233..f39ca2f2b 100644 --- a/spec/models/clean_up_spec.rb +++ b/spec/models/clean_up_spec.rb @@ -297,6 +297,18 @@ RSpec.describe CleanUp, :type => :model do end end + describe "#destroy_empty" do + it "calls the appropriate destroy methods" do + cleaner = create(:clean_up) + + expect(cleaner).to receive(:destroy_vehicle_journeys) + expect(cleaner).to receive(:destroy_journey_patterns) + expect(cleaner).to receive(:destroy_routes) + + cleaner.destroy_empty + end + end + describe "#run_methods" do let(:cleaner) { create(:clean_up) } -- cgit v1.2.3