Files
simple-aircraft-manager-rails/test/integration/ad_import_flow_test.rb
T
rickyandClaude Opus 5.5 a4ec7a691e Record keeping: 43.9/43.11 sign-off fields, AD method, status report
- Logbook entries record the signer's kind of certificate and number and
  an inspection's result; maintenance and inspection entries list what
  43.9 / 43.11 needs that's missing (flagged, not enforced). Transcription
  reads the certificate details too
- AD compliance records the method (inspection, terminating action, AMOC,
  not applicable) and the AD revision complied with, filled in from the AD
  when blank; the method sets the permanent / N/A flags
- Maintenance status report (91.417(a)(2)): total times, life-limited
  parts, time since overhaul, inspection and AD status, major alterations,
  open discrepancies; print or save as PDF; on maintenance share links too
- Archives carry the new fields

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 10:14:21 -05:00

55 lines
2.5 KiB
Ruby

require "test_helper"
class AdImportFlowTest < ActionDispatch::IntegrationTest
setup do
@owner = create_user
@pilot = create_user
@aircraft = create_aircraft(owner: @owner, pilot: @pilot, model: "150L")
end
test "owner uploads, reviews, and imports" do
sign_in @owner
get aircraft_airworthiness_directives_path(@aircraft)
assert_select "a[href='#{new_aircraft_ad_import_path(@aircraft)}']"
post aircraft_ad_import_path(@aircraft), params: { file: fixture_file_upload("drs_ads.csv", "text/csv") }
assert_response :redirect
follow_redirect!
assert_response :success
assert_select "select[name='decisions[2011-10-09]'] option[selected][value='track']"
assert_select "select[name='decisions[87-20-03 R2]'] option[selected][value='skip']"
assert_match "Excel</strong> export includes them", response.body
token = response.body[/name="token"[^>]*value="([^"]+)"/, 1]
post confirm_aircraft_ad_import_path(@aircraft), params: {
token: token, filename: "AD Final Rules.csv",
decisions: { "2011-10-09" => "track", "2008-22-18" => "na", "96-12-22" => "skip", "75-15-08" => "skip", "87-20-03 R2" => "skip" }
}
assert_redirected_to aircraft_airworthiness_directives_path(@aircraft)
assert_equal %w[2008-22-18 2011-10-09], @aircraft.applicable_ads.order(:name).pluck(:name)
follow_redirect!
assert_select "span", text: "N/A"
# CSV exports carry no links, so the AD number isn't a link
assert_select "a", text: "2011-10-09", count: 0
end
test "N/A quick action records a not-applicable determination" do
ad = AirworthinessDirective.create!(name: "2008-22-18", short_description: "BRS")
ad.aircraft << @aircraft
sign_in @owner
get new_aircraft_ad_compliance_path(@aircraft, ad_id: ad.id, not_applicable: 1)
assert_select "select[name='ad_compliance[compliance_method]'] option[selected][value=not_applicable]"
post aircraft_ad_compliances_path(@aircraft), params: { ad_compliance: {
airworthiness_directive_id: ad.id, date_complied: Date.current, compliance_method: "not_applicable",
compliance_notes: "Not applicable: no BRS parachute installed" } }
assert_equal "GREEN", @aircraft.reload.airworthiness.status
end
test "pilots cannot import ADs" do
sign_in @pilot
post aircraft_ad_import_path(@aircraft), params: { file: fixture_file_upload("drs_ads.csv", "text/csv") }
assert_response :redirect
assert_equal 0, @aircraft.applicable_ads.count
end
end