|
12 | 12 |
|
13 | 13 | let(:session) { create(:session, team:) } |
14 | 14 |
|
15 | | - describe "#team_contact_name" do |
16 | | - subject { helper.team_contact_name(session) } |
| 15 | + context "with a session" do |
| 16 | + describe "#team_contact_name" do |
| 17 | + subject { helper.team_contact_name(session:) } |
17 | 18 |
|
18 | | - context "without a subteam" do |
19 | | - it { should eq("SAIS Team") } |
| 19 | + context "without a subteam" do |
| 20 | + it { should eq("SAIS Team") } |
| 21 | + end |
| 22 | + |
| 23 | + context "with a subteam" do |
| 24 | + before do |
| 25 | + subteam = create(:subteam, team:, name: "SAIS Subteam") |
| 26 | + session.team_location.update!(subteam:) |
| 27 | + end |
| 28 | + |
| 29 | + it { should eq("SAIS Subteam") } |
| 30 | + end |
20 | 31 | end |
21 | 32 |
|
22 | | - context "with a subteam" do |
23 | | - before do |
24 | | - subteam = create(:subteam, team:, name: "SAIS Subteam") |
25 | | - session.team_location.update!(subteam:) |
| 33 | + describe "#team_contact_email" do |
| 34 | + subject { helper.team_contact_email(session:) } |
| 35 | + |
| 36 | + context "without a subteam" do |
| 37 | + it { should eq("sais@example.com") } |
26 | 38 | end |
27 | 39 |
|
28 | | - it { should eq("SAIS Subteam") } |
| 40 | + context "with a subteam" do |
| 41 | + before do |
| 42 | + subteam = create(:subteam, team:, email: "subteam@example.com") |
| 43 | + session.team_location.update!(subteam:) |
| 44 | + end |
| 45 | + |
| 46 | + it { should eq("subteam@example.com") } |
| 47 | + end |
29 | 48 | end |
30 | | - end |
31 | 49 |
|
32 | | - describe "#team_contact_email" do |
33 | | - subject { helper.team_contact_email(session) } |
| 50 | + describe "#team_contact_phone" do |
| 51 | + subject { helper.team_contact_phone(session:) } |
34 | 52 |
|
35 | | - context "without a subteam" do |
36 | | - it { should eq("sais@example.com") } |
37 | | - end |
| 53 | + context "without a subteam" do |
| 54 | + it { should eq("01234 567890") } |
| 55 | + end |
38 | 56 |
|
39 | | - context "with a subteam" do |
40 | | - before do |
41 | | - subteam = create(:subteam, team:, email: "subteam@example.com") |
42 | | - session.team_location.update!(subteam:) |
| 57 | + context "with a subteam" do |
| 58 | + before do |
| 59 | + subteam = |
| 60 | + create( |
| 61 | + :subteam, |
| 62 | + team:, |
| 63 | + phone: "01234 567890", |
| 64 | + phone_instructions: "option 2" |
| 65 | + ) |
| 66 | + session.team_location.update!(subteam:) |
| 67 | + end |
| 68 | + |
| 69 | + it { should eq("01234 567890 (option 2)") } |
43 | 70 | end |
| 71 | + end |
| 72 | + end |
44 | 73 |
|
45 | | - it { should eq("subteam@example.com") } |
| 74 | + context "with neither session nor vaccination_record" do |
| 75 | + it "raises an ArgumentError" do |
| 76 | + expect { helper.team_contact_name }.to raise_error(ArgumentError) |
46 | 77 | end |
47 | 78 | end |
48 | 79 |
|
49 | | - describe "#team_contact_phone" do |
50 | | - subject { helper.team_contact_phone(session) } |
| 80 | + context "with both session and vaccination_record" do |
| 81 | + let(:vaccination_record) do |
| 82 | + create(:vaccination_record, programme: Programme.hpv, session:) |
| 83 | + end |
51 | 84 |
|
52 | | - context "without a subteam" do |
53 | | - it { should eq("01234 567890") } |
| 85 | + it "raises an ArgumentError" do |
| 86 | + expect { |
| 87 | + helper.team_contact_name(session:, vaccination_record:) |
| 88 | + }.to raise_error(ArgumentError) |
54 | 89 | end |
| 90 | + end |
55 | 91 |
|
56 | | - context "with a subteam" do |
57 | | - before do |
58 | | - subteam = |
59 | | - create( |
60 | | - :subteam, |
61 | | - team:, |
62 | | - phone: "01234 567890", |
63 | | - phone_instructions: "option 2" |
64 | | - ) |
65 | | - session.team_location.update!(subteam:) |
66 | | - end |
| 92 | + context "with a vaccination_record without a session" do |
| 93 | + let(:school) { create(:gias_school, team:) } |
| 94 | + let(:patient) { create(:patient, school:) } |
| 95 | + let(:vaccination_record) do |
| 96 | + create( |
| 97 | + :vaccination_record, |
| 98 | + :sourced_from_nhs_immunisations_api, |
| 99 | + patient:, |
| 100 | + session: nil |
| 101 | + ) |
| 102 | + end |
| 103 | + |
| 104 | + describe "#team_contact_name" do |
| 105 | + subject { helper.team_contact_name(vaccination_record:) } |
67 | 106 |
|
68 | | - it { should eq("01234 567890 (option 2)") } |
| 107 | + it { should eq("SAIS Team") } |
| 108 | + end |
| 109 | + |
| 110 | + describe "#team_contact_email" do |
| 111 | + subject { helper.team_contact_email(vaccination_record:) } |
| 112 | + |
| 113 | + it { should eq("sais@example.com") } |
| 114 | + end |
| 115 | + |
| 116 | + describe "#team_contact_phone" do |
| 117 | + subject { helper.team_contact_phone(vaccination_record:) } |
| 118 | + |
| 119 | + it { should eq("01234 567890") } |
69 | 120 | end |
70 | 121 | end |
71 | 122 | end |
0 commit comments