mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-17 05:34:04 +00:00
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:
parent
c8e6fabed1
commit
fae6332c36
6 changed files with 57 additions and 6 deletions
|
|
@ -283,6 +283,27 @@ describe Program do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#any_published_schedule?' do
|
||||
let(:event) { create(:event, program: program) }
|
||||
let(:schedule) { create(:schedule, program: program) }
|
||||
let!(:event_schedule) { create(:event_schedule, event: event, schedule: schedule, start_time: DateTime.parse("#{Date.current + 1} 10:00").utc) }
|
||||
|
||||
it 'returns false when schedule_public is disabled' do
|
||||
program.update!(schedule_public: false, selected_schedule: schedule)
|
||||
expect(program.any_published_schedule?).to be false
|
||||
end
|
||||
|
||||
it 'returns false when schedule_public is enabled but no schedule is selected' do
|
||||
program.update!(schedule_public: true, selected_schedule: nil)
|
||||
expect(program.any_published_schedule?).to be false
|
||||
end
|
||||
|
||||
it 'returns true when schedule_public is enabled and the selected schedule has events' do
|
||||
program.update!(schedule_public: true, selected_schedule: schedule)
|
||||
expect(program.any_published_schedule?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
describe '#cfp' do
|
||||
it 'returns the cfp for events' do
|
||||
create(:cfp, cfp_type: 'events', program: program, end_date: Date.current + 1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue