Skip to content
This repository
Browse code

Down to 30 failures total

  • Loading branch information...
commit a5e6295d72733b0ab4d5cff1003574e98913bae8 1 parent 539d9b3
Mikel Lindsaar authored
10  actionmailer/lib/action_mailer/base.rb
@@ -573,8 +573,8 @@ def sort_parts(parts, order = [])
573 573
         order = order.collect { |s| s.downcase }
574 574
 
575 575
         parts = parts.sort do |a, b|
576  
-          a_ct = a.content_type.content_type.downcase
577  
-          b_ct = b.content_type.content_type.downcase
  576
+          a_ct = a.content_type.string.downcase
  577
+          b_ct = b.content_type.string.downcase
578 578
 
579 579
           a_in = order.include? a_ct
580 580
           b_in = order.include? b_ct
@@ -615,11 +615,11 @@ def create_mail
615 615
         
616 616
         if @parts.empty?
617 617
           main_type, sub_type = split_content_type(real_content_type)
618  
-          m.content_type(main_type, sub_type, ctype_attrs)
  618
+          m.content_type([main_type, sub_type, ctype_attrs])
619 619
           m.body = normalize_new_lines(body)
620 620
         elsif @parts.size == 1 && @parts.first.parts.empty?
621 621
           main_type, sub_type = split_content_type(real_content_type)
622  
-          m.content_type(main_type, sub_type, ctype_attrs)
  622
+          m.content_type([main_type, sub_type, ctype_attrs])
623 623
           m.body = normalize_new_lines(@parts.first.body)
624 624
         else
625 625
           @parts.each do |p|
@@ -629,7 +629,7 @@ def create_mail
629 629
           if real_content_type =~ /multipart/
630 630
             ctype_attrs.delete "charset"
631 631
             main_type, sub_type = split_content_type(real_content_type)
632  
-            m.content_type([main_type.to_s, sub_type.to_s, ctype_attrs])
  632
+            m.content_type([main_type, sub_type, ctype_attrs])
633 633
           end
634 634
         end
635 635
 
BIN  actionmailer/test/fixtures/attachments/foo.jpg
2  actionmailer/test/mail_helper_test.rb
@@ -56,7 +56,7 @@ def name_of_the_mailer_class
56 56
 class MailerHelperTest < Test::Unit::TestCase
57 57
   def new_mail( charset="utf-8" )
58 58
     mail = Mail.new
59  
-    mail.content_type ["text", "plain", { "charset" => charset }]
  59
+    mail.content_type(["text", "plain", { "charset" => charset }])
60 60
     mail
61 61
   end
62 62
 
18  actionmailer/test/mail_layout_test.rb
@@ -72,12 +72,12 @@ def test_should_pickup_multipart_layout
72 72
     mail = AutoLayoutMailer.create_multipart(@recipient)
73 73
     # CHANGED: content_type returns an object
74 74
     # assert_equal "multipart/alternative", mail.content_type
75  
-    assert_equal "multipart/alternative", mail.content_type.content_type
  75
+    assert_equal "multipart/alternative", mail.content_type.string
76 76
     assert_equal 2, mail.parts.size
77 77
 
78 78
     # CHANGED: content_type returns an object
79 79
     # assert_equal 'text/plain', mail.parts.first.content_type
80  
-    assert_equal 'text/plain', mail.parts.first.content_type.content_type
  80
+    assert_equal 'text/plain', mail.parts.first.content_type.string
81 81
     
82 82
     # CHANGED: body returns an object
83 83
     # assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body
@@ -85,7 +85,7 @@ def test_should_pickup_multipart_layout
85 85
 
86 86
     # CHANGED: content_type returns an object
87 87
     # assert_equal 'text/html', mail.parts.last.content_type
88  
-    assert_equal 'text/html', mail.parts.last.content_type.content_type
  88
+    assert_equal 'text/html', mail.parts.last.content_type.string
89 89
 
90 90
     # CHANGED: body returns an object
91 91
     # assert_equal "Hello from layout text/html multipart", mail.parts.last.body
@@ -96,19 +96,19 @@ def test_should_pickup_multipartmixed_layout
96 96
     mail = AutoLayoutMailer.create_multipart(@recipient, "multipart/mixed")
97 97
     # CHANGED: content_type returns an object
98 98
     # assert_equal "multipart/mixed", mail.content_type
99  
-    assert_equal "multipart/mixed", mail.content_type.content_type
  99
+    assert_equal "multipart/mixed", mail.content_type.string
100 100
     assert_equal 2, mail.parts.size
101 101
 
102 102
     # CHANGED: content_type returns an object
103 103
     # assert_equal 'text/plain', mail.parts.first.content_type
104  
-    assert_equal 'text/plain', mail.parts.first.content_type.content_type
  104
+    assert_equal 'text/plain', mail.parts.first.content_type.string
105 105
     # CHANGED: body returns an object
106 106
     # assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body
107 107
     assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body.decoded
108 108
 
109 109
     # CHANGED: content_type returns an object
110 110
     # assert_equal 'text/html', mail.parts.last.content_type
111  
-    assert_equal 'text/html', mail.parts.last.content_type.content_type
  111
+    assert_equal 'text/html', mail.parts.last.content_type.string
112 112
     # CHANGED: body returns an object
113 113
     # assert_equal "Hello from layout text/html multipart", mail.parts.last.body
114 114
     assert_equal "Hello from layout text/html multipart", mail.parts.last.body.decoded
@@ -116,13 +116,13 @@ def test_should_pickup_multipartmixed_layout
116 116
 
117 117
   def test_should_fix_multipart_layout
118 118
     mail = AutoLayoutMailer.create_multipart(@recipient, "text/plain")
119  
-    assert_equal "multipart/alternative", mail.content_type.content_type
  119
+    assert_equal "multipart/alternative", mail.content_type.string
120 120
     assert_equal 2, mail.parts.size
121 121
 
122  
-    assert_equal 'text/plain', mail.parts.first.content_type.content_type
  122
+    assert_equal 'text/plain', mail.parts.first.content_type.string
123 123
     assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body.decoded
124 124
 
125  
-    assert_equal 'text/html', mail.parts.last.content_type.content_type
  125
+    assert_equal 'text/html', mail.parts.last.content_type.string
126 126
     assert_equal "Hello from layout text/html multipart", mail.parts.last.body.decoded
127 127
   end
128 128
 
118  actionmailer/test/mail_service_test.rb
@@ -143,7 +143,7 @@ def explicitly_multipart_example(recipient, ct=nil)
143 143
       p.body = "blah"
144 144
     end
145 145
 
146  
-    attachment :content_type => "image/jpeg", :filename => "foo.jpg",
  146
+    attachment :content_type => "image/jpeg", :filename => File.join(File.dirname(__FILE__), "fixtures", "attachments", "foo.jpg"),
147 147
       :body => "123456789"
148 148
 
149 149
     render :text => "plain text default"
@@ -272,12 +272,11 @@ def headers_with_nonalpha_chars(recipient)
272 272
     bcc          "Five: Six <test@example.com>"
273 273
     render :text => "testing"
274 274
   end
275  
-require 'ruby-debug'
  275
+
276 276
   def custom_content_type_attributes
277 277
     recipients   "no.one@nowhere.test"
278 278
     subject      "custom content types"
279 279
     from         "some.one@somewhere.test"
280  
-    debugger
281 280
     content_type "text/plain; format=flowed"
282 281
     render :text => "testing"
283 282
   end
@@ -393,11 +392,21 @@ def test_signed_up
393 392
     created = nil
394 393
     assert_nothing_raised { created = TestMailer.create_signed_up(@recipient) }
395 394
     assert_not_nil created
  395
+    
  396
+    expected.message_id = '<123@456>'
  397
+    created.message_id = '<123@456>'
  398
+
396 399
     assert_equal expected.encoded, created.encoded
397 400
 
398 401
     assert_nothing_raised { TestMailer.deliver_signed_up(@recipient) }
399  
-    assert_not_nil ActionMailer::Base.deliveries.first
400  
-    assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded
  402
+
  403
+    delivered = ActionMailer::Base.deliveries.first
  404
+    assert_not_nil delivered
  405
+
  406
+    expected.message_id = '<123@456>'
  407
+    delivered.message_id = '<123@456>'
  408
+
  409
+    assert_equal expected.encoded, delivered.encoded
401 410
   end
402 411
 
403 412
   def test_subject_with_i18n
@@ -420,6 +429,8 @@ def test_custom_template
420 429
     created = nil
421 430
     assert_nothing_raised { created = TestMailer.create_custom_template(@recipient) }
422 431
     assert_not_nil created
  432
+    expected.message_id = '<123@456>'
  433
+    created.message_id = '<123@456>'
423 434
     assert_equal expected.encoded, created.encoded
424 435
   end
425 436
 
@@ -442,12 +453,12 @@ def test_custom_templating_extension
442 453
     assert_nothing_raised { created = TestMailer.create_custom_templating_extension(@recipient) }
443 454
     assert_not_nil created
444 455
     assert_equal 2, created.parts.length
445  
-    assert_equal 'text/plain', created.parts[0].content_type.content_type
446  
-    assert_equal 'text/html', created.parts[1].content_type.content_type
  456
+    assert_equal 'text/plain', created.parts[0].content_type.string
  457
+    assert_equal 'text/html', created.parts[1].content_type.string
447 458
   end
448 459
 
449 460
   def test_cancelled_account
450  
-    expected = new_mail('US-ASCII')
  461
+    expected = new_mail
451 462
     expected.to      = @recipient
452 463
     expected.subject = "[Cancelled] Goodbye #{@recipient}"
453 464
     expected.body    = "Goodbye, Mr. #{@recipient}"
@@ -471,7 +482,7 @@ def test_cancelled_account
471 482
   end
472 483
 
473 484
   def test_cc_bcc
474  
-    expected = new_mail('US-ASCII')
  485
+    expected = new_mail
475 486
     expected.to      = @recipient
476 487
     expected.subject = "testing bcc/cc"
477 488
     expected.body    = "Nothing to see here."
@@ -516,14 +527,23 @@ def test_reply_to
516 527
       created = TestMailer.create_different_reply_to @recipient
517 528
     end
518 529
     assert_not_nil created
  530
+    
  531
+    expected.message_id = '<123@456>'
  532
+    created.message_id = '<123@456>'
  533
+    
519 534
     assert_equal expected.encoded, created.encoded
520 535
 
521 536
     assert_nothing_raised do
522 537
       TestMailer.deliver_different_reply_to @recipient
523 538
     end
524 539
 
525  
-    assert_not_nil ActionMailer::Base.deliveries.first
526  
-    assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded
  540
+    delivered = ActionMailer::Base.deliveries.first
  541
+    assert_not_nil delivered
  542
+    
  543
+    expected.message_id = '<123@456>'
  544
+    delivered.message_id = '<123@456>'
  545
+    
  546
+    assert_equal expected.encoded, delivered.encoded
527 547
   end
528 548
 
529 549
   def test_iso_charset
@@ -541,14 +561,25 @@ def test_iso_charset
541 561
       created = TestMailer.create_iso_charset @recipient
542 562
     end
543 563
     assert_not_nil created
  564
+    expected.message_id = '<123@456>'
  565
+    created.message_id = '<123@456>'
  566
+    
  567
+    expected.message_id = '<123@456>'
  568
+    created.message_id = '<123@456>'
  569
+    
544 570
     assert_equal expected.encoded, created.encoded
545 571
 
546 572
     assert_nothing_raised do
547 573
       TestMailer.deliver_iso_charset @recipient
548 574
     end
549 575
 
550  
-    assert_not_nil ActionMailer::Base.deliveries.first
551  
-    assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded
  576
+    delivered = ActionMailer::Base.deliveries.first
  577
+    assert_not_nil delivered
  578
+
  579
+    expected.message_id = '<123@456>'
  580
+    delivered.message_id = '<123@456>'
  581
+    
  582
+    assert_equal expected.encoded, delivered.encoded
552 583
   end
553 584
 
554 585
   def test_unencoded_subject
@@ -639,7 +670,12 @@ def test_delivery_logs_sent_mail
639 670
     TestMailer.logger = FakeLogger.new
640 671
     TestMailer.deliver_signed_up(@recipient)
641 672
     assert(TestMailer.logger.info_contents =~ /Sent mail to #{@recipient}/)
642  
-    assert_equal(TestMailer.logger.debug_contents, "\n#{mail.encoded}")
  673
+    expected = TestMailer.logger.debug_contents
  674
+    actual = "\n#{mail.encoded}"
  675
+    expected.gsub!(/Message-ID:.*\r\n/, "Message-ID: <123@456>\r\n")
  676
+    actual.gsub!(/Message-ID:.*\r\n/, "Message-ID: <123@456>\r\n")
  677
+    
  678
+    assert_equal(expected, actual)
643 679
   end
644 680
 
645 681
   def test_unquote_quoted_printable_subject
@@ -728,14 +764,22 @@ def test_extended_headers
728 764
     end
729 765
 
730 766
     assert_not_nil created
  767
+    expected.message_id = '<123@456>'
  768
+    created.message_id = '<123@456>'
  769
+
731 770
     assert_equal expected.encoded, created.encoded
732 771
 
733 772
     assert_nothing_raised do
734 773
       TestMailer.deliver_extended_headers @recipient
735 774
     end
736 775
 
737  
-    assert_not_nil ActionMailer::Base.deliveries.first
738  
-    assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded
  776
+    delivered = ActionMailer::Base.deliveries.first
  777
+    assert_not_nil delivered
  778
+    
  779
+    expected.message_id = '<123@456>'
  780
+    delivered.message_id = '<123@456>'
  781
+    
  782
+    assert_equal expected.encoded, delivered.encoded
739 783
   end
740 784
 
741 785
   def test_utf8_body_is_not_quoted
@@ -825,7 +869,7 @@ def test_decode_message_with_incorrect_charset
825 869
 
826 870
   def test_multipart_with_mime_version
827 871
     mail = TestMailer.create_multipart_with_mime_version(@recipient)
828  
-    assert_equal "1.1", mail.mime_version
  872
+    assert_equal "1.1", mail.mime_version.version
829 873
   end
830 874
 
831 875
   def test_multipart_with_utf8_subject
@@ -842,13 +886,13 @@ def test_explicitly_multipart_messages
842 886
     mail = TestMailer.create_explicitly_multipart_example(@recipient)
843 887
     assert_equal 3, mail.parts.length
844 888
     assert_nil mail.content_type
845  
-    assert_equal "text/plain", mail.parts[0].content_type
  889
+    assert_equal "text/plain", mail.parts[0].content_type.string
846 890
 
847  
-    assert_equal "text/html", mail.parts[1].content_type
848  
-    assert_equal "iso-8859-1", mail.parts[1].sub_header("content-type", "charset")
  891
+    assert_equal "text/html", mail.parts[1].content_type.string
  892
+    assert_equal "iso-8859-1", mail.parts[1].charset
849 893
     assert_equal "inline", mail.parts[1].content_disposition
850 894
 
851  
-    assert_equal "image/jpeg", mail.parts[2].content_type
  895
+    assert_equal "image/jpeg", mail.parts[2].content_type.string
852 896
     assert_equal "attachment", mail.parts[2].content_disposition
853 897
     assert_equal "foo.jpg", mail.parts[2].sub_header("content-disposition", "filename")
854 898
     assert_equal "foo.jpg", mail.parts[2].sub_header("content-type", "name")
@@ -858,7 +902,7 @@ def test_explicitly_multipart_messages
858 902
   def test_explicitly_multipart_with_content_type
859 903
     mail = TestMailer.create_explicitly_multipart_example(@recipient, "multipart/alternative")
860 904
     assert_equal 3, mail.parts.length
861  
-    assert_equal "multipart/alternative", mail.content_type
  905
+    assert_equal "multipart/alternative", mail.content_type.string
862 906
   end
863 907
 
864 908
   def test_explicitly_multipart_with_invalid_content_type
@@ -873,13 +917,13 @@ def test_implicitly_multipart_messages
873 917
     mail = TestMailer.create_implicitly_multipart_example(@recipient)
874 918
     assert_equal 3, mail.parts.length
875 919
     assert_equal "1.0", mail.mime_version.decoded
876  
-    assert_equal "multipart/alternative", mail.content_type.content_type
877  
-    assert_equal "application/x-yaml", mail.parts[0].content_type.content_type
878  
-    assert_equal "utf-8", mail.parts[0].content_type.parameters[:charset]
879  
-    assert_equal "text/plain", mail.parts[1].content_type.content_type
880  
-    assert_equal "utf-8", mail.parts[1].content_type.parameters[:charset]
881  
-    assert_equal "text/html", mail.parts[2].content_type.content_type
882  
-    assert_equal "utf-8", mail.parts[2].content_type.parameters[:charset]
  920
+    assert_equal "multipart/alternative", mail.content_type.string
  921
+    assert_equal "application/x-yaml", mail.parts[0].content_type.string
  922
+    assert_equal "utf-8", mail.parts[0].charset
  923
+    assert_equal "text/plain", mail.parts[1].content_type.string
  924
+    assert_equal "utf-8", mail.parts[1].charset
  925
+    assert_equal "text/html", mail.parts[2].content_type.string
  926
+    assert_equal "utf-8", mail.parts[2].charset
883 927
   end
884 928
 
885 929
   def test_implicitly_multipart_messages_with_custom_order
@@ -887,9 +931,9 @@ def test_implicitly_multipart_messages_with_custom_order
887 931
 
888 932
     mail = TestMailer.create_implicitly_multipart_example(@recipient, nil, ["application/x-yaml", "text/plain"])
889 933
     assert_equal 3, mail.parts.length
890  
-    assert_equal "text/html", mail.parts[0].content_type.content_type
891  
-    assert_equal "text/plain", mail.parts[1].content_type.content_type
892  
-    assert_equal "application/x-yaml", mail.parts[2].content_type.content_type
  934
+    assert_equal "text/html", mail.parts[0].content_type.string
  935
+    assert_equal "text/plain", mail.parts[1].content_type.string
  936
+    assert_equal "application/x-yaml", mail.parts[2].content_type.string
893 937
   end
894 938
 
895 939
   def test_implicitly_multipart_messages_with_charset
@@ -904,7 +948,7 @@ def test_implicitly_multipart_messages_with_charset
904 948
 
905 949
   def test_html_mail
906 950
     mail = TestMailer.create_html_mail(@recipient)
907  
-    assert_equal "text/html", mail.content_type.decoded
  951
+    assert_equal "text/html", mail.content_type.string
908 952
   end
909 953
 
910 954
   def test_html_mail_with_underscores
@@ -922,6 +966,8 @@ def test_various_newlines_multipart
922 966
     mail = TestMailer.create_various_newlines_multipart(@recipient)
923 967
     assert_equal "line #1\nline #2\nline #3\nline #4\n\n", mail.parts[0].body.decoded
924 968
     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.decoded
  969
+    assert_equal "line #1\r\nline #2\r\nline #3\r\nline #4\r\n\r\n", mail.parts[0].body.encoded
  970
+    assert_equal "<p>line #1</p>\r\n<p>line #2</p>\r\n<p>line #3</p>\r\n<p>line #4</p>\r\n\r\n", mail.parts[1].body.encoded
925 971
   end
926 972
 
927 973
   def test_headers_removed_on_smtp_delivery
@@ -995,14 +1041,14 @@ def test_deliver_with_mail_object
995 1041
   def test_multipart_with_template_path_with_dots
996 1042
     mail = FunkyPathMailer.create_multipart_with_template_path_with_dots(@recipient)
997 1043
     assert_equal 2, mail.parts.length
998  
-    assert "text/plain", mail.parts[1].content_type.content_type
  1044
+    assert "text/plain", mail.parts[1].content_type.string
999 1045
     assert "utf-8", mail.parts[1].content_type['charset']
1000 1046
   end
1001 1047
 
1002 1048
   def test_custom_content_type_attributes
1003 1049
     mail = TestMailer.create_custom_content_type_attributes
1004  
-    assert_match %r{format=flowed}, mail.content_type.encoded
1005  
-    assert_match %r{charset=utf-8}, mail.content_type.encoded
  1050
+    assert_match %r{format="flowed"}, mail.content_type.encoded
  1051
+    assert_match %r{charset="utf-8"}, mail.content_type.encoded
1006 1052
   end
1007 1053
 
1008 1054
   def test_return_path_with_create

0 notes on commit a5e6295

Please sign in to comment.
Something went wrong with that request. Please try again.