mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 05:09:38 +02:00
Pass transactions cursor when fetching plaid transactions
This commit is contained in:
parent
6935ffa3d1
commit
aecb5aafd8
6 changed files with 67 additions and 20 deletions
|
@ -26,7 +26,14 @@ class PlaidItem::AccountsSnapshotTest < ActiveSupport::TestCase
|
|||
)
|
||||
]).at_least_once
|
||||
|
||||
@plaid_provider.expects(:get_transactions).with(@plaid_item.access_token).once
|
||||
@plaid_provider.expects(:get_transactions).with(@plaid_item.access_token, next_cursor: nil).returns(
|
||||
OpenStruct.new(
|
||||
added: [],
|
||||
modified: [],
|
||||
removed: [],
|
||||
cursor: "test_cursor_1"
|
||||
)
|
||||
).once
|
||||
@plaid_provider.expects(:get_item_investments).never
|
||||
@plaid_provider.expects(:get_item_liabilities).never
|
||||
|
||||
|
@ -45,6 +52,31 @@ class PlaidItem::AccountsSnapshotTest < ActiveSupport::TestCase
|
|||
@snapshot.get_account_data("123")
|
||||
end
|
||||
|
||||
test "updates next_cursor when fetching transactions" do
|
||||
@plaid_item.update!(available_products: [ "transactions" ], billed_products: [], next_cursor: "test_cursor_1")
|
||||
|
||||
@snapshot.expects(:accounts).returns([
|
||||
OpenStruct.new(
|
||||
account_id: "123",
|
||||
type: "depository"
|
||||
)
|
||||
]).at_least_once
|
||||
|
||||
@plaid_provider.expects(:get_transactions).with(@plaid_item.access_token, next_cursor: "test_cursor_1").returns(
|
||||
OpenStruct.new(
|
||||
added: [],
|
||||
modified: [],
|
||||
removed: [],
|
||||
cursor: "test_cursor_2"
|
||||
)
|
||||
).once
|
||||
|
||||
@plaid_provider.expects(:get_item_investments).never
|
||||
@plaid_provider.expects(:get_item_liabilities).never
|
||||
|
||||
@snapshot.get_account_data("123")
|
||||
end
|
||||
|
||||
test "fetches investments data if item supports investments and investment accounts present" do
|
||||
@plaid_item.update!(available_products: [ "investments" ], billed_products: [])
|
||||
|
||||
|
|
|
@ -33,14 +33,17 @@ class PlaidItem::ImporterTest < ActiveSupport::TestCase
|
|||
PlaidItem::AccountsSnapshot.any_instance.expects(:accounts).returns([
|
||||
OpenStruct.new(
|
||||
account_id: "acc_1",
|
||||
type: "depository"
|
||||
type: "depository",
|
||||
)
|
||||
]).at_least_once
|
||||
|
||||
PlaidItem::AccountsSnapshot.any_instance.expects(:transactions_cursor).returns("test_cursor_1")
|
||||
|
||||
PlaidItem::AccountsSnapshot.any_instance.expects(:get_account_data).with("acc_1").once
|
||||
|
||||
PlaidAccount::Importer.any_instance.expects(:import).once
|
||||
|
||||
@plaid_item.expects(:update!).with(next_cursor: "test_cursor_1")
|
||||
@plaid_item.expects(:upsert_plaid_snapshot!).with(item_data)
|
||||
@plaid_item.expects(:upsert_plaid_institution_snapshot!).with(institution_data)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue