diff --git a/app/views/users/names/edit.html.erb b/app/views/users/names/edit.html.erb index e2c6f5589..64ff41a06 100644 --- a/app/views/users/names/edit.html.erb +++ b/app/views/users/names/edit.html.erb @@ -1,5 +1,5 @@ <% content_for :title_caption, "Manage other users" %> -<% content_for :title, "Change name for #{@user.name}" %> +<% content_for :title, "Change name for #{@user.name_was}" %> <% content_for :breadcrumbs, render("govuk_publishing_components/components/breadcrumbs", { @@ -14,7 +14,7 @@ url: users_path, }, { - title: @user.name, + title: @user.name_was, url: edit_user_path(@user), }, { diff --git a/test/controllers/users/names_controller_test.rb b/test/controllers/users/names_controller_test.rb index 7f446f861..0c65c89da 100644 --- a/test/controllers/users/names_controller_test.rb +++ b/test/controllers/users/names_controller_test.rb @@ -138,6 +138,16 @@ class Users::NamesControllerTest < ActionController::TestCase end end + should "use original name in page title, heading & breadcrumbs if new name was not valid" do + user = create(:user, name: "user-name") + + put :update, params: { user_id: user, user: { name: "" } } + + assert_select "head title", text: /^Change name for user-name/ + assert_select "h1", text: "Change name for user-name" + assert_select ".govuk-breadcrumbs li", text: "user-name" + end + should "display errors if name is not valid" do user = create(:user)