mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
New-AD search covers every installed component
- Besides the aircraft and engine/propeller models (and families), each in-use component is searched as maker + model designator and as component type + designator (e.g. "Champion 4301", "Magneto 4301"), so appliance ADs (magnetos, ELTs, radios, transponders) are found - A match records the component; tracking it makes the AD apply to that component instead of the airframe (ad_alerts.component_id) - Page hint, guide and README updated Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
afaa1ca191
commit
d2f5ce1e92
9 files changed
+90
-19
No files matched your search
@@ -129,7 +129,7 @@ To back up or move a single aircraft with all its files, use **Access & Sharing
|
|||||||
| Squawks | Four priorities. "Ground Aircraft" grounds the aircraft. Inoperative items can be deferred under 91.213(d) after confirming each condition; resolving can record the fix as a logbook entry. Attachments, reopen. |
|
| Squawks | Four priorities. "Ground Aircraft" grounds the aircraft. Inoperative items can be deferred under 91.213(d) after confirming each condition; resolving can record the fix as a logbook entry. Attachments, reopen. |
|
||||||
| Notes | Per-aircraft notes in Markdown, with a preview; shown on share links. |
|
| Notes | Per-aircraft notes in Markdown, with a preview; shown on share links. |
|
||||||
| ADs and bulletins | Shared across aircraft and applicable to the airframe or to specific components. Hour- and month-based recurrence (due at end of month), conditional and non-mandatory types, per-aircraft "not applicable" determinations, and compliance history with method of compliance and the revision complied with. |
|
| ADs and bulletins | Shared across aircraft and applicable to the airframe or to specific components. Hour- and month-based recurrence (due at end of month), conditional and non-mandatory types, per-aircraft "not applicable" determinations, and compliance history with method of compliance and the revision complied with. |
|
||||||
| New ADs | Weekly search of the Federal Register for newly published ADs mentioning the aircraft, engine or propeller models (or your own terms). Review each: track it as an AD or dismiss it. |
|
| New ADs | Weekly search of the Federal Register for newly published ADs mentioning the aircraft model, the engine and propeller models and families, or any installed component's make and model (or your own terms); tracking one found through a component makes it apply to that component. Review each: track it as an AD or dismiss it. |
|
||||||
| AD import | Import ADs from an FAA DRS export (`.xlsx` recommended: its AD numbers link to each AD's DRS page, which the import keeps; `.csv` works without links). ADs are matched by number, so nothing is duplicated. The preview suggests Track, Not applicable or Skip for each AD, and flags superseded or non-current ADs, model mismatches, appliance or STC-only ADs, and repetitive actions. |
|
| AD import | Import ADs from an FAA DRS export (`.xlsx` recommended: its AD numbers link to each AD's DRS page, which the import keeps; `.csv` works without links). ADs are matched by number, so nothing is duplicated. The preview suggests Track, Not applicable or Skip for each AD, and flags superseded or non-current ADs, model mismatches, appliance or STC-only ADs, and repetitive actions. |
|
||||||
| Inspections | Shared inspection types with hour, month, and day recurrence, plus history. Each says what overdue means (grounded, no IFR, no transponder, advisory); an annual can also count as the 100-hour, and the 100-hour's 10-hour overrun is credited (91.409(b)). One click adds the standard Part 91 set. |
|
| Inspections | Shared inspection types with hour, month, and day recurrence, plus history. Each says what overdue means (grounded, no IFR, no transponder, advisory); an annual can also count as the 100-hour, and the 100-hour's 10-hour overrun is credited (91.409(b)). One click adds the standard Part 91 set. |
|
||||||
| Logbook | Maintenance entries with search and a link to a scanned document page. Records the signer's certificate kind and number and an inspection's result, and flags what 43.9 / 43.11 needs that's missing. Entries transcribed by Claude stay "unverified" until someone checks them against the scan. Entry templates (built-in pilot preventive maintenance per 43.3(g) and Part 43 Appendix A(c); admins add and edit their own under Admin → Logbook templates). Engine and propeller entries link the component and record its total time and time since overhaul (SMOH/SFOH/SNEW) at the entry, worked out from the entry's airframe total time; sub-components (an oil filter on the engine…) can be included with their own times. Print entries as a PDF on Avery 5163/8163 or 5164/8164 labels or half-letter/letter pages (boxed) to sign and put in the paper logbook. |
|
| Logbook | Maintenance entries with search and a link to a scanned document page. Records the signer's certificate kind and number and an inspection's result, and flags what 43.9 / 43.11 needs that's missing. Entries transcribed by Claude stay "unverified" until someone checks them against the scan. Entry templates (built-in pilot preventive maintenance per 43.3(g) and Part 43 Appendix A(c); admins add and edit their own under Admin → Logbook templates). Engine and propeller entries link the component and record its total time and time since overhaul (SMOH/SFOH/SNEW) at the entry, worked out from the entry's airframe total time; sub-components (an oil filter on the engine…) can be included with their own times. Print entries as a PDF on Avery 5163/8163 or 5164/8164 labels or half-letter/letter pages (boxed) to sign and put in the paper logbook. |
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class AdAlertsController < ApplicationController
|
|||||||
def check
|
def check
|
||||||
found = AdWatch.new(@aircraft).check!
|
found = AdWatch.new(@aircraft).check!
|
||||||
redirect_to aircraft_airworthiness_directives_path(@aircraft, anchor: "new-ads"),
|
redirect_to aircraft_airworthiness_directives_path(@aircraft, anchor: "new-ads"),
|
||||||
notice: found.any? ? "Found #{helpers.pluralize(found.size, 'newly published AD')} to review." : "No new ADs found for #{AdWatch.new(@aircraft).terms.to_sentence}."
|
notice: found.any? ? "Found #{helpers.pluralize(found.size, 'newly published AD')} to review." : "No new ADs found for #{AdWatch.new(@aircraft).terms.map(&:label).uniq.to_sentence}."
|
||||||
rescue AdWatch::Error => e
|
rescue AdWatch::Error => e
|
||||||
redirect_to aircraft_airworthiness_directives_path(@aircraft), alert: "Couldn't check for new ADs: #{e.message}."
|
redirect_to aircraft_airworthiness_directives_path(@aircraft), alert: "Couldn't check for new ADs: #{e.message}."
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ class AdAlert < ApplicationRecord
|
|||||||
STATUSES = %w[new tracked dismissed].freeze
|
STATUSES = %w[new tracked dismissed].freeze
|
||||||
|
|
||||||
belongs_to :aircraft
|
belongs_to :aircraft
|
||||||
|
belongs_to :component, optional: true
|
||||||
belongs_to :airworthiness_directive, optional: true
|
belongs_to :airworthiness_directive, optional: true
|
||||||
|
|
||||||
validates :fr_document_number, presence: true, uniqueness: { scope: :aircraft_id }
|
validates :fr_document_number, presence: true, uniqueness: { scope: :aircraft_id }
|
||||||
@@ -20,7 +21,13 @@ class AdAlert < ApplicationRecord
|
|||||||
name: ad_number.presence || fr_document_number, short_description: summary, effective_date: effective_on,
|
name: ad_number.presence || fr_document_number, short_description: summary, effective_date: effective_on,
|
||||||
document_url: html_url, docket_number: amendment, required_action: abstract.to_s.truncate(2000)
|
document_url: html_url, docket_number: amendment, required_action: abstract.to_s.truncate(2000)
|
||||||
)
|
)
|
||||||
|
# Matched on an installed component: the AD applies to that component;
|
||||||
|
# otherwise to the airframe.
|
||||||
|
if component && component.aircraft_id == aircraft_id
|
||||||
|
ad.components << component unless ad.components.include?(component)
|
||||||
|
else
|
||||||
ad.aircraft << aircraft unless ad.aircraft.include?(aircraft)
|
ad.aircraft << aircraft unless ad.aircraft.include?(aircraft)
|
||||||
|
end
|
||||||
update!(status: "tracked", airworthiness_directive: ad)
|
update!(status: "tracked", airworthiness_directive: ad)
|
||||||
ad
|
ad
|
||||||
end
|
end
|
||||||
|
|||||||
+43
-10
@@ -16,12 +16,35 @@ class AdWatch
|
|||||||
@aircraft = aircraft
|
@aircraft = aircraft
|
||||||
end
|
end
|
||||||
|
|
||||||
# Model names to search for: the owner's list, or the aircraft, engine and
|
# A search: what's shown ("Champion Slick 4301"), the words that must all
|
||||||
# propeller models.
|
# appear in the AD's text, and the installed component it came from.
|
||||||
|
Term = Data.define(:label, :words, :component_id) do
|
||||||
|
def to_s = label
|
||||||
|
end
|
||||||
|
|
||||||
|
ENGINE_OR_PROP = /engine|propell?er|\bprop\b/i
|
||||||
|
|
||||||
|
# The aircraft model; each engine and propeller model (and its family);
|
||||||
|
# and every other installed component's make and model, so ADs on
|
||||||
|
# appliances (magnetos, ELTs, radios, filters…) are found too.
|
||||||
def self.default_terms(aircraft)
|
def self.default_terms(aircraft)
|
||||||
engines = aircraft.components.in_use.includes(:component_type)
|
terms = []
|
||||||
.select { _1.component_type&.name.to_s.match?(/engine|propell?er|\bprop\b/i) }.map(&:model).compact_blank.map(&:strip)
|
terms << Term.new(aircraft.model.strip, [ aircraft.model.strip ], nil) if aircraft.model.present?
|
||||||
([ aircraft.model.to_s.strip ] + engines.flat_map { [ _1, model_family(_1) ] }).compact_blank.uniq
|
aircraft.components.in_use.includes(:component_type).order(:id).each do |c|
|
||||||
|
model = c.model.to_s.strip
|
||||||
|
next if model.blank?
|
||||||
|
if c.component_type&.name.to_s.match?(ENGINE_OR_PROP)
|
||||||
|
[ model, model_family(model) ].compact.each { |m| terms << Term.new(m, [ m ], c.id) }
|
||||||
|
else
|
||||||
|
label = [ c.manufacturer.to_s.strip, model ].compact_blank.join(" ")
|
||||||
|
# Maker + model, and type + model: ADs often name the maker differently
|
||||||
|
# (a successor company) but say what the part is ("magneto", "ELT").
|
||||||
|
[ c.manufacturer.to_s.strip.split.first, c.component_type&.name.to_s.strip.split.first ].compact_blank.uniq.each do |lead|
|
||||||
|
terms << Term.new(label, ([ lead ] + designators(model)).uniq, c.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
terms.uniq { _1.words.map(&:downcase) }
|
||||||
end
|
end
|
||||||
|
|
||||||
# The engine family ADs often name instead of the exact model, and that also
|
# The engine family ADs often name instead of the exact model, and that also
|
||||||
@@ -32,16 +55,25 @@ class AdWatch
|
|||||||
family unless family.nil? || family == model.to_s.upcase
|
family unless family.nil? || family == model.to_s.upcase
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# The parts of a model name with digits in them ("Slick 4301" -> ["4301"]):
|
||||||
|
# brand words in the model field rarely appear in an AD's text.
|
||||||
|
def self.designators(model)
|
||||||
|
words = model.split
|
||||||
|
with_digits = words.grep(/\d/)
|
||||||
|
with_digits.any? ? with_digits : words
|
||||||
|
end
|
||||||
|
|
||||||
|
# The owner's own list (comma-separated) replaces the defaults.
|
||||||
def terms
|
def terms
|
||||||
custom = @aircraft.ad_watch_terms.to_s.split(/[,;\n]/).map(&:strip).compact_blank
|
custom = @aircraft.ad_watch_terms.to_s.split(/[,;\n]/).map(&:strip).compact_blank
|
||||||
custom.any? ? custom : self.class.default_terms(@aircraft)
|
custom.any? ? custom.map { Term.new(_1, [ _1 ], nil) } : self.class.default_terms(@aircraft)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the new AdAlerts.
|
# Returns the new AdAlerts.
|
||||||
def check!
|
def check!
|
||||||
since = (@aircraft.ad_watch_checked_at || FIRST_LOOKBACK.ago).to_date - 7 # overlap; duplicates are skipped
|
since = (@aircraft.ad_watch_checked_at || FIRST_LOOKBACK.ago).to_date - 7 # overlap; duplicates are skipped
|
||||||
known = AirworthinessDirective.pluck(:name).to_set
|
known = AirworthinessDirective.pluck(:name).to_set
|
||||||
created = terms.flat_map { |term| search(term, since).filter_map { record(_1, term, known) } }
|
created = terms.flat_map { |term| search(term.words, since).filter_map { record(_1, term, known) } }
|
||||||
@aircraft.update_column(:ad_watch_checked_at, Time.current)
|
@aircraft.update_column(:ad_watch_checked_at, Time.current)
|
||||||
created
|
created
|
||||||
end
|
end
|
||||||
@@ -57,15 +89,16 @@ class AdWatch
|
|||||||
fr_document_number: doc["document_number"], ad_number: ad_number,
|
fr_document_number: doc["document_number"], ad_number: ad_number,
|
||||||
amendment: dockets.find { _1.start_with?("Amendment ") }&.delete_prefix("Amendment "),
|
amendment: dockets.find { _1.start_with?("Amendment ") }&.delete_prefix("Amendment "),
|
||||||
title: doc["title"].to_s.truncate(250), abstract: doc["abstract"], html_url: doc["html_url"],
|
title: doc["title"].to_s.truncate(250), abstract: doc["abstract"], html_url: doc["html_url"],
|
||||||
publication_date: doc["publication_date"], effective_on: doc["effective_on"], matched_term: term
|
publication_date: doc["publication_date"], effective_on: doc["effective_on"], matched_term: term.label,
|
||||||
|
component_id: term.component_id
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def search(term, since)
|
def search(words, since)
|
||||||
query = [
|
query = [
|
||||||
[ "per_page", "50" ], [ "order", "newest" ],
|
[ "per_page", "50" ], [ "order", "newest" ],
|
||||||
[ "conditions[agencies][]", "federal-aviation-administration" ], [ "conditions[type][]", "RULE" ],
|
[ "conditions[agencies][]", "federal-aviation-administration" ], [ "conditions[type][]", "RULE" ],
|
||||||
[ "conditions[term]", %("airworthiness directives" "#{term.delete('"')}") ],
|
[ "conditions[term]", ([ "airworthiness directives" ] + words).map { %("#{_1.delete('"')}") }.join(" ") ],
|
||||||
[ "conditions[publication_date][gte]", since.iso8601 ]
|
[ "conditions[publication_date][gte]", since.iso8601 ]
|
||||||
] + FIELDS.map { [ "fields[]", _1 ] }
|
] + FIELDS.map { [ "fields[]", _1 ] }
|
||||||
uri = URI(API)
|
uri = URI(API)
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<div>
|
<div>
|
||||||
<h2 class="card-title">Newly published ADs that may apply</h2>
|
<h2 class="card-title">Newly published ADs that may apply</h2>
|
||||||
<p class="text-xs text-slate-500">Searched weekly in the Federal Register for <%= AdWatch.new(@aircraft).terms.to_sentence.presence || "the aircraft, engine and propeller models" %><%= " · last checked #{time_ago_in_words(@aircraft.ad_watch_checked_at)} ago" if @aircraft.ad_watch_checked_at %>.</p>
|
<p class="text-xs text-slate-500">Searched weekly in the Federal Register for <%= AdWatch.new(@aircraft).terms.map(&:label).uniq.to_sentence.presence || "the aircraft and its installed components" %><%= " · last checked #{time_ago_in_words(@aircraft.ad_watch_checked_at)} ago" if @aircraft.ad_watch_checked_at %>.</p>
|
||||||
</div>
|
</div>
|
||||||
<% if owner? %><%= button_to "Check now", check_aircraft_ad_alerts_path(@aircraft), class: "btn-secondary btn-sm", data: { turbo_submits_with: "Checking…" } %><% end %>
|
<% if owner? %><%= button_to "Check now", check_aircraft_ad_alerts_path(@aircraft), class: "btn-secondary btn-sm", data: { turbo_submits_with: "Checking…" } %><% end %>
|
||||||
</div>
|
</div>
|
||||||
@@ -85,10 +85,10 @@
|
|||||||
<%= form_with url: terms_aircraft_ad_alerts_path(@aircraft), method: :patch, class: "flex flex-wrap items-end gap-2 border-t border-slate-100 px-4 py-3" do %>
|
<%= form_with url: terms_aircraft_ad_alerts_path(@aircraft), method: :patch, class: "flex flex-wrap items-end gap-2 border-t border-slate-100 px-4 py-3" do %>
|
||||||
<div class="min-w-0 flex-1">
|
<div class="min-w-0 flex-1">
|
||||||
<%= label_tag :ad_watch_terms, "Search terms", class: "label" %>
|
<%= label_tag :ad_watch_terms, "Search terms", class: "label" %>
|
||||||
<%= text_field_tag :ad_watch_terms, @aircraft.ad_watch_terms, class: "input", placeholder: AdWatch.default_terms(@aircraft).join(", ").presence || "e.g. 172N, O-320, 1C160" %>
|
<%= text_field_tag :ad_watch_terms, @aircraft.ad_watch_terms, class: "input", placeholder: AdWatch.default_terms(@aircraft).map(&:label).uniq.join(", ").presence || "e.g. 172N, O-320, 1C160" %>
|
||||||
</div>
|
</div>
|
||||||
<%= submit_tag "Save", class: "btn-secondary" %>
|
<%= submit_tag "Save", class: "btn-secondary" %>
|
||||||
<p class="hint w-full">Comma-separated model names. Left blank, the aircraft, engine and propeller models are used. Matches are only possibly applicable: check each AD's applicability (and serial number ranges) before tracking it.</p>
|
<p class="hint w-full">Comma-separated model names. Left blank, the aircraft model, engine and propeller models (and their families) and every installed component’s make and model are used; a match on a component makes the tracked AD apply to that component. Matches are only possibly applicable: check each AD's applicability (and serial number ranges) before tracking it.</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
class AddComponentToAdAlerts < ActiveRecord::Migration[8.1]
|
||||||
|
def change
|
||||||
|
# The installed component whose make/model matched, so tracking the AD
|
||||||
|
# makes it apply to that component (an appliance AD: magneto, ELT, radio…).
|
||||||
|
add_reference :ad_alerts, :component, foreign_key: { on_delete: :nullify }
|
||||||
|
end
|
||||||
|
end
|
||||||
Generated
+4
-1
@@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[8.1].define(version: 2026_11_08_050000) do
|
ActiveRecord::Schema[8.1].define(version: 2026_11_09_010000) do
|
||||||
create_table "active_storage_attachments", force: :cascade do |t|
|
create_table "active_storage_attachments", force: :cascade do |t|
|
||||||
t.string "name", null: false
|
t.string "name", null: false
|
||||||
t.string "record_type", null: false
|
t.string "record_type", null: false
|
||||||
@@ -54,9 +54,11 @@ ActiveRecord::Schema[8.1].define(version: 2026_11_08_050000) do
|
|||||||
t.integer "airworthiness_directive_id"
|
t.integer "airworthiness_directive_id"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
|
t.integer "component_id"
|
||||||
t.index ["aircraft_id", "fr_document_number"], name: "index_ad_alerts_on_aircraft_id_and_fr_document_number", unique: true
|
t.index ["aircraft_id", "fr_document_number"], name: "index_ad_alerts_on_aircraft_id_and_fr_document_number", unique: true
|
||||||
t.index ["aircraft_id"], name: "index_ad_alerts_on_aircraft_id"
|
t.index ["aircraft_id"], name: "index_ad_alerts_on_aircraft_id"
|
||||||
t.index ["airworthiness_directive_id"], name: "index_ad_alerts_on_airworthiness_directive_id"
|
t.index ["airworthiness_directive_id"], name: "index_ad_alerts_on_airworthiness_directive_id"
|
||||||
|
t.index ["component_id"], name: "index_ad_alerts_on_component_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "ad_compliances", force: :cascade do |t|
|
create_table "ad_compliances", force: :cascade do |t|
|
||||||
@@ -823,6 +825,7 @@ ActiveRecord::Schema[8.1].define(version: 2026_11_08_050000) do
|
|||||||
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
|
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
|
||||||
add_foreign_key "ad_alerts", "aircraft"
|
add_foreign_key "ad_alerts", "aircraft"
|
||||||
add_foreign_key "ad_alerts", "airworthiness_directives", on_delete: :nullify
|
add_foreign_key "ad_alerts", "airworthiness_directives", on_delete: :nullify
|
||||||
|
add_foreign_key "ad_alerts", "components", on_delete: :nullify
|
||||||
add_foreign_key "ad_compliances", "aircraft"
|
add_foreign_key "ad_compliances", "aircraft"
|
||||||
add_foreign_key "ad_compliances", "airworthiness_directives"
|
add_foreign_key "ad_compliances", "airworthiness_directives"
|
||||||
add_foreign_key "ad_compliances", "components"
|
add_foreign_key "ad_compliances", "components"
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ The **ADs** tab lists the ADs and bulletins that apply to the aircraft or its co
|
|||||||
|
|
||||||
## Newly published ADs
|
## Newly published ADs
|
||||||
|
|
||||||
The app searches the Federal Register weekly for new ADs mentioning the aircraft, engine and propeller models (or the terms you set). **Check now** runs it straight away. For each match, **Track** it or **Dismiss** it. Matches are only *possibly* applicable: check the AD's applicability and serial number ranges first.
|
The app searches the Federal Register weekly for new ADs mentioning the aircraft model, the engine and propeller models (and their families, e.g. O-200 for an O-200A), and the make and model of every other installed component, such as magnetos, the ELT and radios (or only the terms you set). Tracking an AD found through a component makes it apply to that component. **Check now** runs it straight away. For each match, **Track** it or **Dismiss** it. Matches are only *possibly* applicable: check the AD's applicability and serial number ranges first.
|
||||||
|
|
||||||
## Recording compliance
|
## Recording compliance
|
||||||
|
|
||||||
|
|||||||
@@ -165,9 +165,30 @@ class GroupFourTest < ActionDispatch::IntegrationTest
|
|||||||
{ document_number: "2026-22222", title: "Special Conditions; Something Else", publication_date: "2026-08-02", docket_ids: [] }
|
{ document_number: "2026-22222", title: "Special Conditions; Something Else", publication_date: "2026-08-02", docket_ids: [] }
|
||||||
] }.to_json
|
] }.to_json
|
||||||
|
|
||||||
|
test "the AD search also looks for installed components, and an AD found that way applies to the component" do
|
||||||
|
magneto = create_component(@a, component_type: component_type("Magneto"), manufacturer: "Champion", model: "Slick 4301")
|
||||||
|
create_component(@a, component_type: component_type("ELT"), manufacturer: "Artex", model: "345", status: "SPARE")
|
||||||
|
terms = AdWatch.default_terms(@a)
|
||||||
|
assert_equal [ "172N", "Champion Slick 4301" ], terms.map(&:label).uniq # spares skipped
|
||||||
|
assert_equal [ %w[Champion 4301], %w[Magneto 4301] ], terms.drop(1).map(&:words) # maker + designator, type + designator
|
||||||
|
assert_equal [ magneto.id ], terms.drop(1).map(&:component_id).uniq
|
||||||
|
|
||||||
|
stub_request(:get, %r{federalregister}).to_return(status: 200, body: { results: [] }.to_json)
|
||||||
|
stub = stub_request(:get, %r{federalregister}).with(query: hash_including("conditions" => hash_including("term" => %("airworthiness directives" "Champion" "4301"))))
|
||||||
|
.to_return(status: 200, body: FR_RESPONSE)
|
||||||
|
AdWatch.new(@a).check!
|
||||||
|
assert_requested stub
|
||||||
|
alert = @a.ad_alerts.find_by!(ad_number: "2026-17-10")
|
||||||
|
assert_equal [ "Champion Slick 4301", magneto ], [ alert.matched_term, alert.component ]
|
||||||
|
ad = alert.track!
|
||||||
|
assert_includes magneto.reload.airworthiness_directives, ad
|
||||||
|
refute_includes ad.aircraft, @a
|
||||||
|
assert_includes @a.applicable_ads, ad # through the component
|
||||||
|
end
|
||||||
|
|
||||||
test "newly published ADs are found, tracked or dismissed, and reported weekly" do
|
test "newly published ADs are found, tracked or dismissed, and reported weekly" do
|
||||||
create_component(@a, component_type: component_type("Engine"), model: "O-320-H2AD")
|
create_component(@a, component_type: component_type("Engine"), model: "O-320-H2AD")
|
||||||
assert_equal [ "172N", "O-320-H2AD", "O-320" ], AdWatch.default_terms(@a) # engine family too
|
assert_equal [ "172N", "O-320-H2AD", "O-320" ], AdWatch.default_terms(@a).map(&:label) # engine family too
|
||||||
assert_equal "O-200", AdWatch.model_family("O-200A")
|
assert_equal "O-200", AdWatch.model_family("O-200A")
|
||||||
assert_equal "IO-550", AdWatch.model_family("IO-550-N")
|
assert_equal "IO-550", AdWatch.model_family("IO-550-N")
|
||||||
assert_nil AdWatch.model_family("O-200")
|
assert_nil AdWatch.model_family("O-200")
|
||||||
@@ -207,7 +228,7 @@ class GroupFourTest < ActionDispatch::IntegrationTest
|
|||||||
assert_equal "dismissed", other.reload.status
|
assert_equal "dismissed", other.reload.status
|
||||||
|
|
||||||
patch terms_aircraft_ad_alerts_path(@a), params: { ad_watch_terms: "172, O-320" }
|
patch terms_aircraft_ad_alerts_path(@a), params: { ad_watch_terms: "172, O-320" }
|
||||||
assert_equal [ "172", "O-320" ], AdWatch.new(@a.reload).terms
|
assert_equal [ "172", "O-320" ], AdWatch.new(@a.reload).terms.map(&:label)
|
||||||
|
|
||||||
stub_request(:get, %r{federalregister}).to_return(status: 503)
|
stub_request(:get, %r{federalregister}).to_return(status: 503)
|
||||||
post check_aircraft_ad_alerts_path(@a)
|
post check_aircraft_ad_alerts_path(@a)
|
||||||
|
|||||||
Reference in new issue
Block a user