Skip to content

[WHIT-3323] Keep current url on rename#11445

Merged
lauraghiorghisor-tw merged 4 commits into
mainfrom
keep-current-url-on-rename
May 15, 2026
Merged

[WHIT-3323] Keep current url on rename#11445
lauraghiorghisor-tw merged 4 commits into
mainfrom
keep-current-url-on-rename

Conversation

@lauraghiorghisor-tw
Copy link
Copy Markdown
Contributor

@lauraghiorghisor-tw lauraghiorghisor-tw commented May 13, 2026

What and why

Previously, when the user changed the title of an edition in Whitehall, they were presented with a checkbox allowing them to preserve the document’s current live URL. If they did not check the box, the URL was updated to match the new title of the edition. Several departments have requested that we only update the edition's URL if the publisher specifically selects that behaviour.

The previous checkbox has been replaced by radio buttons, to better express what options the user has:

  • keeping live url
  • using the new title-based url

Keeping the live url is always our pre-checked option, unless the user has actively selected the title-based option.
The copy has been updated to reflect the new functionality. Feature tests now provide extensive coverage.

UI changes

Before After
image image

Related PRs:
#11371
#11424
#11359

Jira

@lauraghiorghisor-tw lauraghiorghisor-tw marked this pull request as draft May 13, 2026 16:23
@lauraghiorghisor-tw lauraghiorghisor-tw changed the title Keep current url on rename [[WHIT-3323] ] Keep current url on rename May 13, 2026
@lauraghiorghisor-tw lauraghiorghisor-tw changed the title [[WHIT-3323] ] Keep current url on rename [WHIT-3323] Keep current url on rename May 13, 2026
Copy link
Copy Markdown
Contributor Author

@lauraghiorghisor-tw lauraghiorghisor-tw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👏 🏁🏁🏁🏁🏁🏁🏁🏁🏁

Small bits and namings and commit message additions.

Comment thread app/models/concerns/edition/identifiable.rb Outdated
Comment thread test/unit/app/models/edition_test.rb Outdated
Comment thread test/unit/app/models/edition_test.rb Outdated
Comment thread test/unit/app/models/edition_test.rb Outdated
Comment thread app/views/admin/editions/_page_address_controls.html.erb
Comment thread test/functional/admin/standard_editions_controller_test.rb Outdated
Comment thread test/functional/admin/standard_editions_controller_test.rb Outdated
Comment thread test/functional/admin/standard_editions_controller_test.rb Outdated
Comment thread test/functional/admin/standard_editions_controller_test.rb Outdated
Comment thread test/functional/admin/standard_editions_controller_test.rb Outdated
@lauraghiorghisor-tw lauraghiorghisor-tw marked this pull request as ready for review May 13, 2026 18:49
Comment thread app/models/concerns/edition/identifiable.rb
Comment thread app/views/admin/editions/_page_address_controls.html.erb Outdated
Comment thread test/unit/app/models/edition_test.rb Outdated
Comment thread test/unit/app/models/edition_test.rb Outdated
Comment thread test/unit/app/models/edition_test.rb Outdated
Comment thread test/functional/admin/standard_editions_controller_test.rb Outdated
Comment thread test/functional/admin/standard_editions_controller_test.rb Outdated
@TonyGDS TonyGDS force-pushed the keep-current-url-on-rename branch 5 times, most recently from ddeaabd to 51fc4d5 Compare May 14, 2026 15:49
Comment thread test/functional/admin/standard_editions_controller_test.rb Outdated
Comment thread test/functional/admin/standard_editions_controller_test.rb Outdated
Comment thread test/unit/app/models/edition_test.rb Outdated
Comment thread test/unit/app/models/edition_test.rb Outdated
Comment thread test/unit/app/models/edition_test.rb Outdated
@TonyGDS TonyGDS force-pushed the keep-current-url-on-rename branch 4 times, most recently from ceae1ff to 4b09bdb Compare May 15, 2026 10:32
TonyGDS added 3 commits May 15, 2026 11:32
Replace the "Live page address" heading and govuk-hint URL with a "URL"
heading and a paragraph containing the live URL as a clickable govuk-link,
so editors can verify and visit the live page from the edit form.

Coverage for the new markup is added in
standard_editions_controller_test rather than
document_collections_controller_test because the link is rendered by the
shared _page_address_controls partial and standard_editions is now the more
representative surface for partial-level UI coverage. The stale
.govuk-hint assertion in document_collections_controller_test is dropped.
Swap the single "Keep the current page URL" checkbox for a pair of
"Keep current URL" / "Update URL to match title" radios on the edit
form, with a short paragraph above explaining the choice.

The "Keep current URL" option is pre-checked when the user has either
explicitly set slug_override OR when the draft's slug already matches
the live edition's slug. This keeps the right option selected on
freshly-loaded drafts with an unchanged title, on re-renders after
validation failure, and on subsequent renames.

Rename the JS variable from "checkbox" to "url-radio-group" so the
reveal-on-title-change logic reads coherently against the new radio
layout. Behaviour is unchanged: the controls stay hidden until the
title diverges from its original value.
Reshape edition-update-slug.feature around two Rules:

- The URL control only appears when the URL can be changed — covered
  by a @javascript scenario that confirms the keep-slug controls are
  hidden until the title is edited.

- Renaming a draft keeps the live URL unless an editor opts out — four
  scenarios covering the simple keep / opt-out pair plus two force-
  publish round-trips where the chosen URL persists across subsequent
  renames.

Replace the obsolete step set (visit_edit_slug, update_slug, the
permission-denied step) with the steps the new scenarios rely on:
seeing/not-seeing the keep-slug option, asserting the saved choice on
re-entering edit, and two Given chains for the kept-URL / updated-URL
force-publish setups.

Adjust the preview-URL step to use Publication.latest_edition so it
keeps working when a published edition and a new draft share the same
title.
@TonyGDS TonyGDS force-pushed the keep-current-url-on-rename branch from 4b09bdb to 56a4bd5 Compare May 15, 2026 10:32
Add a before_save :nullify_redundant_slug_override callback that nils
slug_override whenever it equals the slug_from_title.
The column then only ever holds a value that actually changes the
resulting slug. Drafts whose user picked "Keep current URL" on a
same-slug rename end up with slug_override = nil, as do form submits
where the posted override happens to match the title,
such as when the edition is edited but the title has not changed.

Without this change we would end up with the slug_override matching
the title based slug on a regular save which results in confusing data.

The callback is declared between set_slug_from_title and set_slug so it
sees the freshly-derived slug_from_title, and set_slug sees the
finalised slug_override.
@TonyGDS TonyGDS force-pushed the keep-current-url-on-rename branch from 56a4bd5 to 0ac0a7d Compare May 15, 2026 10:38
Copy link
Copy Markdown
Contributor

@TonyGDS TonyGDS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM & @lauraghiorghisor-tw 🚢

@lauraghiorghisor-tw lauraghiorghisor-tw merged commit e203c18 into main May 15, 2026
25 checks passed
@lauraghiorghisor-tw lauraghiorghisor-tw deleted the keep-current-url-on-rename branch May 15, 2026 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants