diff options
| author | Zog | 2018-05-29 10:18:16 +0200 |
|---|---|---|
| committer | Johan Van Ryseghem | 2018-05-30 16:29:33 +0200 |
| commit | 3e8d95ac8168205ac9526fb8663459d691d09c30 (patch) | |
| tree | fd2bc220473f4defe30a35668d6b9eead76f00fa /app/models/chouette/journey_frequency.rb | |
| parent | 971b267958c3bf78abea332e0af4c46a23679b61 (diff) | |
| download | chouette-core-3e8d95ac8168205ac9526fb8663459d691d09c30.tar.bz2 | |
Refs #6433; Fix specs
Diffstat (limited to 'app/models/chouette/journey_frequency.rb')
| -rw-r--r-- | app/models/chouette/journey_frequency.rb | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/app/models/chouette/journey_frequency.rb b/app/models/chouette/journey_frequency.rb deleted file mode 100644 index 1b4efe96e..000000000 --- a/app/models/chouette/journey_frequency.rb +++ /dev/null @@ -1,35 +0,0 @@ -module Chouette - class JourneyFrequencyValidator < ActiveModel::Validator - def validate(record) - timeband = record.timeband - if timeband - first_departure_time = record.first_departure_time.utc.strftime( "%H%M%S%N" ) - last_departure_time = record.last_departure_time.utc.strftime( "%H%M%S%N" ) - timeband_start_time = timeband.start_time.utc.strftime( "%H%M%S%N" ) - timeband_end_time = timeband.end_time.utc.strftime( "%H%M%S%N" ) - - unless first_departure_time.between? timeband_start_time, timeband_end_time - record.errors[:first_departure_time] << I18n.t('activerecord.errors.models.journey_frequency.start_must_be_after_timeband') - end - unless last_departure_time.between? timeband_start_time, timeband_end_time - record.errors[:last_departure_time] << I18n.t('activerecord.errors.models.journey_frequency.end_must_be_before_timeband') - end - end - if record.first_departure_time == record.last_departure_time - record.errors[:last_departure_time] << I18n.t('activerecord.errors.models.journey_frequency.end_must_be_different_from_first') - end - if record.scheduled_headway_interval.blank? || (record.scheduled_headway_interval.strftime( "%H%M%S%N" ) == Time.current.midnight.strftime( "%H%M%S%N" )) - record.errors[:scheduled_headway_interval] << I18n.t('activerecord.errors.models.journey_frequency.scheduled_headway_interval_greater_than_zero') - end - end - end - - class JourneyFrequency < ActiveRecord - belongs_to :vehicle_journey_frequency, foreign_key: 'vehicle_journey_id' - belongs_to :timeband - validates :first_departure_time, presence: true - validates :last_departure_time, presence: true - validates :scheduled_headway_interval, presence: true - validates_with Chouette::JourneyFrequencyValidator - end -end
\ No newline at end of file |
