Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/jobs/in_person/send_proofing_notification_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ def perform(enrollment_id)

private

def formatter
Idv::InPerson::EnrollmentCodeFormatter
end

def log_job_completed(enrollment:)
analytics(user: enrollment.user).
idv_in_person_send_proofing_notification_job_completed(
Expand Down Expand Up @@ -81,6 +85,7 @@ def notification_message(enrollment:)
app_name: APP_NAME,
proof_date: proof_date,
contact_number: IdentityConfig.store.idv_contact_phone_number,
reference_string: formatter.format(enrollment.enrollment_code),
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion config/locales/telephony/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ en:
code expires in %{expiration} minutes.
confirmation_ipp_enrollment_result:
sms: |-
%{app_name}: You visited the Post Office on %{proof_date}. Check email for your result. Not you? Report this right away: %{contact_number}
%{app_name}: You visited the Post Office on %{proof_date}. Check email for your result. Not you? Report this right away: %{contact_number}. Ref: %{reference_string}
confirmation_otp:
sms: |-
%{app_name}: Your one-time code is %{code}. It expires in %{expiration} minutes. Don't share this code with anyone.
Expand Down
2 changes: 1 addition & 1 deletion config/locales/telephony/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ es:
Este código expira en %{expiration} minutos.
confirmation_ipp_enrollment_result:
sms: |-
%{app_name}: Visitó la oficina de correos el %{proof_date}. Revise su correo electrónico para ver su resultado. ¿No fue usted? Informe ahora mismo: %{contact_number}
%{app_name}: Visitó la oficina de correos el %{proof_date}. Revise su correo electrónico. ¿No fue usted? Llame: %{contact_number}. Ref: %{reference_string}
confirmation_otp:
sms: |-
%{app_name}: La contraseña es %{code}. Esta contraseña puede usarse una vez y se vence en %{expiration} minutos. No la comparta con nadie.
Expand Down
2 changes: 1 addition & 1 deletion config/locales/telephony/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fr:
minutes.
confirmation_ipp_enrollment_result:
sms: |-
%{app_name}: Vous avez visité le bureau de poste le %{proof_date}. Vérifiez votre e-mail pour votre résultat. Ce n'est pas vous? Signalez-le immédiatement: %{contact_number}
%{app_name}: Vous avez visité le bureau de poste le %{proof_date}. Vérifiez votre e-mail. Ce n'est pas vous? Signalez-le: %{contact_number}. Réf: %{reference_string}
confirmation_otp:
sms: |-
%{app_name}: Votre code à usage unique est %{code}. Il est valable pendant %{expiration} minutes. Vous ne devez pas partager ce code avec personne.
Expand Down
87 changes: 68 additions & 19 deletions spec/jobs/in_person/send_proofing_notification_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
:passed,
:with_notification_phone_configuration,
proofed_at: Time.zone.now - 3.days,
enrollment_code: '1234567890123456',
)
end
let(:failing_enrollment) do
Expand Down Expand Up @@ -145,28 +146,76 @@
end
end

it 'sends a message that respects the user email locale preference' do
allow(Telephony).to receive(:send_notification).and_return(sms_success_response)
context 'sends a message that respects the user email locale preference' do
let(:proofed_date) { Time.zone.now.strftime('%m/%d/%Y') }
let(:phone_number) { passed_enrollment.notification_phone_configuration.formatted_phone }
let(:contact_number) { '(844) 555-5555' }
let(:reference_string) { passed_enrollment.enrollment_code }
let(:formatted_string) { '1234-5678-9012-3456' }

passed_enrollment.user.update!(email_language: 'fr')
passed_enrollment.update!(proofed_at: Time.zone.now)
proofed_date = Time.zone.now.strftime('%m/%d/%Y')
phone_number = passed_enrollment.notification_phone_configuration.formatted_phone
contact_number = '(844) 555-5555'
before do
allow(Telephony).to receive(:send_notification).and_return(sms_success_response)
allow(Idv::InPerson::EnrollmentCodeFormatter).to receive(:format).
and_return(formatted_string)
end

expect(Telephony).
to(
receive(:send_notification).
with(
to: phone_number,
message: "Login.gov: Vous avez visité le bureau de poste le #{proofed_date}." \
" Vérifiez votre e-mail pour votre résultat. Ce n'est pas vous?" \
" Signalez-le immédiatement: #{contact_number}",
country_code: Phonelib.parse(phone_number).country,
),
)
it 'handles English language preference' do
passed_enrollment.user.update!(email_language: 'en')
passed_enrollment.update!(proofed_at: Time.zone.now)

job.perform(passed_enrollment.id)
expect(Telephony).
to(
receive(:send_notification).
with(
to: phone_number,
message: "Login.gov: You visited the Post Office on #{proofed_date}." \
" Check email for your result." \
" Not you? Report this right away: #{contact_number}." \
" Ref: #{formatted_string}",
country_code: Phonelib.parse(phone_number).country,
),
)

job.perform(passed_enrollment.id)
end

it 'handles French language preference' do
passed_enrollment.user.update!(email_language: 'fr')
passed_enrollment.update!(proofed_at: Time.zone.now)

expect(Telephony).
to(
receive(:send_notification).
with(
to: phone_number,
message: "Login.gov: Vous avez visité le bureau de poste le #{proofed_date}." \
" Vérifiez votre e-mail. Ce n'est pas vous? Signalez-le: #{contact_number}." \
" Réf: #{formatted_string}",
country_code: Phonelib.parse(phone_number).country,
),
)

job.perform(passed_enrollment.id)
end

it 'handles Spanish language preference' do
passed_enrollment.user.update!(email_language: 'es')
passed_enrollment.update!(proofed_at: Time.zone.now)

expect(Telephony).
to(
receive(:send_notification).
with(
to: phone_number,
message: "Login.gov: Visitó la oficina de correos el #{proofed_date}." \
" Revise su correo electrónico. ¿No fue usted? Llame: #{contact_number}." \
" Ref: #{formatted_string}",
country_code: Phonelib.parse(phone_number).country,
),
)

job.perform(passed_enrollment.id)
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

end
end

Expand Down