Skip to content

Commit

Permalink
[Automated] Merged master into target k8s
Browse files Browse the repository at this point in the history
  • Loading branch information
va-vsp-bot authored Mar 6, 2024
2 parents 0fc0662 + 6bd6b2c commit 7d0bc71
Show file tree
Hide file tree
Showing 8 changed files with 349 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,10 @@ features:
actor_type: user
description: Enables form 40-0247 email submission confirmation (VaNotify)
enable_in_development: true
form1990meb_confirmation_email:
actor_type: user
description: Enables form 1990meb email submission confirmation (VaNotify)
enable_in_development: true
form5490_confirmation_email:
actor_type: user
description: Enables form 5490 email submission confirmation (VaNotify)
Expand Down
3 changes: 3 additions & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,9 @@ vanotify:
form0994_extra_action_confirmation_email: form0994_extra_action_confirmation_email_template_id
form1990_confirmation_email: form1990_confirmation_email_template_id
form1990e_confirmation_email: form1990e_confirmation_email_template_id
form1990meb_approved_confirmation_email: form1990meb_approved_confirmation_email_template_id
form1990meb_offramp_confirmation_email: form1990meb_offramp_confirmation_email_template_id
form1990meb_denied_confirmation_email: form1990meb_denied_confirmation_email_template_id
form1995_confirmation_email: form1995_confirmation_email_template_id
form21_0972_confirmation_email: form21_0972_confirmation_email_template_id
form21_10203_confirmation_email: form21_10203_confirmation_email_template_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require 'dgi/enrollment/service'
require 'dgi/contact_info/service'
require 'dgi/exclusion_period/service'
require 'bgs/service'

module MebApi
module V0
Expand Down Expand Up @@ -72,6 +73,8 @@ def submit_claim

clear_saved_form(params[:form_id]) if params[:form_id]

send_confirmation_email if response.ok? && Flipper.enabled?(:form1990meb_confirmation_email)

render json: {
data: {
'status': response.status
Expand Down Expand Up @@ -154,6 +157,18 @@ def enrollment_service
def exclusion_period_service
MebApi::DGI::ExclusionPeriod::Service.new(@current_user)
end

def send_confirmation_email
form_data = params[:education_benefit]
email = form_data.dig('claimant', 'contact_info', 'email_address')
first_name = form_data.dig('claimant', 'first_name')&.upcase.presence

if email.present?
MebApi::V0::Submit1990mebFormConfirmation.perform_async(
@current_user.uuid, email, first_name
)
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# frozen_string_literal: true

require 'sidekiq'
require 'dgi/claimant/service'
require 'dgi/status/service'

module MebApi
module V0
class Submit1990mebFormConfirmation
include Sidekiq::Worker
include SentryLogging
sidekiq_options retry: 14

def perform(user_uuid, email, first_name)
@current_user = User.find(user_uuid)

VANotify::EmailJob.perform_async(
email,
confirmation_email_template_id,
{
'first_name' => first_name,
'date_submitted' => Time.zone.today.strftime('%B %d, %Y')
}
)
end

private

def confirmation_email_template_id
claimant_service = MebApi::DGI::Claimant::Service.new(@current_user)
claimant_response = claimant_service.get_claimant_info
claimant_id = claimant_response['claimant_id']
claim_status_service = MebApi::DGI::Status::Service.new(@current_user)
claim_status_response = claim_status_service.get_claim_status({ latest: false }, claimant_id)
claim_status = claim_status_response['claim_status']

if claim_status.eql? 'ELIGIBLE'
Settings.vanotify.services.va_gov.template_id.form1990meb_approved_confirmation_email
elsif claim_status.eql? 'DENIED'
Settings.vanotify.services.va_gov.template_id.form1990meb_denied_confirmation_email
else
Settings.vanotify.services.va_gov.template_id.form1990meb_offramp_confirmation_email
end
end
end
end
end
112 changes: 112 additions & 0 deletions modules/meb_api/spec/requests/meb_api/v0/education_benefits_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,117 @@
end
end
end

describe 'POST /meb_api/v0/submit_claim' do
let(:claimant_params) do
{
form_id: 1,
education_benefit: {
claimant: {
first_name: 'Herbert',
middle_name: 'Hoover',
last_name: 'Hoover',
date_of_birth: '1980-03-11',
contact_info: {
address_line1: '503 upper park',
address_line2: '',
city: 'falls church',
zipcode: '22046',
email_address: '[email protected]',
address_type: 'DOMESTIC',
mobile_phone_number: '4409938894',
country_code: 'US',
state_code: 'VA'
},
notification_method: 'EMAIL'
}
},
relinquished_benefit: {
eff_relinquish_date: '2021-10-15',
relinquished_benefit: 'Chapter30'
},
additional_considerations: {
active_duty_kicker: 'N/A',
academy_rotc_scholarship: 'YES',
reserve_kicker: 'N/A',
senior_rotc_scholarship: 'YES',
active_duty_dod_repay_loan: 'YES'
},
comments: {
disagree_with_service_period: false
},
direct_deposit: {
account_number: '123123123123',
account_type: 'savings',
routing_number: '123123123'
}
}
end

context 'confirmation email' do
it 'delegates to submit_0994_form_confirmation job' do
VCR.use_cassette('dgi/submit_claim') do
allow(MebApi::V0::Submit1990mebFormConfirmation).to receive(:perform_async)
expect_any_instance_of(BGS::Service).to receive(:get_ch33_dd_eft_info).and_return({})

post '/meb_api/v0/submit_claim', params: claimant_params

expect(MebApi::V0::Submit1990mebFormConfirmation).to have_received(:perform_async)
.with('b2fab2b5-6af0-45e1-a9e2-394347af91ef', '[email protected]', 'HERBERT')
end
end

it 'does not delegate when claim submission fails' do
VCR.use_cassette('dgi/submit_claim_failure') do
allow(MebApi::V0::Submit1990mebFormConfirmation).to receive(:perform_async)
expect_any_instance_of(BGS::Service).to receive(:get_ch33_dd_eft_info).and_return({})

response = post '/meb_api/v0/submit_claim', params: claimant_params

expect(response).to be(503)
expect(MebApi::V0::Submit1990mebFormConfirmation).not_to have_received(:perform_async)
end
end

it 'does not delegate when feature is disabled' do
VCR.use_cassette('dgi/submit_claim') do
allow(MebApi::V0::Submit1990mebFormConfirmation).to receive(:perform_async)
expect_any_instance_of(BGS::Service).to receive(:get_ch33_dd_eft_info).and_return({})
Flipper.disable(:form1990meb_confirmation_email)

post '/meb_api/v0/submit_claim', params: claimant_params

expect(MebApi::V0::Submit1990mebFormConfirmation).not_to have_received(:perform_async)

Flipper.enable(:form1990meb_confirmation_email)
end
end

it 'does not delegate when email is missing' do
VCR.use_cassette('dgi/submit_claim') do
claimant_params_without_email = {
**claimant_params,
education_benefit: {
**claimant_params[:education_benefit],
claimant: {
**claimant_params[:education_benefit][:claimant],
contact_info: {
**claimant_params[:education_benefit][:claimant][:contact_info],
email_address: nil
}
}
}
}

allow(MebApi::V0::Submit1990mebFormConfirmation).to receive(:perform_async)
expect_any_instance_of(BGS::Service).to receive(:get_ch33_dd_eft_info).and_return({})

post '/meb_api/v0/submit_claim', params: claimant_params_without_email

expect(MebApi::V0::Submit1990mebFormConfirmation).not_to have_received(:perform_async)
end
end
end
end
end
end
67 changes: 67 additions & 0 deletions spec/support/vcr_cassettes/dgi/get_claim_status_denied.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions spec/support/vcr_cassettes/dgi/get_claim_status_in_progress.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions spec/support/vcr_cassettes/dgi/submit_claim_failure.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7d0bc71

Please sign in to comment.