Class: MailsocioQA::MailsocioTest
- Inherits:
-
Minitest::Test
- Object
- Minitest::Test
- MailsocioQA::MailsocioTest
- Defined in:
- lib/mailsocio_qa/mailsocio_test.rb
Instance Method Summary collapse
- #setup ⇒ Object
- #test_authentication_results ⇒ Object
- #test_bulk_routing ⇒ Object
- #test_create_account ⇒ Object
- #test_custom_tracking_domain ⇒ Object
- #test_custom_tracking_hard_bounce ⇒ Object
- #test_hard_bounce ⇒ Object
- #test_newsletter_tracking ⇒ Object
- #test_newsletter_tracking_subsequent_failures ⇒ Object
- #test_nonascii_mail_css_and_tracking ⇒ Object
- #test_send_mail ⇒ Object
- #test_send_newsletter ⇒ Object
- #test_transactional_routing ⇒ Object
Methods inherited from Minitest::Test
Instance Method Details
#setup ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 9 def setup @base_domain = Regexp.escape(Settings.mailsocio.base_domain) @track_domain = "track.#{Settings.mailsocio.base_domain}" @client = TestClient.new addresses = Settings.trap.addresses @john = addresses.john @jane = addresses.jane @invalid = addresses.invalid end |
#test_authentication_results ⇒ Object
192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 192 def test_authentication_results @client.create_account @client. @client.deliver('X-To' => "[\"#{@john}\"]") = @client. auth_results = ['Authentication-Results'].value assert_match /spf=pass/, auth_results assert_match /dkim=pass/, auth_results assert_match "@#{@track_domain}", .return_path assert_match "d=#{@track_domain}", ['DKIM-Signature'].try(:value) end |
#test_bulk_routing ⇒ Object
255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 255 def test_bulk_routing @client.create_account @client. @client.deliver( 'Precedence' => 'bulk', 'X-To' => "[\"#{@john}\"]" ) received = @client..received assert_match /^from (smtp[1-9]\d*\.#{@base_domain}) \(\1\. /, received[-3].value assert_match 'from localhost.localdomain (localhost ', received[-2].value assert_match 'from localhost.localdomain (localhost ', received[-1].value end |
#test_create_account ⇒ Object
20 21 22 23 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 20 def test_create_account @client.create_account refute_nil @client.account_id end |
#test_custom_tracking_domain ⇒ Object
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 206 def test_custom_tracking_domain domain = Settings.trap.custom_tracking_domain attrs = @client.create_account(custom_tracking_domain: domain) @client.custom_tracking_domain = domain assert_wont_raise('Could not read account via custom tracking domain URL') do @client.read_account end assert attrs['custom_tracking_enabled'], 'Custom tracking is disabled' assert attrs['custom_signing_enabled'], 'Custom signing is disabled' @client. @client.deliver('X-To' => "[\"#{@john}\"]") = @client. auth_results = ['Authentication-Results'].value assert_match /spf=pass/, auth_results assert_match /dkim=pass/, auth_results assert_match "@#{domain}", .return_path assert_match "d=#{domain}", ['DKIM-Signature'].try(:value) end |
#test_custom_tracking_hard_bounce ⇒ Object
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 228 def test_custom_tracking_hard_bounce domain = Settings.trap.custom_tracking_domain @client.create_account(custom_tracking_domain: domain) @client. @client.deliver( 'X-Newsletter-Id' => '15', 'X-To' => "[\"#{@invalid}\"]" ) sleep 90 stat = @client.('15') assert_equal 1, stat['queued'] assert_equal 1, stat['hard_bounced'] end |
#test_hard_bounce ⇒ Object
143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 143 def test_hard_bounce @client.create_account @client.deliver( 'X-Newsletter-Id' => '15', 'X-To' => "[\"#{@invalid}\"]" ) sleep 90 stat = @client.('15') assert_equal 1, stat['queued'] assert_equal 1, stat['hard_bounced'] end |
#test_newsletter_tracking ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 89 def @client.create_account @client.('john') @client.('jane') @client.deliver( 'X-Newsletter-Id' => '15', 'X-To' => "[\"#{@john}\",\"#{@jane}\"]", 'X-Track' => 'yes', 'Content-Type' => 'text/html', 'Body' => '<a href="http://google.com/search">Search</a>' ) = @client.('john') page = TestHtmlPage.new(.body.raw_source) stat = @client.('15') assert_equal 2, stat['queued'] assert_equal 2, stat['sent'] assert_equal 0, stat['viewed'] assert_equal 0, stat['clicked'] page.load stat = @client.('15') assert_equal 2, stat['queued'] assert_equal 2, stat['sent'] assert_equal 1, stat['viewed'] assert_equal 0, stat['clicked'] assert_equal 'http://google.com/search', page.click stat = @client.('15') assert_equal 2, stat['queued'] assert_equal 2, stat['sent'] assert_equal 1, stat['viewed'] assert_equal 1, stat['clicked'] = @client.('jane') page = TestHtmlPage.new(.body.raw_source) page.load stat = @client.('15') assert_equal 2, stat['queued'] assert_equal 2, stat['sent'] assert_equal 2, stat['viewed'] assert_equal 1, stat['clicked'] assert_equal 'http://google.com/search', page.click stat = @client.('15') assert_equal 2, stat['queued'] assert_equal 2, stat['sent'] assert_equal 2, stat['viewed'] assert_equal 2, stat['clicked'] end |
#test_newsletter_tracking_subsequent_failures ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 156 def skip("still not in production") @client.create_account @client.deliver( 'X-Newsletter-Id' => '15', 'X-To' => "[\"#{@invalid}\"]", ) sleep 90 stat = @client.('15') assert_equal 0, stat['new'] assert_equal 1, stat['queued'] assert_equal 1, stat['hard_bounced'] assert_equal 0, stat['skipped'] assert_equal 1, stat['sent'] assert_equal 0, stat['delivered'] @client.deliver( 'X-Newsletter-Id' => '16', 'X-To' => "[\"#{@invalid}\"]", ) sleep 30 stat = @client.('16') assert_equal 0, stat['new'] assert_equal 1, stat['queued'] assert_equal 1, stat['hard_bounced'] assert_equal 1, stat['skipped'] assert_equal 1, stat['sent'] assert_equal 0, stat['delivered'] end |
#test_nonascii_mail_css_and_tracking ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 40 def test_nonascii_mail_css_and_tracking @client.create_account @client. @client.deliver( 'X-To' => "[\"#{@john}\"]", 'X-Inline-Css' => 1, 'X-Track' => 1, 'Content-Type' => 'text/html; charset=ISO-8859-1', 'Content-Transfer-Encoding' => 'quoted-printable', 'Subject' => 'Hello', 'Body' => <<NONASCIIHTML <html> <head> <style type=3D"text/css"> body, .wrapper { height: 20px; } </style> </head> <body> <p>English Caf=E9</p> </body> </html> NONASCIIHTML ) = @client. assert_equal 'Hello', .subject assert_match /\s*<body style=3D"height:20px">\r\n/, .body.raw_source.strip, 'No inlined css styles' assert_match /\s*<p>English Caf=E9<\/p>\r\n/, .body.raw_source.strip, 'Not original quoted-printable' assert_match /<img src=3D".*\/assets\/dot\.png\?token=3D/, .body.raw_source.strip, 'No tracking image injected' end |
#test_send_mail ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 25 def test_send_mail @client.create_account @client. @client.deliver( 'X-To' => "{\"#{@john}\":{\"name\":\"John Doe\"}}", 'Subject' => 'Hello', 'Body' => 'Hello, __NAME__' ) = @client. assert_equal 'Hello', .subject assert_equal 'Hello, John Doe', .body.raw_source.strip end |
#test_send_newsletter ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 74 def @client.create_account @client.('john') @client.('jane') @client.deliver( 'X-Newsletter-Id' => '15', 'X-To' => "[\"#{@john}\", \"#{@jane}\"]" ) @client. stat = @client.('15') assert_equal 2, stat['queued'] end |
#test_transactional_routing ⇒ Object
244 245 246 247 248 249 250 251 252 253 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 244 def test_transactional_routing @client.create_account @client. @client.deliver('X-To' => "[\"#{@john}\"]") received = @client..received assert_match /from (smtp0\.#{@base_domain}) \(\1\. /, received[-3].value assert_match 'from localhost.localdomain (localhost ', received[-2].value assert_match 'from localhost.localdomain (localhost ', received[-1].value end |