Serve Brex account setup from ProviderItemsController
Summary
Provider kit Track B, B3b: Brex's account setup actions move into ProviderItemsController, and the provider_items route concern gains the two setup routes. BrexItems::AccountSetupsController goes, so all of Brex's routes are now served by the shared controller through BrexItemsController. Every route helper and path stays as it is.
Part of #5003 (Track B, item 3, second of two slices: B3a connection and account linking, B3b account setup).
Stacked on #5230. Fork pre-flight: jaysbeekay/sure#720 (same branch, same commit; its CI, Gatekeeper review and screenshot history live there).
What changed
ProviderItemsControllergainssetup_accountsandcomplete_account_setup, moved fromBrexItems::AccountSetupsController:- the setup page renders
<key>_items/setup_accountswith@<key>_accountsfromunlinked_provider_accounts; - after setup in a Turbo frame, the provider's card is replaced from
<key>_items/_<key>_item; - submitted types are limited to the adapter's supported types, and subtypes to those types' subtypes. For Brex that is Depository and CreditCard, the same set as before.
- both actions keep the admin guard and load the connection like the other member actions.
- the setup page renders
ProviderItem::AccountFlow.adapter_classbecomes a class method, so the controller reads the supported types from the same place as the flow.config/routes.rb: the concern's member routes addsetup_accountsandcomplete_account_setup;resources :brex_itemsno longer needs a block.
Nothing user-visible changes.
Demo data
No demo data needed: no new records or UI.
Migration notes
No migration.
Verification
-
Existing tests unchanged:
BrexItemsControllerTestand the other Brex tests pass unedited (212 runs, 0 failures). Two test files change:- the controller contract module;
ProviderItemCardsTest, the #3630 guard that every card render passesvisible_accounts. It scans for card renders by literal partial name. Moving Brex's setup render into the shared controller turns"brex_items/brex_item"into"#{provider_key}_items/#{provider_key}_item", so the scan found 11 sites instead of its floor of 12. The guard now also matches the shared controller's form, as it already matches the generator template's, and is back to 12. Droppingvisible_accounts:from the shared render is caught by it.
-
Contract (fail-first):
ProviderItemsControllerTests- checks the two setup routes' paths and that they recognise as
<key>_items#<action>; - adds them to the non-admin rejection test.
Before the change both fail: the routes recognise as
brex_items/account_setups, and that controller serves them. It also adds- "the setup page lists the connection's accounts that are not linked yet",
- "completing setup links only this connection's accounts, with supported types and subtypes": in a Turbo frame, one account is linked with the supported type and not the invalid subtype; an account given an unsupported type and another connection's account stay unlinked; the connection's card is replaced.
- checks the two setup routes' paths and that they recognise as
-
Mutations:
- Caught: setup not admin-gated;
@brex_accountsnot set; any subtype allowed; the card not refreshed after setup; the flow built without the connection. - Survive as equivalent: passing an unsupported type through, and allowing another connection's account ids. The flow repeats both checks (
complete_setup!skips unsupported types and looks up only the connection's own accounts, covered in B2c), so the controller's are defence in depth.
- Caught: setup not admin-gated;
-
bin/rails test(full, at the B3b commit): 16,276 runs, 1 failure, plus the same 8ReleaseNotesWorkflowTesterrors (nonodein the test image). The failure wasSettings::HostingsControllerTest"can update market data sync settings", a sidekiq-cron test that parallel workers race on through shared Redis. It is unrelated to this change, passed in the run before the guard fix, and passed 3 of 3 when re-run on its own. -
bin/rubocopon changed files: no offenses.bin/brakeman: no warnings. No ERB or JS changed. -
Diff with copy detection (
git diff -Cagainst B3a): non-test +110 / -122. -
Checked against upstream AGENTS.md (blob 1a5dbebd, 2026-11-17): no deviations.
Blast radius
- The setup page and the Turbo update read the same view, partial and locals as before (
@brex_accounts,brex_item:,visible_accounts:). - Route helpers
setup_accounts_brex_item_pathandcomplete_account_setup_brex_item_pathare unchanged. - Siblings: the other providers' controllers keep their own setup actions; they move in their own slices.
Summary by cubic
Serves Brex's account setup from ProviderItemsController, so all Brex routes now go through the shared controller and BrexItems::AccountSetupsController is removed. The setup page, card refresh, and route helpers keep their behavior, so nothing user-visible changes.
- Setup actions read supported types and subtypes from
ProviderItem::AccountFlow.adapter_class, now a class method shared by the controller and the flow. - The admin check now runs before the connection lookup, so a non-admin gets the same redirect whether or not the connection id exists.
- The
provider_itemsroute concern gainssetup_accountsandcomplete_account_setup, andbrex_itemsdrops its member block. - Controller contract tests cover the setup routes, their admin gating, the setup page listing only unlinked accounts, and that completing setup links only the connection's own unlinked accounts with supported types and subtypes.
Summary by CodeRabbit
- New Features
- Provider connection setup now lets administrators review and link eligible accounts, including for Brex connections.
- Account types and subtypes are checked against supported options during setup.
- Bug Fixes
- Setup excludes accounts already linked elsewhere and prevents accounts from another connection from being linked accidentally.
- Unsupported account types are skipped, and unsupported subtypes fall back to a supported default.