mirror of
https://github.com/we-promise/sure.git
synced 2026-04-09 23:34:50 +00:00
* refactor: rename `raw_investments_payload` to `raw_holdings_payload` - Update references and models to use consistent naming. - Adjust migrations, tests, and encryption setup accordingly. * fix: improve safety when accessing raw_holdings_payload keys - Use `dig` with safe navigation to prevent potential nil errors. - Add support for decryption from the old column name `raw_investments_payload`. - Adjust related methods and calculations for consistency. --------- Co-authored-by: luckyPipewrench <luckypipewrench@proton.me>
47 lines
1.4 KiB
Ruby
47 lines
1.4 KiB
Ruby
require "test_helper"
|
|
|
|
class PlaidAccount::ImporterTest < ActiveSupport::TestCase
|
|
setup do
|
|
@plaid_account = plaid_accounts(:one)
|
|
@mock_account_snapshot = mock
|
|
end
|
|
|
|
test "imports account data" do
|
|
account_data = OpenStruct.new(
|
|
account_id: "acc_1",
|
|
name: "Test Account",
|
|
mask: "1234",
|
|
)
|
|
|
|
transactions_data = OpenStruct.new(
|
|
added: [],
|
|
modified: [],
|
|
removed: [],
|
|
)
|
|
|
|
investments_data = OpenStruct.new(
|
|
holdings: [],
|
|
transactions: [],
|
|
securities: [],
|
|
)
|
|
|
|
liabilities_data = OpenStruct.new(
|
|
credit: [],
|
|
mortgage: [],
|
|
student: [],
|
|
)
|
|
|
|
@mock_account_snapshot.expects(:account_data).returns(account_data).at_least_once
|
|
@mock_account_snapshot.expects(:transactions_data).returns(transactions_data).at_least_once
|
|
@mock_account_snapshot.expects(:investments_data).returns(investments_data).at_least_once
|
|
@mock_account_snapshot.expects(:liabilities_data).returns(liabilities_data).at_least_once
|
|
|
|
@plaid_account.expects(:upsert_plaid_snapshot!).with(account_data)
|
|
@plaid_account.expects(:upsert_plaid_transactions_snapshot!).with(transactions_data)
|
|
@plaid_account.expects(:upsert_plaid_holdings_snapshot!).with(investments_data)
|
|
@plaid_account.expects(:upsert_plaid_liabilities_snapshot!).with(liabilities_data)
|
|
|
|
PlaidAccount::Importer.new(@plaid_account, account_snapshot: @mock_account_snapshot).import
|
|
end
|
|
end
|