Skip to content

Commit d52172b

Browse files
committed
Merge pull request #4334 from nhsuk/fix-header
Fix header role description
2 parents c98cdd7 + 3e0ecac commit d52172b

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

app/models/user.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,16 @@ def role_name
121121
cis2_info.role_name if cis2_enabled?
122122
end
123123

124+
def role_description
125+
role = (can_prescribe_pgd? ? "Nurse" : "Administrator")
126+
127+
if can_access_sensitive_records? || can_perform_local_admin_tasks?
128+
"#{role} (Superuser)"
129+
else
130+
role
131+
end
132+
end
133+
124134
def can_view?
125135
cis2_enabled? ? cis2_info.can_view? : !fallback_role.nil?
126136
end

app/views/layouts/_header.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<svg class="app-header__account-icon" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
2424
<path fill="currentColor" d="M8 0c4.4 0 8 3.6 8 8s-3.6 8-8 8-8-3.6-8-8 3.6-8 8-8Zm0 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1Zm-1.5 9h3a2.5 2.5 0 0 1 2.5 2.5V14a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1v-1.5A2.5 2.5 0 0 1 6.5 10ZM8 9C6.368 9 5 7.684 5 6s1.316-3 3-3c1.632 0 3 1.316 3 3S9.632 9 8 9"></path>
2525
</svg>
26-
<%= current_user.full_name %> <%= (role_name = current_user.role_name) ? " (#{role_name})" : "" %>
26+
<%= current_user.full_name %> <%= (role_description = current_user.role_description) ? " (#{role_description})" : "" %>
2727
</span>
2828
<% if Settings.cis2.enabled %>
2929
<span class="app-header__account-item">

spec/models/user_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,28 @@
5353
end
5454
end
5555

56+
describe "#role_description" do
57+
subject { user.role_description }
58+
59+
context "when the user is an admin" do
60+
let(:user) { build(:admin) }
61+
62+
it { should eq("Administrator") }
63+
end
64+
65+
context "when the user is a nurse" do
66+
let(:user) { build(:nurse) }
67+
68+
it { should eq("Nurse") }
69+
end
70+
71+
context "when the user is a superuser" do
72+
let(:user) { build(:admin, :superuser) }
73+
74+
it { should eq("Administrator (Superuser)") }
75+
end
76+
end
77+
5678
describe "#can_view?" do
5779
subject { user.can_view? }
5880

0 commit comments

Comments
 (0)