mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 12:04:08 +00:00
Implement auto family syncs on login (#1021)
This commit is contained in:
@@ -25,6 +25,10 @@ class AccountTest < ActiveSupport::TestCase
|
||||
@account.sync start_date: start_date
|
||||
end
|
||||
|
||||
test "needs sync if account has not synced today" do
|
||||
assert @account.needs_sync?
|
||||
end
|
||||
|
||||
test "groups accounts by type" do
|
||||
result = @family.accounts.by_group(period: Period.all)
|
||||
assets = result[:assets]
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user