2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2014-08-30 12:08:24 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
|
|
feature Splashpage do
|
|
|
|
|
|
|
|
|
|
# It is necessary to use bang version of let to build roles before user
|
|
|
|
|
let!(:conference) { create(:conference) }
|
2019-03-13 10:31:42 +01:00
|
|
|
let!(:organizer) { create(:organizer, resource: conference) }
|
2015-01-12 23:13:10 +02:00
|
|
|
let!(:participant) { create(:user, biography: '', is_admin: false) }
|
2014-08-30 12:08:24 +02:00
|
|
|
|
|
|
|
|
scenario 'create a valid splashpage', js: true do
|
|
|
|
|
sign_in organizer
|
|
|
|
|
visit admin_conference_splashpage_path(conference.short_title)
|
|
|
|
|
|
|
|
|
|
click_link 'Create Splashpage'
|
2017-12-21 19:06:36 -08:00
|
|
|
click_button 'Save Changes'
|
2018-10-25 16:16:56 -07:00
|
|
|
page.find('#flash')
|
2014-08-30 12:08:24 +02:00
|
|
|
expect(flash).to eq('Splashpage successfully created.')
|
|
|
|
|
expect(current_path).to eq(admin_conference_splashpage_path(conference.short_title))
|
2018-08-06 11:02:00 -05:00
|
|
|
expect(page.has_text?('Private')).to be true
|
2014-08-30 12:08:24 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'splashpage already created' do
|
|
|
|
|
let!(:splashpage) { create(:splashpage, conference: conference, public: false)}
|
|
|
|
|
|
|
|
|
|
scenario 'update a valid splashpage', js: true do
|
|
|
|
|
sign_in organizer
|
|
|
|
|
visit admin_conference_splashpage_path(conference.short_title)
|
|
|
|
|
|
|
|
|
|
click_link 'Edit'
|
2014-11-18 00:58:43 +01:00
|
|
|
check('Make splash page public')
|
2017-12-21 19:06:36 -08:00
|
|
|
click_button 'Save Changes'
|
2018-10-25 16:16:56 -07:00
|
|
|
page.find('#flash')
|
2014-08-30 12:08:24 +02:00
|
|
|
expect(flash).to eq('Splashpage successfully updated.')
|
|
|
|
|
expect(current_path).to eq(admin_conference_splashpage_path(conference.short_title))
|
2018-08-06 11:02:00 -05:00
|
|
|
expect(page.has_text?('Public')).to be true
|
2014-08-30 12:08:24 +02:00
|
|
|
|
2014-11-18 00:58:43 +01:00
|
|
|
click_link 'Edit'
|
|
|
|
|
expect(page.has_checked_field?('Make splash page public?')).to be true
|
2014-08-30 12:08:24 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
scenario 'delete the splashpage', js: true do
|
|
|
|
|
sign_in organizer
|
|
|
|
|
visit admin_conference_splashpage_path(conference.short_title)
|
|
|
|
|
click_link 'Delete'
|
2018-10-25 16:16:56 -07:00
|
|
|
page.accept_alert
|
|
|
|
|
page.find('#flash')
|
2014-08-30 12:08:24 +02:00
|
|
|
expect(current_path).to eq(admin_conference_splashpage_path(conference.short_title))
|
|
|
|
|
expect(flash).to eq('Splashpage was successfully destroyed.')
|
|
|
|
|
expect(Splashpage.count).to eq(0)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
scenario 'splashpage is accessible for organizers if it is not public' do
|
|
|
|
|
sign_in organizer
|
|
|
|
|
visit conference_path(conference.short_title)
|
|
|
|
|
expect(current_path).to eq(conference_path(conference.short_title))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
scenario 'splashpage is not accessible for participants if it is not public' do
|
|
|
|
|
sign_in participant
|
|
|
|
|
visit conference_path(conference.short_title)
|
2018-10-25 16:16:56 -07:00
|
|
|
page.find('#flash')
|
2014-08-30 12:08:24 +02:00
|
|
|
expect(flash).to eq('You are not authorized to access this page.')
|
|
|
|
|
expect(current_path).to eq(root_path)
|
|
|
|
|
end
|
|
|
|
|
end
|
2017-07-13 04:02:13 +05:30
|
|
|
|
2017-11-07 13:51:10 -08:00
|
|
|
context 'navigation' do
|
2017-07-13 04:02:13 +05:30
|
|
|
let!(:splashpage) { create(:splashpage, conference: conference, public: true)}
|
|
|
|
|
|
2017-11-07 13:51:10 -08:00
|
|
|
context 'multiple organizations' do
|
|
|
|
|
let!(:additional_organization) { create(:organization) }
|
|
|
|
|
|
2021-02-23 21:51:11 -08:00
|
|
|
scenario 'should have organization logo', feature: true, js: true do
|
2017-11-07 13:51:10 -08:00
|
|
|
sign_in participant
|
|
|
|
|
visit conference_path(conference.short_title)
|
2017-07-13 04:02:13 +05:30
|
|
|
|
2021-02-23 21:51:11 -08:00
|
|
|
expect(find('.navbar-brand img')['alt']).to have_content conference.organization.name
|
2017-11-07 13:51:10 -08:00
|
|
|
end
|
2017-07-13 04:02:13 +05:30
|
|
|
end
|
|
|
|
|
end
|
2021-04-19 14:24:54 +08:00
|
|
|
|
|
|
|
|
context 'happening now section is turned on' 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!(:splashpage) { create(:splashpage, conference: conference2, public: true)}
|
|
|
|
|
|
|
|
|
|
let!(:scheduled_event1) do
|
|
|
|
|
program.update_attributes!(selected_schedule: selected_schedule)
|
|
|
|
|
create(:event, program: program, state: 'confirmed', abstract: '`markdown`')
|
|
|
|
|
end
|
|
|
|
|
let!(:scheduled_event2) do
|
|
|
|
|
program.update_attributes!(selected_schedule: selected_schedule)
|
|
|
|
|
create(:event, program: program, state: 'confirmed')
|
|
|
|
|
end
|
|
|
|
|
let!(:scheduled_event3) do
|
|
|
|
|
program.update_attributes!(selected_schedule: selected_schedule)
|
|
|
|
|
create(:event, program: program, state: 'confirmed')
|
|
|
|
|
end
|
|
|
|
|
let!(:scheduled_event4) do
|
|
|
|
|
program.update_attributes!(selected_schedule: selected_schedule)
|
|
|
|
|
create(:event, program: program, state: 'confirmed')
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
before :each do
|
|
|
|
|
sign_in participant
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'displays \'There are no events happening now and next.\' if nothing is happening now and next' do
|
|
|
|
|
visit conference_path(conference2.short_title)
|
|
|
|
|
happening_now = page.find('#happening-now')
|
|
|
|
|
expect(happening_now).to have_content('There are no events happening now and next.')
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'shows all events happening next if nothing is happening now' do
|
|
|
|
|
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'))
|
|
|
|
|
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'))
|
|
|
|
|
visit conference_path(conference2.short_title)
|
|
|
|
|
happening_now = page.find('#happening-now')
|
|
|
|
|
expect(happening_now).to have_content(event_schedule1.event.title)
|
|
|
|
|
expect(happening_now).to have_content(event_schedule2.event.title)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'only shows all events happening now if something is happening now and next' do
|
|
|
|
|
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'))
|
|
|
|
|
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'))
|
|
|
|
|
event_schedule3 = create(:event_schedule, event: scheduled_event3, schedule: selected_schedule, start_time: Time.now.in_time_zone(conference2.timezone).strftime('%a, %d %b %Y %H:%M:%S'))
|
|
|
|
|
visit conference_path(conference2.short_title)
|
|
|
|
|
happening_now = page.find('#happening-now')
|
|
|
|
|
expect(happening_now).to have_content(event_schedule3.event.title)
|
|
|
|
|
expect(happening_now).not_to have_content(event_schedule1.event.title)
|
|
|
|
|
expect(happening_now).not_to have_content(event_schedule2.event.title)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'only shows events happening at the earliest time, not at a later time in the future' do
|
|
|
|
|
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'))
|
|
|
|
|
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'))
|
|
|
|
|
event_schedule3 = create(:event_schedule, event: scheduled_event3, schedule: selected_schedule, start_time: (Time.now.in_time_zone(conference2.timezone) + 2.hours).strftime('%a, %d %b %Y %H:%M:%S'))
|
|
|
|
|
visit conference_path(conference2.short_title)
|
|
|
|
|
happening_now = page.find('#happening-now')
|
|
|
|
|
expect(happening_now).to have_content(event_schedule1.event.title)
|
|
|
|
|
expect(happening_now).to have_content(event_schedule2.event.title)
|
|
|
|
|
expect(happening_now).not_to have_content(event_schedule3.event.title)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'only shows 3 events happening now because of pagination' do
|
|
|
|
|
event_schedule1 = create(:event_schedule, event: scheduled_event1, schedule: selected_schedule, start_time: Time.now.in_time_zone(conference2.timezone).strftime('%a, %d %b %Y %H:%M:%S'))
|
|
|
|
|
event_schedule2 = create(:event_schedule, event: scheduled_event2, schedule: selected_schedule, start_time: Time.now.in_time_zone(conference2.timezone).strftime('%a, %d %b %Y %H:%M:%S'))
|
|
|
|
|
event_schedule3 = create(:event_schedule, event: scheduled_event3, schedule: selected_schedule, start_time: Time.now.in_time_zone(conference2.timezone).strftime('%a, %d %b %Y %H:%M:%S'))
|
|
|
|
|
event_schedule4 = create(:event_schedule, event: scheduled_event4, schedule: selected_schedule, start_time: Time.now.in_time_zone(conference2.timezone).strftime('%a, %d %b %Y %H:%M:%S'))
|
|
|
|
|
|
|
|
|
|
visit conference_path(conference2.short_title)
|
|
|
|
|
happening_now = page.find('#happening-now')
|
|
|
|
|
expect(happening_now).to have_content(event_schedule1.event.title)
|
|
|
|
|
expect(happening_now).to have_content(event_schedule2.event.title)
|
|
|
|
|
expect(happening_now).to have_content(event_schedule3.event.title)
|
|
|
|
|
expect(happening_now).not_to have_content(event_schedule4.event.title)
|
|
|
|
|
|
|
|
|
|
visit conference_path(conference2.short_title, page: 2)
|
|
|
|
|
expect(happening_now).to have_content(event_schedule4.event.title)
|
|
|
|
|
end
|
|
|
|
|
end
|
2014-08-30 12:08:24 +02:00
|
|
|
end
|