Skip to content

Commit

Permalink
fix broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjcumming committed Oct 24, 2024
1 parent cab0081 commit f789abc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
11 changes: 5 additions & 6 deletions app/sidekiq/education_form/create_daily_spool_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,7 @@ def write_files(writer, structured_data:)
# This mailer is intended to only work for development, staging and NOT production
# Rails.env will return 'production' on the development & staging servers and which
# will trip the unwary. To be safe, use Settings.hostname
email_staging_spool_files(contents) if
# local developer development
Rails.env.eql?('development') ||

# VA Staging environment where we really want this to work.
Settings.hostname.eql?('staging-api.va.gov')
email_staging_spool_files(contents) if local_or_staging_env?

# track and update the records as processed once the file has been successfully written
track_submissions(region_id)
Expand Down Expand Up @@ -239,5 +234,9 @@ def log_to_email(region)
def email_staging_spool_files(contents)
CreateStagingSpoolFilesMailer.build(contents).deliver_now
end

def local_or_staging_env?
Rails.env.eql?('development') || Settings.hostname.eql?('staging-api.va.gov')
end
end
end
13 changes: 5 additions & 8 deletions spec/sidekiq/education_form/create_daily_spool_files_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,22 +126,19 @@

context 'with records in staging', run_at: '2016-09-16 03:00:00 EDT' do
before do
ENV['HOSTNAME'] = 'staging-api.va.gov'
application_1606.saved_claim.form = {}.to_json
FactoryBot.create(:va1990_western_region)
FactoryBot.create(:va1995_full_form)
FactoryBot.create(:va0994_full_form)
ActionMailer::Base.deliveries.clear
end

after do
ENV['HOSTNAME'] = nil
end

it 'processes the valid messages' do
expect(Flipper).to receive(:enabled?).with(any_args).and_return(false).at_least(:once)
expect { subject.perform }.to change { EducationBenefitsClaim.unprocessed.count }.from(4).to(0)
expect(ActionMailer::Base.deliveries.count).to be > 0
with_settings(Settings, hostname: 'staging-api.va.gov') do
expect(Flipper).to receive(:enabled?).with(any_args).and_return(false).at_least(:once)
expect { subject.perform }.to change { EducationBenefitsClaim.unprocessed.count }.from(4).to(0)
expect(ActionMailer::Base.deliveries.count).to be > 0
end
end
end

Expand Down

0 comments on commit f789abc

Please sign in to comment.