mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-02 03:55:20 +02:00
Account::Sync model and test fixture simplifications (#968)
* Add sync model * Fresh fixtures for sync tests * Sync tests overhaul * Fix entry tests * Complete remaining model test updates * Update system tests * Update demo data task * Add system tests back to PR checks * More simplifications, add empty family to fixtures for easier testing
This commit is contained in:
parent
de5a2e55b3
commit
c6bdf49f10
60 changed files with 929 additions and 1353 deletions
36
test/models/account/sync_test.rb
Normal file
36
test/models/account/sync_test.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
require "test_helper"
|
||||
|
||||
class Account::SyncTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@account = accounts(:depository)
|
||||
|
||||
@sync = Account::Sync.for(@account)
|
||||
@balance_syncer = mock("Account::Balance::Syncer")
|
||||
Account::Balance::Syncer.expects(:new).with(@account, start_date: nil).returns(@balance_syncer).once
|
||||
end
|
||||
|
||||
test "runs sync" do
|
||||
@balance_syncer.expects(:run).once
|
||||
@balance_syncer.expects(:warnings).returns([ "test sync warning" ]).once
|
||||
|
||||
assert_equal "pending", @sync.status
|
||||
assert_equal [], @sync.warnings
|
||||
assert_nil @sync.last_ran_at
|
||||
|
||||
@sync.run
|
||||
|
||||
assert_equal "completed", @sync.status
|
||||
assert_equal [ "test sync warning" ], @sync.warnings
|
||||
assert @sync.last_ran_at
|
||||
end
|
||||
|
||||
test "handles sync errors" do
|
||||
@balance_syncer.expects(:run).raises(StandardError.new("test sync error"))
|
||||
|
||||
@sync.run
|
||||
|
||||
assert @sync.last_ran_at
|
||||
assert_equal "failed", @sync.status
|
||||
assert_equal "test sync error", @sync.error
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue