mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-31 21:37:16 +00:00
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.
32 lines
785 B
Ruby
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
|