Skip to content

Commit

Permalink
Update direct deposit email job to accept a default parameter of nil …
Browse files Browse the repository at this point in the history
…for the direct deposit type.
  • Loading branch information
tpharrison committed Apr 16, 2024
1 parent 1ae9657 commit e03e4b0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/controllers/v0/profile/direct_deposits_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def control_info_params
end

def send_confirmation_email
VANotifyDdEmailJob.send_to_emails(current_user.all_emails, 'comp_and_pen')
VANotifyDdEmailJob.send_to_emails(current_user.all_emails)
end
end
end
Expand Down
5 changes: 3 additions & 2 deletions app/sidekiq/va_notify_dd_email_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class VANotifyDdEmailJob
STATSD_ERROR_NAME = 'worker.direct_deposit_confirmation_email.error'
STATSD_SUCCESS_NAME = 'worker.direct_deposit_confirmation_email.success'

def self.send_to_emails(user_emails, dd_type)
def self.send_to_emails(user_emails, dd_type = nil)
if user_emails.present?
user_emails.each do |email|
perform_async(email, dd_type)
Expand All @@ -25,7 +25,7 @@ def self.send_to_emails(user_emails, dd_type)
end
end

def perform(email, dd_type)
def perform(email, dd_type = nil)
notify_client = VaNotify::Service.new(Settings.vanotify.services.va_gov.api_key)
template_type = template_type(dd_type)
template_id = Settings.vanotify.services.va_gov.template_id.public_send(template_type)
Expand All @@ -42,6 +42,7 @@ def perform(email, dd_type)
def template_type(dd_type)
return 'direct_deposit_edu' if dd_type&.to_sym == :ch33
return 'direct_deposit_comp_pen' if dd_type&.to_sym == :comp_pen

'direct_deposit'
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
context 'when the user does have an associated email address' do
it 'sends an email through va notify' do
expect(VANotifyDdEmailJob).to receive(:send_to_emails).with(
user.all_emails, 'comp_and_pen'
user.all_emails
)

VCR.use_cassette('lighthouse/direct_deposit/update/200_valid') do
Expand Down
9 changes: 4 additions & 5 deletions spec/sidekiq/va_notify_dd_email_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
describe '#perform' do
let(:notification_client) { double('Notifications::Client') }

context "with a dd type of ch33" do
context 'with a dd type of ch33' do
it 'sends a confirmation email using the edu template' do
allow(VaNotify::Service).to receive(:new)
.with(Settings.vanotify.services.va_gov.api_key).and_return(notification_client)
Expand All @@ -51,12 +51,11 @@
end
end

context "with a dd type of comp_pen" do
context 'with a dd type of comp_pen' do
it 'sends a confirmation email using the comp and pen template' do
allow(VaNotify::Service).to receive(:new)
.with(Settings.vanotify.services.va_gov.api_key).and_return(notification_client)


expect(notification_client).to receive(:send_email).with(
email_address: email, template_id: 'comp_pen_template_id'
)
Expand All @@ -65,11 +64,11 @@
end
end

context "without a dd type" do
context 'without a dd type' do
it 'sends a confirmation email using the direct_deposit template' do
allow(VaNotify::Service).to receive(:new)
.with(Settings.vanotify.services.va_gov.api_key).and_return(notification_client)

expect(notification_client).to receive(:send_email).with(
email_address: email, template_id: 'direct_deposit_template_id'
)
Expand Down

0 comments on commit e03e4b0

Please sign in to comment.