Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the callback_metadata key when we send an email to a user_account #19638

Merged
merged 5 commits into from
Dec 3, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,23 @@ def async_job_with_user_account(user_account, at, template_id)
first_name_from_user_account = get_first_name_from_user_account
return unless first_name_from_user_account

VANotify::UserAccountJob.perform_at(
at,
user_account.id,
template_id,
get_personalization(first_name_from_user_account)
)
if Flipper.enabled?(:simple_forms_notification_callbacks)
VANotify::UserAccountJob.perform_at(
at,
user_account.id,
template_id,
get_personalization(first_name_from_user_account),
Settings.vanotify.services.va_gov.api_key,
{ callback_metadata: { notification_type:, form_number:, statsd_tags: } }
)
else
VANotify::UserAccountJob.perform_at(
at,
user_account.id,
template_id,
get_personalization(first_name_from_user_account)
)
end
end

def send_email_now(template_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
let(:user_account) { create(:user_account) }

it 'sends the email at the specified time' do
time = double
time = Time.zone.now
profile = double(given_names: ['Bob'])
mpi_profile = double(profile:, error: nil)
allow(VANotify::UserAccountJob).to receive(:perform_at)
Expand All @@ -126,8 +126,27 @@

subject.send(at: time)

expect(VANotify::UserAccountJob).to have_received(:perform_at).with(time, user_account.id, anything,
anything)
expect(VANotify::UserAccountJob).to have_received(:perform_at).with(
time,
user_account.id,
"form21_10210_#{notification_type}_email_template_id",
{
'confirmation_number' => 'confirmation_number',
'date_submitted' => time.strftime('%B %d, %Y'),
'first_name' => 'Bob',
'lighthouse_updated_at' => nil
},
'fake_secret',
{
callback_metadata: {
form_number: 'vba_21_10210',
notification_type:,
statsd_tags: {
'function' => 'vba_21_10210 form submission to Lighthouse', 'service' => 'veteran-facing-forms'
}
}
}
)
end
end

Expand Down
Loading