Files
simple-aircraft-manager-rails/test/models/component_test.rb
T
rickyandClaude Opus 5.5 1c6c2f88c0 Blackstone oil analysis, .sam.zip export/import, AI logbook transcription
- Oil analysis: Blackstone PDF import (20 elements, oil properties, universal
  averages), results stored per element, oil type, "leave out of trends",
  the original app's statuses; AvLab fixes (multi-line comments, unrelated
  labels no longer steal values). Existing records migrate.
- Aircraft archives in the original app's .sam.zip format (schema v2): export
  from Access & Sharing, background import from the Fleet page, rake tasks.
  Archives move both ways between this app and the original.
- Scanned logbook pages (images or PDFs) upload as a document; with
  ANTHROPIC_API_KEY set, Claude transcribes them into logbook entries.
- Fix: deleting a component or aircraft failed when AD compliances or
  inspection records pointed at a component.

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

24 lines
1.1 KiB
Ruby

require "test_helper"
class ComponentTest < ActiveSupport::TestCase
test "deleting a component, or its aircraft, works when records point at it" do
a = create_aircraft
engine = create_component(a)
ad = AirworthinessDirective.create!(name: "2020-01-01", short_description: "Check")
compliance = a.ad_compliances.create!(airworthiness_directive: ad, date_complied: Date.current, compliance_notes: "Done",
permanent: true, component: engine)
annual = InspectionType.create!(name: "Annual")
record = a.inspection_records.create!(inspection_type: annual, date: Date.current, component: engine)
engine.destroy!
assert_nil compliance.reload.component_id
assert_nil record.reload.component_id
other = create_component(a)
a.ad_compliances.create!(airworthiness_directive: ad, date_complied: Date.current, compliance_notes: "Done", permanent: true, component: other)
a.inspection_records.create!(inspection_type: annual, date: Date.current, component: other)
a.destroy!
assert_not Aircraft.exists?(a.id)
end
end