From eac82cfb475286ef4513e57c87b31c1e3a9cd698 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 21 Aug 2026 03:31:36 +0000 Subject: [PATCH] Add the two review-requested regression tests Covers the invalid-amount half of "malformed rows are offered, not dropped" -- the existing test only exercised an unparseable date. Asserts the raw value is stored verbatim rather than coerced to 0, so the review step shows the user what the statement actually said. Also covers the Entry validation added in f5ba646: assigning reconciled_by_statement without reconciled_at must fail model validation rather than reaching chk_entries_reconciled_at_present_when_statement_set and raising StatementInvalid. Both requested by CodeRabbit on f5ba646. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01KvWSJotDiqP6qSR7qEiC8Q --- test/models/entry_reconciliation_test.rb | 10 ++++++++++ test/models/pdf_import_reconciliation_test.rb | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/test/models/entry_reconciliation_test.rb b/test/models/entry_reconciliation_test.rb index 2160f8c12..083d72f2e 100644 --- a/test/models/entry_reconciliation_test.rb +++ b/test/models/entry_reconciliation_test.rb @@ -50,6 +50,16 @@ class EntryReconciliationTest < ActiveSupport::TestCase assert_nil entry.reconciled_by_statement_id end + test "an entry cannot cite a statement without being reconciled" do + entry = create_transaction(account: @account) + entry.reconciled_by_statement = @statement + + # Mirrors chk_entries_reconciled_at_present_when_statement_set: the model + # rejects it before the database constraint is reached. + assert_not entry.valid? + assert_predicate entry.errors[:reconciled_at], :any? + end + test "scopes partition reconciled from unreconciled" do reconciled = create_transaction(account: @account) unreconciled = create_transaction(account: @account) diff --git a/test/models/pdf_import_reconciliation_test.rb b/test/models/pdf_import_reconciliation_test.rb index 81b9781ad..7d5a5fb74 100644 --- a/test/models/pdf_import_reconciliation_test.rb +++ b/test/models/pdf_import_reconciliation_test.rb @@ -100,6 +100,20 @@ class PdfImportReconciliationTest < ActiveSupport::TestCase assert_equal 1, @import.reload.rows_count end + test "a row whose amount cannot be parsed is offered with its raw value intact" do + @import.update!(extracted_data: { "transactions" => [ + { "date" => @date.to_s, "amount" => "not-a-number", "name" => "Mystery" } + ] }) + + @import.generate_rows_from_extracted_data + + row = @import.reload.rows.sole + assert_equal 1, @import.rows_count + # Stored verbatim rather than coerced to 0, so the review step shows the user + # what the statement actually said. + assert_equal "not-a-number", row.amount + end + test "reassigning the account re-judges the rows and releases the old reconciliation" do other = @family.accounts.create!( name: "Second Checking", balance: 0, currency: "USD", accountable: Depository.new