diff --git a/app/controllers/v0/profile/direct_deposits_controller.rb b/app/controllers/v0/profile/direct_deposits_controller.rb index 4d4f6b92316..942a666f594 100644 --- a/app/controllers/v0/profile/direct_deposits_controller.rb +++ b/app/controllers/v0/profile/direct_deposits_controller.rb @@ -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 diff --git a/app/sidekiq/va_notify_dd_email_job.rb b/app/sidekiq/va_notify_dd_email_job.rb index 5f0867f0e78..1f8a81c0697 100644 --- a/app/sidekiq/va_notify_dd_email_job.rb +++ b/app/sidekiq/va_notify_dd_email_job.rb @@ -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) @@ -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) @@ -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 diff --git a/spec/controllers/v0/profile/direct_deposits_controller_spec.rb b/spec/controllers/v0/profile/direct_deposits_controller_spec.rb index 1e0af7acae2..3dd8abc3e91 100644 --- a/spec/controllers/v0/profile/direct_deposits_controller_spec.rb +++ b/spec/controllers/v0/profile/direct_deposits_controller_spec.rb @@ -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 diff --git a/spec/sidekiq/va_notify_dd_email_job_spec.rb b/spec/sidekiq/va_notify_dd_email_job_spec.rb index 33e9cef9290..406ee454aa7 100644 --- a/spec/sidekiq/va_notify_dd_email_job_spec.rb +++ b/spec/sidekiq/va_notify_dd_email_job_spec.rb @@ -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) @@ -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' ) @@ -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' )