Skip to content

Commit

Permalink
Merge pull request #2417 from UKGovernmentBEIS/refactor/download-link…
Browse files Browse the repository at this point in the history
…-mailer

Refactor DownloadLinkMailer
  • Loading branch information
mec authored Nov 21, 2024
2 parents 8561560 + 1bb38c9 commit 4456bc3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions app/jobs/spending_breakdown_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ def perform(requester_id:, fund_id:)
fund_activity.save!

DownloadLinkMailer.send_link(
recipient: requester,
file_name: upload.timestamped_filename
requester,
upload.timestamped_filename
).deliver
rescue => error
log_error(error, requester)
DownloadLinkMailer.send_failure_notification(recipient: requester).deliver
DownloadLinkMailer.send_failure_notification(requester).deliver
end

def save_tempfile(export)
Expand Down
4 changes: 2 additions & 2 deletions app/mailers/download_link_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class DownloadLinkMailer < ApplicationMailer
def send_link(recipient:, file_name:)
def send_link(recipient, file_name)
@file_name = file_name
@file_url = exports_url

Expand All @@ -15,7 +15,7 @@ def send_link(recipient:, file_name:)
)
end

def send_failure_notification(recipient:)
def send_failure_notification(recipient)
view_mail(
ENV["NOTIFY_VIEW_TEMPLATE"],
to: recipient.email,
Expand Down
6 changes: 3 additions & 3 deletions spec/jobs/spending_breakdown_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@

expect(DownloadLinkMailer)
.to have_received(:send_failure_notification)
.with(recipient: requester)
.with(requester)
expect(email).to have_received(:deliver)
end
end
Expand All @@ -136,8 +136,8 @@
SpendingBreakdownJob.perform_now(requester_id: double, fund_id: double)

expect(DownloadLinkMailer).to have_received(:send_link).with(
recipient: requester,
file_name: "timestamped_filename.csv"
requester,
"timestamped_filename.csv"
)
expect(email).to have_received(:deliver)
end
Expand Down
6 changes: 3 additions & 3 deletions spec/mailers/download_link_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
describe "#send_link(recipient:, file_url:, file_name:)" do
let(:mail) do
DownloadLinkMailer.send_link(
recipient: user,
file_name: "spending_breakdown.csv"
user,
"spending_breakdown.csv"
)
end

Expand Down Expand Up @@ -72,7 +72,7 @@

describe "#send_failure_notification(recipient:)" do
let(:mail) do
DownloadLinkMailer.send_failure_notification(recipient: user)
DownloadLinkMailer.send_failure_notification(user)
end

it "sends the email to the given recipient" do
Expand Down

0 comments on commit 4456bc3

Please sign in to comment.