[fix] Fix style; Fix start_hour and end_hour in test

This commit is contained in:
Jimmy 2021-03-19 17:22:08 +08:00
parent 1c54d38094
commit 3019a022c7
3 changed files with 3 additions and 2 deletions

View file

@ -56,6 +56,7 @@ class EventSchedule < ApplicationRecord
#
def happening_now?(threshold = 30.minutes)
return false if end_time < Time.now
event_time_range = start_time..end_time
now_range = (Time.now - threshold)..(Time.now + threshold)
event_time_range.overlaps?(now_range)

View file

@ -12,7 +12,7 @@
%h3
This page was loaded at
= inyourtz(Time.now) do
#{Time.now.strftime('%a %b %d at %I:%M %P (%z)').to_s}
= Time.now.strftime('%a %b %d at %I:%M %P (%z)')
.row
/ TODO: Clean this up, merge with all events page.

View file

@ -30,7 +30,7 @@ describe SchedulesController do
describe 'GET #happening_now' do
before do
@conference2 = create(:full_conference, start_date: 1.day.ago, end_date: 7.days.from_now)
@conference2 = create(:full_conference, start_date: 1.day.ago, end_date: 7.days.from_now, start_hour: 0, end_hour: 24)
@program = @conference2.program
@selected_schedule = create(:schedule, program: @program)
@program.update_attributes!(selected_schedule: @selected_schedule)