1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 15:49:39 +02:00

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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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