-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add govdelivery server to app yml * use govdelivery server in staging email method * use govdelivery server in config helper * fix server name * add year to date report to scheduler * perform doesnt require argument * fix statds for spring, add govdelivery server to figaro * add govdelivery server to travis * add va stakeholders * lint * rename report mailer * rename constants
- Loading branch information
Showing
13 changed files
with
129 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# frozen_string_literal: true | ||
class YearToDateReportMailer < ApplicationMailer | ||
REPORT_TEXT = 'Year to date report' | ||
|
||
VA_STAKEHOLDERS = { | ||
to: %w( | ||
Christopher.Marino2@va.gov | ||
224A.VBACO@va.gov | ||
rodney.alexander@va.gov | ||
URSULA.BRITT@va.gov | ||
Carolyn.McCollam@va.gov | ||
shay.norton@va.gov | ||
Christina.DiTucci@va.gov | ||
), | ||
cc: %w( | ||
robert.orifici@va.gov | ||
Erin.Haskins@va.gov | ||
Shante.Kinzie@va.gov | ||
Brandye.Terrell@va.gov | ||
michele.mendola@va.gov | ||
Schnell.Carraway@va.gov | ||
Danita.Johnson@va.gov | ||
jude.lopez1@va.gov | ||
Steven.Wayland@va.gov | ||
) | ||
}.freeze | ||
|
||
def build(report_file) | ||
s3_resource = new_s3_resource | ||
obj = s3_resource.bucket(s3_bucket).object("#{SecureRandom.uuid}.csv") | ||
obj.upload_file(report_file, content_type: 'text/csv') | ||
url = obj.presigned_url(:get, expires_in: 1.week) | ||
|
||
opt = {} | ||
if FeatureFlipper.staging_email? | ||
opt[:to] = 'lihan@adhocteam.us' | ||
else | ||
opt = VA_STAKEHOLDERS.clone | ||
end | ||
|
||
mail( | ||
opt.merge( | ||
subject: REPORT_TEXT, | ||
body: "#{REPORT_TEXT} (link expires in one week)<br>#{url}" | ||
) | ||
) | ||
end | ||
|
||
private | ||
|
||
def s3_bucket | ||
ENV['REPORTS_AWS_S3_BUCKET'] | ||
end | ||
|
||
def new_s3_resource | ||
Aws::S3::Resource.new( | ||
region: ENV['REPORTS_AWS_S3_REGION'], | ||
access_key_id: ENV['REPORTS_AWS_ACCESS_KEY_ID'], | ||
secret_access_key: ENV['REPORTS_AWS_SECRET_ACCESS_KEY'] | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# frozen_string_literal: true | ||
require 'rails_helper' | ||
|
||
RSpec.describe YearToDateReportMailer, type: [:mailer, :aws_helpers] do | ||
describe '#year_to_date_report_email' do | ||
let(:filename) { 'foo' } | ||
let(:mail) { described_class.build(filename).deliver_now } | ||
subject do | ||
stub_reports_s3(filename) do | ||
end | ||
end | ||
|
||
it 'should send the right email' do | ||
subject | ||
text = described_class::REPORT_TEXT | ||
expect(mail.body.encoded).to eq("#{text} (link expires in one week)<br>#{subject}") | ||
expect(mail.subject).to eq(text) | ||
end | ||
|
||
context 'when not sending staging emails' do | ||
before do | ||
expect(FeatureFlipper).to receive(:staging_email?).once.and_return(false) | ||
end | ||
|
||
it 'should email the va stakeholders' do | ||
subject | ||
expect(mail.to).to eq( | ||
['Christopher.Marino2@va.gov', | ||
'224A.VBACO@va.gov', | ||
'rodney.alexander@va.gov', | ||
'URSULA.BRITT@va.gov', | ||
'Carolyn.McCollam@va.gov', | ||
'shay.norton@va.gov', | ||
'Christina.DiTucci@va.gov'] | ||
) | ||
|
||
expect(mail.cc).to eq( | ||
['robert.orifici@va.gov', | ||
'Erin.Haskins@va.gov', | ||
'Shante.Kinzie@va.gov', | ||
'Brandye.Terrell@va.gov', | ||
'michele.mendola@va.gov', | ||
'Schnell.Carraway@va.gov', | ||
'Danita.Johnson@va.gov', | ||
'jude.lopez1@va.gov', | ||
'Steven.Wayland@va.gov'] | ||
) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters