Link the parent breadcrumb on account and SSO provider pages
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#showsetsHome > Accounts (linked to accounts_path) > <account name>.Admin::SsoProvidersControllergets a privateset_form_breadcrumbs(action)helper that setsHome > SSO providers (linked to admin_sso_providers_path) > <form title>. It is called fromnew,edit, and both failed-save re-renders increateandupdate, so a rejected form keeps its trail. The form titles come from the existingadmin.sso_providers.new.titleandedit.titlekeys.
Left out on purpose:
Breadcrumbable's default andlayouts/shared/_breadcrumbs.html.erbare 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.accountsandbreadcrumbs.sso_providersalready 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.
| Page | Before | After |
|---|---|---|
| Account | Accounts, as the unlinked current page"> | Accounts > Checking Account"> |
| New SSO provider | SSO providers"> | SSO providers > Add SSO Provider"> |
| Edit SSO provider | SSO providers"> | 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 toaccounts_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 toadmin_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
mainwithExpected 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
@breadcrumbsassignments or helper calls; unlinking either section crumb; dropping or replacing the account name; making the helper ignorenewvsedit. A default that links the section to itself fails both list-page guards. bin/rails test: full suite green.bin/rubocopreports no offenses on the changed files, andbin/brakemanreports no warnings. No ERB was changed. No system test touches these breadcrumbs.
Accounts, as the unlinked current page">
Accounts > Checking Account">
SSO providers">
SSO providers > Add SSO Provider">
SSO providers">
SSO providers > Edit SSO Provider">