Skip to content

Phase 1: multi-tenant fleet core#4

Merged
faborubio merged 2 commits into
mainfrom
phase-1-fleet-core
Jun 12, 2026
Merged

Phase 1: multi-tenant fleet core#4
faborubio merged 2 commits into
mainfrom
phase-1-fleet-core

Conversation

@faborubio

Copy link
Copy Markdown
Owner

Summary

Implements the fleet management core on top of the Phase 0 foundations:

  • Authentication & onboarding — Rails 8 native auth (sessions, password reset) plus a signup flow where a Registration form object creates the Account and its first admin user in a single transaction.
  • Multi-tenancy — row-level isolation by account_id. Controllers only reach data through Current.account associations; Assignment additionally validates that vehicle and driver belong to the same account. Request specs assert cross-tenant access returns 404.
  • Authorization — Pundit policies with three roles: viewer (read-only), manager (fleet CRUD), admin.
  • Vehicles — CRUD with VIN normalization (uppercase, I/O/Q rejected, unique per account), search + status filters with a Stimulus autosubmit controller, Pagy pagination, and background VIN decoding against the free NHTSA vPIC API (VinDecoder service + VinDecodeJob; user-entered data is never overwritten).
  • Drivers — CRUD with license expiry tracking.
  • Assignments — vehicle ↔ driver with per-vehicle and per-driver overlap validation and assignment history on both show pages.
  • UI — Tailwind app shell (nav, flashes), responsive tables, forms and empty states.

Test plan

  • 73 RSpec examples green: models, policies, requests, service (WebMock), job, 2 system specs
  • RuboCop, Brakeman, bundler-audit, importmap audit clean
  • db:seed produces a demo account (admin@fleetpilot.test / password123)
  • CI green on this PR

🤖 Generated with Claude Code

faborubio and others added 2 commits June 11, 2026 19:18
- Rails 8 native authentication plus signup flow (Registration form object
  creates the Account and its first admin user in one transaction)
- Row-level multi-tenancy: every domain record belongs to an Account and is
  only reachable through Current.account associations
- Pundit role policies: viewer (read-only), manager, admin
- Vehicles CRUD with VIN normalization/validation, search + status filters
  (Stimulus autosubmit), Pagy pagination, and background VIN decoding via
  the free NHTSA vPIC API (never overwrites user-entered data)
- Drivers CRUD with license expiry tracking
- Assignments with overlap validation per vehicle and per driver, and
  cross-account integrity checks
- Tailwind UI: app shell, tables, forms, empty states
- 73 specs: models, policies, requests (tenant isolation, authorization),
  service with WebMock, job, and 2 end-to-end system specs

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The stock bin/dev installs foreman as a global gem, which fails on this
machine (root-owned rbenv installs to a non-PATH user dir). foreman now
lives in the Gemfile and bin/dev invokes it with bundle exec. Logged in
docs/POSTMORTEMS.md.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@faborubio
faborubio merged commit 3bc6ae8 into main Jun 12, 2026
4 checks passed
@faborubio
faborubio deleted the phase-1-fleet-core branch June 12, 2026 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant