Account::Sync model and test fixture simplifications #968
Reference in New Issue
Block a user
Delete Branch "zachgoll/sync-model"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR introduces an
Account::Syncmodel for better visibility into the account sync process, error handling, and separation of concerns.The two significant changes in this PR are:
Account sync
This PR introduces a new domain concept of
Account::Sync, which acts as an audit log of individual account syncs. Thesyncandsync_latermethods onAccountare part ofAccount::Syncable.In the happy path, an account sync moves from
pending->syncing->completed, with an optional array ofwarningsto alert the user that something may be wrong with their account.An unsuccessful sync transitions from
pending->syncing->failedand populates anerrorspecifying why the sync failed. This error is then shown on the user's account page.Testing
Currently, we've got a ton of fixtures and have been tracking the expected family results (after account syncs) via a Google Sheet to visualize the expected results better. This was initially created as a placeholder to better visualize everything in one spot, but the codebase has started to outgrow it.
While this sheet can be very helpful as a reference, asserting against "magic numbers" in the sheet creates a tight coupling between fixtures and requires constant updates as we add in more nuance to the sync algorithm (such as the soon-to-be-implemented investment portfolios).
This PR is essentially a "reset" of fixtures and reduces each fixture file to ~2 fixtures each representing base cases. Variations of these base cases live directly in test files and test helper functions are used as our "factories" when needed. Due to the open source nature of this project, MiniTest + fixtures will likely remain the choice for testing, but these changes reflect an effort to incorporate some of the FactoryBot concepts to improve the readability of tests for newcomers.
@@ -98,4 +98,3 @@- name: System testsrun: DISABLE_PARALLELIZATION=true bin/rails test:systemcontinue-on-error: true # TODO: Eventually we'll enforce for PRsCodebase stability has improved, so will throw this back in.