mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 15:49:39 +02:00
Prepare fixture data for account sync tests (#493)
* Rename account balance field for clarity `original_balance` and `original_currency` may infer that these values are "original" to the account. In reality, they represent the "current" balance and currency on the account. * Prepare fixture data for account sync testing * Update to new field * Fix conflicts * Remove local schema change
This commit is contained in:
parent
d3b326d273
commit
7d48c01833
37 changed files with 230 additions and 265 deletions
|
@ -2,8 +2,8 @@ require "test_helper"
|
|||
|
||||
class AccountsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
sign_in @user = users(:bob)
|
||||
@account = accounts(:dylan_checking)
|
||||
sign_in @user = users(:family_admin)
|
||||
@account = accounts(:generic)
|
||||
end
|
||||
|
||||
test "new" do
|
||||
|
|
|
@ -2,7 +2,7 @@ require "test_helper"
|
|||
|
||||
class PagesControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
sign_in users(:bob)
|
||||
sign_in users(:family_admin)
|
||||
end
|
||||
|
||||
test "dashboard" do
|
||||
|
|
|
@ -2,7 +2,7 @@ require "test_helper"
|
|||
|
||||
class PasswordResetsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@user = users(:bob)
|
||||
@user = users(:family_admin)
|
||||
end
|
||||
|
||||
test "new" do
|
||||
|
|
|
@ -2,8 +2,8 @@ require "test_helper"
|
|||
|
||||
class TransactionsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
sign_in @user = users(:bob)
|
||||
@transaction = transactions(:one)
|
||||
sign_in @user = users(:family_admin)
|
||||
@transaction = transactions(:checking_one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
|
|
|
@ -2,8 +2,8 @@ require "test_helper"
|
|||
|
||||
class ValuationsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
sign_in @user = users(:bob)
|
||||
@account = accounts(:dylan_checking)
|
||||
sign_in @user = users(:family_admin)
|
||||
@account = accounts(:generic)
|
||||
end
|
||||
|
||||
test "new" do
|
||||
|
|
10
test/fixtures/account/credits.yml
vendored
10
test/fixtures/account/credits.yml
vendored
|
@ -1,11 +1 @@
|
|||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the "{}" from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
||||
|
|
12
test/fixtures/account/depositories.yml
vendored
12
test/fixtures/account/depositories.yml
vendored
|
@ -1,11 +1 @@
|
|||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the "{}" from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
||||
checking: {}
|
||||
|
|
10
test/fixtures/account/investments.yml
vendored
10
test/fixtures/account/investments.yml
vendored
|
@ -1,11 +1 @@
|
|||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the "{}" from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
||||
|
|
10
test/fixtures/account/loans.yml
vendored
10
test/fixtures/account/loans.yml
vendored
|
@ -1,11 +1 @@
|
|||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the "{}" from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
||||
|
|
10
test/fixtures/account/other_assets.yml
vendored
10
test/fixtures/account/other_assets.yml
vendored
|
@ -1,11 +1 @@
|
|||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the "{}" from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
||||
|
|
10
test/fixtures/account/other_liabilities.yml
vendored
10
test/fixtures/account/other_liabilities.yml
vendored
|
@ -1,11 +1 @@
|
|||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the "{}" from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
||||
|
|
10
test/fixtures/account/properties.yml
vendored
10
test/fixtures/account/properties.yml
vendored
|
@ -1,11 +1 @@
|
|||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the "{}" from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
||||
|
|
10
test/fixtures/account/vehicles.yml
vendored
10
test/fixtures/account/vehicles.yml
vendored
|
@ -1,11 +1 @@
|
|||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the "{}" from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
||||
|
|
20
test/fixtures/account_balances.yml
vendored
20
test/fixtures/account_balances.yml
vendored
|
@ -1,13 +1,13 @@
|
|||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
account: dylan_checking
|
||||
date: 2024-02-12
|
||||
balance: 9.99
|
||||
currency: MyString
|
||||
# one:
|
||||
# account: generic
|
||||
# date: 2024-02-12
|
||||
# balance: 9.99
|
||||
# currency: MyString
|
||||
|
||||
two:
|
||||
account: richards_savings
|
||||
date: 2024-02-12
|
||||
balance: 9.99
|
||||
currency: MyString
|
||||
# two:
|
||||
# account: generic
|
||||
# date: 2024-02-13
|
||||
# balance: 9.99
|
||||
# currency: MyString
|
||||
|
|
29
test/fixtures/accounts.yml
vendored
29
test/fixtures/accounts.yml
vendored
|
@ -1,14 +1,23 @@
|
|||
dylan_checking:
|
||||
# No transactions, no valuations, just a generic account
|
||||
generic:
|
||||
family: dylan_family
|
||||
name: Bob's Checking
|
||||
original_balance: 1200
|
||||
name: No history, generic account
|
||||
balance: 1200
|
||||
|
||||
dylan_roth:
|
||||
# Account with only valuations
|
||||
collectible:
|
||||
family: dylan_family
|
||||
name: Bob's Roth IRA
|
||||
original_balance: 1200
|
||||
name: Collectible Account
|
||||
balance: 500
|
||||
|
||||
richards_savings:
|
||||
family: richards_family
|
||||
name: Keef's HYSA
|
||||
original_balance: 1500
|
||||
# Account with only transactions
|
||||
checking:
|
||||
family: dylan_family
|
||||
name: Checking Account
|
||||
balance: 5000
|
||||
|
||||
# Account with both transactions and valuations
|
||||
savings_with_valuation_overrides:
|
||||
family: dylan_family
|
||||
name: Savings account with valuation overrides
|
||||
balance: 20000
|
||||
|
|
20
test/fixtures/exchange_rates.yml
vendored
20
test/fixtures/exchange_rates.yml
vendored
|
@ -1,13 +1,13 @@
|
|||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
base_currency: one
|
||||
converted_currency: one
|
||||
rate: 9.99
|
||||
date: 2024-02-09
|
||||
# one:
|
||||
# base_currency: one
|
||||
# converted_currency: one
|
||||
# rate: 9.99
|
||||
# date: 2024-02-09
|
||||
|
||||
two:
|
||||
base_currency: two
|
||||
converted_currency: two
|
||||
rate: 9.99
|
||||
date: 2024-02-09
|
||||
# two:
|
||||
# base_currency: two
|
||||
# converted_currency: two
|
||||
# rate: 9.99
|
||||
# date: 2024-02-09
|
||||
|
|
5
test/fixtures/families.yml
vendored
5
test/fixtures/families.yml
vendored
|
@ -1,7 +1,2 @@
|
|||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
dylan_family:
|
||||
name: The Dylan Family
|
||||
|
||||
richards_family:
|
||||
name: The Richards Family
|
||||
|
|
66
test/fixtures/transactions.yml
vendored
66
test/fixtures/transactions.yml
vendored
|
@ -1,15 +1,55 @@
|
|||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
# Checking account transactions
|
||||
checking_one:
|
||||
name: Starbucks
|
||||
date: <%= 5.days.ago.to_date %>
|
||||
amount: 10
|
||||
account: checking
|
||||
|
||||
one:
|
||||
name: MyString
|
||||
date: 2024-02-23
|
||||
amount: 9.99
|
||||
currency: MyString
|
||||
account: dylan_checking
|
||||
checking_two:
|
||||
name: Chipotle
|
||||
date: <%= 12.days.ago.to_date %>
|
||||
amount: 30
|
||||
account: checking
|
||||
|
||||
two:
|
||||
name: MyString
|
||||
date: 2024-02-20
|
||||
amount: 9.99
|
||||
currency: MyString
|
||||
account: dylan_checking
|
||||
checking_three:
|
||||
name: Amazon
|
||||
date: <%= 15.days.ago.to_date %>
|
||||
amount: 20
|
||||
account: checking
|
||||
|
||||
checking_four:
|
||||
name: Paycheck
|
||||
date: <%= 22.days.ago.to_date %>
|
||||
amount: -1075
|
||||
account: checking
|
||||
|
||||
checking_five:
|
||||
name: Netflix
|
||||
date: <%= 30.days.ago.to_date %>
|
||||
amount: 15
|
||||
account: checking
|
||||
|
||||
# Savings account that has these transactions and valuation overrides
|
||||
savings_one:
|
||||
name: Interest Received
|
||||
date: <%= 5.days.ago.to_date %>
|
||||
amount: -200
|
||||
account: savings_with_valuation_overrides
|
||||
|
||||
savings_two:
|
||||
name: Check Deposit
|
||||
date: <%= 12.days.ago.to_date %>
|
||||
amount: -50
|
||||
account: savings_with_valuation_overrides
|
||||
|
||||
savings_three:
|
||||
name: Withdrawal
|
||||
date: <%= 18.days.ago.to_date %>
|
||||
amount: 2000
|
||||
account: savings_with_valuation_overrides
|
||||
|
||||
savings_four:
|
||||
name: Check Deposit
|
||||
date: <%= 30.days.ago.to_date %>
|
||||
amount: -500
|
||||
account: savings_with_valuation_overrides
|
||||
|
|
11
test/fixtures/users.yml
vendored
11
test/fixtures/users.yml
vendored
|
@ -1,20 +1,13 @@
|
|||
bob:
|
||||
family_admin:
|
||||
family: dylan_family
|
||||
first_name: Bob
|
||||
last_name: Dylan
|
||||
email: bob@bobdylan.com
|
||||
password_digest: <%= BCrypt::Password.create('password') %>
|
||||
|
||||
jakob:
|
||||
family_member:
|
||||
family: dylan_family
|
||||
first_name: Jakob
|
||||
last_name: Dylan
|
||||
email: jakobdylan@yahoo.com
|
||||
password_digest: <%= BCrypt::Password.create('password') %>
|
||||
|
||||
keith:
|
||||
family: richards_family
|
||||
first_name: Keith
|
||||
last_name: Richards
|
||||
email: keith@rollingstones.com
|
||||
password_digest: <%= BCrypt::Password.create('password') %>
|
||||
|
|
33
test/fixtures/valuations.yml
vendored
33
test/fixtures/valuations.yml
vendored
|
@ -1,11 +1,26 @@
|
|||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
# For collectible account that only has valuations (no transactions)
|
||||
collectible_one:
|
||||
value: 550
|
||||
date: <%= 4.days.ago.to_date %>
|
||||
account: collectible
|
||||
|
||||
one:
|
||||
value: 9.99
|
||||
date: 2024-02-15
|
||||
account: dylan_checking
|
||||
collectible_two:
|
||||
value: 700
|
||||
date: <%= 12.days.ago.to_date %>
|
||||
account: collectible
|
||||
|
||||
two:
|
||||
value: 9.99
|
||||
date: 2024-02-15
|
||||
account: richards_savings
|
||||
collectible_three:
|
||||
value: 400
|
||||
date: <%= 30.days.ago.to_date %>
|
||||
account: collectible
|
||||
|
||||
# For checking account that has valuations and transactions
|
||||
savings_one:
|
||||
value: 20500
|
||||
date: <%= 3.days.ago.to_date %>
|
||||
account: savings_with_valuation_overrides
|
||||
|
||||
savings_two:
|
||||
value: 19500
|
||||
date: <%= 12.days.ago.to_date %>
|
||||
account: savings_with_valuation_overrides
|
||||
|
|
|
@ -2,8 +2,9 @@ require "test_helper"
|
|||
|
||||
class AccountTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
depository = Account::Depository.create!
|
||||
@account = Account.create!(family: families(:dylan_family), name: "Explicit Checking", original_balance: 1200, accountable: depository)
|
||||
depository = account_depositories(:checking)
|
||||
@account = accounts(:checking)
|
||||
@account.accountable = depository
|
||||
end
|
||||
|
||||
test "new account should be valid" do
|
||||
|
|
|
@ -2,7 +2,7 @@ require "test_helper"
|
|||
|
||||
class CurrentTest < ActiveSupport::TestCase
|
||||
test "family returns user family" do
|
||||
user = users(:bob)
|
||||
user = users(:family_admin)
|
||||
Current.user = user
|
||||
assert_equal user.family, Current.family
|
||||
end
|
||||
|
|
|
@ -6,12 +6,12 @@ class FamilyTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
test "should have many users" do
|
||||
assert_equal 2, @dylan_family.users.size
|
||||
assert @dylan_family.users.include?(users(:bob))
|
||||
assert @dylan_family.users.size > 0
|
||||
assert @dylan_family.users.include?(users(:family_admin))
|
||||
end
|
||||
|
||||
test "should have many accounts" do
|
||||
assert_equal 2, @dylan_family.accounts.size
|
||||
assert @dylan_family.accounts.size > 0
|
||||
end
|
||||
|
||||
test "should destroy dependent users" do
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
require "test_helper"
|
||||
|
||||
class TransactionTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@ require "test_helper"
|
|||
|
||||
class UserTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
@user = users(:bob)
|
||||
@user = users(:family_admin)
|
||||
end
|
||||
|
||||
test "should be valid" do
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
require "test_helper"
|
||||
|
||||
class ValuationTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@ require "application_system_test_case"
|
|||
|
||||
class AccountsTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in @user = users(:bob)
|
||||
sign_in @user = users(:family_admin)
|
||||
end
|
||||
|
||||
test "should create account" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue