File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ def perform(
5454 e . message . include? ( TEAM_ONLY_API_KEY_MESSAGE )
5555 # Prevent retries and job failures.
5656 Sentry . capture_exception ( e )
57+ [ nil , "technical_failure" ]
5758 elsif e . message == INVALID_UK_MOBILE_NUMBER_ERROR
5859 [ nil , "not_uk_mobile_number_failure" ]
5960 else
Original file line number Diff line number Diff line change 127127 end
128128 end
129129
130+ context "when the parent phone number is not part of the allow list" do
131+ before do
132+ allow ( notifications_client ) . to receive ( :send_sms ) . and_raise (
133+ Notifications ::Client ::BadRequestError . new (
134+ OpenStruct . new (
135+ code : 400 ,
136+ body : "Can’t send to this recipient using a team-only API key"
137+ )
138+ )
139+ )
140+ end
141+
142+ it "creates a log entry for the failure" do
143+ expect { perform_now } . to change ( NotifyLogEntry , :count ) . by ( 1 )
144+
145+ notify_log_entry = NotifyLogEntry . last
146+ expect ( notify_log_entry ) . to be_sms
147+ expect ( notify_log_entry ) . to be_technical_failure
148+ expect ( notify_log_entry . delivery_id ) . to be_nil
149+ expect ( notify_log_entry . recipient ) . to eq ( "01234 567890" )
150+ expect ( notify_log_entry . template_id ) . to eq (
151+ GOVUK_NOTIFY_SMS_TEMPLATES [ template_name ]
152+ )
153+ expect ( notify_log_entry . parent ) . to eq ( parent )
154+ expect ( notify_log_entry . patient ) . to eq ( patient )
155+ expect ( notify_log_entry . programme_ids ) . to eq ( programmes . map ( &:id ) )
156+ expect ( notify_log_entry . sent_by ) . to eq ( sent_by )
157+ end
158+ end
159+
130160 context "with a consent form" do
131161 let ( :consent_form ) do
132162 create ( :consent_form , session :, parent_phone : "01234567890" )
You can’t perform that action at this time.
0 commit comments