|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +describe "Notify email templates: triage_vaccination_will_happen_mmr_second_dose", |
| 4 | + type: :view do |
| 5 | + subject(:rendered) { render_template } |
| 6 | + |
| 7 | + let(:programme) { Programme.mmr } |
| 8 | + let(:team) { create(:team, :with_one_nurse, programmes: [programme]) } |
| 9 | + let(:session) do |
| 10 | + create( |
| 11 | + :session, |
| 12 | + team:, |
| 13 | + programmes: [programme], |
| 14 | + date: Date.new(2025, 6, 10) |
| 15 | + ) |
| 16 | + end |
| 17 | + let(:patient) do |
| 18 | + create( |
| 19 | + :patient, |
| 20 | + :partially_vaccinated_triage_needed, |
| 21 | + given_name: "Filip", |
| 22 | + date_of_birth: Date.new(2015, 6, 1), |
| 23 | + session: |
| 24 | + ) |
| 25 | + end |
| 26 | + let(:consent) { patient.consents.first } |
| 27 | + |
| 28 | + def render_template |
| 29 | + PatientStatusUpdater.call(patient:) |
| 30 | + patient.programme_statuses.reload |
| 31 | + personalisation = GovukNotifyPersonalisation.new(consent:, session:) |
| 32 | + NotifyTemplate.find( |
| 33 | + :triage_vaccination_will_happen_mmr_second_dose, |
| 34 | + channel: :email |
| 35 | + ).render(personalisation) |
| 36 | + end |
| 37 | + |
| 38 | + context "with an MMR programme" do |
| 39 | + it "includes the programme name in the subject" do |
| 40 | + expect(rendered[:subject]).to include("MMR vaccination") |
| 41 | + end |
| 42 | + |
| 43 | + it "describes the first dose given" do |
| 44 | + expect(rendered[:body]).to include( |
| 45 | + "We recently gave Filip their 1st dose of the MMR vaccination" |
| 46 | + ) |
| 47 | + end |
| 48 | + |
| 49 | + it "describes the next dose" do |
| 50 | + expect(rendered[:body]).to include( |
| 51 | + "plan to give Filip their 2nd dose then" |
| 52 | + ) |
| 53 | + end |
| 54 | + end |
| 55 | + |
| 56 | + context "with an MMRV programme" do |
| 57 | + let(:patient) do |
| 58 | + create( |
| 59 | + :patient, |
| 60 | + :partially_vaccinated_triage_needed, |
| 61 | + given_name: "Filip", |
| 62 | + date_of_birth: Date.new(2020, 6, 1), |
| 63 | + session: |
| 64 | + ) |
| 65 | + end |
| 66 | + |
| 67 | + it "includes the programme name in the subject" do |
| 68 | + expect(rendered[:subject]).to include("MMRV vaccination") |
| 69 | + end |
| 70 | + |
| 71 | + it "describes the first dose given" do |
| 72 | + expect(rendered[:body]).to include( |
| 73 | + "We recently gave Filip their 1st dose of the MMRV vaccination" |
| 74 | + ) |
| 75 | + end |
| 76 | + |
| 77 | + it "describes the next dose" do |
| 78 | + expect(rendered[:body]).to include( |
| 79 | + "plan to give Filip their 2nd dose then" |
| 80 | + ) |
| 81 | + end |
| 82 | + end |
| 83 | +end |
0 commit comments