|
22 | 22 | expect(parser.new_body).to match(/^Hello world! https:\/\/click\.#{message.domain.name}/)
|
23 | 23 | expect(parser.tracked_links).to eq 1
|
24 | 24 | end
|
| 25 | + |
| 26 | + it "should not replace links in messages if the header is set to no" do |
| 27 | + message = create_plain_text_message(server, "Hello world! http://github.com/atech/postal", "[email protected]", { custom_headers: { "x-track-clicks" => "no" } }) |
| 28 | + create(:track_domain, server: server, domain: message.domain) |
| 29 | + parser = Postal::MessageParser.new(message) |
| 30 | + expect(parser.actioned?).to be false |
| 31 | + expect(parser.new_body).to include("Hello world! http://github.com/atech/postal") |
| 32 | + expect(parser.tracked_links).to eq 0 |
| 33 | + end |
| 34 | + |
| 35 | + it "should insert tracking pixels in messages" do |
| 36 | + message = create_html_message(server, "<p>Hello world! <a href='http://github.com/atech/postal'>Github</a></p>", "[email protected]") |
| 37 | + create(:track_domain, server: server, domain: message.domain) |
| 38 | + parser = Postal::MessageParser.new(message) |
| 39 | + expect(parser.actioned?).to be true |
| 40 | + expect(parser.new_body).to match(/<p class='ampimg' style='display:none;visibility:none;margin:0;padding:0;line-height:0;'><img src='https:\/\/click\.#{message.domain.name}/) |
| 41 | + expect(parser.tracked_images).to eq 1 |
| 42 | + end |
| 43 | + |
| 44 | + it "should not insert tracking pixels in messages if the header is set to no" do |
| 45 | + message = create_html_message(server, "<p>Hello world! <a href='http://github.com/atech/postal'>Github</a></p>", "[email protected]", { custom_headers: { "x-track-opens" => "no" } }) |
| 46 | + create(:track_domain, server: server, domain: message.domain) |
| 47 | + parser = Postal::MessageParser.new(message) |
| 48 | + expect(parser.actioned?).to be true |
| 49 | + expect(parser.new_body).to_not include("<p class='ampimg' style='display:none;visibility:none;margin:0;padding:0;line-height:0;'><img src='https:\/\/click\.#{message.domain.name}") |
| 50 | + expect(parser.tracked_images).to eq 0 |
| 51 | + end |
25 | 52 | end
|
0 commit comments