mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
Editable logbook templates; component times follow the airframe time
- Templates move to the database (Admin -> Logbook templates: add, edit, delete, restore the built-in ones). The built-in preventive maintenance set is added once on first use; deletions stick. A template can set the entry type, logbook (picking the matching component) and certificate - Template list shows "Name — Part 43 App. A (c)(6), (c)(23)" instead of the doubled parentheses - Component total time and time since overhaul are worked out from the entry's airframe total time (current times shifted by the difference); blank when the entry predates the overhaul; typing them stops the automatic updates Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a51f78ebf3
commit
72e1d7760f
22 files changed
+366
-74
No files matched your search
@@ -34,14 +34,46 @@ class GroupFourTest < ActionDispatch::IntegrationTest
|
||||
refute first.reload.verified?
|
||||
end
|
||||
|
||||
test "preventive maintenance templates fill in the entry with the Part 43 reference" do
|
||||
test "built-in templates are added once, show their reference, and fill in the entry" do
|
||||
sign_in @owner
|
||||
get new_aircraft_logbook_entry_path(@a)
|
||||
assert_select "select[data-entry-template-target=template] option", PreventiveMaintenance::ITEMS.size + 1
|
||||
assert_select "option[value=spark_plugs][data-text*='Part 43 Appendix A paragraph (c)(20)']"
|
||||
assert_select "option[value=oil_change][data-text*='14 CFR 43.3(g)']"
|
||||
count = LogbookTemplate.defaults.size
|
||||
assert_equal count, LogbookTemplate.count
|
||||
assert_select "select[data-entry-template-target=template] option", count + 1
|
||||
assert_select "option[data-log-type=ENG][data-certificate=PILOT][data-entry-type=MAINTENANCE]", text: "Oil and filter change — Part 43 App. A (c)(6), (c)(23)"
|
||||
assert_select "option[data-text*='Part 43 Appendix A paragraph (c)(20)']", text: /Cleaning or replacing spark plugs/
|
||||
get edit_aircraft_logbook_entry_path(@a, @a.logbook_entries.create!(date: Date.current, text: "x"))
|
||||
assert_select "select[data-entry-template-target=template]", 0
|
||||
|
||||
LogbookTemplate.delete_all # deleting them sticks
|
||||
get new_aircraft_logbook_entry_path(@a)
|
||||
assert_equal 0, LogbookTemplate.count
|
||||
assert_select "select[data-entry-template-target=template]", 0
|
||||
end
|
||||
|
||||
test "admins add, edit and restore templates" do
|
||||
sign_in @owner
|
||||
get admin_logbook_templates_path
|
||||
assert_redirected_to root_path
|
||||
|
||||
admin = create_user("admin@example.com", admin: true)
|
||||
sign_in admin
|
||||
get admin_logbook_templates_path
|
||||
assert_select "a", text: "+ New Template"
|
||||
oil = LogbookTemplate.find_by!(name: "Oil and filter change")
|
||||
post admin_logbook_templates_path, params: { logbook_template: { name: "Annual sign-off", reference: "14 CFR 43.11", entry_type: "INSPECTION",
|
||||
log_type: "AC", certificate_type: "IA", text: "Annual inspection completed IAW Part 43 Appendix D." } }
|
||||
assert_redirected_to admin_logbook_templates_path
|
||||
assert_equal [ "INSPECTION", "AC", "IA" ], LogbookTemplate.find_by!(name: "Annual sign-off").then { [ _1.entry_type, _1.log_type, _1.certificate_type ] }
|
||||
post admin_logbook_templates_path, params: { logbook_template: { name: "", text: "", entry_type: "NOPE" } }
|
||||
assert_response :unprocessable_entity
|
||||
|
||||
patch admin_logbook_template_path(oil), params: { logbook_template: { text: "Changed oil: __ qt of __." } }
|
||||
assert_equal "Changed oil: __ qt of __.", oil.reload.text
|
||||
delete admin_logbook_template_path(oil)
|
||||
post restore_admin_logbook_templates_path
|
||||
assert_equal "Restored 1 built-in template.", flash[:notice]
|
||||
assert LogbookTemplate.exists?(name: "Oil and filter change")
|
||||
end
|
||||
|
||||
test "an STC's ICA becomes a tracked inspection linked from its major record" do
|
||||
|
||||
Reference in new issue
Block a user