Skip to content

Commit

Permalink
RST-5353 Removing sendgrid related code (#1454)
Browse files Browse the repository at this point in the history
and migrating rest to notify
  • Loading branch information
zaparka authored Jul 31, 2023
1 parent 5c3505f commit 98116e3
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 211 deletions.
1 change: 1 addition & 0 deletions .env.development.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ NOTIFY_COMPLETED_CY_PAPER_TEMPLATE_ID='9f52cb39-33bd-4df6-871c-e337c058972b'
NOTIFY_COMPLETED_CY_TEMPLATE_ID=''
NOTIFY_COMPLETED_CY_REFUND_ONLINE_TEMPLATE_ID=''
NOTIFY_COMPLETED_CY_REFUND_PAPER_TEMPLATE_ID=''
NOTIFY_DWP_DOWN_TEMPLATE_ID='22025e7a-1bdd-450b-bb8f-a35f7493bd7c'

MAINTENANCE_ENABLED=false
MAINTENANCE_ALLOWED_IPS=''
Expand Down
3 changes: 2 additions & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ NOTIFY_COMPLETED_CY_ONLINE_TEMPLATE_ID='61cb8166-c137-459b-b1c0-b0ca63c1da6e'
NOTIFY_COMPLETED_CY_PAPER_TEMPLATE_ID='9f52cb39-33bd-4df6-871c-e337c058972b'
NOTIFY_COMPLETED_CY_TEMPLATE_ID=''
NOTIFY_COMPLETED_CY_REFUND_ONLINE_TEMPLATE_ID=''
NOTIFY_COMPLETED_CY_REFUND_PAPER_TEMPLATE_ID=''
NOTIFY_COMPLETED_CY_REFUND_PAPER_TEMPLATE_ID=''
NOTIFY_DWP_DOWN_TEMPLATE_ID='22025e7a-1bdd-450b-bb8f-a35f7493bd7c'
2 changes: 1 addition & 1 deletion app/jobs/dwp_report_status_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def run_dwp_check
end

def send_email_notifications
ApplicationMailer.dwp_is_down_notifier.deliver_now
NotifyMailer.dwp_is_down_notifier.deliver_now
log_notification
end

Expand Down
12 changes: 0 additions & 12 deletions app/mailers/application_mailer.rb

This file was deleted.

8 changes: 8 additions & 0 deletions app/mailers/notify_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ def password_reset(user, reset_link)
mail(to: user.email)
end

def dwp_is_down_notifier
set_template(ENV.fetch('NOTIFY_DWP_DOWN_TEMPLATE_ID', nil))
set_personalisation(
environment: ENV.fetch('ENV', 'test')
)
mail(to: Settings.mail.dwp_notification_alert)
end

private

def template(locale, method_name)
Expand Down
38 changes: 0 additions & 38 deletions app/mailers/public_mailer.rb

This file was deleted.

20 changes: 0 additions & 20 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,24 +76,4 @@
# configure devise mailer
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }

config.after_initialize do
sending_host = ENV.fetch('SENDING_HOST', 'localhost')
ActionMailer::Base.delivery_method = :sendmail
ActionMailer::Base.default from: Settings.mail.from
ActionMailer::Base.default reply_to: Settings.mail.reply_to
ActionMailer::Base.default_url_options = { host: sending_host, protocol: 'http', port: '3000' }
ActionMailer::Base.smtp_settings = {
address: 'smtp.sendgrid.net',
port: '587',
authentication: :plain,
user_name: ENV.fetch('SENDGRID_USERNAME', nil),
password: ENV.fetch('SENDGRID_PASSWORD', nil),
domain: 'feeremissions.dsd.io',
enable_starttls_auto: true
}
# debugging N+1 queries
# Bullet.enable = true
# Bullet.rails_logger = true
end

end
20 changes: 0 additions & 20 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,24 +107,4 @@
config.logstasher.logger_path = $stdout
config.logstasher.source = 'logstasher'

config.after_initialize do
smtp_domain = ENV.fetch('SMTP_DOMAIN', 'localhost')

ActionMailer::Base.default_url_options = {
host: smtp_domain,
protocol: ENV.fetch('SMTP_PROTOCOL', 'http')
}
ActionMailer::Base.default from: Settings.mail.from
ActionMailer::Base.default reply_to: Settings.mail.reply_to
ActionMailer::Base.smtp_settings = {
address: ENV.fetch('SMTP_HOSTNAME', 'localhost'),
port: ENV.fetch('SMTP_PORT', 587),
domain: smtp_domain,
user_name: ENV.fetch('SMTP_USERNAME', ''),
password: ENV.fetch('SMTP_PASSWORD', ''),
authentication: :login,
enable_starttls_auto: true
}
end

end
3 changes: 0 additions & 3 deletions config/locales/emails_en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,3 @@ en-GB:
one: 1. Your help with fees application will be assessed by staff at our Central Office.
two: 2. The Central Office will let you know the outcome of your help with fees application, or if they need more information from you. This usually takes no longer than 5 working days.
warning: 'Your case will not proceed until you send your help with fees reference number and employment tribunal claim number to the tribunal.'
dwp_alert_notification:
subject: Help With Fees - DWP API Checker alert (%{environment})
message: Help With Fees - DWP API Checker seems to be down. Please be aware.
2 changes: 1 addition & 1 deletion spec/jobs/dwp_report_status_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
allow(ApplicationInsights::TelemetryClient).to receive(:new).and_return app_insight
allow(app_insight).to receive(:track_event)
allow(DwpMonitor).to receive(:new).and_return dwp_monitor
allow(ApplicationMailer).to receive(:dwp_is_down_notifier).and_return mailer
allow(NotifyMailer).to receive(:dwp_is_down_notifier).and_return mailer
described_class.perform_now
end

Expand Down
19 changes: 0 additions & 19 deletions spec/mailers/application_mailer_spec.rb

This file was deleted.

14 changes: 14 additions & 0 deletions spec/mailers/notify_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@

end

describe '#dwp_is_down_notifier' do
let(:mail) { described_class.dwp_is_down_notifier }

it_behaves_like 'a Notify mail', template_id: ENV.fetch('NOTIFY_DWP_DOWN_TEMPLATE_ID', nil)

it 'has the right values' do
expect(mail.govuk_notify_personalisation).to eq({
environment: 'test'
})
expect(mail.to).to eq(['[email protected]', '[email protected]'])
end

end

describe '#submission_confirmation_online' do
let(:mail) { described_class.submission_confirmation_online(application, 'en') }

Expand Down
24 changes: 0 additions & 24 deletions spec/mailers/previews/public_mailer_preview.rb

This file was deleted.

71 changes: 0 additions & 71 deletions spec/mailers/public_mailer_spec.rb

This file was deleted.

2 changes: 1 addition & 1 deletion spec/models/forms/evidence/hmrc_check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@

it 'additional_income' do
form.load_additional_income_from_benefits
expect(form.additional_income_amount).to eq nil
expect(form.additional_income_amount).to be_nil
expect(form.additional_income).to be false
end
end
Expand Down

0 comments on commit 98116e3

Please sign in to comment.