Browse Source

Use first or second person perspective when refering to users

pull/676/head
Paul Robert Lloyd 3 years ago
parent
commit
5e73b5b2e5
  1. 4
      app/helpers/user_helper.rb
  2. 4
      app/views/users/edit.html.erb
  3. 4
      app/views/users/new.html.erb
  4. 8
      app/views/users/show.html.erb
  5. 8
      spec/features/user_spec.rb
  6. 10
      spec/helpers/user_helper_spec.rb
  7. 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)

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 %>

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

@ -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

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