mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Fixes Start date being greater than End date
This commit is contained in:
parent
24f0625be1
commit
4eafa43f7e
2 changed files with 18 additions and 0 deletions
|
|
@ -95,6 +95,9 @@ class Conference < ActiveRecord::Base
|
||||||
|
|
||||||
validates_uniqueness_of :short_title
|
validates_uniqueness_of :short_title
|
||||||
validates_format_of :short_title, with: /\A[a-zA-Z0-9_-]*\z/
|
validates_format_of :short_title, with: /\A[a-zA-Z0-9_-]*\z/
|
||||||
|
|
||||||
|
# This validation is needed since a conference with a start date greater than the end date is not possible
|
||||||
|
validate :valid_date_range?
|
||||||
before_create :generate_guid
|
before_create :generate_guid
|
||||||
before_create :create_event_types
|
before_create :create_event_types
|
||||||
before_create :create_difficulty_levels
|
before_create :create_difficulty_levels
|
||||||
|
|
@ -583,6 +586,14 @@ class Conference < ActiveRecord::Base
|
||||||
self.create_contact
|
self.create_contact
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Checks if start date of the conference is greater than the end date
|
||||||
|
#
|
||||||
|
# Reports an error when such a condition is found
|
||||||
|
def valid_date_range?
|
||||||
|
errors.add(:start_date, "Start date is greater than End date") if start_date > end_date
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Calculates the weeks from a start and a end week.
|
# Calculates the weeks from a start and a end week.
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -1516,6 +1516,13 @@ describe Conference do
|
||||||
should_not allow_value('&%§!?äÄüÜ/()').for(:short_title)
|
should_not allow_value('&%§!?äÄüÜ/()').for(:short_title)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'valid_date_range?' do
|
||||||
|
|
||||||
|
it 'is not valid if start date is greater than end date' do
|
||||||
|
expect(subject.start_date).to be <= subject.end_date
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'before create callbacks' do
|
describe 'before create callbacks' do
|
||||||
|
|
||||||
it 'has an email setting after creation' do
|
it 'has an email setting after creation' do
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue