Skip to content

Commit

Permalink
Ndbex/69209 ch36 to benefits intake (#16351)
Browse files Browse the repository at this point in the history
* level set

* level set with master

* removing yarn.lock

* placeholder

* Renaming and restructuring ecc job and dependencies

* Added new feature flag name

* SMall change to ecc claim model spec

* Tests may not be tested properly

* Fixed failing tests due to improperly calling perform_async when it should just be perform

* ECC model claim file was not listed in codeowners file

* Another codeowners change to have backend-review-group in it

* Test and call update for ECC

* CODEOWNERS change and removing sentry calls in the job

* Rubocop

* log message tweaks
  • Loading branch information
micahaspyr authored Apr 16, 2024
1 parent 39ccf4e commit 839a958
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 25 deletions.
3 changes: 2 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ app/models/session.rb @department-of-veterans-affairs/octo-identity
app/models/saved_claim/burial.rb @department-of-veterans-affairs/benefits-non-disability @department-of-veterans-affairs/pensions @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/models/saved_claim/pension.rb @department-of-veterans-affairs/pensions @department-of-veterans-affairs/backend-review-group
app/models/saved_claim/veteran_readiness_employment_claim.rb @department-of-veterans-affairs/benefits-non-disability @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/models/saved_claim/education_career_counseling_claim.rb @department-of-veterans-affairs/benefits-non-disability @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/models/sign_in @department-of-veterans-affairs/octo-identity
app/models/single_logout_request.rb @department-of-veterans-affairs/octo-identity
app/models/spool_file_event.rb @department-of-veterans-affairs/my-education-benefits @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down Expand Up @@ -582,7 +583,6 @@ app/sidekiq/account_login_statistics_job.rb @department-of-veterans-affairs/octo
app/sidekiq/benefits_intake_status_job.rb @department-of-veterans-affairs/platform-va-product-forms @department-of-veterans-affairs/Disability-Experience @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/sidekiq/bgs @department-of-veterans-affairs/benefits-dependents-management @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/sidekiq/central_mail/delete_old_claims.rb @department-of-veterans-affairs/mbs-core-team @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/sidekiq/central_mail/submit_career_counseling_job.rb @department-of-veterans-affairs/my-education-benefits @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/sidekiq/central_mail/submit_form4142_job.rb @department-of-veterans-affairs/Disability-Experience @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/sidekiq/central_mail/submit_saved_claim_job.rb @department-of-veterans-affairs/backend-review-group
app/sidekiq/central_mail/submit_central_form686c_job.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group @department-of-veterans-affairs/benefits-dependents-management
Expand Down Expand Up @@ -618,6 +618,7 @@ app/sidekiq/income_limits @department-of-veterans-affairs/vfs-public-websites-fr
app/sidekiq/in_progress_form_cleaner.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/sidekiq/kms_key_rotation @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/sidekiq/lighthouse @department-of-veterans-affairs/backend-review-group
app/sidekiq/lighthouse/submit_career_counseling_job.rb @department-of-veterans-affairs/my-education-benefits @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/sidekiq/mhv @department-of-veterans-affairs/vfs-mhv-medical-records @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/sidekiq/pager_duty @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/sidekiq/preneeds @department-of-veterans-affairs/mbs-core-team @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def create
raise Common::Exceptions::ValidationErrors, claim
end

CentralMail::SubmitCareerCounselingJob.perform_async(claim.id, @current_user&.uuid)
Lighthouse::SubmitCareerCounselingJob.perform_async(claim.id, @current_user&.uuid)

Rails.logger.info "ClaimID=#{claim.confirmation_number} Form=#{claim.class::FORM}"
clear_saved_form(claim.form_id)
Expand Down
8 changes: 6 additions & 2 deletions app/models/saved_claim/education_career_counseling_claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def regional_office
[]
end

def send_to_central_mail!
def send_to_benefits_intake!
form_copy = parsed_form

if form_copy['veteranSocialSecurityNumber'].blank?
Expand All @@ -27,7 +27,11 @@ def process_attachments!
files = PersistentAttachment.where(guid: refs.map(&:confirmationCode))
files.find_each { |f| f.update(saved_claim_id: id) }

CentralMail::SubmitSavedClaimJob.new.perform(id)
if Flipper.enabled?(:ecc_benefits_intake_submission)
Lighthouse::SubmitBenefitsIntakeClaim.new.perform(id)
else
CentralMail::SubmitSavedClaimJob.new.perform(id)
end
end

def business_line
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
# frozen_string_literal: true

module CentralMail
module Lighthouse
class SubmitCareerCounselingJob
include Sidekiq::Job
include SentryLogging
RETRY = 14

STATSD_KEY_PREFIX = 'worker.central_mail.submit_career_counseling_job'
STATSD_KEY_PREFIX = 'worker.lighthouse.submit_career_counseling_job'

sidekiq_options retry: RETRY

sidekiq_retries_exhausted do |msg, _ex|
Rails.logger.error(
"Failed all retries on CentralMail::SubmitCareerCounselingJob, last error: #{msg['error_message']}"
"Failed all retries on SubmitCareerCounselingJob, last error: #{msg['error_message']}"
)
StatsD.increment("#{STATSD_KEY_PREFIX}.exhausted")
end

def perform(claim_id, user_uuid = nil)
begin
@claim = SavedClaim.find(claim_id)
@claim.send_to_central_mail!
@claim.send_to_benefits_intake!
send_confirmation_email(user_uuid)
rescue => e
log_message_to_sentry('CentralMail::SubmitCareerCounselingJob failed, retrying...', :warn,
generate_sentry_details(e))
Rails.logger.warn('SubmitCareerCounselingJob failed, retrying...', { error_message: e.message })
raise
end
log_message_to_sentry('Successfully submitted form 25-8832', :info, { uuid: user_uuid })
Rails.logger.info('Successfully submitted form 25-8832', { uuid: user_uuid })
end

def send_confirmation_email(user_uuid)
Expand All @@ -38,8 +36,7 @@ def send_confirmation_email(user_uuid)
end

if email.blank?
log_message_to_sentry('No email to send confirmation regarding submitted form 25-8832', :info,
{ uuid: user_uuid })
Rails.logger.info("No email to send confirmation regarding submitted form 25-8832 for uuid: #{user_uuid}")
return
end

Expand Down
3 changes: 3 additions & 0 deletions config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,9 @@ features:
central_mail_benefits_intake_submission:
actor_type: user
description: Enable central mail claims submission uses Benefits Intake API
ecc_benefits_intake_submission:
actor_type: user
description: Enable education and career counseling claim submissions to use Benefits Intake API
virtual_agent_enable_param_error_detection:
actor_type: user
description: If enabled, Allows for the detection of errors in the chatbot params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
end

it 'calls successfully submits the career counseling job' do
expect(CentralMail::SubmitCareerCounselingJob).to receive(:perform_async)
expect(Lighthouse::SubmitCareerCounselingJob).to receive(:perform_async)

post(:create, params: form_params)
end
Expand Down
30 changes: 26 additions & 4 deletions spec/models/saved_claim/education_career_counseling_claim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,40 @@
end
end

describe '#send_to_central_mail!' do
it 'formats data before sending to central mail' do
describe '#send_to_benefits_intake!' do
it 'formats data before sending to central mail or benefits intake' do
allow(claim).to receive(:process_attachments!)

expect(claim).to receive(:update).with(form: a_string_including('"veteranSocialSecurityNumber":"333224444"'))

claim.send_to_central_mail!
claim.send_to_benefits_intake!
end

it 'calls process_attachments! method' do
expect(claim).to receive(:process_attachments!)
claim.send_to_central_mail!
claim.send_to_benefits_intake!
end

context 'Feature ecc_benefits_intake_submission is true' do
before do
Flipper.enable(:ecc_benefits_intake_submission)
end

it 'calls Lighthouse::SubmitBenefitsIntakeClaim job' do
expect_any_instance_of(Lighthouse::SubmitBenefitsIntakeClaim).to receive(:perform).with(claim.id)
claim.send_to_benefits_intake!
end
end

context 'Feature ecc_benefits_intake_submission is false' do
before do
Flipper.disable(:ecc_benefits_intake_submission)
end

it 'calls CentralMail::SubmitSavedClaimJob job' do
expect_any_instance_of(CentralMail::SubmitSavedClaimJob).to receive(:perform).with(claim.id)
claim.send_to_benefits_intake!
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

require 'rails_helper'

RSpec.describe CentralMail::SubmitCareerCounselingJob do
RSpec.describe Lighthouse::SubmitCareerCounselingJob do
let(:claim) { create(:education_career_counseling_claim) }
let(:job) { described_class.new }

describe '#perform' do
it 'sends to central mail' do
expect_any_instance_of(SavedClaim::EducationCareerCounselingClaim).to receive(:send_to_central_mail!)
expect_any_instance_of(SavedClaim::EducationCareerCounselingClaim).to receive(:send_to_benefits_intake!)

job.perform(claim.id)
end

it 'sends confirmation email' do
allow_any_instance_of(SavedClaim::EducationCareerCounselingClaim).to receive(:send_to_central_mail!)
allow_any_instance_of(SavedClaim::EducationCareerCounselingClaim).to receive(:send_to_benefits_intake!)

expect(job).to receive(:send_confirmation_email).with(nil)

Expand Down Expand Up @@ -60,11 +60,11 @@

describe 'sidekiq_retries_exhausted block' do
it 'logs error when retries are exhausted' do
CentralMail::SubmitCareerCounselingJob.within_sidekiq_retries_exhausted_block do
Lighthouse::SubmitCareerCounselingJob.within_sidekiq_retries_exhausted_block do
expect(Rails.logger).to receive(:error).exactly(:once).with(
'Failed all retries on CentralMail::SubmitCareerCounselingJob, last error: An error occured'
'Failed all retries on SubmitCareerCounselingJob, last error: An error occured'
)
expect(StatsD).to receive(:increment).with('worker.central_mail.submit_career_counseling_job.exhausted')
expect(StatsD).to receive(:increment).with('worker.lighthouse.submit_career_counseling_job.exhausted')
end
end
end
Expand Down

0 comments on commit 839a958

Please sign in to comment.