diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index bfcf84627ab..b52b430ccdf 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -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 @@ -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 @@ -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 diff --git a/app/controllers/v0/education_career_counseling_claims_controller.rb b/app/controllers/v0/education_career_counseling_claims_controller.rb index 7f2e36b7eb3..a79a27a5b74 100644 --- a/app/controllers/v0/education_career_counseling_claims_controller.rb +++ b/app/controllers/v0/education_career_counseling_claims_controller.rb @@ -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) diff --git a/app/models/saved_claim/education_career_counseling_claim.rb b/app/models/saved_claim/education_career_counseling_claim.rb index 4ca69e12edf..0c3a548eae8 100644 --- a/app/models/saved_claim/education_career_counseling_claim.rb +++ b/app/models/saved_claim/education_career_counseling_claim.rb @@ -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? @@ -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 diff --git a/app/sidekiq/central_mail/submit_career_counseling_job.rb b/app/sidekiq/lighthouse/submit_career_counseling_job.rb similarity index 63% rename from app/sidekiq/central_mail/submit_career_counseling_job.rb rename to app/sidekiq/lighthouse/submit_career_counseling_job.rb index ecb0bda9090..9ee4cbac7b6 100644 --- a/app/sidekiq/central_mail/submit_career_counseling_job.rb +++ b/app/sidekiq/lighthouse/submit_career_counseling_job.rb @@ -1,18 +1,17 @@ # 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 @@ -20,14 +19,13 @@ class SubmitCareerCounselingJob 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) @@ -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 diff --git a/config/features.yml b/config/features.yml index ae830b1ec0e..7011dffe9f1 100644 --- a/config/features.yml +++ b/config/features.yml @@ -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 diff --git a/spec/controllers/v0/education_career_counseling_claims_controller_spec.rb b/spec/controllers/v0/education_career_counseling_claims_controller_spec.rb index 9481d2dceaa..d7d5deeb77b 100644 --- a/spec/controllers/v0/education_career_counseling_claims_controller_spec.rb +++ b/spec/controllers/v0/education_career_counseling_claims_controller_spec.rb @@ -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 diff --git a/spec/models/saved_claim/education_career_counseling_claim_spec.rb b/spec/models/saved_claim/education_career_counseling_claim_spec.rb index 0c3c80b5d13..57a684aa202 100644 --- a/spec/models/saved_claim/education_career_counseling_claim_spec.rb +++ b/spec/models/saved_claim/education_career_counseling_claim_spec.rb @@ -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 diff --git a/spec/sidekiq/central_mail/submit_career_counseling_job_spec.rb b/spec/sidekiq/lighthouse/submit_career_counseling_job_spec.rb similarity index 80% rename from spec/sidekiq/central_mail/submit_career_counseling_job_spec.rb rename to spec/sidekiq/lighthouse/submit_career_counseling_job_spec.rb index 980c183089d..d4dccbd2a6a 100644 --- a/spec/sidekiq/central_mail/submit_career_counseling_job_spec.rb +++ b/spec/sidekiq/lighthouse/submit_career_counseling_job_spec.rb @@ -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) @@ -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