Ogni destinatario mostra se la mail è partita e se è stata aperta, con conteggi in dashboard. Co-authored-by: Cursor <cursoragent@cursor.com>
23 lines
865 B
Ruby
23 lines
865 B
Ruby
require "test_helper"
|
|
|
|
class Mailings::OpenPixelTest < ActiveSupport::TestCase
|
|
test "injects a tracking pixel before body close" do
|
|
mailing = create_mailing
|
|
mailing.rebuild_recipients!
|
|
recipient = mailing.mailing_recipients.first
|
|
html = Mailings::OpenPixel.call("<html><body><p>Ciao</p></body></html>", recipient)
|
|
|
|
assert_includes html, "/t/o/#{recipient.tracking_token}.gif"
|
|
assert_match %r{<img src="http://example.com/t/o/#{Regexp.escape(recipient.tracking_token)}\.gif"[^>]*width="1"}, html
|
|
assert_includes html, "</body>"
|
|
assert html.index("t/o/") < html.index("</body>")
|
|
end
|
|
|
|
test "skips test recipients without a token" do
|
|
html = "<p>Ciao</p>"
|
|
recipient = Mailings::TestRecipient.new(mailing: create_mailing, email: "test@example.com")
|
|
|
|
assert_equal html, Mailings::OpenPixel.call(html, recipient)
|
|
end
|
|
end
|