diff --git a/app/jobs/reports/identity_verification_report.rb b/app/jobs/reports/identity_verification_report.rb index 8101c0c85e8..e3c335649f5 100644 --- a/app/jobs/reports/identity_verification_report.rb +++ b/app/jobs/reports/identity_verification_report.rb @@ -54,7 +54,7 @@ def preamble end def emails - [IdentityConfig.store.team_ada_email] + [IdentityConfig.store.team_ada_email].compact end def reports diff --git a/spec/jobs/reports/identity_verification_report_spec.rb b/spec/jobs/reports/identity_verification_report_spec.rb index 6e0a6d4ad05..3303cf97d9d 100644 --- a/spec/jobs/reports/identity_verification_report_spec.rb +++ b/spec/jobs/reports/identity_verification_report_spec.rb @@ -5,11 +5,12 @@ before do allow(IdentityConfig.store).to receive(:s3_reports_enabled).and_return(true) - allow(IdentityConfig.store).to receive(:team_ada_email).and_return('ada@example.com') end describe '#perform' do it 'gets a CSV from the report maker, saves it to S3, and sends email to team' do + allow(IdentityConfig.store).to receive(:team_ada_email).and_return('ada@example.com') + reports = Reporting::EmailableReport.new( title: 'Identity Verification Metrics', @@ -61,6 +62,26 @@ subject.perform(report_date) end + + it 'does not send report in email if the email field is empty' do + allow(IdentityConfig.store).to receive(:team_ada_email).and_return(nil) + + report_maker = double( + Reporting::IdentityVerificationReport, + to_csv: 'I am a CSV, see', + identity_verification_emailable_report: 'I am a report', + ) + allow(subject).to receive(:report_maker).and_return(report_maker) + expect(subject).to receive(:save_report).with( + 'identity-verification-report', + 'I am a CSV, see', + extension: 'csv', + ) + + expect(ReportMailer).to_not receive(:tables_report) + + subject.perform(report_date) + end end describe '#report_maker' do