Skip to content

Commit

Permalink
824 create 22 1995 confirmation email trigger (#12514)
Browse files Browse the repository at this point in the history
  • Loading branch information
nhill360 authored Jun 1, 2023
1 parent 7be501b commit 5d02f24
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
42 changes: 42 additions & 0 deletions app/models/saved_claim/education_benefits/va_1995.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,46 @@

class SavedClaim::EducationBenefits::VA1995 < SavedClaim::EducationBenefits
add_form_and_validation('22-1995')

# Pulled from https://github.com/department-of-veterans-affairs/vets-website/src/applications/edu-benefits/utils/helpers.jsx#L100
# & https://github.com/department-of-veterans-affairs/vets-website/blob/main/src/applications/edu-benefits/utils/labels.jsx
BENEFIT_TITLE_FOR_1995 = {
'chapter30' => 'Montgomery GI Bill (MGIB, Chapter 30)',
'chapter33Post911' => 'Post-9/11 GI Bill (Chapter 33)',
'chapter33FryScholarship' => 'Fry Scholarship (Chapter 33)',
'chapter1606' => 'Montgomery GI Bill Selected Reserve (MGIB-SR, Chapter 1606)',
'chapter32' => 'Post-Vietnam Era Veterans’ Educational Assistance Program (VEAP, chapter 32)',
'transferOfEntitlement' => 'Transfer of Entitlement Program (TOE)'
}.freeze

def after_submit(_user)
return unless Flipper.enabled?(:form1995_confirmation_email)

parsed_form_data ||= JSON.parse(form)
email = parsed_form_data['email']
return if email.blank?

send_confirmation_email(parsed_form_data, email)
end

private

def send_confirmation_email(parsed_form_data, email)
VANotify::EmailJob.perform_async(
email,
Settings.vanotify.services.va_gov.template_id.form1995_confirmation_email,
{
'first_name' => parsed_form.dig('veteranFullName', 'first')&.upcase.presence,
'benefit' => benefit_claimed(parsed_form_data),
'date_submitted' => Time.zone.today.strftime('%B %d, %Y'),
'confirmation_number' => education_benefits_claim.confirmation_number,
'regional_office_address' => regional_office_address
}
)
end

def benefit_claimed(parsed_form_data)
benefit ||= parsed_form_data['benefit']
BENEFIT_TITLE_FOR_1995[benefit]
end
end
4 changes: 4 additions & 0 deletions config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,10 @@ features:
actor_type: user
description: Enables form 1990 email submission confirmation (VaNotify)
enable_in_development: true
form1995_confirmation_email:
actor_type: user
description: Enables form 1995 email submission confirmation (VaNotify)
enable_in_development: true
form1990e_confirmation_email:
actor_type: user
description: Enables form 1990e email submission confirmation (VaNotify)
Expand Down
1 change: 1 addition & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,7 @@ vanotify:
contact_info_change: fake_template_id
form1990_confirmation_email: form1990_confirmation_email_template_id
form1990e_confirmation_email: form1990e_confirmation_email_template_id
form1995_confirmation_email: form1995_confirmation_email_template_id
form526_confirmation_email: fake_template_id
form526_submission_failed_email: fake_template_id
form5490_confirmation_email: form5490_confirmation_email_template_id
Expand Down
27 changes: 27 additions & 0 deletions spec/models/saved_claim/education_benefits/va1995_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,31 @@
it_behaves_like 'saved_claim'

validate_inclusion(:form_id, '22-1995')

describe '#after_submit' do
let(:user) { create(:user) }

describe 'sends confirmation email for the 1995' do
it 'successfully submits' do
allow(VANotify::EmailJob).to receive(:perform_async)

subject = create(:va1995_full_form)
confirmation_number = subject.education_benefits_claim.confirmation_number

subject.after_submit(user)

expect(VANotify::EmailJob).to have_received(:perform_async).with(
'[email protected]',
'form1995_confirmation_email_template_id',
{
'first_name' => 'FIRST',
'benefit' => 'Transfer of Entitlement Program (TOE)',
'date_submitted' => Time.zone.today.strftime('%B %d, %Y'),
'confirmation_number' => confirmation_number,
'regional_office_address' => "P.O. Box 4616\nBuffalo, NY 14240-4616"
}
)
end
end
end
end

0 comments on commit 5d02f24

Please sign in to comment.