aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorTeddy Wing2017-07-17 18:19:23 +0200
committerTeddy Wing2017-07-21 15:59:53 +0200
commit0166ef93691416b687091c4ff0aa6fb308a449e2 (patch)
treea020939742335e0df4809afd1aa5fedfba0d0d23 /spec
parent161f3184783ba3419238d3ce6b2291ef9fabfa01 (diff)
downloadchouette-core-0166ef93691416b687091c4ff0aa6fb308a449e2.tar.bz2
VehicleJourneyAtStop: Add validation messages to day offset validator
Since we can't use the lambda syntax when passing a message to a validator, write a custom validation method that allows us to be more flexible when setting a message. The correct message with the correct data is now used for the offset error. This eliminates our validation of `numberiality`, making our two validation specs no longer valid. Refs #3597
Diffstat (limited to 'spec')
-rw-r--r--spec/models/chouette/vehicle_journey_at_stop_spec.rb13
1 files changed, 7 insertions, 6 deletions
diff --git a/spec/models/chouette/vehicle_journey_at_stop_spec.rb b/spec/models/chouette/vehicle_journey_at_stop_spec.rb
index 82b0783a6..23f33fc8f 100644
--- a/spec/models/chouette/vehicle_journey_at_stop_spec.rb
+++ b/spec/models/chouette/vehicle_journey_at_stop_spec.rb
@@ -22,15 +22,16 @@ RSpec.describe Chouette::VehicleJourneyAtStop, type: :model do
arrival_day_offset: bad_offset,
departure_day_offset: bad_offset
)
+ error_message = I18n.t(
+ 'vehicle_journey_at_stops.errors.day_offset_must_not_exceed_max',
+ local_id: at_stop.vehicle_journey.objectid.local_id,
+ max: 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')
- )
+ expect(at_stop.errors[:arrival_day_offset]).to include(error_message)
+ expect(at_stop.errors[:departure_day_offset]).to include(error_message)
end
end
end