2024-02-02 09:05:04 -06:00
|
|
|
require "test_helper"
|
|
|
|
|
|
|
|
class AccountTest < ActiveSupport::TestCase
|
2025-04-14 11:40:34 -04:00
|
|
|
include SyncableInterfaceTest, EntriesTestHelper
|
2024-07-10 11:22:59 -04:00
|
|
|
|
|
|
|
setup do
|
2024-11-15 13:49:37 -05:00
|
|
|
@account = @syncable = accounts(:depository)
|
2024-03-21 13:39:10 -04:00
|
|
|
@family = families(:dylan_family)
|
2024-02-06 12:30:51 -05:00
|
|
|
end
|
|
|
|
|
2025-01-20 11:37:01 -05:00
|
|
|
test "can destroy" do
|
|
|
|
assert_difference "Account.count", -1 do
|
|
|
|
@account.destroy
|
|
|
|
end
|
|
|
|
end
|
2025-04-22 13:10:50 -05:00
|
|
|
|
|
|
|
test "gets short/long subtype label" do
|
|
|
|
account = @family.accounts.create!(
|
|
|
|
name: "Test Investment",
|
|
|
|
balance: 1000,
|
|
|
|
currency: "USD",
|
|
|
|
subtype: "hsa",
|
|
|
|
accountable: Investment.new
|
|
|
|
)
|
|
|
|
|
|
|
|
assert_equal "HSA", account.short_subtype_label
|
|
|
|
assert_equal "Health Savings Account", account.long_subtype_label
|
|
|
|
|
|
|
|
# Test with nil subtype
|
|
|
|
account.update!(subtype: nil)
|
|
|
|
assert_equal "Investments", account.short_subtype_label
|
|
|
|
assert_equal "Investments", account.long_subtype_label
|
|
|
|
end
|
2024-02-02 09:05:04 -06:00
|
|
|
end
|