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