Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/jobs/reports/identity_verification_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def preamble
end

def emails
[IdentityConfig.store.team_ada_email]
[IdentityConfig.store.team_ada_email].compact
end

def reports
Expand Down
23 changes: 22 additions & 1 deletion spec/jobs/reports/identity_verification_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test passes without the changes. I think we're missing a call to actually perform the job?

Suggested change
expect(ReportMailer).to_not receive(:tables_report)
expect(ReportMailer).to_not receive(:tables_report)
subject.perform(report_date)


subject.perform(report_date)
end
end

describe '#report_maker' do
Expand Down