Serve Mercury from ProviderItemsController

Merged
JA
1d ago
+30-259

Summary

Provider kit Track B, B8b: Mercury's controller moves onto the provider kit. MercuryItemsController becomes a thin ProviderItemsController subclass that names its permitted params, and its routes use the provider_items concern. A pure move, as B7b was for Lunch Flow: the Mercury convergence slices (C2d–C2g) made every action behave as the kit's, so nothing changes. Two existing tests are edited, both to follow the move (see Verification); every other existing Mercury test passes unedited.

Part of #5003 (Track B, step 8: the Mercury conversion, controller and routes).

Stacked on #5254. Fork pre-flight: jaysbeekay/sure#747 (same branch, same commit; its CI, Gatekeeper review and screenshot history live there).

What changed

  • app/controllers/mercury_items_controller.rb: 9 lines (from 250): < ProviderItemsController with item_params. It keeps Mercury's rule that a blank token on an existing connection leaves the stored one alone.
  • config/routes.rb: resources :mercury_items, …, concerns: :provider_items. The app lists the same 16 /mercury_items routes before and after, verb, path and name (diffed from Rails.application.routes at both heads).
  • Contract: Mercury's lifecycle test includes the whole ProviderItemLifecycleTests, and a new MercuryItemsProviderKitTest includes ProviderItemsControllerTests.
  • test/views/provider_item_cards_test.rb: the render-site floor goes from 11 to 10, since Mercury's card render now is the kit controller's shared one.

Demo data

No demo data needed.

Migration notes

No migration.

Verification

  • Existing tests: two are edited to follow the move. MercuryItem::LifecycleTest now includes the full ProviderItemLifecycleTests contract (with its three provider helpers) instead of the model half, and ProviderItemCardsTest lowers its admin-only render-site floor from 11 to 10 because Mercury's controller response is now the kit's. Unedited: all Mercury controller and model tests, with the selection, setup, connection, return-path and view tests, pass (200 runs, 0 failures).
  • Contract (fail-first): on the old controller the two controller-contract tests that pin the move fail: the routes test (MercuryItemsController isn't a ProviderItemsController) and the non-admin rejection.
  • Mutations, each caught: the blank token no longer dropped on update ("blank token update preserves the selected mercury token"); base_url not permitted ("update changes only the selected mercury connection").
  • bin/rails test (full, at the B8b commit): 16,477 runs, 0 failures; the same 8 ReleaseNotesWorkflowTest errors (no node in the test image).
  • bin/rubocop on changed files: no offenses. bin/brakeman: no warnings.
  • Size: non-test +3 / -256.
  • Checked against upstream AGENTS.md (blob 1a5dbebd, 2026-11-17): no deviations.

Blast radius

  • Routes and helper names are unchanged (diffed above).
  • ProviderItemsController is unchanged; it now also serves mercury_items.

Review notes

This slice mirrors Lunch Flow's B7b, whose review is answered on jaysbeekay/sure#737 (the template-less index/show/new/edit routes carried over, and the hand-lowered render-site floor).


Summary by cubic

Moves Mercury's controller and routes onto the provider kit. MercuryItemsController becomes a thin ProviderItemsController subclass that names its permitted params. Since the prior convergence slices made every action behave as the kit's, this is a pure move — behavior is unchanged.

Refactors

  • MercuryItemsController shrinks to a subclass plus item_params; it still keeps a stored token when a form submits a blank one.
  • Routes use the provider_items concern, with the same 16 routes and names before and after.
  • Mercury's lifecycle test now includes the full ProviderItemLifecycleTests, and a new MercuryItemsProviderKitTest includes ProviderItemsControllerTests.
  • The admin-only card render-site floor drops from 11 to 10 since Mercury shares the kit controller's card render; all other Mercury tests pass unedited.