mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Both iCalendar routes were unusable: * `/conferences/.../schedule.ics` raised `NoMethodError: undefined method 'icalendar_proposals'` because the `ConferenceHelper#icalendar_proposals` helper isn't auto-included in controllers; the action crashed before rendering. * `/calendar.ics` silently redirected to `/`. The controller goes through `load_and_authorize_resource`, which authorises `:calendar` on `Conference` and is rejected for anonymous visitors because no ability grants it — CanCan's `AccessDenied` rescue redirects to root. The helper is invoked through the controller `helpers` proxy so it works in both contexts, and the calendar action is opted out of resource loading and explicitly marked as not requiring authorization since it serves a public feed across conferences. The helper is also hardened so that proposals missing a room, difficulty level, track, event type or scheduled time produce a valid event instead of crashing the whole feed.
73 lines
2.1 KiB
Ruby
73 lines
2.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'spec_helper'
|
|
|
|
describe ConferencesController do
|
|
let(:conference) { create(:conference, splashpage: create(:splashpage, public: true), venue: create(:venue)) }
|
|
let!(:cfp) { create(:cfp, program: conference.program) }
|
|
let(:room) { create(:room, venue: conference.venue) }
|
|
|
|
describe 'GET #index' do
|
|
it 'Response code is 200' do
|
|
get :index
|
|
expect(response.response_code).to eq(200)
|
|
end
|
|
end
|
|
|
|
describe 'GET #show' do
|
|
context 'conference made public' do
|
|
it 'assigns the requested conference to conference' do
|
|
get :show, params: { id: conference.short_title }
|
|
expect(assigns(:conference)).to eq conference
|
|
end
|
|
|
|
it 'renders the show template' do
|
|
get :show, params: { id: conference.short_title }
|
|
expect(response).to render_template :show
|
|
end
|
|
end
|
|
|
|
context 'accessing conference via custom domain' do
|
|
before do
|
|
conference.update_attribute(:custom_domain, 'lvh.me')
|
|
@request.host = 'lvh.me'
|
|
end
|
|
|
|
it 'assigns correct conference' do
|
|
get :show
|
|
|
|
expect(response).to render_template :show
|
|
expect(assigns(:conference)).to eq conference
|
|
end
|
|
end
|
|
end
|
|
|
|
describe 'OPTIONS #index' do
|
|
it 'Response code is 200' do
|
|
process :index
|
|
expect(response.response_code).to eq(200)
|
|
end
|
|
end
|
|
|
|
describe 'GET #calendar' do
|
|
it 'returns iCalendar data for all conferences' do
|
|
get :calendar, params: { format: :ics }
|
|
|
|
expect(response).to be_successful
|
|
expect(response.content_type).to start_with('text/calendar')
|
|
expect(response.body).to start_with('BEGIN:VCALENDAR')
|
|
end
|
|
|
|
it 'returns iCalendar data with full schedule when full=true' do
|
|
conference.program.update!(schedule_public: true)
|
|
create(:event_scheduled, program: conference.program)
|
|
|
|
get :calendar, params: { full: true, format: :ics }
|
|
|
|
expect(response).to be_successful
|
|
expect(response.content_type).to start_with('text/calendar')
|
|
expect(response.body).to start_with('BEGIN:VCALENDAR')
|
|
end
|
|
end
|
|
|
|
end
|