mirror of
https://github.com/we-promise/sure.git
synced 2026-09-03 05:41:18 +00:00
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 inf5ba646: 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 onf5ba646. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KvWSJotDiqP6qSR7qEiC8Q
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user