Skip to content

Commit 1c208eb

Browse files
committed
Fix follow-up requested consent label in activity log
The raw enum value "follow_up_requested" was interpolated directly into the timeline title, producing "Consent follow_up_requested". Use Consent.human_enum_name to resolve the I18n translation instead, which yields the correct human-readable label for all response types ("Consent given", "Consent refused", "Follow-up requested").
1 parent 9b96ea4 commit 1c208eb

2 files changed

Lines changed: 36 additions & 3 deletions

File tree

app/components/app_activity_log_component.rb

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,19 +216,34 @@ def consent_events
216216
consents.flat_map do |consent|
217217
events = []
218218

219-
original_response = consent.withdrawn? ? "given" : consent.response
219+
original_response =
220+
if consent.withdrawn?
221+
"given"
222+
elsif consent.follow_up_requested?
223+
"follow_up_requested"
224+
else
225+
consent.response
226+
end
227+
human_response = Consent.human_enum_name(:response, original_response)
228+
229+
title =
230+
if original_response == "not_provided"
231+
"Consent not provided"
232+
else
233+
human_response
234+
end
220235

221236
events << if (consent_form = consent.consent_form)
222237
{
223-
title: "Consent #{original_response}",
238+
title:,
224239
at: consent_form.recorded_at,
225240
by: consent_form.parent_relationship.label_with_parent,
226241
programmes: [consent.programme]
227242
}
228243
else
229244
{
230245
title:
231-
"Consent #{original_response} by #{consent.name} (#{consent.who_responded.downcase_first})",
246+
"#{title} by #{consent.name} (#{consent.who_responded.downcase_first})",
232247
at: consent.submitted_at,
233248
by: consent.recorded_by,
234249
programmes: [consent.programme]

spec/components/app_activity_log_component_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,24 @@
526526
programme: "HPV"
527527
end
528528

529+
describe "follow-up requested consent" do
530+
before do
531+
create(
532+
:consent,
533+
:follow_up_requested,
534+
programme: programmes.first,
535+
patient:,
536+
parent: mum,
537+
submitted_at: Time.zone.local(2025, 5, 30, 12)
538+
)
539+
end
540+
541+
include_examples "card",
542+
title: "Follow-up requested by Jane Doe (mum)",
543+
date: "30 May 2025 at 12:00pm",
544+
programme: "HPV"
545+
end
546+
529547
describe "gillick assessments" do
530548
let(:programmes) { [Programme.td_ipv] }
531549

0 commit comments

Comments
 (0)