- encode
- new_mail
- setup
- test_attachment_using_content_location
- test_attachment_with_custom_header
- test_attachment_with_text_type
- test_cancelled_account
- test_cc_bcc
- test_custom_content_type_attributes
- test_custom_template
- test_decode_attachment_without_charset
- test_decode_encoded_attachment_filename
- test_decode_message_with_incorrect_charset
- test_decode_message_with_unknown_charset
- test_decode_message_with_unquoted_atchar_in_header
- test_decode_message_without_content_type
- test_decode_part_without_content_type
- test_deliver_with_mail_object
- test_deliveries_array
- test_empty_header_values_omitted
- test_explicitly_multipart_messages
- test_explicitly_multipart_with_content_type
- test_explicitly_multipart_with_invalid_content_type
- test_extended_headers
- test_headers_removed_on_smtp_delivery
- test_headers_with_nonalpha_chars
- test_html_mail
- test_html_mail_with_underscores
- test_implicitly_multipart_messages
- test_implicitly_multipart_messages_with_charset
- test_implicitly_multipart_messages_with_custom_order
- test_implicitly_multipart_with_utf8
- test_instances_are_nil
- test_iso_charset
- test_multipart_with_mime_version
- test_multipart_with_template_path_with_dots
- test_multipart_with_utf8_subject
- test_multiple_utf8_recipients
- test_nested_parts
- test_perform_deliveries_flag
- test_receive_attachments
- test_receive_decodes_base64_encoded_mail
- test_recursive_multipart_processing
- test_signed_up
- test_unencoded_subject
- test_unquote_7bit_body
- test_unquote_7bit_subject
- test_unquote_base64_body
- test_unquote_quoted_printable_body
- test_unquote_quoted_printable_subject
- test_utf8_body_is_not_quoted
- test_various_newlines
- test_various_newlines_multipart
- test_wrong_mail_header
- ActionMailer::Quoting
[ show source ]
# File test/mail_service_test.rb, line 281
281: def encode( text, charset="utf-8" )
282: quoted_printable( text, charset )
283: end
[ show source ]
# File test/mail_service_test.rb, line 285
285: def new_mail( charset="utf-8" )
286: mail = TMail::Mail.new
287: if charset
288: mail.set_content_type "text", "plain", { "charset" => charset }
289: end
290: mail
291: end
[ show source ]
# File test/mail_service_test.rb, line 293
293: def setup
294: ActionMailer::Base.delivery_method = :test
295: ActionMailer::Base.perform_deliveries = true
296: ActionMailer::Base.deliveries = []
297:
298: @recipient = 'test@localhost'
299: end
[ show source ]
# File test/mail_service_test.rb, line 621
621: def test_attachment_using_content_location
622: fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email12")
623: mail = TMail::Mail.parse(fixture)
624: assert_equal 1, mail.attachments.length
625: assert_equal "Photo25.jpg", mail.attachments.first.original_filename
626: end
[ show source ]
# File test/mail_service_test.rb, line 314
314: def test_attachment_with_custom_header
315: created = nil
316: assert_nothing_raised { created = TestMailer.create_attachment_with_custom_header(@recipient)}
317: assert_equal "<test@test.com>", created.parts[1].header['content-id'].to_s
318: end
[ show source ]
# File test/mail_service_test.rb, line 628
628: def test_attachment_with_text_type
629: fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email13")
630: mail = TMail::Mail.parse(fixture)
631: assert mail.has_attachments?
632: assert_equal 1, mail.attachments.length
633: assert_equal "hello.rb", mail.attachments.first.original_filename
634: end
[ show source ]
# File test/mail_service_test.rb, line 353
353: def test_cancelled_account
354: expected = new_mail
355: expected.to = @recipient
356: expected.subject = "[Cancelled] Goodbye #{@recipient}"
357: expected.body = "Goodbye, Mr. #{@recipient}"
358: expected.from = "system@loudthinking.com"
359: expected.date = Time.local(2004, 12, 12)
360:
361: created = nil
362: assert_nothing_raised { created = TestMailer.create_cancelled_account(@recipient) }
363: assert_not_nil created
364: assert_equal expected.encoded, created.encoded
365:
366: assert_nothing_raised { TestMailer.deliver_cancelled_account(@recipient) }
367: assert_not_nil ActionMailer::Base.deliveries.first
368: assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded
369: end
[ show source ]
# File test/mail_service_test.rb, line 371
371: def test_cc_bcc
372: expected = new_mail
373: expected.to = @recipient
374: expected.subject = "testing bcc/cc"
375: expected.body = "Nothing to see here."
376: expected.from = "system@loudthinking.com"
377: expected.cc = "nobody@loudthinking.com"
378: expected.bcc = "root@loudthinking.com"
379: expected.date = Time.local 2004, 12, 12
380:
381: created = nil
382: assert_nothing_raised do
383: created = TestMailer.create_cc_bcc @recipient
384: end
385: assert_not_nil created
386: assert_equal expected.encoded, created.encoded
387:
388: assert_nothing_raised do
389: TestMailer.deliver_cc_bcc @recipient
390: end
391:
392: assert_not_nil ActionMailer::Base.deliveries.first
393: assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded
394: end
[ show source ]
# File test/mail_service_test.rb, line 819
819: def test_custom_content_type_attributes
820: mail = TestMailer.create_custom_content_type_attributes
821: assert_match %r{format=flowed}, mail['content-type'].to_s
822: assert_match %r{charset=utf-8}, mail['content-type'].to_s
823: end
[ show source ]
# File test/mail_service_test.rb, line 339
339: def test_custom_template
340: expected = new_mail
341: expected.to = @recipient
342: expected.subject = "[Signed up] Welcome #{@recipient}"
343: expected.body = "Hello there, \n\nMr. #{@recipient}"
344: expected.from = "system@loudthinking.com"
345: expected.date = Time.local(2004, 12, 12)
346:
347: created = nil
348: assert_nothing_raised { created = TestMailer.create_custom_template(@recipient) }
349: assert_not_nil created
350: assert_equal expected.encoded, created.encoded
351: end
[ show source ]
# File test/mail_service_test.rb, line 614
614: def test_decode_attachment_without_charset
615: fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email3")
616: mail = TMail::Mail.parse(fixture)
617: attachment = mail.attachments.last
618: assert_equal 1026, attachment.read.length
619: end
[ show source ]
# File test/mail_service_test.rb, line 768
768: def test_decode_encoded_attachment_filename
769: fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email8")
770: mail = TMail::Mail.parse(fixture)
771: attachment = mail.attachments.last
772: assert_equal "01QuienTeDijat.Pitbull.mp3", attachment.original_filename
773: end
[ show source ]
# File test/mail_service_test.rb, line 648
648: def test_decode_message_with_incorrect_charset
649: fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email6")
650: mail = TMail::Mail.parse(fixture)
651: assert_nothing_raised { mail.body }
652: end
[ show source ]
# File test/mail_service_test.rb, line 780
780: def test_decode_message_with_unknown_charset
781: fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email10")
782: mail = TMail::Mail.parse(fixture)
783: assert_nothing_raised { mail.body }
784: end
[ show source ]
# File test/mail_service_test.rb, line 786
786: def test_decode_message_with_unquoted_atchar_in_header
787: fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email11")
788: mail = TMail::Mail.parse(fixture)
789: assert_not_nil mail.from
790: end
[ show source ]
# File test/mail_service_test.rb, line 642
642: def test_decode_message_without_content_type
643: fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email5")
644: mail = TMail::Mail.parse(fixture)
645: assert_nothing_raised { mail.body }
646: end
[ show source ]
# File test/mail_service_test.rb, line 636
636: def test_decode_part_without_content_type
637: fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email4")
638: mail = TMail::Mail.parse(fixture)
639: assert_nothing_raised { mail.body }
640: end
[ show source ]
# File test/mail_service_test.rb, line 808
808: def test_deliver_with_mail_object
809: mail = TestMailer.create_headers_with_nonalpha_chars(@recipient)
810: assert_nothing_raised { TestMailer.deliver(mail) }
811: assert_equal 1, TestMailer.deliveries.length
812: end
[ show source ]
# File test/mail_service_test.rb, line 451
451: def test_deliveries_array
452: assert_not_nil ActionMailer::Base.deliveries
453: assert_equal 0, ActionMailer::Base.deliveries.size
454: TestMailer.deliver_signed_up(@recipient)
455: assert_equal 1, ActionMailer::Base.deliveries.size
456: assert_not_nil ActionMailer::Base.deliveries.first
457: end
[ show source ]
# File test/mail_service_test.rb, line 792
792: def test_empty_header_values_omitted
793: result = TestMailer.create_unnamed_attachment(@recipient).encoded
794: assert_match %r{Content-Type: application/octet-stream[^;]}, result
795: assert_match %r{Content-Disposition: attachment[^;]}, result
796: end
[ show source ]
# File test/mail_service_test.rb, line 669
669: def test_explicitly_multipart_messages
670: mail = TestMailer.create_explicitly_multipart_example(@recipient)
671: assert_equal 3, mail.parts.length
672: assert_nil mail.content_type
673: assert_equal "text/plain", mail.parts[0].content_type
674:
675: assert_equal "text/html", mail.parts[1].content_type
676: assert_equal "iso-8859-1", mail.parts[1].sub_header("content-type", "charset")
677: assert_equal "inline", mail.parts[1].content_disposition
678:
679: assert_equal "image/jpeg", mail.parts[2].content_type
680: assert_equal "attachment", mail.parts[2].content_disposition
681: assert_equal "foo.jpg", mail.parts[2].sub_header("content-disposition", "filename")
682: assert_equal "foo.jpg", mail.parts[2].sub_header("content-type", "name")
683: assert_nil mail.parts[2].sub_header("content-type", "charset")
684: end
[ show source ]
# File test/mail_service_test.rb, line 686
686: def test_explicitly_multipart_with_content_type
687: mail = TestMailer.create_explicitly_multipart_example(@recipient, "multipart/alternative")
688: assert_equal 3, mail.parts.length
689: assert_equal "multipart/alternative", mail.content_type
690: end
[ show source ]
# File test/mail_service_test.rb, line 692
692: def test_explicitly_multipart_with_invalid_content_type
693: mail = TestMailer.create_explicitly_multipart_example(@recipient, "text/xml")
694: assert_equal 3, mail.parts.length
695: assert_nil mail.content_type
696: end
[ show source ]
# File test/mail_service_test.rb, line 541
541: def test_extended_headers
542: @recipient = "Grytøyr <test@localhost>"
543:
544: expected = new_mail "iso-8859-1"
545: expected.to = quote_address_if_necessary @recipient, "iso-8859-1"
546: expected.subject = "testing extended headers"
547: expected.body = "Nothing to see here."
548: expected.from = quote_address_if_necessary "Grytøyr <stian1@example.net>", "iso-8859-1"
549: expected.cc = quote_address_if_necessary "Grytøyr <stian2@example.net>", "iso-8859-1"
550: expected.bcc = quote_address_if_necessary "Grytøyr <stian3@example.net>", "iso-8859-1"
551: expected.date = Time.local 2004, 12, 12
552:
553: created = nil
554: assert_nothing_raised do
555: created = TestMailer.create_extended_headers @recipient
556: end
557:
558: assert_not_nil created
559: assert_equal expected.encoded, created.encoded
560:
561: assert_nothing_raised do
562: TestMailer.deliver_extended_headers @recipient
563: end
564:
565: assert_not_nil ActionMailer::Base.deliveries.first
566: assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded
567: end
[ show source ]
# File test/mail_service_test.rb, line 751
751: def test_headers_removed_on_smtp_delivery
752: ActionMailer::Base.delivery_method = :smtp
753: TestMailer.deliver_cc_bcc(@recipient)
754: assert MockSMTP.deliveries[0][2].include?("root@loudthinking.com")
755: assert MockSMTP.deliveries[0][2].include?("nobody@loudthinking.com")
756: assert MockSMTP.deliveries[0][2].include?(@recipient)
757: assert_match %r{^Cc: nobody@loudthinking.com}, MockSMTP.deliveries[0][0]
758: assert_match %r{^To: #{@recipient}}, MockSMTP.deliveries[0][0]
759: assert_no_match %r{^Bcc: root@loudthinking.com}, MockSMTP.deliveries[0][0]
760: end
[ show source ]
# File test/mail_service_test.rb, line 798
798: def test_headers_with_nonalpha_chars
799: mail = TestMailer.create_headers_with_nonalpha_chars(@recipient)
800: assert !mail.from_addrs.empty?
801: assert !mail.cc_addrs.empty?
802: assert !mail.bcc_addrs.empty?
803: assert_match(/:/, mail.from_addrs.to_s)
804: assert_match(/:/, mail.cc_addrs.to_s)
805: assert_match(/:/, mail.bcc_addrs.to_s)
806: end
[ show source ]
# File test/mail_service_test.rb, line 729
729: def test_html_mail
730: mail = TestMailer.create_html_mail(@recipient)
731: assert_equal "text/html", mail.content_type
732: end
[ show source ]
# File test/mail_service_test.rb, line 734
734: def test_html_mail_with_underscores
735: mail = TestMailer.create_html_mail_with_underscores(@recipient)
736: assert_equal %{<a href="http://google.com" target="_blank">_Google</a>}, mail.body
737: end
[ show source ]
# File test/mail_service_test.rb, line 698
698: def test_implicitly_multipart_messages
699: mail = TestMailer.create_implicitly_multipart_example(@recipient)
700: assert_equal 3, mail.parts.length
701: assert_equal "1.0", mail.mime_version
702: assert_equal "multipart/alternative", mail.content_type
703: assert_equal "text/yaml", mail.parts[0].content_type
704: assert_equal "utf-8", mail.parts[0].sub_header("content-type", "charset")
705: assert_equal "text/plain", mail.parts[1].content_type
706: assert_equal "utf-8", mail.parts[1].sub_header("content-type", "charset")
707: assert_equal "text/html", mail.parts[2].content_type
708: assert_equal "utf-8", mail.parts[2].sub_header("content-type", "charset")
709: end
[ show source ]
# File test/mail_service_test.rb, line 719
719: def test_implicitly_multipart_messages_with_charset
720: mail = TestMailer.create_implicitly_multipart_example(@recipient, 'iso-8859-1')
721:
722: assert_equal "multipart/alternative", mail.header['content-type'].body
723:
724: assert_equal 'iso-8859-1', mail.parts[0].sub_header("content-type", "charset")
725: assert_equal 'iso-8859-1', mail.parts[1].sub_header("content-type", "charset")
726: assert_equal 'iso-8859-1', mail.parts[2].sub_header("content-type", "charset")
727: end
[ show source ]
# File test/mail_service_test.rb, line 711
711: def test_implicitly_multipart_messages_with_custom_order
712: mail = TestMailer.create_implicitly_multipart_example(@recipient, nil, ["text/yaml", "text/plain"])
713: assert_equal 3, mail.parts.length
714: assert_equal "text/html", mail.parts[0].content_type
715: assert_equal "text/plain", mail.parts[1].content_type
716: assert_equal "text/yaml", mail.parts[2].content_type
717: end
[ show source ]
# File test/mail_service_test.rb, line 664
664: def test_implicitly_multipart_with_utf8
665: mail = TestMailer.create_implicitly_multipart_with_utf8
666: assert_match(/\nSubject: =\?utf-8\?Q\?Foo_.*?\?=/, mail.encoded)
667: end
[ show source ]
# File test/mail_service_test.rb, line 446
446: def test_instances_are_nil
447: assert_nil ActionMailer::Base.new
448: assert_nil TestMailer.new
449: end
[ show source ]
# File test/mail_service_test.rb, line 396
396: def test_iso_charset
397: expected = new_mail( "iso-8859-1" )
398: expected.to = @recipient
399: expected.subject = encode "testing isø charsets", "iso-8859-1"
400: expected.body = "Nothing to see here."
401: expected.from = "system@loudthinking.com"
402: expected.cc = "nobody@loudthinking.com"
403: expected.bcc = "root@loudthinking.com"
404: expected.date = Time.local 2004, 12, 12
405:
406: created = nil
407: assert_nothing_raised do
408: created = TestMailer.create_iso_charset @recipient
409: end
410: assert_not_nil created
411: assert_equal expected.encoded, created.encoded
412:
413: assert_nothing_raised do
414: TestMailer.deliver_iso_charset @recipient
415: end
416:
417: assert_not_nil ActionMailer::Base.deliveries.first
418: assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded
419: end
[ show source ]
# File test/mail_service_test.rb, line 654
654: def test_multipart_with_mime_version
655: mail = TestMailer.create_multipart_with_mime_version(@recipient)
656: assert_equal "1.1", mail.mime_version
657: end
[ show source ]
# File test/mail_service_test.rb, line 814
814: def test_multipart_with_template_path_with_dots
815: mail = FunkyPathMailer.create_multipart_with_template_path_with_dots(@recipient)
816: assert_equal 2, mail.parts.length
817: end
[ show source ]
# File test/mail_service_test.rb, line 659
659: def test_multipart_with_utf8_subject
660: mail = TestMailer.create_multipart_with_utf8_subject(@recipient)
661: assert_match(/\nSubject: =\?utf-8\?Q\?Foo_.*?\?=/, mail.encoded)
662: end
[ show source ]
# File test/mail_service_test.rb, line 584
584: def test_multiple_utf8_recipients
585: @recipient = ["\"Foo áëô îü\" <extended@example.net>", "\"Example Recipient\" <me@example.com>"]
586: expected = new_mail "utf-8"
587: expected.to = quote_address_if_necessary @recipient, "utf-8"
588: expected.subject = "testing utf-8 body"
589: expected.body = "åœö blah"
590: expected.from = quote_address_if_necessary @recipient.first, "utf-8"
591: expected.cc = quote_address_if_necessary @recipient, "utf-8"
592: expected.bcc = quote_address_if_necessary @recipient, "utf-8"
593: expected.date = Time.local 2004, 12, 12
594:
595: created = TestMailer.create_utf8_body @recipient
596: assert_match(/\nFrom: =\?utf-8\?Q\?Foo_.*?\?= <extended@example.net>\r/, created.encoded)
597: assert_match(/\nTo: =\?utf-8\?Q\?Foo_.*?\?= <extended@example.net>, Example Recipient <me/, created.encoded)
598: end
[ show source ]
# File test/mail_service_test.rb, line 301
301: def test_nested_parts
302: created = nil
303: assert_nothing_raised { created = TestMailer.create_nested_multipart(@recipient)}
304: assert_equal 2,created.parts.size
305: assert_equal 2,created.parts.first.parts.size
306:
307: assert_equal "multipart/mixed", created.content_type
308: assert_equal "multipart/alternative", created.parts.first.content_type
309: assert_equal "text/plain", created.parts.first.parts.first.content_type
310: assert_equal "text/html", created.parts.first.parts[1].content_type
311: assert_equal "application/octet-stream", created.parts[1].content_type
312: end
[ show source ]
# File test/mail_service_test.rb, line 459
459: def test_perform_deliveries_flag
460: ActionMailer::Base.perform_deliveries = false
461: TestMailer.deliver_signed_up(@recipient)
462: assert_equal 0, ActionMailer::Base.deliveries.size
463: ActionMailer::Base.perform_deliveries = true
464: TestMailer.deliver_signed_up(@recipient)
465: assert_equal 1, ActionMailer::Base.deliveries.size
466: end
[ show source ]
# File test/mail_service_test.rb, line 606
606: def test_receive_attachments
607: fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email2")
608: mail = TMail::Mail.parse(fixture)
609: attachment = mail.attachments.last
610: assert_equal "smime.p7s", attachment.original_filename
611: assert_equal "application/pkcs7-signature", attachment.content_type
612: end
[ show source ]
# File test/mail_service_test.rb, line 600
600: def test_receive_decodes_base64_encoded_mail
601: fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email")
602: TestMailer.receive(fixture)
603: assert_match(/Jamis/, TestMailer.received_body)
604: end
[ show source ]
# File test/mail_service_test.rb, line 762
762: def test_recursive_multipart_processing
763: fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email7")
764: mail = TMail::Mail.parse(fixture)
765: assert_equal "This is the first part.\n\nAttachment: test.rb\nAttachment: test.pdf\n\n\nAttachment: smime.p7s\n", mail.body
766: end
[ show source ]
# File test/mail_service_test.rb, line 320
320: def test_signed_up
321: expected = new_mail
322: expected.to = @recipient
323: expected.subject = "[Signed up] Welcome #{@recipient}"
324: expected.body = "Hello there, \n\nMr. #{@recipient}"
325: expected.from = "system@loudthinking.com"
326: expected.date = Time.local(2004, 12, 12)
327: expected.mime_version = nil
328:
329: created = nil
330: assert_nothing_raised { created = TestMailer.create_signed_up(@recipient) }
331: assert_not_nil created
332: assert_equal expected.encoded, created.encoded
333:
334: assert_nothing_raised { TestMailer.deliver_signed_up(@recipient) }
335: assert_not_nil ActionMailer::Base.deliveries.first
336: assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded
337: end
[ show source ]
# File test/mail_service_test.rb, line 421
421: def test_unencoded_subject
422: expected = new_mail
423: expected.to = @recipient
424: expected.subject = "testing unencoded subject"
425: expected.body = "Nothing to see here."
426: expected.from = "system@loudthinking.com"
427: expected.cc = "nobody@loudthinking.com"
428: expected.bcc = "root@loudthinking.com"
429: expected.date = Time.local 2004, 12, 12
430:
431: created = nil
432: assert_nothing_raised do
433: created = TestMailer.create_unencoded_subject @recipient
434: end
435: assert_not_nil created
436: assert_equal expected.encoded, created.encoded
437:
438: assert_nothing_raised do
439: TestMailer.deliver_unencoded_subject @recipient
440: end
441:
442: assert_not_nil ActionMailer::Base.deliveries.first
443: assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded
444: end
[ show source ]
# File test/mail_service_test.rb, line 496
496: def test_unquote_7bit_body
497: msg = "From: me@example.com\nSubject: subject\nContent-Type: text/plain; charset=iso-8859-1\nContent-Transfer-Encoding: 7bit\n\nThe=3Dbody\n"
498: mail = TMail::Mail.parse(msg)
499: assert_equal "The=3Dbody", mail.body.strip
500: assert_equal "The=3Dbody", mail.quoted_body.strip
501: end
[ show source ]
# File test/mail_service_test.rb, line 482
482: def test_unquote_7bit_subject
483: msg = "From: me@example.com\nSubject: this == working?\nContent-Type: text/plain; charset=iso-8859-1\n\nThe body\n"
484: mail = TMail::Mail.parse(msg)
485: assert_equal "this == working?", mail.subject
486: assert_equal "this == working?", mail.quoted_subject
487: end
[ show source ]
# File test/mail_service_test.rb, line 526
526: def test_unquote_base64_body
527: msg = "From: me@example.com\nSubject: subject\nContent-Type: text/plain; charset=iso-8859-1\nContent-Transfer-Encoding: base64\n\nVGhlIGJvZHk=\n"
528: mail = TMail::Mail.parse(msg)
529: assert_equal "The body", mail.body.strip
530: assert_equal "VGhlIGJvZHk=", mail.quoted_body.strip
531: end
[ show source ]
# File test/mail_service_test.rb, line 511
511: def test_unquote_quoted_printable_body
512: msg = "From: me@example.com\nSubject: subject\nContent-Type: text/plain; charset=iso-8859-1\nContent-Transfer-Encoding: quoted-printable\n\nThe=3Dbody\n"
513: mail = TMail::Mail.parse(msg)
514: assert_equal "The=body", mail.body.strip
515: assert_equal "The=3Dbody", mail.quoted_body.strip
516: end
[ show source ]
# File test/mail_service_test.rb, line 468
468: def test_unquote_quoted_printable_subject
469: msg = "From: me@example.com\nSubject: =?utf-8?Q?testing_testing_=D6=A4?=\nContent-Type: text/plain; charset=iso-8859-1\n\nThe body\n"
470: mail = TMail::Mail.parse(msg)
471: assert_equal "testing testing \326\244", mail.subject
472: assert_equal "=?utf-8?Q?testing_testing_=D6=A4?=", mail.quoted_subject
473: end
[ show source ]
# File test/mail_service_test.rb, line 569
569: def test_utf8_body_is_not_quoted
570: @recipient = "Foo áëô îü <extended@example.net>"
571: expected = new_mail "utf-8"
572: expected.to = quote_address_if_necessary @recipient, "utf-8"
573: expected.subject = "testing utf-8 body"
574: expected.body = "åœö blah"
575: expected.from = quote_address_if_necessary @recipient, "utf-8"
576: expected.cc = quote_address_if_necessary @recipient, "utf-8"
577: expected.bcc = quote_address_if_necessary @recipient, "utf-8"
578: expected.date = Time.local 2004, 12, 12
579:
580: created = TestMailer.create_utf8_body @recipient
581: assert_match(/åœö blah/, created.encoded)
582: end
[ show source ]
# File test/mail_service_test.rb, line 739
739: def test_various_newlines
740: mail = TestMailer.create_various_newlines(@recipient)
741: assert_equal("line #1\nline #2\nline #3\nline #4\n\n" +
742: "line #5\n\nline#6\n\nline #7", mail.body)
743: end
[ show source ]
# File test/mail_service_test.rb, line 745
745: def test_various_newlines_multipart
746: mail = TestMailer.create_various_newlines_multipart(@recipient)
747: assert_equal "line #1\nline #2\nline #3\nline #4\n\n", mail.parts[0].body
748: assert_equal "<p>line #1</p>\n<p>line #2</p>\n<p>line #3</p>\n<p>line #4</p>\n\n", mail.parts[1].body
749: end
[ show source ]
# File test/mail_service_test.rb, line 775
775: def test_wrong_mail_header
776: fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email9")
777: assert_raise(TMail::SyntaxError) { TMail::Mail.parse(fixture) }
778: end