diff options
| -rw-r--r-- | app/models/chouette/vehicle_journey.rb | 11 | ||||
| -rw-r--r-- | spec/models/chouette/vehicle_journey_spec.rb | 19 |
2 files changed, 28 insertions, 2 deletions
diff --git a/app/models/chouette/vehicle_journey.rb b/app/models/chouette/vehicle_journey.rb index 19299d098..bc2713973 100644 --- a/app/models/chouette/vehicle_journey.rb +++ b/app/models/chouette/vehicle_journey.rb @@ -23,7 +23,10 @@ module Chouette validates_presence_of :route validates_presence_of :journey_pattern - validates :vehicle_journey_at_stops, :vjas_departure_time_must_be_before_next_stop_arrival_time, + validates :vehicle_journey_at_stops, + # Validation temporarily removed for day offsets + # :vjas_departure_time_must_be_before_next_stop_arrival_time, + vehicle_journey_at_stops_are_in_increasing_time_order: true validates_presence_of :number @@ -34,6 +37,12 @@ module Chouette before_validation :set_default_values, :calculate_vehicle_journey_at_stop_day_offset + # TODO: Remove this validator + # We've eliminated this validation because it prevented vehicle journeys + # from being saved with at-stops having a day offset greater than 0, + # because these would have times that were "earlier" than the previous + # at-stop. TBD by Luc whether we're deleting this validation altogether or + # instead rejiggering it to work with day offsets. def vjas_departure_time_must_be_before_next_stop_arrival_time notice = 'departure time must be before next stop arrival time' vehicle_journey_at_stops.each_with_index do |current_stop, index| diff --git a/spec/models/chouette/vehicle_journey_spec.rb b/spec/models/chouette/vehicle_journey_spec.rb index c495becac..645513735 100644 --- a/spec/models/chouette/vehicle_journey_spec.rb +++ b/spec/models/chouette/vehicle_journey_spec.rb @@ -1,7 +1,24 @@ require 'spec_helper' describe Chouette::VehicleJourney, :type => :model do - describe "vjas_departure_time_must_be_before_next_stop_arrival_time" do + it "must be valid with an at-stop day offset of 1" do + vehicle_journey = create( + :vehicle_journey, + stop_arrival_time: '23:00:00', + stop_departure_time: '23:00:00' + ) + vehicle_journey.vehicle_journey_at_stops.last.update( + arrival_time: '00:30:00', + departure_time: '00:30:00', + arrival_day_offset: 1, + departure_day_offset: 1 + ) + + expect(vehicle_journey).to be_valid + end + + describe "vjas_departure_time_must_be_before_next_stop_arrival_time", + skip: "Validation currently commented out because it interferes with day offsets" do let(:vehicle_journey) { create :vehicle_journey } let(:vjas) { vehicle_journey.vehicle_journey_at_stops } |
