2026.11.1: offline flight logging fixed, inspections from logbook entries, life limits from installation, component inspections moved to inspection types

- Service worker keeps the Log Flight form when opened via Turbo, serves the offline page's script and icon, and treats 502/503/504 as offline; the offline page only links forms actually kept
- Serviced sub-components restart from the airframe time flown since the entry
- New logbook entries can complete inspections (recorded and linked to the entry)
- Components: replacement limit can count from installation (life limit)
- Component-level "Inspect every" / "Inspection critical" removed; a migration converts any unlinked settings into inspection types with a first record; component page lists its inspections

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-12 07:30:59 -05:00
1 parent 7552e4a8a3
commit 352a38c7fb
28 files changed
+289 -69

No files matched your search

+2 -2
View File
@@ -10,7 +10,7 @@ class CalendarFeedTest < ActionDispatch::IntegrationTest
@oil = create_component(@a, component_type: component_type("Oil"), manufacturer: "Phillips", model: "20W50",
replacement_hours: 50, replacement_days: 120, hours_since_overhaul: 45, overhaul_date: Date.current - 30)
@mag = create_component(@a, component_type: component_type("Magneto"), manufacturer: "Bendix", model: "S4LN-21",
inspection_hours: 500, hours_since_overhaul: 450, overhaul_date: Date.current - 400)
tbo_hours: 500, hours_since_overhaul: 450, overhaul_date: Date.current - 400)
@a.documents.create!(name: "Registration", doc_type: "REGISTRATION", expires_on: Date.current + 200)
end
@@ -20,7 +20,7 @@ class CalendarFeedTest < ActionDispatch::IntegrationTest
assert_equal Date.current + 50, oil.date # 5 hrs at 0.1/day, before the 120-day limit (90 days left)
assert oil.projected
assert_equal 1005.0, oil.due_hours.to_f
assert_equal Date.current + 500, items["inspect-#{@mag.id}"].date # 50 hrs / 0.1 a day
assert_equal Date.current + 500, items["tbo-#{@mag.id}"].date # 50 hrs / 0.1 a day
assert_equal Date.current + 200, items["document-#{@a.documents.first.id}"].date
refute items["document-#{@a.documents.first.id}"].projected
end
@@ -68,6 +68,28 @@ class LogbookEntryPartsTest < ActionDispatch::IntegrationTest
assert_select "select[name='logbook_entry[parts][#{oil.id}][service]']", 0
end
test "servicing new oil typed in at 0 hours restarts it from the airframe time flown since the entry" do
oil = create_component(@a, component_type: component_type("Oil"), manufacturer: "Phillips", model: "20W50",
parent_component: @engine, hours_in_service: 36.0, hours_since_overhaul: 36.0)
post aircraft_logbook_entries_path(@a), params: { logbook_entry: entry_params(aircraft_hours_at_entry: 4210.3, parts: {
oil.id => { include: "1", hours: "0.0", since: "0.0", service: "serviced" } }) }
assert_equal [ 0.0, 36.0, Date.new(2026, 8, 20) ], oil.reload.then { [ _1.hours_since_overhaul.to_f, _1.hours_in_service.to_f, _1.overhaul_date ] }
end
test "a new entry can complete inspections such as an oil change" do
oil_change = InspectionType.create!(name: "Oil Change", recurring: true, recurring_hours: 50).tap { _1.aircraft << @a }
get new_aircraft_logbook_entry_path(@a)
assert_select "input[name='logbook_entry[inspection_type_ids][]'][value='#{oil_change.id}']"
post aircraft_logbook_entries_path(@a), params: { logbook_entry: entry_params(inspection_type_ids: [ "", oil_change.id ]) }
entry = @a.logbook_entries.sole
record = @a.inspection_records.sole
assert_equal [ oil_change, entry, Date.new(2026, 8, 20), 4200.3 ], [ record.inspection_type, record.logbook_entry, record.date, record.aircraft_hours.to_f ]
assert @a.events.exists?(event_name: "Inspection completed: Oil Change (logbook entry 2026-08-20)")
get edit_aircraft_logbook_entry_path(@a, entry) # not offered again on edit (it would record twice)
assert_select "input[name='logbook_entry[inspection_type_ids][]']", 0
end
test "printouts add a line per sub-component; archives carry them" do
entry = @a.logbook_entries.create!(entry_params.merge(component: @engine))
entry.parts.create!(component: @filter, hours_at_entry: 110.5, since_overhaul_at_entry: 10.5)
+20 -10
View File
@@ -36,20 +36,30 @@ class OverviewAndIntervalsTest < ActionDispatch::IntegrationTest
assert_includes response.body, "No flights logged yet."
end
test "hours already run out count as overdue; an inspection covering a component replaces its own interval" do
test "hours already run out count as overdue" do
filter = create_component(@a, component_type: component_type("Oil Filter"), manufacturer: "Champion", model: "CH48110",
inspection_hours: 50, hours_since_overhaul: 60, overhaul_date: Date.current - 300)
mag = create_component(@a, component_type: component_type("Magneto"), manufacturer: "Slick", model: "4371",
inspection_hours: 500, hours_since_overhaul: 120, overhaul_date: Date.current - 300)
replacement_hours: 50, hours_since_overhaul: 60, overhaul_date: Date.current - 300)
items = DueList.new(@a).items.index_by(&:key)
assert items["inspect-#{filter.id}"].overdue?
assert_equal Date.current, items["inspect-#{filter.id}"].date
assert items["replace-#{filter.id}"].overdue?
assert_equal Date.current, items["replace-#{filter.id}"].date
refute items["replace-#{@oil.id}"].overdue?
end
type = InspectionType.create!(name: "Oil change", effect: "advisory", recurring: true, recurring_hours: 50)
type.components << filter
assert_nil DueList.new(@a).items.find { _1.key == "inspect-#{filter.id}" }
assert DueList.new(@a).items.find { _1.key == "inspect-#{mag.id}" }
test "a component's page lists the inspections applied to it and offers to add one for it" do
sign_in @owner
mag = create_component(@a, component_type: component_type("Magneto"), manufacturer: "Slick", model: "4371", install_location: "Left")
get aircraft_component_path(@a, mag)
assert_select "#inspections", text: /None/
get new_aircraft_inspection_type_path(@a, component_id: mag.id)
assert_select "input[name='inspection_type[name]'][value='Magneto (Left) inspection']"
assert_select "input#comp_#{mag.id}[checked]"
assert_select "input[name=applies_to_airframe]:not([checked])"
InspectionType.create!(name: "Left magneto 500-hour", effect: "advisory", recurring: true, recurring_hours: 500).components << mag
get aircraft_component_path(@a, mag)
assert_select "#inspections td", text: /Left magneto 500-hour/
get edit_aircraft_component_path(@a, mag)
assert_select "input[name='component[inspection_hours]']", 0
end
test "a component limit in years is stored as months and lands on the same date" do