Link the parent breadcrumb on account and SSO provider pages

Closed
JA
1mo ago
+1383-20

Part of jaysbeekay/sure#504: the account and SSO provider half. The bills half is in jaysbeekay/sure#509 on fork main, which closes the issue.

Upstream PR: we-promise/sure#4373 (draft), on upstream issue we-promise/sure#4365. Same branch, same commit: this pre-flight runs the fork's CI and Gatekeeper reviews on up/parent-breadcrumbs against mirror/upstream-main. It ports the account and SSO parts of jaysbeekay/sure#509 (fork main) onto upstream main. The Bills part is left out because upstream folded the bill page into its drawer (we-promise/sure#3981).

Problem

On an account's page (/accounts/:id) the breadcrumb reads Home > Accounts, and "Accounts" is plain text, so the trail gives no way back to the accounts list. The SSO provider admin forms (/admin/sso_providers/new and /:id/edit) have the same problem: Home > SSO providers, and "SSO providers" is not a link.

These actions never assign @breadcrumbs, so they get Breadcrumbable#default_breadcrumbs: [[Home, root_path], [<section>, nil]]. That trail is correct on the list page itself, where the section is the current page. Under the list, the section crumb has no path, and the shared partial renders the last crumb as a <span> in any case.

Change

  • AccountsController#show sets Home > Accounts (linked to accounts_path) > <account name>.
  • Admin::SsoProvidersController gets a private set_form_breadcrumbs(action) helper that sets Home > SSO providers (linked to admin_sso_providers_path) > <form title>. It is called from new, edit, and both failed-save re-renders in create and update, so a rejected form keeps its trail. The form titles come from the existing admin.sso_providers.new.title and edit.title keys.

Left out on purpose:

  • Breadcrumbable's default and layouts/shared/_breadcrumbs.html.erb are unchanged. A generic "link the section to its index" default would also link index routes that are not standalone pages, and list pages keep their unlinked current crumb.
  • No locale changes. breadcrumbs.accounts and breadcrumbs.sso_providers already exist.
  • No view or CSS changes, so nothing changes visually beyond the crumb becoming a link and the page name being added.

Screenshots

Captured by a system test against the test fixtures: before on main at 7917bc1e4, after on this branch.

PageBeforeAfter
AccountBefore: Home  class= Accounts, as the unlinked current page">After: Home  class= Accounts > Checking Account">
New SSO providerBefore: Home  class= SSO providers">After: Home  class= SSO providers > Add SSO Provider">
Edit SSO providerBefore: Home  class= SSO providers">After: Home  class= SSO providers > Edit SSO Provider">

Tests

Every assertion is scoped to [data-breadcrumbs], so sidebar links cannot satisfy it.

test/controllers/accounts_controller_test.rb

  • show links the Accounts crumb back to the accounts list: the Accounts crumb links to accounts_path, and the account name is the last crumb.
  • the accounts list itself stays the unlinked current crumb: the list has no link to itself, and "Accounts" is the last crumb.

test/controllers/admin/sso_providers_controller_test.rb

  • the new page / the edit page links its SSO providers crumb back to the list: the crumb links to admin_sso_providers_path, and the form title is the last crumb.
  • a rejected create / a rejected update keeps the trail back to the list: a 422 re-render keeps the same trail and title.
  • the providers list itself stays the unlinked current crumb.

Evidence:

  • All five behaviour tests failed on main with Expected at least 1 element matching "[data-breadcrumbs] a[href=...]", found 0. The two list-page tests pass before and after, as regression guards.
  • I broke each change in turn and a test caught every one: removing any of the five @breadcrumbs assignments or helper calls; unlinking either section crumb; dropping or replacing the account name; making the helper ignore new vs edit. A default that links the section to itself fails both list-page guards.
  • bin/rails test: full suite green. bin/rubocop reports no offenses on the changed files, and bin/brakeman reports no warnings. No ERB was changed. No system test touches these breadcrumbs.