mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15:50:36 -05:00
Rails 8.1 + SQLite rewrite of marbindrakon/simple-aircraft-manager, designed to self-host as a single container (Solid Queue/Cache/Cable, Active Storage on disk, Hotwire + importmap, Tailwind). - Airworthiness engine ported from health/services.py (ADs, grounding squawks, inspection recurrency, component replacement) - Hours updates and flight logs cascading to in-service components, optional airworthiness enforcement - Components, squawks, ADs, inspections, logbook, documents, major records, oil/fuel consumption stats and charts, activity log - Admin/owner/pilot RBAC and public share links (status/maintenance) - Docker Compose and Kamal deployment, env-driven production config - Service and integration tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
37 lines
1.2 KiB
Ruby
37 lines
1.2 KiB
Ruby
ENV["RAILS_ENV"] ||= "test"
|
|
require_relative "../config/environment"
|
|
require "rails/test_help"
|
|
|
|
module ActiveSupport
|
|
class TestCase
|
|
parallelize(workers: :number_of_processors)
|
|
|
|
def create_user(email = "user#{SecureRandom.hex(3)}@example.com", admin: false)
|
|
User.create!(email_address: email, password: "password123", name: email.split("@").first, admin: admin)
|
|
end
|
|
|
|
def create_aircraft(owner: nil, pilot: nil, **attrs)
|
|
Aircraft.create!({ tail_number: "N#{rand(10000..99999)}", tach_time: 1000 }.merge(attrs)).tap do |a|
|
|
a.roles.create!(user: owner, role: "owner") if owner
|
|
a.roles.create!(user: pilot, role: "pilot") if pilot
|
|
end
|
|
end
|
|
|
|
def component_type(name = "Engine")
|
|
ComponentType.find_or_create_by!(name: name)
|
|
end
|
|
|
|
def create_component(aircraft, **attrs)
|
|
aircraft.components.create!({ component_type: component_type, manufacturer: "Lycoming", model: "O-320",
|
|
status: "IN-USE", date_in_service: 1.year.ago.to_date }.merge(attrs))
|
|
end
|
|
end
|
|
end
|
|
|
|
class ActionDispatch::IntegrationTest
|
|
def sign_in(user)
|
|
post session_path, params: { email_address: user.email_address, password: "password123" }
|
|
follow_redirect!
|
|
end
|
|
end
|