Stop offering the schedule page when no schedule is published

The home and splash page render a link to the schedule based purely on
the `schedule_public` flag, even when an admin has not yet selected a
schedule or scheduled any events. Following that link rendered the
schedule view, which then failed inside `_carousel.html.haml` because
`@rooms` (and the selected schedule) had no data — a 500 error instead
of a graceful response.

Treat `schedule_public` as an allowance rather than an unchecked
control: introduce `Program#any_published_schedule?` (true only when
the flag is on *and* there is at least one event in a selected
schedule) and use it to decide whether to render the link from the
home and splash pages. The schedule controller now returns 404 when no
event has been scheduled, so bookmarked URLs surface as "not found"
instead of an internal server error.
This commit is contained in:
Asish Kumar 2026-05-14 09:23:06 +05:30
parent c8e6fabed1
commit fae6332c36
6 changed files with 57 additions and 6 deletions

View file

@ -26,5 +26,17 @@ describe SchedulesController do
expect(response).to be_successful
end
end
context 'when schedule is public but no events are scheduled' do
before :each do
conference.program.update!(schedule_public: true)
end
it 'returns 404 instead of rendering a broken page' do
expect do
get :show, params: { conference_id: conference.short_title }
end.to raise_error(ActionController::RoutingError)
end
end
end
end