2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2016-04-17 11:32:06 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
|
|
describe ApplicationHelper, type: :helper do
|
2017-11-26 20:34:27 -08:00
|
|
|
let(:conference) { create(:full_conference) }
|
2016-04-22 18:18:46 +03:00
|
|
|
let(:event) { create(:event, program: conference.program) }
|
2017-11-26 20:34:27 -08:00
|
|
|
let(:sponsor) { create(:sponsor) }
|
2016-04-22 18:18:46 +03:00
|
|
|
|
2017-02-23 15:20:53 +05:30
|
|
|
describe '#date_string' do
|
|
|
|
|
it 'when conference lasts 1 day' do
|
|
|
|
|
expect(date_string('Sun, 19 Feb 2017'.to_time, 'Sun, 19 Feb 2017'.to_time)).to eq 'February 19 2017'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'when conference starts and ends in the same month and year' do
|
|
|
|
|
expect(date_string('Sun, 19 Feb 2017'.to_time, 'Tue, 28 Feb 2017'.to_time)).to eq 'February 19 - 28, 2017'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'when conference ends in another month, of the same year' do
|
|
|
|
|
expect(date_string('Sun, 19 Feb 2017'.to_time, 'Tue, 28 March 2017'.to_time)).to eq 'February 19 - March 28, 2017'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'when conference ends in another month, of a different year' do
|
|
|
|
|
expect(date_string('Sun, 19 Feb 2017'.to_time, 'Sun, 12 March 2018'.to_time)).to eq 'February 19, 2017 - March 12, 2018'
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2017-02-07 01:22:49 +05:30
|
|
|
describe '#concurrent_events' do
|
|
|
|
|
before :each do
|
|
|
|
|
@other_event = create(:event, program: conference.program, state: 'confirmed')
|
|
|
|
|
schedule = create(:schedule, program: conference.program)
|
2022-02-14 17:53:58 +01:00
|
|
|
conference.program.update_attribute(:selected_schedule, schedule)
|
2017-04-22 01:20:05 +05:30
|
|
|
@event_schedule = create(:event_schedule, event: event, start_time: conference.start_date + conference.start_hour.hours, room: create(:room), schedule: schedule)
|
|
|
|
|
@other_event_schedule = create(:event_schedule, event: @other_event, start_time: conference.start_date + conference.start_hour.hours, room: create(:room), schedule: schedule)
|
2017-02-07 01:22:49 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'does return correct concurrent events' do
|
|
|
|
|
it 'when events starts at the same time' do
|
2022-03-30 12:39:01 +02:00
|
|
|
expect(concurrent_events(event).include?(@other_event)).to be true
|
2017-02-07 01:22:49 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'when event is in between the other event' do
|
2022-02-14 17:53:58 +01:00
|
|
|
@event_schedule.update_attribute(:start_time, @other_event_schedule.start_time + 10.minutes)
|
2022-03-30 12:39:01 +02:00
|
|
|
expect(concurrent_events(event).include?(@other_event)).to be true
|
2017-02-07 01:22:49 +05:30
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2022-03-30 12:39:01 +02:00
|
|
|
describe 'does not return as concurrent event' do
|
2017-02-07 01:22:49 +05:30
|
|
|
it 'when event is not scheduled' do
|
|
|
|
|
@event_schedule.destroy
|
2022-03-30 12:39:01 +02:00
|
|
|
expect(concurrent_events(event).present?).to be false
|
2017-02-07 01:22:49 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'when one event starts and other ends at the same time' do
|
2022-02-14 17:53:58 +01:00
|
|
|
@event_schedule.update_attribute(:start_time, @other_event_schedule.end_time)
|
2022-03-30 12:39:01 +02:00
|
|
|
expect(concurrent_events(event).present?).to be false
|
2017-02-07 01:22:49 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'when conference program does not have a selected schedule' do
|
2022-02-14 17:53:58 +01:00
|
|
|
conference.program.update_attribute(:selected_schedule_id, nil)
|
2022-03-30 12:39:01 +02:00
|
|
|
expect(concurrent_events(event).present?).to be false
|
2017-02-07 01:22:49 +05:30
|
|
|
end
|
|
|
|
|
end
|
2017-11-07 13:51:10 -08:00
|
|
|
|
|
|
|
|
describe 'navigation title link' do
|
|
|
|
|
it 'should default to OSEM' do
|
|
|
|
|
ENV.delete('OSEM_NAME')
|
|
|
|
|
expect(nav_root_link_for(nil)).to match 'OSEM'
|
|
|
|
|
end
|
|
|
|
|
end
|
2017-02-07 01:22:49 +05:30
|
|
|
end
|
2017-11-26 20:34:27 -08:00
|
|
|
|
|
|
|
|
describe '#get_logo' do
|
|
|
|
|
context 'first sponsorship_level' do
|
|
|
|
|
before do
|
|
|
|
|
first_sponsorship_level = create(:sponsorship_level, position: 1)
|
2022-02-14 17:53:58 +01:00
|
|
|
sponsor.update_attribute(:sponsorship_level, first_sponsorship_level)
|
2017-11-26 20:34:27 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns correct url' do
|
|
|
|
|
expect(get_logo(sponsor)).to match %r{.*(\bfirst/#{sponsor.logo_file_name}\b)}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'second sponsorship_level' do
|
|
|
|
|
before do
|
|
|
|
|
second_sponsorship_level = create(:sponsorship_level, position: 2)
|
2022-02-14 17:53:58 +01:00
|
|
|
sponsor.update_attribute(:sponsorship_level, second_sponsorship_level)
|
2017-11-26 20:34:27 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns correct url' do
|
|
|
|
|
expect(get_logo(sponsor)).to match %r{.*(\bsecond/#{sponsor.logo_file_name}\b)}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'other sponsorship_level' do
|
|
|
|
|
before do
|
|
|
|
|
other_sponsorship_level = create(:sponsorship_level, position: 3)
|
2022-02-14 17:53:58 +01:00
|
|
|
sponsor.update_attribute(:sponsorship_level, other_sponsorship_level)
|
2017-11-26 20:34:27 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns correct url' do
|
|
|
|
|
expect(get_logo(sponsor)).to match %r{.*(\bothers/#{sponsor.logo_file_name}\b)}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'non-sponsor' do
|
|
|
|
|
it 'returns correct url' do
|
|
|
|
|
expect(get_logo(conference)).to match %r{.*(\blarge/#{conference.logo_file_name}\b)}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2016-04-17 11:32:06 +05:30
|
|
|
end
|