mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Merge 11e7c27759 into e267adf8b7
This commit is contained in:
commit
95a4508f64
2 changed files with 12 additions and 1 deletions
|
|
@ -22,9 +22,13 @@ class EventType < ApplicationRecord
|
|||
|
||||
##
|
||||
# Check if length is a divisor of program schedule cell size. Used as validation.
|
||||
# Skipped when length is missing or non-numeric so that the numericality
|
||||
# validator can produce a proper error instead of crashing.
|
||||
#
|
||||
def length_step
|
||||
errors.add(:length, "must be a divisor of #{program.schedule_interval}") if program && length % program.schedule_interval != 0
|
||||
return unless program && length.is_a?(Numeric)
|
||||
|
||||
errors.add(:length, "must be a divisor of #{program.schedule_interval}") if length % program.schedule_interval != 0
|
||||
end
|
||||
|
||||
def capitalize_color
|
||||
|
|
|
|||
|
|
@ -44,6 +44,13 @@ describe EventType do
|
|||
it 'is not valid when length is not multiple of LENGTH_STEP' do
|
||||
expect(build(:event_type, program: conference.program, length: 37)).not_to be_valid
|
||||
end
|
||||
|
||||
it 'is not valid when length is blank and does not raise during validation' do
|
||||
event_type = build(:event_type, program: conference.program, length: nil)
|
||||
expect { event_type.valid? }.not_to raise_error
|
||||
expect(event_type).not_to be_valid
|
||||
expect(event_type.errors[:length]).to be_present
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue