From f87cd94cb5b2369b463b642fe965a501aae0b69b Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Wed, 4 Jun 2014 23:55:02 +0530 Subject: [PATCH] Added method registration_dates_given? --- app/models/conference.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/models/conference.rb b/app/models/conference.rb index 7f13cdd2..c8019aca 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -102,11 +102,25 @@ class Conference < ActiveRecord::Base # * +true+ -> If today is in the registration period. def registration_open? today = Date.current - if self.registration_start_date.blank? || self.registration_end_date.blank? + if registration_dates_given? + (registration_start_date..registration_end_date).cover?(today) + else false end + end - (registration_start_date..registration_end_date).cover?(today) + ## + # Checks if the registration dates for the conference are provided + # + # ====Returns + # * +false+ -> If the conference registration dates are not set + # * +true+ -> If conference registration dates are set + def registration_dates_given? + if self.registration_start_date.blank? || self.registration_end_date.blank? + false + else + true + end end ##