mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15:50:36 -05:00
AirTrail (https://github.com/johanohly/AirTrail): - File export (Flights → Export for AirTrail) in AirTrail's import format, validated against its schema; same-day repeat legs get leg numbers so AirTrail's de-duplication doesn't merge them. - Automatic sync through AirTrail's REST API (Profile → AirTrail sync): per-user connection with an encrypted API key and scope check; flights are created/updated/deleted in background jobs; a full sync first links flights already in AirTrail (e.g. from a file import) instead of duplicating them; airports are resolved and cached, with manual mapping for unknown codes. - GPS tracks: GPX, KML and CSV track logs are converted to AirTrail's track format for both sync and export; the flight page shows a summary. - Aircraft ICAO type (e.g. C150) for AirTrail's aircraft type. Airport database (OurAirports, the source AirTrail uses): - Managed like AirTrail: downloaded in the background on first start, updated in place from Admin → Airports (adds, changes, removes; ids stable), with admin-managed custom airports that updates never touch. - Each airport carries AirTrail's code, so logged codes translate to AirTrail's exactly (1B9 → K1B9, 4MB → K5M3). - From/To autocomplete on new flights (airports this aircraft has used rank first); From is pre-filled with the last flight's destination; codes are normalized to uppercase. - Flights → Standardize airport codes: rewrite logged codes to the standard code, and fix codes not in the database (typos such as 0R8 → 08R are suggested). Also: admin pages grouped under an Admin dropdown menu. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
40 lines
1.4 KiB
Ruby
40 lines
1.4 KiB
Ruby
ENV["RAILS_ENV"] ||= "test"
|
|
require_relative "../config/environment"
|
|
require "rails/test_help"
|
|
require "webmock/minitest"
|
|
WebMock.disable_net_connect!(allow_localhost: true)
|
|
Dir[File.expand_path("support/**/*.rb", __dir__)].each { require _1 }
|
|
|
|
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
|