Browse Source

Content tweaks for user and organisation management (#676)

pull/687/head
Paul Robert Lloyd 3 years ago committed by GitHub
parent
commit
34f6da7ea7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/helpers/user_helper.rb
  2. 2
      app/models/organisation.rb
  3. 4
      app/views/users/edit.html.erb
  4. 6
      app/views/users/new.html.erb
  5. 8
      app/views/users/show.html.erb
  6. 2
      spec/features/organisation_spec.rb
  7. 8
      spec/features/user_spec.rb
  8. 10
      spec/helpers/user_helper_spec.rb
  9. 28
      spec/requests/users_controller_spec.rb

4
app/helpers/user_helper.rb

@ -3,8 +3,8 @@ module UserHelper
current_user == user ? edit_account_path : edit_user_path(user) current_user == user ? edit_account_path : edit_user_path(user)
end end
def pronoun(user, current_user) def perspective(user, current_user)
current_user == user ? "you" : "they" current_user == user ? "Are you" : "Is this person"
end end
def can_edit_names?(user, current_user) def can_edit_names?(user, current_user)

2
app/models/organisation.rb

@ -67,7 +67,7 @@ class Organisation < ApplicationRecord
{ name: "telephone_number", value: phone, editable: true }, { name: "telephone_number", value: phone, editable: true },
{ name: "type", value: display_provider_type, editable: false }, { name: "type", value: display_provider_type, editable: false },
{ name: "rent_periods", value: rent_period_labels, editable: false, format: :bullet }, { name: "rent_periods", value: rent_period_labels, editable: false, format: :bullet },
{ name: "holds_own_stock", value: holds_own_stock.to_s.humanize, editable: false }, { name: "Owns housing stock", value: holds_own_stock ? "Yes" : "No", editable: false },
{ name: "other_stock_owners", value: other_stock_owners, editable: false }, { name: "other_stock_owners", value: other_stock_owners, editable: false },
{ name: "managing_agents", value: managing_agents, editable: false }, { name: "managing_agents", value: managing_agents, editable: false },
{ name: "data_protection_agreement", value: data_protection_agreement_string, editable: false }, { name: "data_protection_agreement", value: data_protection_agreement_string, editable: false },

4
app/views/users/edit.html.erb

@ -38,13 +38,13 @@
[OpenStruct.new(id: true, name: "Yes"), OpenStruct.new(id: false, name: "No")], [OpenStruct.new(id: true, name: "Yes"), OpenStruct.new(id: false, name: "No")],
:id, :id,
:name, :name,
legend: { text: "Are #{pronoun(@user, current_user)} the organisation’s data protection officer?", size: "m" } %> legend: { text: "#{perspective(@user, current_user)} the organisation’s data protection officer?", size: "m" } %>
<%= f.govuk_collection_radio_buttons :is_key_contact, <%= f.govuk_collection_radio_buttons :is_key_contact,
[OpenStruct.new(id: true, name: "Yes"), OpenStruct.new(id: false, name: "No")], [OpenStruct.new(id: true, name: "Yes"), OpenStruct.new(id: false, name: "No")],
:id, :id,
:name, :name,
legend: { text: "Are #{pronoun(@user, current_user)} a key contact for this service?", size: "m" }, legend: { text: "#{perspective(@user, current_user)} a key contact for this service?", size: "m" },
hint: { text: "This is a person responsible for sharing information about social housing lettings and sales data within the organisation." } %> hint: { text: "This is a person responsible for sharing information about social housing lettings and sales data within the organisation." } %>
<% end %> <% end %>

6
app/views/users/new.html.erb

@ -1,4 +1,4 @@
<% content_for :title, "Invite user to submit CORE data" %> <% content_for :title, "Invite somebody to submit CORE data" %>
<% content_for :before_content do %> <% content_for :before_content do %>
<%= govuk_back_link( <%= govuk_back_link(
@ -55,13 +55,13 @@
[OpenStruct.new(id: true, name: "Yes"), OpenStruct.new(id: false, name: "No")], [OpenStruct.new(id: true, name: "Yes"), OpenStruct.new(id: false, name: "No")],
:id, :id,
:name, :name,
legend: { text: "Are #{pronoun(@user, current_user)} the organisation’s data protection officer?", size: "m" } %> legend: { text: "#{perspective(@user, current_user)} the organisation’s data protection officer?", size: "m" } %>
<%= f.govuk_collection_radio_buttons :is_key_contact, <%= f.govuk_collection_radio_buttons :is_key_contact,
[OpenStruct.new(id: true, name: "Yes"), OpenStruct.new(id: false, name: "No")], [OpenStruct.new(id: true, name: "Yes"), OpenStruct.new(id: false, name: "No")],
:id, :id,
:name, :name,
legend: { text: "Is this user a key contact for this service?", size: "m" }, legend: { text: "#{perspective(@user, current_user)} a key contact for this service?", size: "m" },
hint: { text: "This is a person responsible for sharing information about social housing lettings and sales data within the organisation." } %> hint: { text: "This is a person responsible for sharing information about social housing lettings and sales data within the organisation." } %>
<%= f.govuk_submit "Continue" %> <%= f.govuk_submit "Continue" %>

8
app/views/users/show.html.erb

@ -80,9 +80,9 @@
row.value { @user.is_data_protection_officer? ? "Yes" : "No" } row.value { @user.is_data_protection_officer? ? "Yes" : "No" }
if can_edit_dpo?(@user, current_user) if can_edit_dpo?(@user, current_user)
row.action( row.action(
visually_hidden_text: "are #{pronoun(@user, current_user)} a data protection officer?", visually_hidden_text: "if data protection officer",
href: aliased_user_edit(@user, current_user), href: aliased_user_edit(@user, current_user),
html_attributes: { "data-qa": "change-are-#{pronoun(@user, current_user)}-a-data-protection-officer" }, html_attributes: { "data-qa": "change-data-protection-officer" },
) )
else else
row.action row.action
@ -94,9 +94,9 @@
row.value { @user.is_key_contact? ? "Yes" : "No" } row.value { @user.is_key_contact? ? "Yes" : "No" }
if can_edit_key_contact?(@user, current_user) if can_edit_key_contact?(@user, current_user)
row.action( row.action(
visually_hidden_text: "are #{pronoun(@user, current_user)} a key contact?", visually_hidden_text: "if a key contact",
href: aliased_user_edit(@user, current_user), href: aliased_user_edit(@user, current_user),
html_attributes: { "data-qa": "change-are-#{pronoun(@user, current_user)}-a-key-contact" }, html_attributes: { "data-qa": "change-key-contact" },
) )
else else
row.action row.action

2
spec/features/organisation_spec.rb

@ -47,7 +47,7 @@ RSpec.describe "User Features" do
click_link("Users") click_link("Users")
click_link("Invite user") click_link("Invite user")
expect(page).to have_current_path("/users/new") expect(page).to have_current_path("/users/new")
expect(page).to have_content("Invite user to submit CORE data") expect(page).to have_content("Invite somebody to submit CORE data")
fill_in("user[name]", with: "New User") fill_in("user[name]", with: "New User")
fill_in("user[email]", with: "new_user@example.com") fill_in("user[email]", with: "new_user@example.com")
choose("user-role-data-provider-field") choose("user-role-data-provider-field")

8
spec/features/user_spec.rb

@ -199,8 +199,8 @@ RSpec.describe "User Features" do
it "does not have change links for dpo and key contact" do it "does not have change links for dpo and key contact" do
visit("/account") visit("/account")
expect(page).not_to have_selector('[data-qa="change-are-you-a-data-protection-officer"]') expect(page).not_to have_selector('[data-qa="change-if-data-protection-officer"]')
expect(page).not_to have_selector('[data-qa="change-are-you-a-key-contact"]') expect(page).not_to have_selector('[data-qa="change-if-key-contact"]')
end end
it "does not have dpo and key contact as editable fields" do it "does not have dpo and key contact as editable fields" do
@ -288,8 +288,8 @@ RSpec.describe "User Features" do
it "has dpo and key contact as editable fields" do it "has dpo and key contact as editable fields" do
visit("/account") visit("/account")
expect(page).to have_selector('[data-qa="change-are-you-a-data-protection-officer"]') expect(page).to have_selector('[data-qa="change-data-protection-officer"]')
expect(page).to have_selector('[data-qa="change-are-you-a-key-contact"]') expect(page).to have_selector('[data-qa="change-key-contact"]')
end end
end end

10
spec/helpers/user_helper_spec.rb

@ -20,18 +20,18 @@ RSpec.describe UserHelper do
end end
end end
describe "pronoun" do describe "perspective" do
context "when the current logged in user is the same as the user being viewed" do context "when the current logged in user is the same as the user being viewed" do
let(:user) { current_user } let(:user) { current_user }
it "returns 'you'" do it "returns 'Are you'" do
expect(pronoun(user, current_user)).to eq("you") expect(perspective(user, current_user)).to eq("Are you")
end end
end end
context "when the current logged in user is not the same as the user being viewed" do context "when the current logged in user is not the same as the user being viewed" do
it "returns 'they'" do it "returns 'Is this person'" do
expect(pronoun(user, current_user)).to eq("they") expect(perspective(user, current_user)).to eq("Is this person")
end end
end end
end end

28
spec/requests/users_controller_spec.rb

@ -144,8 +144,8 @@ RSpec.describe UsersController, type: :request do
expect(page).to have_link("Change", text: "email address") expect(page).to have_link("Change", text: "email address")
expect(page).to have_link("Change", text: "password") expect(page).to have_link("Change", text: "password")
expect(page).not_to have_link("Change", text: "role") expect(page).not_to have_link("Change", text: "role")
expect(page).not_to have_link("Change", text: "are you a data protection officer?") expect(page).not_to have_link("Change", text: "if data protection officer")
expect(page).not_to have_link("Change", text: "are you a key contact?") expect(page).not_to have_link("Change", text: "if a key contact")
end end
it "does not allow deactivating the user" do it "does not allow deactivating the user" do
@ -196,8 +196,8 @@ RSpec.describe UsersController, type: :request do
expect(page).not_to have_link("Change", text: "email address") expect(page).not_to have_link("Change", text: "email address")
expect(page).not_to have_link("Change", text: "password") expect(page).not_to have_link("Change", text: "password")
expect(page).not_to have_link("Change", text: "role") expect(page).not_to have_link("Change", text: "role")
expect(page).not_to have_link("Change", text: "are you a data protection officer?") expect(page).not_to have_link("Change", text: "if data protection officer")
expect(page).not_to have_link("Change", text: "are you a key contact?") expect(page).not_to have_link("Change", text: "if a key contact")
end end
it "does not allow deactivating the user" do it "does not allow deactivating the user" do
@ -511,8 +511,8 @@ RSpec.describe UsersController, type: :request do
expect(page).to have_link("Change", text: "email address") expect(page).to have_link("Change", text: "email address")
expect(page).to have_link("Change", text: "password") expect(page).to have_link("Change", text: "password")
expect(page).to have_link("Change", text: "role") expect(page).to have_link("Change", text: "role")
expect(page).to have_link("Change", text: "are you a data protection officer?") expect(page).to have_link("Change", text: "if data protection officer")
expect(page).to have_link("Change", text: "are you a key contact?") expect(page).to have_link("Change", text: "if a key contact")
end end
it "does not allow deactivating the user" do it "does not allow deactivating the user" do
@ -551,8 +551,8 @@ RSpec.describe UsersController, type: :request do
expect(page).to have_link("Change", text: "email address") expect(page).to have_link("Change", text: "email address")
expect(page).not_to have_link("Change", text: "password") expect(page).not_to have_link("Change", text: "password")
expect(page).to have_link("Change", text: "role") expect(page).to have_link("Change", text: "role")
expect(page).to have_link("Change", text: "are they a data protection officer?") expect(page).to have_link("Change", text: "if data protection officer")
expect(page).to have_link("Change", text: "are they a key contact?") expect(page).to have_link("Change", text: "if a key contact")
end end
it "allows deactivating the user" do it "allows deactivating the user" do
@ -1168,8 +1168,8 @@ RSpec.describe UsersController, type: :request do
expect(page).to have_link("Change", text: "email address") expect(page).to have_link("Change", text: "email address")
expect(page).to have_link("Change", text: "password") expect(page).to have_link("Change", text: "password")
expect(page).to have_link("Change", text: "role") expect(page).to have_link("Change", text: "role")
expect(page).to have_link("Change", text: "are you a data protection officer?") expect(page).to have_link("Change", text: "if data protection officer")
expect(page).to have_link("Change", text: "are you a key contact?") expect(page).to have_link("Change", text: "if a key contact")
end end
it "does not allow deactivating the user" do it "does not allow deactivating the user" do
@ -1197,8 +1197,8 @@ RSpec.describe UsersController, type: :request do
expect(page).to have_link("Change", text: "email address") expect(page).to have_link("Change", text: "email address")
expect(page).not_to have_link("Change", text: "password") expect(page).not_to have_link("Change", text: "password")
expect(page).to have_link("Change", text: "role") expect(page).to have_link("Change", text: "role")
expect(page).to have_link("Change", text: "are they a data protection officer?") expect(page).to have_link("Change", text: "if data protection officer")
expect(page).to have_link("Change", text: "are they a key contact?") expect(page).to have_link("Change", text: "if a key contact")
end end
it "allows deactivating the user" do it "allows deactivating the user" do
@ -1237,8 +1237,8 @@ RSpec.describe UsersController, type: :request do
expect(page).to have_link("Change", text: "email address") expect(page).to have_link("Change", text: "email address")
expect(page).not_to have_link("Change", text: "password") expect(page).not_to have_link("Change", text: "password")
expect(page).to have_link("Change", text: "role") expect(page).to have_link("Change", text: "role")
expect(page).to have_link("Change", text: "are they a data protection officer?") expect(page).to have_link("Change", text: "if data protection officer")
expect(page).to have_link("Change", text: "are they a key contact?") expect(page).to have_link("Change", text: "if a key contact")
end end
end end
end end

Loading…
Cancel
Save