diff options
| author | Teddy Wing | 2017-07-17 17:59:34 +0200 |
|---|---|---|
| committer | Teddy Wing | 2017-07-21 15:59:53 +0200 |
| commit | 161f3184783ba3419238d3ce6b2291ef9fabfa01 (patch) | |
| tree | dc7e42217b3b4052fc98331568316d4e0543abdd /spec | |
| parent | ac03cfc3b24c49b952a31f84cf7063a9cd68acc4 (diff) | |
| download | chouette-core-161f3184783ba3419238d3ce6b2291ef9fabfa01.tar.bz2 | |
VehicleJourneyAtStop: Add error message to max day offset error
Add a custom error message for when the day offset exceeds our maximum.
Unfortunately, this uses Rails 5 lambda syntax, so it doesn't work. Will
need to extract it to a method, but figured I'd just commit this anyway
for posterity.
The French error message text was taken from the Redmine issue, authored
by Luc. I translated it into English.
Refs #3597
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 |
