|
3 | 3 | describe VaccinationRecordPolicy do
|
4 | 4 | subject(:policy) { described_class.new(user, vaccination_record) }
|
5 | 5 |
|
| 6 | + let(:programme) { create(:programme) } |
| 7 | + let(:team) { create(:team, programmes: [programme]) } |
| 8 | + |
6 | 9 | describe "update?" do
|
7 | 10 | subject(:update?) { policy.update? }
|
8 | 11 |
|
9 |
| - let(:programme) { create(:programme) } |
10 |
| - let(:team) { create(:team, programmes: [programme]) } |
11 |
| - |
12 | 12 | let(:vaccination_record) { create(:vaccination_record, programme:) }
|
13 | 13 |
|
14 | 14 | context "with an admin" do
|
|
45 | 45 | describe "destroy?" do
|
46 | 46 | subject(:destroy?) { policy.destroy? }
|
47 | 47 |
|
48 |
| - let(:vaccination_record) { create(:vaccination_record) } |
| 48 | + context "when vaccination record is from the nhs immunisations api" do |
| 49 | + let(:vaccination_record) do |
| 50 | + create(:vaccination_record, programme:, source: "nhs_immunisations_api") |
| 51 | + end |
49 | 52 |
|
50 |
| - context "with an admin" do |
51 |
| - let(:user) { build(:admin) } |
| 53 | + context "with an admin with superuser access" do |
| 54 | + let(:user) { build(:admin, :superuser) } |
52 | 55 |
|
53 |
| - it { should be(false) } |
| 56 | + it { should be(false) } |
| 57 | + end |
54 | 58 |
|
55 |
| - context "and superuser access" do |
56 |
| - let(:user) { build(:admin, :superuser) } |
| 59 | + context "with a nurse with superuser access" do |
| 60 | + let(:user) { build(:nurse, :superuser) } |
57 | 61 |
|
58 |
| - it { should be(true) } |
| 62 | + it { should be(false) } |
59 | 63 | end
|
60 | 64 | end
|
61 | 65 |
|
62 |
| - context "with a nurse" do |
63 |
| - let(:user) { build(:nurse) } |
| 66 | + context "when vaccination record is managed in mavis" do |
| 67 | + let(:session) { create(:session, team:, programmes: [programme]) } |
| 68 | + let(:vaccination_record) do |
| 69 | + create( |
| 70 | + :vaccination_record, |
| 71 | + team:, |
| 72 | + programme:, |
| 73 | + source: "mavis", |
| 74 | + session: |
| 75 | + ) |
| 76 | + end |
64 | 77 |
|
65 |
| - it { should be(false) } |
| 78 | + context "with an admin" do |
| 79 | + let(:user) { build(:admin) } |
66 | 80 |
|
67 |
| - context "and superuser access" do |
68 |
| - let(:user) { build(:nurse, :superuser) } |
| 81 | + it { should be(false) } |
69 | 82 |
|
70 |
| - it { should be(true) } |
| 83 | + context "and superuser access" do |
| 84 | + let(:user) { build(:admin, :superuser) } |
| 85 | + |
| 86 | + it { should be(true) } |
| 87 | + end |
| 88 | + end |
| 89 | + |
| 90 | + context "with a nurse" do |
| 91 | + let(:user) { build(:nurse) } |
| 92 | + |
| 93 | + it { should be(false) } |
| 94 | + |
| 95 | + context "and superuser access" do |
| 96 | + let(:user) { build(:nurse, :superuser) } |
| 97 | + |
| 98 | + it { should be(true) } |
| 99 | + end |
71 | 100 | end
|
72 | 101 | end
|
73 | 102 | end
|
|
0 commit comments