Skip to content

Commit 6d43ac3

Browse files
authored
Merge pull request #4455 from nhsuk/prescriber-record-psd
Allow prescribers to record PSDs
2 parents f32cd3b + f8df809 commit 6d43ac3

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

app/policies/patient_specific_direction_policy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
class PatientSpecificDirectionPolicy < ApplicationPolicy
44
def create?
5-
user.is_nurse?
5+
user.is_nurse? || user.is_prescriber?
66
end
77
end

app/views/sessions/patient_specific_directions/show.html.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
There are <%= @eligible_for_bulk_psd_count %> children with consent for the nasal flu vaccine
2727
who do not require triage and do not yet have a PSD in place.
2828
</p>
29-
<% if current_user.is_nurse? %>
29+
30+
<% if policy(PatientSpecificDirection).create? %>
3031
<%= link_to new_session_patient_specific_directions_path(@session), class: "nhsuk-action-link" do %>
3132
<svg class="nhsuk-icon nhsuk-icon--arrow-right-circle" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" focusable="false" aria-hidden="true">
3233
<path d="M12 2a10 10 0 0 0-10 9h11.7l-4-4a1 1 0 0 1 1.5-1.4l5.6 5.7a1 1 0 0 1 0 1.4l-5.6 5.7a1 1 0 0 1-1.5 0 1 1 0 0 1 0-1.4l4-4H2A10 10 0 1 0 12 2z" />
Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
# frozen_string_literal: true
22

3-
RSpec.describe PatientSpecificDirectionPolicy do
3+
describe PatientSpecificDirectionPolicy do
44
subject(:policy) { described_class.new(user, PatientSpecificDirection) }
55

6-
context "cis2 is disabled", cis2: :disabled do
7-
describe "#create?" do
8-
context "when user is a nurse" do
9-
let(:user) { build(:user, :nurse) }
6+
describe "#create?" do
7+
subject(:create?) { policy.create? }
108

11-
it "permits creation" do
12-
expect(policy.create?).to be(true)
13-
end
14-
end
9+
context "when user is a nurse" do
10+
let(:user) { build(:user, :nurse) }
1511

16-
context "when user is not a nurse" do
17-
let(:user) { build(:user, :healthcare_assistant) }
12+
it { should be(true) }
13+
end
14+
15+
context "when user is a prescriber" do
16+
let(:user) { build(:user, :prescriber) }
17+
18+
it { should be(true) }
19+
end
20+
21+
context "when user is a healthcare assistant" do
22+
let(:user) { build(:user, :healthcare_assistant) }
1823

19-
it "denies creation" do
20-
expect(policy.create?).to be(false)
21-
end
22-
end
24+
it { should be(false) }
2325
end
2426
end
2527
end

0 commit comments

Comments
 (0)