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
25 changes: 18 additions & 7 deletions app/models/saved_claim/education_benefits.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,24 @@ def send_education_benefits_confirmation_email(email, parsed_form_data, template
callback_options = build_callback_options(form_number)

begin
VANotify::EmailJob.perform_async(
email,
template_id,
all_params,
Settings.vanotify.services.va_gov.api_key,
callback_options
)
if Flipper.enabled?(:va_notify_v2_edu_benefits_confirmation_email)
api_key_path = 'Settings.vanotify.services.va_gov.api_key'
VANotify::V2::QueueEmailJob.enqueue(
email,
template_id,
all_params,
api_key_path,
callback_options
)
else
VANotify::EmailJob.perform_async(
email,
template_id,
all_params,
Settings.vanotify.services.va_gov.api_key,
callback_options
)
end
rescue => e
method_name = 'send_confirmation_email'
Rails.logger.error "#{self.class.name}##{method_name}: Failed to queue confirmation email: #{e.message}"
Expand Down
5 changes: 5 additions & 0 deletions config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2978,6 +2978,11 @@ features:
description: >-
If enabled, SubmitCareerCounselingJob will use VANotify::V2::QueueEmailJob instead of
VANotify::EmailJob for confirmation emails
va_notify_v2_edu_benefits_confirmation_email:
actor_type: user
description: >-
If enabled, education benefits confirmation emails will use VANotify::V2::QueueEmailJob
instead of VANotify::EmailJob
va_notify_v2_preneeds_burial_form_job:
actor_type: user
description: >-
Expand Down
6 changes: 6 additions & 0 deletions spec/models/saved_claim/education_benefits/va10203_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@

it 'sends the confirmation email with the form email with the callback paarameters' do
allow(Flipper).to receive(:enabled?).with(:form21_10203_confirmation_email).and_return(true)
allow(Flipper).to receive(:enabled?).with(:va_notify_v2_edu_benefits_confirmation_email)
.and_return(false)
allow(VANotify::EmailJob).to receive(:perform_async)

subject = instance
Expand Down Expand Up @@ -354,6 +356,7 @@

it 'sends the confirmation email with the form email with the callback paarameters' do
allow(Flipper).to receive(:enabled?).with(:form21_10203_confirmation_email).and_return(true)
allow(Flipper).to receive(:enabled?).with(:va_notify_v2_edu_benefits_confirmation_email).and_return(false)
allow(VANotify::EmailJob).to receive(:perform_async)

subject = instance
Expand Down Expand Up @@ -530,6 +533,8 @@

it 'sends the confirmation email with the form email with the callback paarameters' do
allow(Flipper).to receive(:enabled?).with(:form21_10203_confirmation_email).and_return(true)
allow(Flipper).to receive(:enabled?).with(:va_notify_v2_edu_benefits_confirmation_email)
.and_return(false)
allow(VANotify::EmailJob).to receive(:perform_async)

subject = instance
Expand Down Expand Up @@ -747,6 +752,7 @@

it 'sends the confirmation email with the form email with the callback paarameters' do
allow(Flipper).to receive(:enabled?).with(:form21_10203_confirmation_email).and_return(true)
allow(Flipper).to receive(:enabled?).with(:va_notify_v2_edu_benefits_confirmation_email).and_return(false)
allow(VANotify::EmailJob).to receive(:perform_async)

subject = instance
Expand Down
78 changes: 61 additions & 17 deletions spec/models/saved_claim/education_benefits/va10297_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,69 @@
}
end

before { Flipper.enable(:form10297_confirmation_email_with_silent_failure_processing) }
before do
allow(Flipper)
.to receive(:enabled?)
.with(:form10297_confirmation_email_with_silent_failure_processing)
.and_return(true)
end

it 'sends an email with the silent failure callback parameters' do
subject = create(:va10297_simple_form)
confirmation_number = subject.education_benefits_claim.confirmation_number
context 'when the va_notify_v2_edu_benefits_confirmation_email feature flag is disabled' do
before do
allow(Flipper)
.to receive(:enabled?)
.with(:va_notify_v2_edu_benefits_confirmation_email)
.and_return(false)
end

it 'sends an email via V1 EmailJob with the silent failure callback parameters' do
subject = create(:va10297_simple_form)
confirmation_number = subject.education_benefits_claim.confirmation_number

subject.after_submit(user)
expect(VANotify::EmailJob).to have_received(:perform_async).with(
'test@test.com',
'form10297_confirmation_email_template_id',
{
'first_name' => 'TEST',
'date_submitted' => Time.zone.today.strftime('%B %d, %Y'),
'confirmation_number' => confirmation_number,
'regional_office_address' => "P.O. Box 4616\nBuffalo, NY 14240-4616"
},
Settings.vanotify.services.va_gov.api_key,
callback_options
)
end
end

subject.after_submit(user)
expect(VANotify::EmailJob).to have_received(:perform_async).with(
'test@test.com',
'form10297_confirmation_email_template_id',
{
'first_name' => 'TEST',
'date_submitted' => Time.zone.today.strftime('%B %d, %Y'),
'confirmation_number' => confirmation_number,
'regional_office_address' => "P.O. Box 4616\nBuffalo, NY 14240-4616"
},
Settings.vanotify.services.va_gov.api_key,
callback_options
)
context 'when the va_notify_v2_edu_benefits_confirmation_email feature flag is enabled' do
before do
allow(Flipper)
.to receive(:enabled?)
.with(:va_notify_v2_edu_benefits_confirmation_email)
.and_return(true)
allow(VANotify::V2::QueueEmailJob).to receive(:enqueue)
end

it 'sends an email via V2 QueueEmailJob with the silent failure callback parameters' do
subject = create(:va10297_simple_form)
confirmation_number = subject.education_benefits_claim.confirmation_number

subject.after_submit(user)
expect(VANotify::V2::QueueEmailJob).to have_received(:enqueue).with(
'test@test.com',
'form10297_confirmation_email_template_id',
{
'first_name' => 'TEST',
'date_submitted' => Time.zone.today.strftime('%B %d, %Y'),
'confirmation_number' => confirmation_number,
'regional_office_address' => "P.O. Box 4616\nBuffalo, NY 14240-4616"
},
'Settings.vanotify.services.va_gov.api_key',
callback_options
)
expect(VANotify::EmailJob).not_to have_received(:perform_async)
end
end
end
end
Expand Down
Loading