Workflow polish: setup checklist, next leg, grouped component limits

- Setup checklist on a new aircraft's Overview (owners): components,
  standard inspections, DRS AD import, registration/airworthiness
  certificate, weight and balance; hideable per device
- Log Flight: "Save and log next leg" reopens the form on the same date,
  starting where the leg ended
- Component form: limits in two collapsible groups (replacement and expiry;
  overhaul and TBO), open when in use
- Squawk form warns what "Ground Aircraft" does
- Logbook entry form: inspection result only for inspection entries
  (show-when controller); document names default from the file
- Dates in pickers, the activity log, airworthiness lines, search, audits
  and transcription notes use the app format
- No duplicate Report Squawk button on Squawks; "Record service" label

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-14 07:43:03 -05:00
1 parent 3452a35896
commit 03b9ad65cb
34 files changed
+303 -77

No files matched your search

@@ -44,7 +44,7 @@ class ElectronicSignaturesTest < ActionDispatch::IntegrationTest
assert_equal [ @entry.content_digest, :valid ], [ sig.content_digest, sig.status ]
assert_equal "Replaced left landing light lamp P/N 4509.", JSON.parse(sig.content_snapshot)["text"]
assert_equal "You signed a logbook entry for N12345", ActionMailer::Base.deliveries.last.subject
assert_equal "Logbook entry signed electronically (2026-10-01)", @a.events.last.event_name
assert_equal "Logbook entry signed electronically (Oct 1, 2026)", @a.events.last.event_name
get aircraft_logbook_entry_path(@a, @entry)
assert_includes response.body, "Certified by Sam Mechanic, A&amp;P 7654321"
+2 -2
View File
@@ -61,7 +61,7 @@ class LogbookEntryPartsTest < ActionDispatch::IntegrationTest
# dated to the entry; the 10 hours flown since the entry carry over
assert_equal [ Date.new(2026, 8, 20), 10.0, 120.5 ], [ @filter.overhaul_date, @filter.hours_since_overhaul.to_f, @filter.hours_in_service.to_f ]
assert_equal [ 10.0, 10.0, Date.new(2026, 8, 20) ], [ oil.hours_since_overhaul.to_f, oil.hours_in_service.to_f, oil.date_in_service ]
assert @a.events.exists?(event_name: "Replaced: #{oil} (logbook entry 2026-08-20)")
assert @a.events.exists?(event_name: "Replaced: #{oil} (logbook entry Aug 20, 2026)")
entry = @a.logbook_entries.last # editing doesn't offer it again (it would apply twice)
get edit_aircraft_logbook_entry_path(@a, entry)
@@ -84,7 +84,7 @@ class LogbookEntryPartsTest < ActionDispatch::IntegrationTest
entry = @a.logbook_entries.sole
record = @a.inspection_records.sole
assert_equal [ oil_change, entry, Date.new(2026, 8, 20), 4200.3 ], [ record.inspection_type, record.logbook_entry, record.date, record.aircraft_hours.to_f ]
assert @a.events.exists?(event_name: "Inspection completed: Oil Change (logbook entry 2026-08-20)")
assert @a.events.exists?(event_name: "Inspection completed: Oil Change (logbook entry Aug 20, 2026)")
get edit_aircraft_logbook_entry_path(@a, entry) # not offered again on edit (it would record twice)
assert_select "input[name='logbook_entry[inspection_type_ids][]']", 0
+1 -1
View File
@@ -26,7 +26,7 @@ class OilAnalysisFlowTest < ActionDispatch::IntegrationTest
latest = @aircraft.oil_analyses.recent_first.first
assert_redirected_to aircraft_oil_analysis_path(@aircraft, latest)
assert latest.report.attached?
assert_equal [ "Oil analysis added (sampled 2026-08-01)" ], @aircraft.events.where(category: "oil_analysis").limit(1).pluck(:event_name)
assert_equal [ "Oil analysis added (sampled Aug 1, 2026)" ], @aircraft.events.where(category: "oil_analysis").limit(1).pluck(:event_name)
get aircraft_oil_analyses_path(@aircraft)
assert_response :success
+2 -2
View File
@@ -68,7 +68,7 @@ class PwaFeaturesTest < ActionDispatch::IntegrationTest
test "squawks can be reported offline and are received once" do
sign_in @pilot
get new_aircraft_squawk_path(@a)
assert_select "form[data-controller=offline-form][data-offline-form-kind-value=squawk][data-offline-form-tail-value=N12345]"
assert_select "form[data-controller~=offline-form][data-offline-form-kind-value=squawk][data-offline-form-tail-value=N12345]"
assert_select "input[type=hidden][name='squawk[client_key]']"
params = { squawk: { priority: 1, issue_reported: "Left landing light inop", client_key: "sq-1" } }
@@ -78,7 +78,7 @@ class PwaFeaturesTest < ActionDispatch::IntegrationTest
get edit_aircraft_squawk_path(@a, @a.squawks.last) # pilots can't edit; owners' edit form isn't queued
sign_in @owner
get edit_aircraft_squawk_path(@a, @a.squawks.last)
assert_select "form[data-controller=offline-form]", count: 0
assert_select "form[data-controller~=offline-form]", count: 0
end
test "home-screen shortcuts open the form for your only aircraft, or let you choose" do
+1 -1
View File
@@ -51,7 +51,7 @@ class RecordsIntegrityTest < ActionDispatch::IntegrationTest
RecordVersion.where(id: victim.id).delete_all
check = RecordsIntegrity.check!
refute check.ok
assert(check.problems.any? { _1.include?("the 2026-10-01 logbook entry (signed by Sam Mechanic) changed after it was signed") })
assert(check.problems.any? { _1.include?("the Oct 1, 2026 logbook entry (signed by Sam Mechanic) changed after it was signed") })
assert(check.problems.any? { _1.include?("doesn't follow the one before it") || _1.include?("missing") } || RecordVersion.where(aircraft_id: other.id).count.zero?)
RecordVersion.where(aircraft_id: @a.id).last.then { RecordVersion.where(id: _1.id).update_all(payload: _1.payload.sub("Changed oil", "Changed gas")) }
+1 -1
View File
@@ -36,7 +36,7 @@ class UserCertificatesTest < ActionDispatch::IntegrationTest
@owner.certificates.create!(kind: "IA", number: "7654321", expires_on: 1.day.ago.to_date) # expired: not offered
sign_in @owner
get new_aircraft_logbook_entry_path(@a)
assert_select "form[data-controller='entry-template signer component-times']"
assert_select "form[data-controller~=signer]"
assert_select "select[data-signer-target=choice] option[data-kind=AP][data-number='7654321'][data-name='Sam Mechanic']"
assert_select "select[data-signer-target=choice] option[data-kind=IA]", 0
assert_select "input[name='logbook_entry[signoff_person]'][data-signer-target=name]"
+77
View File
@@ -0,0 +1,77 @@
require "test_helper"
# Small workflow refinements: readable dates in pickers and the activity log,
# fields that appear when they apply, the next-leg button, grouped component
# limits and the setup checklist for a new aircraft.
class WorkflowPolishTest < ActionDispatch::IntegrationTest
setup do
@owner = create_user("owner@example.com")
@pilot = create_user("pilot@example.com")
@a = create_aircraft(owner: @owner, pilot: @pilot, tail_number: "N12345", tach_time: 1000)
end
test "logbook entry pickers and activity show dates the app's way" do
entry = @a.logbook_entries.create!(date: Date.new(2025, 12, 14), entry_type: "MAINTENANCE", log_type: "AC", text: "Oil changed")
sign_in @owner
get new_aircraft_inspection_record_path(@a)
assert_select "select[name='inspection_record[logbook_entry_id]'] option[value='#{entry.id}']", text: /\ADec 14, 2025 – Oil changed/
end
test "the inspection result appears only for inspection entries" do
sign_in @owner
get new_aircraft_logbook_entry_path(@a)
assert_select "form[data-controller~=show-when] select[name='logbook_entry[entry_type]'][data-show-when-target=source]"
assert_select "[data-show-when-target=item][data-show-when-value=INSPECTION] select[name='logbook_entry[inspection_result]']"
end
test "choosing Ground Aircraft warns what it does" do
sign_in @pilot
get new_aircraft_squawk_path(@a)
assert_select "[data-show-when-target=item][data-show-when-value='0'][hidden]", /This grounds N12345/
get aircraft_squawks_path(@a)
assert_select "main a[href='#{new_aircraft_squawk_path(@a)}']", 1 # just the header's Report Squawk
end
test "Save and log next leg comes back to the form, starting where the flight ended" do
sign_in @pilot
post aircraft_flight_logs_path(@a), params: { next_leg: "1", flight_log: { date: "2026-11-08", tach_out: 1000, tach_in: 1001.2, departure_location: "KOQU", destination_location: "KBID" } }
assert_redirected_to new_aircraft_flight_log_path(@a, date: "2026-11-08")
follow_redirect!
assert_match "The next leg starts where it ended.", flash[:notice]
assert_select "input[name='flight_log[date]'][value='2026-11-08']"
assert_select "input[name='flight_log[tach_out]'][value='1001.2']"
assert_select "input[name='flight_log[departure_location]'][value=KBID]"
end
test "a new document is named from its file, and the setup checklist can preset its type" do
sign_in @owner
get new_aircraft_document_path(@a, doc_type: "REGISTRATION")
assert_select "form[data-controller=name-from-file] input[name='document[name]'][data-name-from-file-target=name]"
assert_select "input[type=file][data-action='name-from-file#fill']"
assert_select "select[name='document[doc_type]'] option[selected][value=REGISTRATION]"
end
test "component limits are grouped and open when in use" do
sign_in @owner
get new_aircraft_component_path(@a)
assert_select "form details:not([open])", 2 # replacement and expiry; overhaul and TBO
engine = @a.components.create!(component_type: ComponentType.find_or_create_by!(name: "Engine"), manufacturer: "Continental", model: "O-200", date_in_service: Date.current, status: "IN-USE", tbo_hours: 1800)
get edit_aircraft_component_path(@a, engine)
assert_select "details[open] input[name='component[tbo_hours]']"
get aircraft_components_path(@a)
assert_select "a", text: "Record service"
end
test "owners see what's left to set up a new aircraft; pilots don't" do
sign_in @owner
get aircraft_path(@a)
assert_select "[data-controller=dismiss] li", 5
assert_select "[data-controller=dismiss]", /0 of 5 done/
@a.components.create!(component_type: ComponentType.find_or_create_by!(name: "Engine"), manufacturer: "Continental", model: "O-200", date_in_service: Date.current, status: "IN-USE")
get aircraft_path(@a)
assert_select "[data-controller=dismiss]", /1 of 5 done/
sign_in @pilot
get aircraft_path(@a)
assert_select "[data-controller=dismiss]", 0
end
end