aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorTeddy Wing2017-05-12 17:32:09 +0200
committerTeddy Wing2017-05-12 17:56:27 +0200
commitb11e7d792b2c3743ca95f7a2d6d5c7bdc4a39105 (patch)
treed987caa2f0034922e1a8a0ac5207492f93ee5273 /spec
parent7bf94bc6e6ce6558252252e68419e89a23213573 (diff)
downloadchouette-core-b11e7d792b2c3743ca95f7a2d6d5c7bdc4a39105.tar.bz2
VehicleJourneysController: When filtering departure_time allow nil stops
There's a `params[:q][:vehicle_journey_without_departure_time]` parameter coming in from the frontend that's supposed to allow it to decide whether or not to include vehicle journeys that have nil stops. Allow this parameter to function for the `VehicleJourney.where_departure_time_between` method by conditionally checking an input parameter to determine whether to add the "OR" condition onto the "WHERE" filter. Refs #3370
Diffstat (limited to 'spec')
-rw-r--r--spec/models/chouette/vehicle_journey_spec.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/models/chouette/vehicle_journey_spec.rb b/spec/models/chouette/vehicle_journey_spec.rb
index caa4af203..7f2305134 100644
--- a/spec/models/chouette/vehicle_journey_spec.rb
+++ b/spec/models/chouette/vehicle_journey_spec.rb
@@ -346,6 +346,23 @@ describe Chouette::VehicleJourney, :type => :model do
.to_a
).to eq([journey_middle])
end
+
+ it "can include vehicle journeys that have nil stops" do
+ journey = create(:vehicle_journey_empty)
+ route = journey.route
+
+ expect(route
+ .vehicle_journeys
+ .select('DISTINCT "vehicle_journeys".*')
+ .joins('
+ LEFT JOIN "vehicle_journey_at_stops"
+ ON "vehicle_journey_at_stops"."vehicle_journey_id" =
+ "vehicle_journeys"."id"
+ ')
+ .where_departure_time_between('02:30', '03:30', allow_empty: true)
+ .to_a
+ ).to eq([journey])
+ end
end
subject { create(:vehicle_journey_odd) }