From 6f3cc781ef675e905f7e53ab1d1df3b613da0276 Mon Sep 17 00:00:00 2001 From: Paul Robert Lloyd Date: Tue, 30 Nov 2021 11:18:27 +0000 Subject: [PATCH] Use govuk_summary_list helper for personal details summary --- app/views/users/account/index.html.erb | 94 +++++++++----------------- spec/features/user_spec.rb | 4 +- 2 files changed, 33 insertions(+), 65 deletions(-) diff --git a/app/views/users/account/index.html.erb b/app/views/users/account/index.html.erb index 83b5d76fd..3dde070eb 100644 --- a/app/views/users/account/index.html.erb +++ b/app/views/users/account/index.html.erb @@ -6,68 +6,36 @@

Personal details

-
-
-
- Name -
-
- <%= current_user.name %> -
-
- - Change - name - -
-
-
-
- Email address -
-
- <%= current_user.email %> -
-
- - Change - email address - -
-
-
-
- Password -
-
- •••••••• -
-
- <%= govuk_link_to "Change", edit_user_registration_path, id: "change-password" %> -
-
-
-
- Organisation -
-
- <%= current_user.organisation %> -
-
- -
-
-
-
- Role -
-
- <%= current_user.role %> -
-
- -
-
-
+ <%= govuk_summary_list do |summary_list| %> + <%= summary_list.row do |row| + row.key { 'Name' } + row.value { current_user.name } + row.action(visually_hidden_text: 'name', href: '/users/account/personal_details', html_attributes: { 'data-qa': 'change-name' }) + end %> + + <%= summary_list.row() do |row| + row.key { 'Email address' } + row.value { current_user.email } + row.action(visually_hidden_text: 'email address', href: '/users/account/personal_details', html_attributes: { 'data-qa': 'change-email' }) + end %> + + <%= summary_list.row do |row| + row.key { 'Password' } + row.value { '••••••••' } + row.action(visually_hidden_text: 'password', href: edit_user_registration_path, html_attributes: { 'data-qa': 'change-password' }) + end %> + + <%= summary_list.row do |row| + row.key { 'Organisation' } + row.value { current_user.organisation } + row.action() + end %> + + <%= summary_list.row do |row| + row.key { 'Role' } + row.value { current_user.role } + row.action() + end %> + <% end %> diff --git a/spec/features/user_spec.rb b/spec/features/user_spec.rb index 5dcabcf7d..e41551845 100644 --- a/spec/features/user_spec.rb +++ b/spec/features/user_spec.rb @@ -112,7 +112,7 @@ RSpec.describe "User Features" do it "can navigate to change your password page from main account page" do visit("/users/account") - click_link("change-password") + find('[data-qa="change-password"]').click expect(page).to have_content("Change your password") fill_in("user[current_password]", with: "pAssword1") fill_in("user[password]", with: "Password123!") @@ -122,7 +122,7 @@ RSpec.describe "User Features" do it "allow user to change name" do visit("/users/account") - click_link("change-name") + find('[data-qa="change-name"]').click expect(page).to have_content("Change your personal details") fill_in("user[name]", with: "Test New") click_button("Save changes")