aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorTeddy Wing2017-07-17 18:28:21 +0200
committerTeddy Wing2017-07-21 15:59:53 +0200
commitdca839c6b1d55413d613a02ad8e8d98b688b3155 (patch)
treec6eded086a18345e17c207a5f421f595d4b65079 /app
parent0166ef93691416b687091c4ff0aa6fb308a449e2 (diff)
downloadchouette-core-dca839c6b1d55413d613a02ad8e8d98b688b3155.tar.bz2
VehicleJourneyAtStop: Add new specs for day offset validation
Replace our numericality validation tests with an equivalent set of tests since we're now using a custom validation function. Move `#outside_range` into the class scope so we can test it. Ignoring model validation tests and hooking into this method as the "real" important validator. Refs #3597
Diffstat (limited to 'app')
-rw-r--r--app/models/chouette/vehicle_journey_at_stop.rb13
1 files changed, 7 insertions, 6 deletions
diff --git a/app/models/chouette/vehicle_journey_at_stop.rb b/app/models/chouette/vehicle_journey_at_stop.rb
index 6e719fc61..1cb1c4767 100644
--- a/app/models/chouette/vehicle_journey_at_stop.rb
+++ b/app/models/chouette/vehicle_journey_at_stop.rb
@@ -35,10 +35,6 @@ module Chouette
end
def day_offset_must_be_within_range
- def outside_range(offset)
- offset < 0 || offset > DAY_OFFSET_MAX
- end
-
def error_message
I18n.t(
'vehicle_journey_at_stops.errors.day_offset_must_not_exceed_max',
@@ -47,14 +43,19 @@ module Chouette
)
end
- if outside_range(arrival_day_offset)
+ if day_offset_outside_range?(arrival_day_offset)
errors.add(:arrival_day_offset, error_message)
end
- if outside_range(departure_day_offset)
+ if day_offset_outside_range?(departure_day_offset)
errors.add(:departure_day_offset, error_message)
end
end
+ def day_offset_outside_range?(offset)
+ offset < 0 || offset > DAY_OFFSET_MAX
+ end
+
+
end
end