Class: MailsocioQA::MailsocioTest
- Inherits:
-
Minitest::Test
- Object
- Minitest::Test
- MailsocioQA::MailsocioTest
- Defined in:
- lib/mailsocio_qa/mailsocio_test.rb
Instance Method Summary collapse
- #settings ⇒ Object
- #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
#settings ⇒ Object
9 10 11 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 9 def settings @settings ||= Settings.new(ENV.fetch("CONFIG_FILE", File.('../../../settings.yml', __FILE__))) end |
#setup ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 13 def setup @base_domain = Regexp.escape(settings.mailsocio.base_domain) @track_domain = "track.#{settings.mailsocio.base_domain}" @client = TestClient.new(settings) addresses = settings.trap.addresses @john = addresses.john @jane = addresses.jane @invalid = addresses.invalid end |
#test_authentication_results ⇒ Object
196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 196 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
259 260 261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 259 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
24 25 26 27 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 24 def test_create_account @client.create_account refute_nil @client.account_id end |
#test_custom_tracking_domain ⇒ Object
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 210 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
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 232 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
147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 147 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
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 142 143 144 145 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 93 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
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 191 192 193 194 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 160 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
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 73 74 75 76 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 44 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
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 29 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
78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 78 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
248 249 250 251 252 253 254 255 256 257 |
# File 'lib/mailsocio_qa/mailsocio_test.rb', line 248 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 |