|
3 | 3 | describe ConsentsHelper do |
4 | 4 | subject(:reasons) { helper.consent_refusal_reasons(consent) } |
5 | 5 |
|
| 6 | + describe "#consent_refusal_reasons" do |
| 7 | + subject(:reasons) { helper.consent_refusal_reasons(consent) } |
| 8 | + |
| 9 | + context "with a ConsentForm for a school session" do |
| 10 | + let(:session) { create(:session, location: create(:gias_school)) } |
| 11 | + let(:consent) { build(:consent_form, session:) } |
| 12 | + |
| 13 | + it "includes do_not_want_vaccination_at_school" do |
| 14 | + expect(reasons.map(&:value)).to include( |
| 15 | + "do_not_want_vaccination_at_school" |
| 16 | + ) |
| 17 | + end |
| 18 | + |
| 19 | + it "includes the hint for do_not_want_vaccination_at_school" do |
| 20 | + reason = |
| 21 | + reasons.find { |r| r.value == "do_not_want_vaccination_at_school" } |
| 22 | + expect(reason.hint).to eq( |
| 23 | + "For example, you do not want your child to be vaccinated in a busy environment" |
| 24 | + ) |
| 25 | + end |
| 26 | + end |
| 27 | + |
| 28 | + context "with a ConsentForm for a clinic session" do |
| 29 | + let(:session) { create(:session, location: create(:generic_clinic)) } |
| 30 | + let(:consent) { build(:consent_form, session:) } |
| 31 | + |
| 32 | + it "does not include do_not_want_vaccination_at_school" do |
| 33 | + expect(reasons.map(&:value)).not_to include( |
| 34 | + "do_not_want_vaccination_at_school" |
| 35 | + ) |
| 36 | + end |
| 37 | + end |
| 38 | + |
| 39 | + context "with any consent form" do |
| 40 | + let(:session) { create(:session) } |
| 41 | + let(:consent) { build(:consent_form, session:) } |
| 42 | + |
| 43 | + it "includes the hint for will_be_vaccinated_elsewhere" do |
| 44 | + reason = reasons.find { |r| r.value == "will_be_vaccinated_elsewhere" } |
| 45 | + expect(reason.hint).to eq( |
| 46 | + "For example, you've booked your child into a clinic" |
| 47 | + ) |
| 48 | + end |
| 49 | + |
| 50 | + it "does not include hints for other reasons" do |
| 51 | + reasons_without_hints = |
| 52 | + reasons.reject do |r| |
| 53 | + %w[ |
| 54 | + will_be_vaccinated_elsewhere |
| 55 | + do_not_want_vaccination_at_school |
| 56 | + ].include?(r.value) |
| 57 | + end |
| 58 | + expect(reasons_without_hints.map(&:hint)).to all(be_nil) |
| 59 | + end |
| 60 | + end |
| 61 | + end |
| 62 | + |
6 | 63 | shared_examples "refusal reason label" do |expected_label| |
7 | 64 | it "uses the programme-specific refusal reason label" do |
8 | 65 | reason = reasons.find { |reason| reason.value == "contains_gelatine" } |
|
0 commit comments