Browse Source

Nil safe humanizing

pull/632/head
baarkerlounger 3 years ago
parent
commit
1446d171e5
  1. 2
      app/views/users/show.html.erb
  2. 13
      spec/requests/users_controller_spec.rb

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

@ -63,7 +63,7 @@
<%= summary_list.row do |row| <%= summary_list.row do |row|
row.key { "Role" } row.key { "Role" }
row.value { @user.role.humanize } row.value { @user.role&.humanize }
if can_edit_roles?(@user, current_user) if can_edit_roles?(@user, current_user)
row.action( row.action(
visually_hidden_text: "role", visually_hidden_text: "role",

13
spec/requests/users_controller_spec.rb

@ -164,6 +164,19 @@ RSpec.describe UsersController, type: :request do
end end
end end
context "when the user does not have a role because they are a data protection officer only" do
let(:user) { FactoryBot.create(:user, role: nil) }
before do
sign_in user
get "/users/#{user.id}", headers:, params: {}
end
it "shows their details" do
expect(response).to have_http_status(:ok)
end
end
context "when the current user does not match the user ID" do context "when the current user does not match the user ID" do
before do before do
sign_in user sign_in user

Loading…
Cancel
Save