Move Brex account setup into the shared account flow
Summary
Provider kit Track B, B2c: Brex's account setup (BrexItem::AccountFlow::Setup) moves to ProviderItem::AccountFlow::Setup, completing the move of Brex's account flow onto the provider kit. Importing the reported accounts, the account type and subtype options, and completing setup now live in the shared flow.
Part of jaysbeekay/sure#670 (Track B, item 2, last of three slices: B2a selection, B2b linking, B2c setup). Stacked on B2b (jaysbeekay/sure#717) in fork stack #687.
Upstream draft PR: https://github.com/we-promise/sure/pull/5229 (same branch, same commit), in native stack we-promise/sure#5268 on refactor/provider-kit.
What changed
app/models/brex_item/account_flow/setup.rb→app/models/provider_item/account_flow/setup.rb, with Brex's names replaced by the provider's: messages from<key>_items.*, supported types fromProvider::<Key>Adapter, accounts throughprovider_accounts, logs naming the provider by its key.unlinked_brex_accountsbecomesunlinked_provider_accounts.ProviderItem::AccountFlowincludesSetupand ownsSetupResult/SetupCompletion. A new hook,provider_account_snapshot_changed?, decides whether an import refreshes an account the provider already reported.BrexItem::AccountFlowimplements that hook (Brex's existing snapshot comparison) and keepsunlinked_brex_accountsas an alias, whichBrexItems::AccountSetupsControllerreads. The two bridges B2a and B2b added forSetup(theNoApiTokenErroralias andupsert_brex_account!) are removed.
Brex's account flow is now 81 lines of hooks and old names over the shared flow.
Nothing user-visible changes.
Demo data
No demo data needed: no new records or UI.
Migration notes
No migration.
Verification
- Existing tests unchanged: the
test/diff against B2b touches only the contract module. Brex's flow (including its setup tests), controller, item, account, importer and syncer tests pass unedited (207 runs, 0 failures across Brex, provider settings and the provider connections API). - Contract (fail-first):
ProviderItemLifecycleTestsadds- "setup imports the reported accounts and creates the ones given a supported type": three accounts imported and offered as unlinked; one set up with a supported type, one skipped, one given an unsupported type and skipped; one sync; the linked one leaves the unlinked list; setting it up again creates nothing and counts no failure;
- "setup leaves an imported account alone when the provider reports it unchanged";
- and the old-constants test now covers
SetupResultandSetupCompletion.
Without the change they fail:uninitialized constant ProviderItem::AccountFlow::SetupResultandundefined method 'unlinked_provider_accounts'.
- Mutations, each caught: an unsupported type not skipped; "skip" not skipped; an already-linked account set up again; unchanged accounts re-saved on import; the unlinked list including linked accounts; no sync after setup; Brex's snapshot comparison always saying unchanged; the success message read from a missing key.
bin/rails test(full, at the B2c commit): 16,270 runs, 0 failures; the same 8ReleaseNotesWorkflowTesterrors (nonodein the test image).bin/rubocopon changed files: no offenses.bin/brakeman: no warnings. No ERB or JS changed.- Size: non-test +261 / -261 with git's default rename threshold, which shows
setup.rbas a delete and an add because about 40% of its lines change names. Withgit diff -M30%it is a rename, and the non-test change is +97 / -97. - Checked against upstream AGENTS.md (blob 1a5dbebd, 2026-11-17): no deviations.
Blast radius
BrexItems::AccountSetupsControllercallsimport_accounts_with_user_facing_error,unlinked_brex_accounts,account_type_options,displayable_account_type_options,subtype_optionsandcomplete_setup_result; all keep their names.- Nothing else referenced
BrexItem::AccountFlow::Setupor required its file. - Siblings: the other providers (Lunch Flow, Mercury, Sophtron, SimpleFIN and others) build their own type and subtype options in their controllers; they move in their own slices.