1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 15:49:39 +02:00

Implement auto family syncs on login (#1021)

This commit is contained in:
Zach Gollwitzer 2024-07-25 12:51:50 -04:00 committed by GitHub
parent c8590d53ba
commit ef4be7948a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 59 additions and 9 deletions

View file

@ -48,6 +48,14 @@ class FamilyTest < ActiveSupport::TestCase
assert_equal Money.new(50000, @family.currency), @family.net_worth
end
test "needs sync if last family sync was before today" do
assert @family.needs_sync?
@family.update! last_synced_at: Time.now
assert_not @family.needs_sync?
end
test "syncs active accounts" do
account = create_account(balance: 1000, accountable: CreditCard.new, is_active: false)
@ -57,7 +65,9 @@ class FamilyTest < ActiveSupport::TestCase
account.update! is_active: true
Account.any_instance.expects(:sync_later).with(start_date: nil).once
Account.any_instance.expects(:needs_sync?).once.returns(true)
Account.any_instance.expects(:last_sync_date).once.returns(2.days.ago.to_date)
Account.any_instance.expects(:sync_later).with(start_date: 2.days.ago.to_date).once
@family.sync
end