Files
rickyandClaude Opus 5.5 acb8b87ca3 Avionics logbook type
Aircraft with a separate avionics logbook can file radio, transponder and
autopilot work under it: AVIONICS joins Aircraft, Engine, Propeller and
Other everywhere a logbook is chosen or filtered (entry form, logbook
filter, squawk resolution, templates, imports).

- Logbook transcription knows it (schema enum and prompt), so scanned
  avionics pages aren't filed as Aircraft.
- The API's ?log= filter and drafts API accept it; docs updated.
- No migration: log_type is a string column. Existing entries unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 16:28:23 -05:00

31 lines
1.4 KiB
Ruby

require "test_helper"
# Aircraft with a separate avionics logbook file their radio, transponder
# and autopilot work under it.
class AvionicsLogbookTest < ActionDispatch::IntegrationTest
setup do
@owner = create_user("owner@example.com")
@a = create_aircraft(owner: @owner, tail_number: "N12345")
sign_in @owner
end
test "an entry can be written to the avionics logbook and the list filtered to it" do
post aircraft_logbook_entries_path(@a), params: { logbook_entry: { date: "2026-10-01", log_type: "AVIONICS", entry_type: "MAINTENANCE",
text: "Replaced Comm 2 radio; operational check normal." } }
entry = @a.logbook_entries.sole
assert_equal "AVIONICS", entry.log_type
@a.logbook_entries.create!(date: Date.new(2026, 10, 2), log_type: "AC", entry_type: "MAINTENANCE", text: "Lubricated door hinges.")
get aircraft_logbook_entries_path(@a, log_type: "AVIONICS")
assert_response :success
assert_includes response.body, "Replaced Comm 2 radio"
assert_not_includes response.body, "Lubricated door hinges"
assert_includes response.body, ">Avionics<"
end
test "logbook transcription and the drafts API know the avionics logbook" do
assert LogbookEntry::LOG_TYPES.key?("AVIONICS")
assert_includes JSON.parse(Rails.root.join("app/services/logbook_transcriber/schema.json").read).to_s, "AVIONICS"
end
end