Cache Lunch Flow's account list per connection
Summary
Lunch Flow convergence, C1c: Lunch Flow's cached accounts list is keyed per connection, under the provider kit's key, and dropped when the connection's credentials change, as Brex's is.
Part of jaysbeekay/sure#670 (Track B, Lunch Flow convergence). Stacked on C1b (jaysbeekay/sure#727) in fork stack #687.
Upstream draft PR: https://github.com/we-promise/sure/pull/5239 (same branch, same commit), in native stack we-promise/sure#5268 on refactor/provider-kit.
Behaviour delta (Lunch Flow)
| Before | After | |
|---|---|---|
| Cache key for the accounts list (preload, select accounts, select an existing account) | lunchflow_accounts_<family> | lunchflow_accounts_<family>_<connection>. The connection is the one whose API key lists the accounts, as Provider::LunchflowAdapter.build_provider picks it. |
| Changing the connection's API key or base URL | the old list stayed cached for up to 5 minutes | the connection's cached list is dropped |
| Renaming the connection or changing its start date | the cache is kept only when the request leaves out api_key and base_url. The settings panel always submits both, so every panel save drops it: one extra provider call per save, never stale data. |
Entries under the old family key are simply no longer read, and expire within 5 minutes. Lunch Flow still uses one credentialed connection per family; the kit treats a family with a single credentialed connection the same way, so selection behaves as before.
What changed
LunchflowItemsController: the three cache reads and writes uselunchflow_accounts_cache_key(credentialed_lunchflow_item), andupdatedeletes that key whenapi_keyorbase_urlis submitted and saved.
Demo data
No demo data needed.
Migration notes
No migration.
Verification
-
Tests (fail-first): new
LunchflowItemsAccountCacheTest:- preloading caches under the connection's key, not the family's;
- selecting accounts reads the connection's cached list;
- changing the API key drops it;
- changing the base URL drops it;
- renaming keeps it.
Before the change, the preload, select and API-key tests fail. The rename test passes before and after, as a guard.
-
Existing tests unchanged:
LunchflowItemsControllerTestand the Lunch Flow model tests pass unedited (70 runs, 0 failures). -
Mutations, each caught: the family-wide key again; the cache never dropped on a credentials change; dropped on every update; dropped only for the API key, not the base URL.
-
bin/rails test(full, at the C1c commit): 16,318 runs, 0 failures; the same 8ReleaseNotesWorkflowTesterrors (nonodein the test image). -
bin/rubocopon changed files: no offenses.bin/brakeman: no warnings. -
Size: non-test +16 / -4.
-
Checked against upstream AGENTS.md (blob 1a5dbebd, 2026-11-17): no deviations.
Blast radius
- Only
LunchflowItemsControllerreads or writeslunchflow_accounts_*. fetch_lunchflow_accounts_from_api(setup) doesn't use the cache and is unchanged.