mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15:50:36 -05:00
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>
This commit is contained in:
1 parent
2d068e1a63
commit
1c6c2f88c0
54 files changed
+2794
-286
No files matched your search
@@ -6,7 +6,8 @@ class OilAnalysisTest < ActiveSupport::TestCase
|
||||
def analysis(**attrs) = @a.oil_analyses.new({ sample_date: Date.current }.merge(attrs))
|
||||
|
||||
test "flags readings well above the lab average" do
|
||||
a = analysis(iron: 60, iron_avg: 35, copper: 10, copper_avg: 20, silicon: 20, silicon_avg: 13.3, tin: 5)
|
||||
a = analysis(elements: { iron: 60, copper: 10, silicon: 20, tin: 5 },
|
||||
element_averages: { iron: 35, copper: 20, silicon: 13.3 })
|
||||
assert a.flagged?("iron")
|
||||
refute a.flagged?("copper")
|
||||
assert a.flagged?("silicon") # exactly 1.5×
|
||||
@@ -14,13 +15,34 @@ class OilAnalysisTest < ActiveSupport::TestCase
|
||||
assert_equal %w[iron silicon], a.flagged_elements
|
||||
end
|
||||
|
||||
test "validates status, non-negative results, and engine on this aircraft" do
|
||||
test "results from a form: blanks dropped, numbers kept, unknown keys ignored" do
|
||||
a = analysis(elements: { "iron" => "30.5", "copper" => "", "unobtainium" => "9" },
|
||||
oil_properties: { "flashpoint_f" => "445", "water_percent" => "0" })
|
||||
assert a.valid?
|
||||
assert_equal({ "iron" => 30.5 }, a.elements)
|
||||
assert_equal({ "flashpoint_f" => 445.0, "water_percent" => 0.0 }, a.oil_properties)
|
||||
a.save!
|
||||
assert_equal({ "iron" => 30.5 }, a.reload.elements)
|
||||
end
|
||||
|
||||
test "validates status, non-negative numeric results, and engine on this aircraft" do
|
||||
assert analysis.valid?
|
||||
assert analysis(status: "").valid? # not rated
|
||||
assert analysis(status: "monitor").valid?
|
||||
refute analysis(status: "bad").valid?
|
||||
refute analysis(iron: -1).valid?
|
||||
a = analysis(elements: { iron: "-1", copper: "lots" })
|
||||
refute a.valid?
|
||||
assert_match "Iron and Copper", a.errors[:elements].first
|
||||
refute analysis(oil_properties: { fuel_percent: "x" }).valid?
|
||||
other_engine = create_component(create_aircraft)
|
||||
a = analysis(component: other_engine)
|
||||
refute a.valid?
|
||||
assert_includes a.errors[:component], "must be on this aircraft"
|
||||
end
|
||||
|
||||
test "elements_in lists elements any sample has, in display order" do
|
||||
a = analysis(elements: { lead: 900, iron: 30 })
|
||||
b = analysis(elements: { zinc: 4 })
|
||||
assert_equal %w[iron lead zinc], OilAnalysis.elements_in([ a, b ])
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user