aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2017-05-04 16:28:19 +0200
committerTeddy Wing2017-05-04 17:10:59 +0200
commitcdf9056747432473df79390ded435d474e5f2e69 (patch)
tree57048ce718f4e80e7fde94b6b5401082deb4568a
parent8978ffb9e346d35176371ef7d7879c8e41e96a97 (diff)
downloadchouette-core-cdf9056747432473df79390ded435d474e5f2e69.tar.bz2
vehicle_journey_spec.rb: #with_stops should sort empty journeys
Empty journeys, or vehicle journeys with an empty `vehicle_journey_at_stops` collection should be sorted at the end of the list. Refs #3268
-rw-r--r--spec/models/chouette/vehicle_journey_spec.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/models/chouette/vehicle_journey_spec.rb b/spec/models/chouette/vehicle_journey_spec.rb
index ace28bd70..e537721af 100644
--- a/spec/models/chouette/vehicle_journey_spec.rb
+++ b/spec/models/chouette/vehicle_journey_spec.rb
@@ -260,6 +260,31 @@ describe Chouette::VehicleJourney, :type => :model do
.to_a
).to eq(expected_journey_order)
end
+
+ it "orders journeys with nil times at the end" do
+ pattern = create(:journey_pattern)
+ journey_nil = build(
+ :vehicle_journey_common,
+ journey_pattern: pattern
+ )
+ journey_nil.route = journey_nil.journey_pattern.route
+ journey_nil.save
+ journey = create(
+ :vehicle_journey,
+ route: journey_nil.route,
+ journey_pattern: journey_nil.journey_pattern
+ )
+
+ expected_journey_order = [journey, journey_nil]
+
+ expect(
+ journey
+ .route
+ .vehicle_journeys
+ .with_stops
+ .to_a
+ ).to eq(expected_journey_order)
+ end
end
subject { create(:vehicle_journey_odd) }