aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorTeddy Wing2017-07-17 12:03:32 +0200
committerTeddy Wing2017-07-21 15:59:53 +0200
commitac03cfc3b24c49b952a31f84cf7063a9cd68acc4 (patch)
treea0ed3dcf29bd376ceb06c4f6251a11b6de9c8e1c /spec
parent92d1abd1ef31a357260b5cb629dfed9559dd53fb (diff)
downloadchouette-core-ac03cfc3b24c49b952a31f84cf7063a9cd68acc4.tar.bz2
VehicleJourneyAtStop: Validate day offsets are not greater than 1 day
We want to ensure day offsets can only be used to make at-stops for the current day and the next day. Any more days are declared to be invalid. For now, with bus and rail modes of transportation, we don't plan on having journeys that extend beyond a day after the initial departure. Also prevent setting negative day offsets while we're at it because it goes in the same validation block and we should allow have those. Refs #3597
Diffstat (limited to 'spec')
-rw-r--r--spec/models/chouette/vehicle_journey_at_stop_spec.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/models/chouette/vehicle_journey_at_stop_spec.rb b/spec/models/chouette/vehicle_journey_at_stop_spec.rb
new file mode 100644
index 000000000..f0b34d77a
--- /dev/null
+++ b/spec/models/chouette/vehicle_journey_at_stop_spec.rb
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+RSpec.describe Chouette::VehicleJourneyAtStop, type: :model do
+ it do
+ should validate_numericality_of(:arrival_day_offset)
+ .is_greater_than_or_equal_to(0)
+ .is_less_than_or_equal_to(Chouette::VehicleJourneyAtStop::DAY_OFFSET_MAX)
+ end
+
+ it do
+ should validate_numericality_of(:departure_day_offset)
+ .is_greater_than_or_equal_to(0)
+ .is_less_than_or_equal_to(Chouette::VehicleJourneyAtStop::DAY_OFFSET_MAX)
+ end
+end