Files
openfoodnetwork/spec/mailers/report_mailer_spec.rb
Maikel Linke 860fe85af9 Add report download link to email notification
I added a system spec to verify that the download link can be generated
within the mailer in a background job. ActiveStorage is a bit particular
when it comes to genererating URLs and depending on the situation it may
generate a redirect URL, a proxy URL or link directly to the storage.
But we want a redirect URL here.
2023-05-15 19:41:45 +02:00

32 lines
785 B
Ruby

# frozen_string_literal: true
require 'spec_helper'
describe ReportMailer do
describe "#report_ready" do
subject(:email) {
ReportMailer.with(
to: "current_user@example.net",
blob: blob,
).report_ready
}
let(:blob) { ReportBlob.create_for_upload_later!("customers.csv") }
it "notifies about a report" do
expect(email.subject).to eq "Report ready"
expect(email.body).to have_content "Report ready for download"
end
it "notifies the user" do
expect(email.to).to eq ["current_user@example.net"]
end
it "contains a download link" do
expect(email.body).to have_link(
"customers.csv",
href: %r"^http://test\.host/rails/active_storage/disk/.*/customers\.csv$"
)
end
end
end