[test]Add test for ConferenceHelper#get_happening_next_events_schedules
This commit is contained in:
parent
612af49ca0
commit
648f3bacb5
2 changed files with 35 additions and 1 deletions
|
|
@ -99,4 +99,38 @@ describe ConferenceHelper, type: :helper do
|
||||||
expect(conference_color(conference2)).to eq('#0B3559')
|
expect(conference_color(conference2)).to eq('#0B3559')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#get_happening_next_events_schedules' do
|
||||||
|
let!(:conference2) { create(:full_conference, start_date: 1.day.ago, end_date: 7.days.from_now, start_hour: 0, end_hour: 24) }
|
||||||
|
let!(:program) { conference2.program }
|
||||||
|
let!(:selected_schedule) { create(:schedule, program: program) }
|
||||||
|
let!(:scheduled_event1) do
|
||||||
|
program.update_attributes!(selected_schedule: selected_schedule)
|
||||||
|
create(:event, program: program, state: 'confirmed', abstract: '`markdown`')
|
||||||
|
end
|
||||||
|
let!(:event_schedule1) { create(:event_schedule, event: scheduled_event1, schedule: selected_schedule, start_time: (Time.now.in_time_zone(conference2.timezone) + 1.hour).strftime('%a, %d %b %Y %H:%M:%S')) }
|
||||||
|
let!(:scheduled_event2) do
|
||||||
|
program.update_attributes!(selected_schedule: selected_schedule)
|
||||||
|
create(:event, program: program, state: 'confirmed')
|
||||||
|
end
|
||||||
|
let!(:event_schedule2) { create(:event_schedule, event: scheduled_event2, schedule: selected_schedule, start_time: (Time.now.in_time_zone(conference2.timezone) + 1.hour).strftime('%a, %d %b %Y %H:%M:%S')) }
|
||||||
|
let!(:scheduled_event3) do
|
||||||
|
program.update_attributes!(selected_schedule: selected_schedule)
|
||||||
|
create(:event, program: program, state: 'confirmed')
|
||||||
|
end
|
||||||
|
let!(:event_schedule3) { create(:event_schedule, event: scheduled_event3, schedule: selected_schedule, start_time: (Time.now.in_time_zone(conference2.timezone) - 1.hour).strftime('%a, %d %b %Y %H:%M:%S')) }
|
||||||
|
let!(:scheduled_event4) do
|
||||||
|
program.update_attributes!(selected_schedule: selected_schedule)
|
||||||
|
create(:event, program: program, state: 'confirmed')
|
||||||
|
end
|
||||||
|
let!(:event_schedule4) { create(:event_schedule, event: scheduled_event4, schedule: selected_schedule, start_time: (Time.now.in_time_zone(conference2.timezone) + 2.hours).strftime('%a, %d %b %Y %H:%M:%S')) }
|
||||||
|
|
||||||
|
it 'returns all the events happening at the earliest time in the future but not later or in the past' do
|
||||||
|
events_schedules = get_happening_next_events_schedules(conference2)
|
||||||
|
expect(events_schedules).to include(event_schedule1)
|
||||||
|
expect(events_schedules).to include(event_schedule2)
|
||||||
|
expect(events_schedules).to_not include(event_schedule3)
|
||||||
|
expect(events_schedules).to_not include(event_schedule4)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,7 @@ describe EventSchedule do
|
||||||
create(:event, program: program, state: 'confirmed')
|
create(:event, program: program, state: 'confirmed')
|
||||||
end
|
end
|
||||||
let!(:event_schedule3) { create(:event_schedule, event: scheduled_event3, schedule: selected_schedule, start_time: (Time.now.in_time_zone(conference2.timezone) - 1.hour).strftime('%a, %d %b %Y %H:%M:%S')) }
|
let!(:event_schedule3) { create(:event_schedule, event: scheduled_event3, schedule: selected_schedule, start_time: (Time.now.in_time_zone(conference2.timezone) - 1.hour).strftime('%a, %d %b %Y %H:%M:%S')) }
|
||||||
|
|
||||||
it 'returns true if the event is happening in the future' do
|
it 'returns true if the event is happening in the future' do
|
||||||
expect(event_schedule1.happening_later?).to be true
|
expect(event_schedule1.happening_later?).to be true
|
||||||
expect(event_schedule2.happening_later?).to be true
|
expect(event_schedule2.happening_later?).to be true
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue