mirror of
https://github.com/we-promise/sure.git
synced 2026-05-07 21:04:12 +00:00
* Fix loan account subtype not persisting on create The LoansController was missing :subtype in permitted_accountable_attributes, causing form submissions with account[subtype] to be silently ignored. This is the same bug that was fixed for Investment accounts in PR #1039 and Crypto accounts in PR #1022. Fixes: loan account subtype not saving (v0.7.0-alpha.4) * Validate loan subtype values Agent-Logs-Url: https://github.com/we-promise/sure/sessions/54bc6874-2cc0-43aa-ac44-9acd50316be3 Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com> --------- Co-authored-by: SureBot <sure-bot@we-promise.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com>
27 lines
692 B
Ruby
27 lines
692 B
Ruby
require "test_helper"
|
|
|
|
class LoanTest < ActiveSupport::TestCase
|
|
test "rejects invalid subtype" do
|
|
loan = Loan.new(subtype: "invalid")
|
|
|
|
assert_not loan.valid?
|
|
assert_includes loan.errors[:subtype], "is not included in the list"
|
|
end
|
|
|
|
test "calculates correct monthly payment for fixed rate loan" do
|
|
loan_account = Account.create! \
|
|
family: families(:dylan_family),
|
|
name: "Mortgage Loan",
|
|
balance: 500000,
|
|
currency: "USD",
|
|
accountable: Loan.create!(
|
|
subtype: "mortgage",
|
|
interest_rate: 3.5,
|
|
term_months: 360,
|
|
rate_type: "fixed"
|
|
)
|
|
|
|
assert_equal 2245, loan_account.loan.monthly_payment.amount
|
|
end
|
|
end
|