Serve Mercury from ProviderItemsController

JA
6d 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 jaysbeekay/sure#670 (Track B, step 8: the Mercury conversion, controller and routes). Stacked on C2g (jaysbeekay/sure#746) in fork stack #687.

Upstream draft PR: https://github.com/we-promise/sure/pull/5255 (same branch, same commit), in native stack we-promise/sure#5268 on refactor/provider-kit.

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 #737 (the template-less index/show/new/edit routes carried over, and the hand-lowered render-site floor).