-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Automated] Merged master into target k8s
- Loading branch information
Showing
8 changed files
with
349 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
modules/meb_api/app/workers/meb_api/v0/submit_1990meb_form_confirmation.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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
67
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.
Oops, something went wrong.
67 changes: 67 additions & 0 deletions
67
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.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.