diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/models/chouette/vehicle_journey_at_stop_spec.rb | 21 |
1 files changed, 21 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 index f0b34d77a..82b0783a6 100644 --- a/spec/models/chouette/vehicle_journey_at_stop_spec.rb +++ b/spec/models/chouette/vehicle_journey_at_stop_spec.rb @@ -12,4 +12,25 @@ RSpec.describe Chouette::VehicleJourneyAtStop, type: :model do .is_greater_than_or_equal_to(0) .is_less_than_or_equal_to(Chouette::VehicleJourneyAtStop::DAY_OFFSET_MAX) end + + describe "#validate" do + it "displays the proper error message when day offset exceeds the max" do + bad_offset = Chouette::VehicleJourneyAtStop::DAY_OFFSET_MAX + 1 + + at_stop = build_stubbed( + :vehicle_journey_at_stop, + arrival_day_offset: bad_offset, + departure_day_offset: bad_offset + ) + + at_stop.validate + + expect(at_stop.errors[:arrival_day_offset]).to include( + I18n.t('vehicle_journey_at_stops.errors.day_offset_must_not_exceed_max') + ) + expect(at_stop.errors[:departure_day_offset]).to include( + I18n.t('vehicle_journey_at_stops.errors.day_offset_must_not_exceed_max') + ) + end + end end |
