Skip to content

Commit

Permalink
old spec has been updated to use flipper to isolate tests to each pos…
Browse files Browse the repository at this point in the history
…sible submission route; however, found problem in subject code which needs a little intent research.
  • Loading branch information
SloopKoning committed Apr 25, 2024
1 parent a975810 commit a15662c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/sidekiq/central_mail/submit_form4142_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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)

Check failure on line 181 in app/sidekiq/central_mail/submit_form4142_job.rb

View workflow job for this annotation

GitHub Actions / Linting and Security

Lint/UselessAssignment: Useless assignment to variable - `response_values`. Did you mean `response`?
CentralMailResponseError.new(key, response_values, nil, nil)
CentralMailResponseError # TDV .new(key, response_values, nil, nil)
end

def response_values(key, source, status, detail)
Expand Down
35 changes: 34 additions & 1 deletion spec/sidekiq/central_mail/submit_form4142_job_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# spec/sidekiq/central_mail/submit_form4142_job_spec.rb
#
# frozen_string_literal: true

require 'rails_helper'
Expand All @@ -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)

Check failure on line 14 in spec/sidekiq/central_mail/submit_form4142_job_spec.rb

View workflow job for this annotation

GitHub Actions / Linting and Security

Naming/VariableNumber: Use normalcase for symbol numbers.
end

describe "Test old CentralMail route" do

Check failure on line 17 in spec/sidekiq/central_mail/submit_form4142_job_spec.rb

View workflow job for this annotation

GitHub Actions / Linting and Security

Layout/IndentationConsistency: Inconsistent indentation detected.

Check failure on line 17 in spec/sidekiq/central_mail/submit_form4142_job_spec.rb

View workflow job for this annotation

GitHub Actions / Linting and Security

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

before do
# Make Job use old CentralMail route for all tests
Flipper.disable(:disability_compensation_form_4142)
end

let(:user) { FactoryBot.create(:user, :loa3) }
Expand Down Expand Up @@ -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
Expand All @@ -131,12 +148,28 @@

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
expect(form526_job_status.status).to eq(Form526JobStatus::STATUS[:exhausted])
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

0 comments on commit a15662c

Please sign in to comment.