mirror of
https://github.com/we-promise/sure.git
synced 2026-04-18 19:44:09 +00:00
Add instituion details & notes to Account model (#481)
- Add institution name & domain, to allow fetching logos when no provider is configured - Add free-form textarea for storing misc. notes (eg. sort codes, account numbers) - Update account settings form to support these new fields
This commit is contained in:
committed by
GitHub
parent
104324a82b
commit
68864b1fdb
@@ -18,6 +18,9 @@ class CreditCardsControllerTest < ActionDispatch::IntegrationTest
|
||||
name: "New Credit Card",
|
||||
balance: 1000,
|
||||
currency: "USD",
|
||||
institution_name: "Amex",
|
||||
institution_domain: "americanexpress.com",
|
||||
notes: "Primary card",
|
||||
accountable_type: "CreditCard",
|
||||
accountable_attributes: {
|
||||
available_credit: 5000,
|
||||
@@ -35,6 +38,9 @@ class CreditCardsControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_equal "New Credit Card", created_account.name
|
||||
assert_equal 1000, created_account.balance
|
||||
assert_equal "USD", created_account.currency
|
||||
assert_equal "Amex", created_account[:institution_name]
|
||||
assert_equal "americanexpress.com", created_account[:institution_domain]
|
||||
assert_equal "Primary card", created_account[:notes]
|
||||
assert_equal 5000, created_account.accountable.available_credit
|
||||
assert_equal 25.51, created_account.accountable.minimum_payment
|
||||
assert_equal 15.99, created_account.accountable.apr
|
||||
@@ -53,6 +59,9 @@ class CreditCardsControllerTest < ActionDispatch::IntegrationTest
|
||||
name: "Updated Credit Card",
|
||||
balance: 2000,
|
||||
currency: "USD",
|
||||
institution_name: "Chase",
|
||||
institution_domain: "chase.com",
|
||||
notes: "Updated notes",
|
||||
accountable_type: "CreditCard",
|
||||
accountable_attributes: {
|
||||
id: @account.accountable_id,
|
||||
@@ -70,6 +79,9 @@ class CreditCardsControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
assert_equal "Updated Credit Card", @account.name
|
||||
assert_equal 2000, @account.balance
|
||||
assert_equal "Chase", @account[:institution_name]
|
||||
assert_equal "chase.com", @account[:institution_domain]
|
||||
assert_equal "Updated notes", @account[:notes]
|
||||
assert_equal 6000, @account.accountable.available_credit
|
||||
assert_equal 50, @account.accountable.minimum_payment
|
||||
assert_equal 14.99, @account.accountable.apr
|
||||
|
||||
@@ -18,6 +18,9 @@ class LoansControllerTest < ActionDispatch::IntegrationTest
|
||||
name: "New Loan",
|
||||
balance: 50000,
|
||||
currency: "USD",
|
||||
institution_name: "Local Bank",
|
||||
institution_domain: "localbank.example",
|
||||
notes: "Mortgage notes",
|
||||
accountable_type: "Loan",
|
||||
accountable_attributes: {
|
||||
interest_rate: 5.5,
|
||||
@@ -34,6 +37,9 @@ class LoansControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_equal "New Loan", created_account.name
|
||||
assert_equal 50000, created_account.balance
|
||||
assert_equal "USD", created_account.currency
|
||||
assert_equal "Local Bank", created_account[:institution_name]
|
||||
assert_equal "localbank.example", created_account[:institution_domain]
|
||||
assert_equal "Mortgage notes", created_account[:notes]
|
||||
assert_equal 5.5, created_account.accountable.interest_rate
|
||||
assert_equal 60, created_account.accountable.term_months
|
||||
assert_equal "fixed", created_account.accountable.rate_type
|
||||
@@ -51,6 +57,9 @@ class LoansControllerTest < ActionDispatch::IntegrationTest
|
||||
name: "Updated Loan",
|
||||
balance: 45000,
|
||||
currency: "USD",
|
||||
institution_name: "Updated Bank",
|
||||
institution_domain: "updatedbank.example",
|
||||
notes: "Updated loan notes",
|
||||
accountable_type: "Loan",
|
||||
accountable_attributes: {
|
||||
id: @account.accountable_id,
|
||||
@@ -67,6 +76,9 @@ class LoansControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
assert_equal "Updated Loan", @account.name
|
||||
assert_equal 45000, @account.balance
|
||||
assert_equal "Updated Bank", @account[:institution_name]
|
||||
assert_equal "updatedbank.example", @account[:institution_domain]
|
||||
assert_equal "Updated loan notes", @account[:notes]
|
||||
assert_equal 4.5, @account.accountable.interest_rate
|
||||
assert_equal 48, @account.accountable.term_months
|
||||
assert_equal "fixed", @account.accountable.rate_type
|
||||
|
||||
@@ -14,6 +14,9 @@ class PropertiesControllerTest < ActionDispatch::IntegrationTest
|
||||
account: {
|
||||
name: "New Property",
|
||||
subtype: "house",
|
||||
institution_name: "Property Lender",
|
||||
institution_domain: "propertylender.example",
|
||||
notes: "Property notes",
|
||||
accountable_type: "Property",
|
||||
accountable_attributes: {
|
||||
year_built: 1990,
|
||||
@@ -28,6 +31,9 @@ class PropertiesControllerTest < ActionDispatch::IntegrationTest
|
||||
assert created_account.accountable.is_a?(Property)
|
||||
assert_equal "draft", created_account.status
|
||||
assert_equal 0, created_account.balance
|
||||
assert_equal "Property Lender", created_account[:institution_name]
|
||||
assert_equal "propertylender.example", created_account[:institution_domain]
|
||||
assert_equal "Property notes", created_account[:notes]
|
||||
assert_equal 1990, created_account.accountable.year_built
|
||||
assert_equal 1200, created_account.accountable.area_value
|
||||
assert_equal "sqft", created_account.accountable.area_unit
|
||||
@@ -39,6 +45,9 @@ class PropertiesControllerTest < ActionDispatch::IntegrationTest
|
||||
patch property_path(@account), params: {
|
||||
account: {
|
||||
name: "Updated Property",
|
||||
institution_name: "Updated Lender",
|
||||
institution_domain: "updatedlender.example",
|
||||
notes: "Updated property notes",
|
||||
accountable_attributes: {
|
||||
id: @account.accountable.id,
|
||||
subtype: "condominium"
|
||||
@@ -50,6 +59,9 @@ class PropertiesControllerTest < ActionDispatch::IntegrationTest
|
||||
@account.reload
|
||||
assert_equal "Updated Property", @account.name
|
||||
assert_equal "condominium", @account.subtype
|
||||
assert_equal "Updated Lender", @account[:institution_name]
|
||||
assert_equal "updatedlender.example", @account[:institution_domain]
|
||||
assert_equal "Updated property notes", @account[:notes]
|
||||
|
||||
# If account is active, it renders edit view; otherwise redirects to balances
|
||||
if @account.active?
|
||||
|
||||
@@ -18,6 +18,9 @@ class VehiclesControllerTest < ActionDispatch::IntegrationTest
|
||||
name: "Vehicle",
|
||||
balance: 30000,
|
||||
currency: "USD",
|
||||
institution_name: "Auto Lender",
|
||||
institution_domain: "autolender.example",
|
||||
notes: "Lease notes",
|
||||
accountable_type: "Vehicle",
|
||||
accountable_attributes: {
|
||||
make: "Toyota",
|
||||
@@ -32,6 +35,12 @@ class VehiclesControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
created_account = Account.order(:created_at).last
|
||||
|
||||
assert_equal "Vehicle", created_account.name
|
||||
assert_equal 30000, created_account.balance
|
||||
assert_equal "USD", created_account.currency
|
||||
assert_equal "Auto Lender", created_account[:institution_name]
|
||||
assert_equal "autolender.example", created_account[:institution_domain]
|
||||
assert_equal "Lease notes", created_account[:notes]
|
||||
assert_equal "Toyota", created_account.accountable.make
|
||||
assert_equal "Camry", created_account.accountable.model
|
||||
assert_equal 2020, created_account.accountable.year
|
||||
@@ -50,6 +59,9 @@ class VehiclesControllerTest < ActionDispatch::IntegrationTest
|
||||
name: "Updated Vehicle",
|
||||
balance: 28000,
|
||||
currency: "USD",
|
||||
institution_name: "Updated Lender",
|
||||
institution_domain: "updatedlender.example",
|
||||
notes: "Updated lease notes",
|
||||
accountable_type: "Vehicle",
|
||||
accountable_attributes: {
|
||||
id: @account.accountable_id,
|
||||
@@ -64,6 +76,13 @@ class VehiclesControllerTest < ActionDispatch::IntegrationTest
|
||||
}
|
||||
end
|
||||
|
||||
@account.reload
|
||||
assert_equal "Updated Vehicle", @account.name
|
||||
assert_equal 28000, @account.balance
|
||||
assert_equal "Updated Lender", @account[:institution_name]
|
||||
assert_equal "updatedlender.example", @account[:institution_domain]
|
||||
assert_equal "Updated lease notes", @account[:notes]
|
||||
|
||||
assert_redirected_to account_path(@account)
|
||||
assert_equal "Vehicle account updated", flash[:notice]
|
||||
assert_enqueued_with(job: SyncJob)
|
||||
|
||||
Reference in New Issue
Block a user