File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -129,10 +129,15 @@ def consent_link
129129 end
130130
131131 def consented_vaccine_methods_message
132- return nil if consent_form . nil?
133- return "" if consent_form . programmes . none? ( &:flu? )
132+ return nil if consent . nil? && consent_form . nil?
134133
135- consent_form_programmes = consent_form . consent_form_programmes
134+ if ( consent && !consent . programme . flu? ) ||
135+ ( consent_form && consent_form . programmes . none? ( &:flu? ) )
136+ return ""
137+ end
138+
139+ consent_form_programmes =
140+ consent ? [ consent ] : consent_form . consent_form_programmes
136141
137142 consented_vaccine_methods =
138143 if consent_form_programmes . any? ( &:vaccine_method_injection_and_nasal? )
Original file line number Diff line number Diff line change 194194 it do
195195 expect ( to_h ) . to match (
196196 hash_including (
197+ consented_vaccine_methods_message : "" ,
197198 reason_for_refusal : "of personal choice" ,
198199 survey_deadline_date : "8 January 2024"
199200 )
200201 )
201202 end
203+
204+ context "for the flu programme" do
205+ let ( :programmes ) { [ create ( :programme , :flu ) ] }
206+
207+ it do
208+ expect ( to_h ) . to include (
209+ consented_vaccine_methods_message :
210+ "You’ve agreed that John can have the injected flu vaccine."
211+ )
212+ end
213+
214+ context "when consented to both nasal and injection" do
215+ before { consent . update! ( vaccine_methods : %w[ nasal injection ] ) }
216+
217+ it do
218+ expect ( to_h ) . to include (
219+ consented_vaccine_methods_message :
220+ "You’ve agreed that John can have the nasal spray flu vaccine, " \
221+ "or the injected flu vaccine if the nasal spray is not suitable."
222+ )
223+ end
224+ end
225+
226+ context "when consented only to nasal" do
227+ before { consent . update! ( vaccine_methods : %w[ nasal ] ) }
228+
229+ it do
230+ expect ( to_h ) . to include (
231+ consented_vaccine_methods_message :
232+ "You’ve agreed that John can have the nasal spray flu vaccine."
233+ )
234+ end
235+ end
236+ end
202237 end
203238
204239 context "with a consent form" do
You can’t perform that action at this time.
0 commit comments