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

Account namespace updates: part 1 (#893)

* Rename accountable types

* Merge conflicts

* Fix broken tests

* Add back sidebar changes
This commit is contained in:
Zach Gollwitzer 2024-06-20 07:26:25 -04:00 committed by GitHub
parent 778098ebb0
commit a947db92b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
54 changed files with 349 additions and 184 deletions

View file

@ -47,7 +47,7 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
assert_difference [ "Account.count", "Valuation.count" ], 1 do
post accounts_path, params: {
account: {
accountable_type: "Account::Depository",
accountable_type: "Depository",
balance: 200,
subtype: "checking",
institution_id: institutions(:chase).id
@ -63,7 +63,7 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
assert_difference -> { Account.count } => 1, -> { Valuation.count } => 2 do
post accounts_path, params: {
account: {
accountable_type: "Account::Depository",
accountable_type: "Depository",
balance: 200,
subtype: "checking",
institution_id: institutions(:chase).id,

View file

@ -2,21 +2,21 @@ collectable:
family: dylan_family
name: Collectable Account
balance: 550
accountable_type: Account::OtherAsset
accountable_type: OtherAsset
accountable: other_asset_collectable
iou:
family: dylan_family
name: IOU (personal debt to friend)
balance: 200
accountable_type: Account::OtherLiability
accountable_type: OtherLiability
accountable: other_liability_iou
checking:
family: dylan_family
name: Checking Account
balance: 5000
accountable_type: Account::Depository
accountable_type: Depository
accountable: depository_checking
institution: chase
@ -24,7 +24,7 @@ savings:
family: dylan_family
name: Savings account with valuation overrides
balance: 19700
accountable_type: Account::Depository
accountable_type: Depository
accountable: depository_savings
institution: chase
@ -32,7 +32,7 @@ credit_card:
family: dylan_family
name: Credit Card
balance: 1000
accountable_type: Account::Credit
accountable_type: CreditCard
accountable: credit_one
institution: chase
@ -41,7 +41,7 @@ eur_checking:
name: Euro Checking Account
currency: EUR
balance: 12000
accountable_type: Account::Depository
accountable_type: Depository
accountable: depository_eur_checking
institution: revolut
@ -51,7 +51,7 @@ multi_currency:
name: Multi Currency Account
currency: USD # multi-currency accounts still have a "primary" currency
balance: 9467
accountable_type: Account::Depository
accountable_type: Depository
accountable: depository_multi_currency
institution: revolut
@ -60,7 +60,7 @@ brokerage:
name: Robinhood Brokerage Account
currency: USD
balance: 10000
accountable_type: Account::Investment
accountable_type: Investment
accountable: investment_brokerage
mortgage_loan:
@ -68,7 +68,7 @@ mortgage_loan:
name: Mortgage Loan
currency: USD
balance: 500000
accountable_type: Account::Loan
accountable_type: Loan
accountable: loan_mortgage
house:
@ -76,7 +76,7 @@ house:
name: 123 Maybe Court
currency: USD
balance: 550000
accountable_type: Account::Property
accountable_type: Property
accountable: property_house
car:
@ -84,5 +84,5 @@ car:
name: Honda Accord
currency: USD
balance: 18000
accountable_type: Account::Vehicle
accountable_type: Vehicle
accountable: vehicle_honda_accord

View file

@ -1,7 +0,0 @@
require "test_helper"
class Account::DepositoryTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -1,7 +0,0 @@
require "test_helper"
class Account::InvestmentTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -1,7 +0,0 @@
require "test_helper"
class Account::OtherAssetTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -1,7 +0,0 @@
require "test_helper"
class Account::OtherLiabilityTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -1,7 +0,0 @@
require "test_helper"
class Account::PropertyTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -60,15 +60,15 @@ class AccountTest < ActiveSupport::TestCase
assert_equal @family.assets, assets.sum
assert_equal @family.liabilities, liabilities.sum
depositories = assets.children.find { |group| group.name == "Account::Depository" }
properties = assets.children.find { |group| group.name == "Account::Property" }
vehicles = assets.children.find { |group| group.name == "Account::Vehicle" }
investments = assets.children.find { |group| group.name == "Account::Investment" }
other_assets = assets.children.find { |group| group.name == "Account::OtherAsset" }
depositories = assets.children.find { |group| group.name == "Depository" }
properties = assets.children.find { |group| group.name == "Property" }
vehicles = assets.children.find { |group| group.name == "Vehicle" }
investments = assets.children.find { |group| group.name == "Investment" }
other_assets = assets.children.find { |group| group.name == "OtherAsset" }
credits = liabilities.children.find { |group| group.name == "Account::Credit" }
loans = liabilities.children.find { |group| group.name == "Account::Loan" }
other_liabilities = liabilities.children.find { |group| group.name == "Account::OtherLiability" }
credits = liabilities.children.find { |group| group.name == "CreditCard" }
loans = liabilities.children.find { |group| group.name == "Loan" }
other_liabilities = liabilities.children.find { |group| group.name == "OtherLiability" }
assert_equal 4, depositories.children.count
assert_equal 1, properties.children.count

View file

@ -1,6 +1,6 @@
require "test_helper"
class Account::CreditTest < ActiveSupport::TestCase
class CreditCardTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end

View file

@ -1,6 +1,6 @@
require "test_helper"
class Account::CryptoTest < ActiveSupport::TestCase
class CryptoTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end

View file

@ -0,0 +1,7 @@
require "test_helper"
class DepositoryTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -0,0 +1,7 @@
require "test_helper"
class InvestmentTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -1,6 +1,6 @@
require "test_helper"
class Account::LoanTest < ActiveSupport::TestCase
class LoanTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end

View file

@ -0,0 +1,7 @@
require "test_helper"
class OtherAssetTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -0,0 +1,7 @@
require "test_helper"
class OtherLiabilityTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -0,0 +1,7 @@
require "test_helper"
class PropertyTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -1,6 +1,6 @@
require "test_helper"
class Account::VehicleTest < ActiveSupport::TestCase
class VehicleTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end

View file

@ -0,0 +1,77 @@
require "application_system_test_case"
class AccountsTest < ApplicationSystemTestCase
setup do
sign_in @user = users(:family_admin)
visit root_url
open_new_account_modal
end
test "can create depository account" do
assert_account_created("Depository")
end
test "can create investment account" do
assert_account_created("Investment")
end
test "can create crypto account" do
assert_account_created("Crypto")
end
test "can create property account" do
assert_account_created("Property")
end
test "can create vehicle account" do
assert_account_created("Vehicle")
end
test "can create other asset account" do
assert_account_created("OtherAsset")
end
test "can create credit card account" do
assert_account_created("CreditCard")
end
test "can create loan account" do
assert_account_created("Loan")
end
test "can create other liability account" do
assert_account_created("OtherLiability")
end
private
def open_new_account_modal
click_link "sidebar-new-account"
end
def assert_account_created(accountable_type)
click_link humanized_accountable(accountable_type)
click_link "Enter account balance manually"
account_name = "[system test] #{accountable_type} Account"
fill_in "Account name", with: account_name
select "Chase", from: "Financial institution"
fill_in "account[balance]", with: 100.99
check "Add a start balance for this account"
fill_in "Start date (optional)", with: 10.days.ago.to_date.to_s
fill_in "Start balance (optional)", with: 95
click_button "Add #{humanized_accountable(accountable_type).downcase}"
find("details", text: humanized_accountable(accountable_type)).click
assert_text account_name
visit accounts_url
assert_text account_name
end
def humanized_accountable(accountable_type)
accountable_type.constantize.model_name.human
end
end