Skip to content

Commit dce9ccd

Browse files
committed
Add GOV.UK Notify personalisation include today's date
In c6f8b2a we updated the `next_session_` personalisation variables to remove today's date from any of these values. This was to fix an issue where today's date was showing in session reminders. However, this broke the consent confirmation emails where we do need to include today's date if consent happens to be given on the day of a session. To resolve this, we introduce a new set of personalisation variables that includes today's date and we will update the consent templates to use these new variables. Jira-Issue: MAV-944
1 parent e557a74 commit dce9ccd

2 files changed

Lines changed: 37 additions & 2 deletions

File tree

app/lib/govuk_notify_personalisation.rb

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ def to_h
3939
day_month_year_of_vaccination:,
4040
full_and_preferred_patient_name:,
4141
location_name:,
42+
next_or_today_session_date:,
43+
next_or_today_session_dates:,
44+
next_or_today_session_dates_or:,
4245
next_session_date:,
4346
next_session_dates:,
4447
next_session_dates_or:,
@@ -136,6 +139,24 @@ def location_name
136139
session.location.name
137140
end
138141

142+
def next_or_today_session_date
143+
session.next_date(include_today: true)&.to_fs(:short_day_of_week)
144+
end
145+
146+
def next_or_today_session_dates
147+
session
148+
.today_or_future_dates
149+
.map { it.to_fs(:short_day_of_week) }
150+
.to_sentence
151+
end
152+
153+
def next_or_today_session_dates_or
154+
session
155+
.today_or_future_dates
156+
.map { it.to_fs(:short_day_of_week) }
157+
.to_sentence(last_word_connector: ", or ", two_words_connector: " or ")
158+
end
159+
139160
def next_session_date
140161
session.next_date(include_today: false)&.to_fs(:short_day_of_week)
141162
end
@@ -147,7 +168,7 @@ def next_session_dates
147168
def next_session_dates_or
148169
session
149170
.future_dates
150-
.map { _1.to_fs(:short_day_of_week) }
171+
.map { it.to_fs(:short_day_of_week) }
151172
.to_sentence(last_word_connector: ", or ", two_words_connector: " or ")
152173
end
153174

spec/lib/govuk_notify_personalisation_spec.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
"http://localhost:4000/consents/#{session.slug}/hpv/start",
5757
full_and_preferred_patient_name: "John Smith",
5858
location_name: "Hogwarts",
59+
next_or_today_session_date: "Thursday 1 January",
60+
next_or_today_session_dates: "Thursday 1 January",
61+
next_or_today_session_dates_or: "Thursday 1 January",
5962
next_session_date: "Thursday 1 January",
6063
next_session_dates: "Thursday 1 January",
6164
next_session_dates_or: "Thursday 1 January",
@@ -86,8 +89,9 @@
8689
)
8790
end
8891

89-
it "doesn't show today's date" do
92+
it "doesn't show today's date in next date" do
9093
expect(to_h).to include(
94+
next_or_today_session_date: Date.current.to_fs(:short_day_of_week),
9195
next_session_date: Date.tomorrow.to_fs(:short_day_of_week)
9296
)
9397
end
@@ -121,6 +125,11 @@
121125
expect(to_h).to match(
122126
hash_including(
123127
consent_deadline: "Wednesday 31 December",
128+
next_or_today_session_date: "Thursday 1 January",
129+
next_or_today_session_dates:
130+
"Thursday 1 January and Friday 2 January",
131+
next_or_today_session_dates_or:
132+
"Thursday 1 January or Friday 2 January",
124133
next_session_date: "Thursday 1 January",
125134
next_session_dates: "Thursday 1 January and Friday 2 January",
126135
next_session_dates_or: "Thursday 1 January or Friday 2 January",
@@ -137,6 +146,11 @@
137146
expect(to_h).to match(
138147
hash_including(
139148
consent_deadline: "Thursday 1 January",
149+
next_or_today_session_date: "Thursday 1 January",
150+
next_or_today_session_dates:
151+
"Thursday 1 January and Friday 2 January",
152+
next_or_today_session_dates_or:
153+
"Thursday 1 January or Friday 2 January",
140154
next_session_date: "Friday 2 January",
141155
subsequent_session_dates_offered_message: ""
142156
)

0 commit comments

Comments
 (0)