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