Add currency validation to account, update demo data generator (#996)

* Add currency validation to account, update demo data generator

* Fix tests
This commit is contained in:
Zach Gollwitzer
2024-07-17 14:18:12 -04:00
committed by GitHub
parent ef0f910b9b
commit b200b71284
6 changed files with 44 additions and 27 deletions

View File

@@ -48,7 +48,7 @@ class Account::EntryTest < ActiveSupport::TestCase
test "can search entries" do
family = families(:empty)
account = family.accounts.create! name: "Test", balance: 0, accountable: Depository.new
account = family.accounts.create! name: "Test", balance: 0, currency: "USD", accountable: Depository.new
category = family.categories.first
merchant = family.merchants.first
@@ -70,7 +70,7 @@ class Account::EntryTest < ActiveSupport::TestCase
test "can calculate total spending for a group of transactions" do
family = families(:empty)
account = family.accounts.create! name: "Test", balance: 0, accountable: Depository.new
account = family.accounts.create! name: "Test", balance: 0, currency: "USD", accountable: Depository.new
create_transaction(account: account, amount: 100)
create_transaction(account: account, amount: 100)
create_transaction(account: account, amount: -500) # income, will be ignored
@@ -80,7 +80,7 @@ class Account::EntryTest < ActiveSupport::TestCase
test "can calculate total income for a group of transactions" do
family = families(:empty)
account = family.accounts.create! name: "Test", balance: 0, accountable: Depository.new
account = family.accounts.create! name: "Test", balance: 0, currency: "USD", accountable: Depository.new
create_transaction(account: account, amount: -100)
create_transaction(account: account, amount: -100)
create_transaction(account: account, amount: 500) # income, will be ignored
@@ -95,7 +95,7 @@ class Account::EntryTest < ActiveSupport::TestCase
end
test "cannot sell more shares of stock than owned" do
account = families(:empty).accounts.create! name: "Test", balance: 0, accountable: Investment.new
account = families(:empty).accounts.create! name: "Test", balance: 0, currency: "USD", accountable: Investment.new
security = securities(:aapl)
error = assert_raises ActiveRecord::RecordInvalid do