AD baseline: record DRS imports and the models they covered; weekly search starts from the last import; reminders and audit check

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-11 20:56:20 -05:00
1 parent ba0455b149
commit 8bea2abf75
13 files changed
+169 -4

No files matched your search

+29
View File
@@ -27,6 +27,8 @@ class AdImportFlowTest < ActionDispatch::IntegrationTest
}
assert_redirected_to aircraft_airworthiness_directives_path(@aircraft)
assert_equal %w[2008-22-18 2011-10-09], @aircraft.applicable_ads.order(:name).pluck(:name)
drs = @aircraft.drs_imports.sole # the AD baseline is recorded
assert_equal [ [ "150L" ], @owner, "AD Final Rules.csv" ], [ drs.models_covered, drs.user, drs.filename ]
follow_redirect!
assert_select "span", text: "N/A"
# CSV exports carry no links, so the AD number isn't a link
@@ -51,4 +53,31 @@ class AdImportFlowTest < ActionDispatch::IntegrationTest
assert_response :redirect
assert_equal 0, @aircraft.applicable_ads.count
end
test "the AD baseline: missing models, renewal, where the weekly search starts, reminders and the audit" do
create_component(@aircraft, component_type: component_type("Engine"), model: "O-200A")
assert_equal %w[150L O-200A], DrsImport.missing_models(@aircraft)
assert DrsImport.renewal_due?(@aircraft)
assert_equal 2.years.ago.to_date, AdWatch.new(@aircraft).start_date
travel_to Time.zone.local(2026, 11, 2) do
@aircraft.drs_imports.create!(user: @owner, models_covered: [ "150L" ])
@aircraft.drs_imports.create!(user: @owner, models_covered: [ "O-200-A" ]) # matches O-200A
end
assert_empty DrsImport.missing_models(@aircraft)
travel_to Time.zone.local(2026, 11, 20) do
refute DrsImport.renewal_due?(@aircraft)
assert_equal Date.new(2026, 9, 3), AdWatch.new(@aircraft).start_date # last import less 60 days
sign_in @owner
get aircraft_airworthiness_directives_path(@aircraft)
assert_includes response.body, "Last import <strong>2026-11-02</strong>"
end
travel_to Time.zone.local(2027, 12, 1) do # over a year: the first Monday-of-month email and the audit flag it
assert DrsImport.renewal_due?(@aircraft)
assert ReminderMailer.anything_for?(@owner, today: Date.new(2027, 12, 6))
refute ReminderMailer.anything_for?(@owner, today: Date.new(2027, 12, 13))
assert_includes ReminderMailer.weekly(@owner).text_part.body.to_s, "needs a refresh"
refute RecordsAudit.new.auto_items.find { _1.key == "drs" }.passed
end
end
end