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
5 changes: 2 additions & 3 deletions app/jobs/reports/monthly_key_metrics_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,9 @@ def reports
end

def emails
emails = [IdentityConfig.store.team_agnes_email]
emails = [*IdentityConfig.store.team_daily_reports_emails]
if report_date.next_day.day == 1
emails << IdentityConfig.store.team_all_feds_email
emails << IdentityConfig.store.team_all_contractors_email
emails += IdentityConfig.store.team_all_login_emails
end
emails
end
Expand Down
10 changes: 4 additions & 6 deletions config/application.yml.default
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,8 @@ otp_min_attempts_remaining_warning_count: 3
system_demand_report_email: 'foo@bar.com'
sp_issuer_user_counts_report_configs: '[]'
team_ada_email: ''
team_agnes_email: ''
team_all_contractors_email: ''
team_all_feds_email: ''
team_all_login_emails: '[]'
team_daily_reports_emails: '[]'
team_ursula_email: ''
test_ssn_allowed_list: ''
totp_code_interval: 30
Expand Down Expand Up @@ -578,9 +577,8 @@ test:
skip_encryption_allowed_list: '[]'
state_tracking_enabled: true
team_ada_email: 'ada@example.com'
team_agnes_email: 'a@example.com'
team_all_contractors_email: 'c@example.com'
team_all_feds_email: 'f@example.com'
team_all_login_emails: '["b@example.com", "c@example.com"]'
team_daily_reports_emails: '["a@example.com", "d@example.com"]'
telephony_adapter: test
test_ssn_allowed_list: '999999999'
totp_code_interval: 3
Expand Down
5 changes: 2 additions & 3 deletions lib/identity_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,8 @@ def self.build_store(config_map)
config.add(:state_tracking_enabled, type: :boolean)
config.add(:system_demand_report_email, type: :string)
config.add(:team_ada_email, type: :string)
config.add(:team_agnes_email, type: :string)
config.add(:team_all_contractors_email, type: :string)
config.add(:team_all_feds_email, type: :string)
config.add(:team_all_login_emails, type: :json)
config.add(:team_daily_reports_emails, type: :json)
config.add(:team_ursula_email, type: :string)
config.add(:telephony_adapter, type: :string)
config.add(:test_ssn_allowed_list, type: :comma_separated_string_list)
Expand Down
49 changes: 37 additions & 12 deletions spec/jobs/reports/monthly_key_metrics_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,19 @@
}
end

let(:mock_proofing_report_data) do
[
['metric', 'num_users', 'percent'],
]
end
let(:mock_all_login_emails) { ['mock_feds@example.com', 'mock_contractors@example.com'] }
let(:mock_daily_reports_emails) { ['mock_agnes@example.com', 'mock_daily@example.com'] }

let(:mock_proofing_rate_data) do
[
['Metric', 'Trailing 30d', 'Trailing 60d', 'Trailing 90d'],
]
end
let(:mock_proofing_report_data) do
[
['metric', 'num_users', 'percent'],
]
end

before do
allow(Identity::Hostdata).to receive(:env).and_return('int')
Expand All @@ -57,11 +59,16 @@

allow(report.proofing_rate_report).to receive(:as_csv).
and_return(mock_proofing_rate_data)

allow(IdentityConfig.store).to receive(:team_daily_reports_emails).
and_return(mock_daily_reports_emails)
allow(IdentityConfig.store).to receive(:team_all_login_emails).
and_return(mock_all_login_emails)
end

it 'sends out a report to just to team agnes' do
expect(ReportMailer).to receive(:tables_report).once.with(
email: [IdentityConfig.store.team_agnes_email],
email: anything,
subject: 'Monthly Key Metrics Report - 2021-03-02',
reports: anything,
message: report.preamble,
Expand All @@ -76,11 +83,7 @@

it 'sends out a report to everybody' do
expect(ReportMailer).to receive(:tables_report).once.with(
email: [
IdentityConfig.store.team_agnes_email,
IdentityConfig.store.team_all_feds_email,
IdentityConfig.store.team_all_contractors_email,
],
email: anything,
subject: 'Monthly Key Metrics Report - 2021-02-28',
reports: anything,
message: report.preamble,
Expand All @@ -92,7 +95,7 @@
end

it 'does not send out a report with no emails' do
allow(IdentityConfig.store).to receive(:team_agnes_email).and_return('')
allow(IdentityConfig.store).to receive(:team_daily_reports_emails).and_return('')

expect(report).to_not receive(:reports)

Expand All @@ -112,6 +115,28 @@
report.perform(report_date)
end

describe '#emails' do
context 'on the first of the month' do
let(:report_date) { Date.new(2021, 3, 1).prev_day }

it 'emails the whole login team' do
expected_array = mock_daily_reports_emails
expected_array += mock_all_login_emails

expect(report.emails).to match_array(expected_array)
end
end

context 'during the rest of the month' do
let(:report_date) { Date.new(2021, 3, 2).prev_day }
it 'only emails team_daily_reports' do
expect(report.emails).to match_array(
mock_daily_reports_emails,
)
end
end
end

describe '#preamble' do
let(:env) { 'prod' }
subject(:preamble) { report.preamble(env:) }
Expand Down