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("

Ciao

", recipient) assert_includes html, "/t/o/#{recipient.tracking_token}.gif" assert_match %r{]*width="1"}, html assert_includes html, "" assert html.index("t/o/") < html.index("") end test "skips test recipients without a token" do html = "

Ciao

" recipient = Mailings::TestRecipient.new(mailing: create_mailing, email: "test@example.com") assert_equal html, Mailings::OpenPixel.call(html, recipient) end end