Oil & Fuel: records load 50 at a time, the rest as you scroll (all records reachable; was capped at 200)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-11 20:27:48 -05:00
1 parent 455a26a346
commit 85326d494c
5 files changed
+77 -21

No files matched your search

@@ -0,0 +1,29 @@
require "test_helper"
# Oil & Fuel records load a page at a time (no more hidden records past 200).
class ConsumableRecordsPagingTest < ActionDispatch::IntegrationTest
setup do
@owner = create_user("owner@example.com")
@a = create_aircraft(owner: @owner, tail_number: "N12345")
per = ConsumableRecordsController::RECORDS_PER_PAGE
(per + 7).times do |i|
@a.consumable_records.create!(record_type: i.even? ? "fuel" : "oil", date: Date.new(2026, 1, 1) + i, quantity_added: 1 + i, flight_hours: 1000 + i)
end
end
test "the first page has the charts and a page of records; the next page comes in a lazy frame" do
sign_in @owner
get aircraft_consumable_records_path(@a)
assert_select "tr.consumable-record", ConsumableRecordsController::RECORDS_PER_PAGE
assert_select "turbo-frame#consumable-records-1[target=_top]"
assert_select "turbo-frame#consumable-records-2[loading=lazy][src=?]", aircraft_consumable_records_path(@a, page: 2)
assert_select "h2", text: "Fuel Burn"
get aircraft_consumable_records_path(@a, page: 2), headers: { "Turbo-Frame" => "consumable-records-2" }
assert_select "turbo-frame#consumable-records-2 tr.consumable-record", 7
assert_select "turbo-frame#consumable-records-3", 0
assert_select "thead", 0 # header only on the first page
assert_select "h2", text: "Fuel Burn", count: 0
assert_includes response.body, "2026-01-01" # the oldest record is reachable
end
end