Added test for RootRouteConstraint and conferences#current
This commit is contained in:
parent
529b8eb710
commit
ee7684d845
5 changed files with 60 additions and 5 deletions
|
|
@ -1,10 +1,19 @@
|
|||
class RootRouteConstraint
|
||||
def initialize
|
||||
@current = Conference.where('end_date >= ?', Date.current).reorder(start_date: :asc)
|
||||
@current = Conference.where('start_date <= ? AND end_date >= ?', Date.current, Date.current).reorder(start_date: :asc)
|
||||
end
|
||||
|
||||
##
|
||||
# Checks if only one conference is live and has a public splashpage
|
||||
# If any conference is live it checks how many live conferences are there
|
||||
# ====Returns
|
||||
# * +true+ -> only one conferene is live AND the conference has public splashpage
|
||||
# * +false+ -> no or more than one conferences are live or the only live conferece has no public splashpage
|
||||
def matches?(*)
|
||||
return unless @current.present? && @current.first.splashpage.present?
|
||||
@current.count == 1 && @current.first.splashpage.public?
|
||||
if @current.present? && @current.first.splashpage.present?
|
||||
@current.count == 1 && @current.first.splashpage.public?
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue