mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 13:19:39 +02:00
* Basic plaid data model and linking * Remove institutions, add plaid items * Improve schema and Plaid provider * Add webhook verification sketch * Webhook verification * Item accounts and balances sync setup * Provide test encryption keys * Fix test * Only provide encryption keys in prod * Try defining keys in test env * Consolidate account sync logic * Add back plaid account initialization * Plaid transaction sync * Sync UI overhaul for Plaid * Add liability and investment syncing * Handle investment webhooks and process current day holdings * Remove logs * Remove "all" period select for performance * fix amount calc * Remove todo comment * Coming soon for investment historical data * Document Plaid configuration * Listen for holding updates
49 lines
1.3 KiB
Ruby
49 lines
1.3 KiB
Ruby
require "test_helper"
|
|
require "ostruct"
|
|
|
|
class PlaidItemsControllerTest < ActionDispatch::IntegrationTest
|
|
setup do
|
|
sign_in @user = users(:family_admin)
|
|
|
|
@plaid_provider = mock
|
|
|
|
PlaidItem.stubs(:plaid_provider).returns(@plaid_provider)
|
|
end
|
|
|
|
test "create" do
|
|
public_token = "public-sandbox-1234"
|
|
|
|
@plaid_provider.expects(:exchange_public_token).with(public_token).returns(
|
|
OpenStruct.new(access_token: "access-sandbox-1234", item_id: "item-sandbox-1234")
|
|
)
|
|
|
|
assert_difference "PlaidItem.count", 1 do
|
|
post plaid_items_url, params: {
|
|
plaid_item: {
|
|
public_token: public_token,
|
|
metadata: { institution: { name: "Plaid Item Name" } }
|
|
}
|
|
}
|
|
end
|
|
|
|
assert_equal "Account linked successfully. Please wait for accounts to sync.", flash[:notice]
|
|
assert_redirected_to accounts_path
|
|
end
|
|
|
|
test "destroy" do
|
|
delete plaid_item_url(plaid_items(:one))
|
|
|
|
assert_equal "Accounts scheduled for deletion.", flash[:notice]
|
|
assert_enqueued_with job: DestroyJob
|
|
assert_redirected_to accounts_path
|
|
end
|
|
|
|
test "sync" do
|
|
plaid_item = plaid_items(:one)
|
|
PlaidItem.any_instance.expects(:sync_later).once
|
|
|
|
post sync_plaid_item_url(plaid_item)
|
|
|
|
assert_redirected_to accounts_path
|
|
end
|
|
end
|