From a15662c014201d60bbda4d2202269dba4e5206a7 Mon Sep 17 00:00:00 2001 From: Dewayne VanHoozer Date: Thu, 25 Apr 2024 14:41:24 -0500 Subject: [PATCH] old spec has been updated to use flipper to isolate tests to each possible submission route; however, found problem in subject code which needs a little intent research. --- .../central_mail/submit_form4142_job.rb | 3 +- .../central_mail/submit_form4142_job_spec.rb | 35 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/app/sidekiq/central_mail/submit_form4142_job.rb b/app/sidekiq/central_mail/submit_form4142_job.rb index f807b7527f1..2fe74fdf8c0 100644 --- a/app/sidekiq/central_mail/submit_form4142_job.rb +++ b/app/sidekiq/central_mail/submit_form4142_job.rb @@ -27,6 +27,7 @@ class SubmitForm4142Job < EVSS::DisabilityCompensationForm::Job LIGHTHOUSE_STATSD_KEY_PREFIX = 'worker.lighthouse.submit_form4142' class BenefitsIntake4142Error < StandardError; end + class CentralMailResponseError < StandardError; end sidekiq_retries_exhausted do |msg, _ex| job_id = msg['jid'] @@ -178,7 +179,7 @@ def handle_service_exception(response) def create_service_error(key, source, response, _error = nil) response_values = response_values(key, source, response.status, response.body) - CentralMailResponseError.new(key, response_values, nil, nil) + CentralMailResponseError # TDV .new(key, response_values, nil, nil) end def response_values(key, source, status, detail) diff --git a/spec/sidekiq/central_mail/submit_form4142_job_spec.rb b/spec/sidekiq/central_mail/submit_form4142_job_spec.rb index 3ca0cdebf17..9e52a9eb254 100644 --- a/spec/sidekiq/central_mail/submit_form4142_job_spec.rb +++ b/spec/sidekiq/central_mail/submit_form4142_job_spec.rb @@ -1,3 +1,5 @@ +# spec/sidekiq/central_mail/submit_form4142_job_spec.rb +# # frozen_string_literal: true require 'rails_helper' @@ -8,6 +10,15 @@ before do Sidekiq::Job.clear_all + # Make Job use old CentralMail route for all tests + Flipper.disable(:disability_compensation_form_4142) + end + +describe "Test old CentralMail route" do + + before do + # Make Job use old CentralMail route for all tests + Flipper.disable(:disability_compensation_form_4142) end let(:user) { FactoryBot.create(:user, :loa3) } @@ -118,6 +129,12 @@ it 'raises a central mail response error' do VCR.use_cassette('central_mail/submit_4142_400') do subject.perform_async(submission.id) + # begin # TDV + # result = described_class.drain + # rescue => e + # puts e.callback + # raise e + # end expect { described_class.drain }.to raise_error(CentralMail::SubmitForm4142Job::CentralMailResponseError) end end @@ -131,7 +148,7 @@ it 'updates a StatsD counter and updates the status on an exhaustion event' do subject.within_sidekiq_retries_exhausted_block({ 'jid' => form526_job_status.job_id }) do - expect(StatsD).to receive(:increment).with("#{subject::STATSD_KEY_PREFIX}.exhausted") + expect(StatsD).to receive(:increment).with("#{subject::CENTRAL_MAIL_STATSD_KEY_PREFIX}.exhausted") expect(Rails).to receive(:logger).and_call_original end form526_job_status.reload @@ -139,4 +156,20 @@ end end end + + +# End of the Old CentralMail Route tests +end + +describe "Test new Lighthouse route" do + + before do + # Make Job use new Lighthouse route for all tests + Flipper.enable(:disability_compensation_form_4142) + end + +# End of the new Lighthouse Route tests +end + +# End of the overall Spec end