Browse Source

Use govuk_summary_list helper for personal details summary

pull/118/head
Paul Robert Lloyd 3 years ago
parent
commit
6f3cc781ef
  1. 94
      app/views/users/account/index.html.erb
  2. 4
      spec/features/user_spec.rb

94
app/views/users/account/index.html.erb

@ -6,68 +6,36 @@
<h2 class="govuk-heading-m"> <h2 class="govuk-heading-m">
Personal details Personal details
</h2> </h2>
<dl class="govuk-summary-list"> <%= govuk_summary_list do |summary_list| %>
<div class="govuk-summary-list__row"> <%= summary_list.row do |row|
<dt class="govuk-summary-list__key"> row.key { 'Name' }
Name row.value { current_user.name }
</dt> row.action(visually_hidden_text: 'name', href: '/users/account/personal_details', html_attributes: { 'data-qa': 'change-name' })
<dd class="govuk-summary-list__value"> end %>
<%= current_user.name %>
</dd> <%= summary_list.row() do |row|
<dd class="govuk-summary-list__actions"> row.key { 'Email address' }
<a class="govuk-link" href="/users/account/personal_details" id="change-name"> row.value { current_user.email }
Change<span class="govuk-visually-hidden"> row.action(visually_hidden_text: 'email address', href: '/users/account/personal_details', html_attributes: { 'data-qa': 'change-email' })
name</span> end %>
</a>
</dd> <%= summary_list.row do |row|
</div> row.key { 'Password' }
<div class="govuk-summary-list__row"> row.value { '••••••••' }
<dt class="govuk-summary-list__key"> row.action(visually_hidden_text: 'password', href: edit_user_registration_path, html_attributes: { 'data-qa': 'change-password' })
Email address end %>
</dt>
<dd class="govuk-summary-list__value"> <%= summary_list.row do |row|
<%= current_user.email %> row.key { 'Organisation' }
</dd> row.value { current_user.organisation }
<dd class="govuk-summary-list__actions"> row.action()
<a class="govuk-link" href="/users/account/personal_details" id="change-email"> end %>
Change<span class="govuk-visually-hidden">
email address</span> <%= summary_list.row do |row|
</a> row.key { 'Role' }
</dd> row.value { current_user.role }
</div> row.action()
<div class="govuk-summary-list__row"> end %>
<dt class="govuk-summary-list__key"> <% end %>
Password
</dt>
<dd class="govuk-summary-list__value">
••••••••
</dd>
<dd class="govuk-summary-list__actions">
<%= govuk_link_to "Change", edit_user_registration_path, id: "change-password" %>
</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
Organisation
</dt>
<dd class="govuk-summary-list__value">
<%= current_user.organisation %>
</dd>
<dd class="govuk-summary-list__actions">
<a class="govuk-link" href=""></a>
</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
Role
</dt>
<dd class="govuk-summary-list__value">
<%= current_user.role %>
</dd>
<dd class="govuk-summary-list__actions">
<a class="govuk-link" href=""></a>
</dd>
</div>
</dl>
</div> </div>
</div> </div>

4
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 it "can navigate to change your password page from main account page" do
visit("/users/account") visit("/users/account")
click_link("change-password") find('[data-qa="change-password"]').click
expect(page).to have_content("Change your password") expect(page).to have_content("Change your password")
fill_in("user[current_password]", with: "pAssword1") fill_in("user[current_password]", with: "pAssword1")
fill_in("user[password]", with: "Password123!") fill_in("user[password]", with: "Password123!")
@ -122,7 +122,7 @@ RSpec.describe "User Features" do
it "allow user to change name" do it "allow user to change name" do
visit("/users/account") visit("/users/account")
click_link("change-name") find('[data-qa="change-name"]').click
expect(page).to have_content("Change your personal details") expect(page).to have_content("Change your personal details")
fill_in("user[name]", with: "Test New") fill_in("user[name]", with: "Test New")
click_button("Save changes") click_button("Save changes")

Loading…
Cancel
Save