Upcoming events for the organisers' dashboard

Ruby · Rails · intermediate · modification

Adds the upcoming events list for the organisers' team dashboard. `config/routes.rb` routes `GET /upcoming_events` to the new `UpcomingEventsController#index`, which reads the account's events through a new `Event.upcoming` scope (`app/models/event.rb`: events starting now or later, in start order) and renders each one with its host's name and its count of `going` RSVPs. `test/controllers/upcoming_events_controller_test.rb` adds integration tests for the list and for the missing-token case.

Rails 8.1 API app on Ruby 4.0, Minitest integration tests with inline records (`ActiveSupport::Testing::TimeHelpers` available). SQLite in development and test, PostgreSQL 16 in production on a managed instance in the same region; nothing in this PR depends on which one. `config.time_zone` is the default UTC. `ApplicationController` (existing, unchanged) is an `ActionController::API` that includes the `Authentication` concern: a `before_action` looks up `User.find_by(api_token:)` from the bearer token, answers 401 itself when there is none, and sets `Current.user`; `Current.account` delegates to `Current.user.account` (one users query during authentication, then one accounts query the first time `Current.account` is read). Models (existing, unchanged apart from the new scope): `Account` `has_many :users, :events`; `User` (`name`, `api_token`) `belongs_to :account`; `Event` (`title`, `starts_at`, both `NOT NULL`) `belongs_to :account` and `belongs_to :host, class_name: "User"` with `host_id NOT NULL` and a foreign key to `users`, `has_many :rsvps`; a host is always a user of the event's account. `Rsvp` `belongs_to :event, :user` with `enum :status, { going: 0, maybe: 1, declined: 2 }` (`NOT NULL`), one RSVP per user and event (unique index on `[event_id, user_id]`). `events` has an index on `[account_id, starts_at]`. Rails' per-request query cache is on (the default). The dashboard itself ships separately in the web app.

Requirements

Files touched

Review this PR

Ruby practice