mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
- Inspection types say what overdue means: grounds the aircraft, no IFR
(91.411), no transponder (91.413) or advisory. Overdue limitations show
as a new LIMITED status ("VFR only", "No transponder") and don't block
flights under airworthiness enforcement
- "Also counts as": an annual satisfies the 100-hour (91.409(b))
- Overrun allowance: a 100-hour done within 10 hrs of due counts the next
one from when it was due; done early, from when it was done
- Per-aircraft maintenance clock (tach or Hobbs) for time in service; new
records default to it (fixes the tach-offset mismatch)
- Status labels Current / Due soon / limitation / Grounded, with the
91.7 pilot-in-command note
- Migration converts existing types by name; archives carry the new fields
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
38 lines
1.9 KiB
Ruby
38 lines
1.9 KiB
Ruby
require "test_helper"
|
|
|
|
class InspectionRulesFlowTest < ActionDispatch::IntegrationTest
|
|
setup do
|
|
@owner = create_user("owner@example.com")
|
|
@a = create_aircraft(owner: @owner)
|
|
sign_in @owner
|
|
end
|
|
|
|
test "owner sets what overdue means, the overrun allowance and what an inspection also counts as" do
|
|
hundred = InspectionType.create!(name: "100-hour", recurring: true, recurring_hours: 100).tap { _1.aircraft << @a }
|
|
elsewhere = InspectionType.create!(name: "Other aircraft's", recurring: true).tap { _1.aircraft << create_aircraft }
|
|
post aircraft_inspection_types_path(@a), params: { inspection_type: {
|
|
name: "Annual", recurring: "1", recurring_months: 12, effect: "grounds", satisfies_id: hundred.id } }
|
|
annual = InspectionType.find_by!(name: "Annual")
|
|
assert_equal hundred, annual.satisfies
|
|
|
|
patch aircraft_inspection_type_path(@a, hundred), params: { inspection_type: { hours_tolerance: "10", satisfies_id: elsewhere.id } }
|
|
assert_equal [ 10, nil ], [ hundred.reload.hours_tolerance.to_i, hundred.satisfies_id ] # other aircraft's types can't be chosen
|
|
|
|
get edit_aircraft_inspection_type_path(@a, hundred)
|
|
assert_select "select[name='inspection_type[effect]'] option[value=no_ifr]"
|
|
get aircraft_inspections_path(@a)
|
|
assert_includes response.body, "Also counts as 100-hour"
|
|
end
|
|
|
|
test "maintenance clock on the aircraft form; new records default to time in service" do
|
|
patch aircraft_path(@a), params: { aircraft: { time_basis: "hobbs", hobbs_time_offset: 0 } }
|
|
@a.update_columns(hobbs_time: 1234.5)
|
|
assert_equal "hobbs", @a.reload.time_basis
|
|
get new_aircraft_inspection_record_path(@a)
|
|
assert_select "input[name='inspection_record[aircraft_hours]'][value='1234.5']"
|
|
get aircraft_path(@a)
|
|
assert_includes response.body, "pilot in command decides whether the aircraft is airworthy"
|
|
assert_select ".badge-green", text: "Current"
|
|
end
|
|
end
|