actionmailer 1.3.6 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionmailer might be problematic. Click here for more details.

Files changed (96) hide show
  1. data/CHANGELOG +40 -28
  2. data/MIT-LICENSE +1 -1
  3. data/README +2 -2
  4. data/Rakefile +4 -3
  5. data/install.rb +1 -1
  6. data/lib/action_mailer.rb +5 -3
  7. data/lib/action_mailer/base.rb +57 -36
  8. data/lib/action_mailer/helpers.rb +4 -4
  9. data/lib/action_mailer/part.rb +2 -5
  10. data/lib/action_mailer/test_case.rb +59 -0
  11. data/lib/action_mailer/test_helper.rb +67 -0
  12. data/lib/action_mailer/vendor.rb +14 -0
  13. data/lib/action_mailer/vendor/{text → text-format-0.6.3/text}/format.rb +0 -0
  14. data/lib/action_mailer/vendor/tmail-1.1.0/tmail.rb +4 -0
  15. data/lib/action_mailer/vendor/tmail-1.1.0/tmail/Makefile +19 -0
  16. data/lib/action_mailer/vendor/{tmail → tmail-1.1.0/tmail}/address.rb +6 -3
  17. data/lib/action_mailer/vendor/{tmail → tmail-1.1.0/tmail}/attachments.rb +10 -2
  18. data/lib/action_mailer/vendor/tmail-1.1.0/tmail/base64.rb +52 -0
  19. data/lib/action_mailer/vendor/tmail-1.1.0/tmail/compat.rb +39 -0
  20. data/lib/action_mailer/vendor/{tmail → tmail-1.1.0/tmail}/config.rb +5 -3
  21. data/lib/action_mailer/vendor/tmail-1.1.0/tmail/core_extensions.rb +67 -0
  22. data/lib/action_mailer/vendor/{tmail → tmail-1.1.0/tmail}/encode.rb +23 -9
  23. data/lib/action_mailer/vendor/{tmail → tmail-1.1.0/tmail}/facade.rb +0 -0
  24. data/lib/action_mailer/vendor/{tmail → tmail-1.1.0/tmail}/header.rb +23 -6
  25. data/lib/action_mailer/vendor/{tmail → tmail-1.1.0/tmail}/info.rb +0 -0
  26. data/lib/action_mailer/vendor/tmail-1.1.0/tmail/interface.rb +540 -0
  27. data/lib/action_mailer/vendor/{tmail → tmail-1.1.0/tmail}/loader.rb +0 -0
  28. data/lib/action_mailer/vendor/{tmail → tmail-1.1.0/tmail}/mail.rb +20 -5
  29. data/lib/action_mailer/vendor/{tmail → tmail-1.1.0/tmail}/mailbox.rb +5 -3
  30. data/lib/action_mailer/vendor/{tmail → tmail-1.1.0/tmail}/mbox.rb +0 -0
  31. data/lib/action_mailer/vendor/{tmail → tmail-1.1.0/tmail}/net.rb +5 -3
  32. data/lib/action_mailer/vendor/{tmail → tmail-1.1.0/tmail}/obsolete.rb +5 -3
  33. data/lib/action_mailer/vendor/{tmail → tmail-1.1.0/tmail}/parser.rb +234 -281
  34. data/lib/action_mailer/vendor/tmail-1.1.0/tmail/parser.y +381 -0
  35. data/lib/action_mailer/vendor/{tmail → tmail-1.1.0/tmail}/port.rb +5 -3
  36. data/lib/action_mailer/vendor/{tmail → tmail-1.1.0/tmail}/quoting.rb +12 -1
  37. data/lib/action_mailer/vendor/{tmail → tmail-1.1.0/tmail}/scanner.rb +5 -3
  38. data/lib/action_mailer/vendor/{tmail → tmail-1.1.0/tmail}/scanner_r.rb +1 -1
  39. data/lib/action_mailer/vendor/{tmail → tmail-1.1.0/tmail}/stringio.rb +6 -4
  40. data/lib/action_mailer/vendor/{tmail → tmail-1.1.0/tmail}/tmail.rb +0 -0
  41. data/lib/action_mailer/vendor/{tmail → tmail-1.1.0/tmail}/utils.rb +50 -7
  42. data/lib/action_mailer/vendor/{tmail/base64.rb → tmail-1.1.0/tmail/version.rb} +7 -40
  43. data/lib/action_mailer/version.rb +3 -3
  44. data/lib/actionmailer.rb +1 -0
  45. data/test/abstract_unit.rb +19 -0
  46. data/test/delivery_method_test.rb +51 -0
  47. data/test/fixtures/first_mailer/share.erb +1 -0
  48. data/test/fixtures/first_mailer/share.rhtml +0 -1
  49. data/test/fixtures/helper_mailer/use_example_helper.erb +1 -0
  50. data/test/fixtures/helper_mailer/use_example_helper.rhtml +0 -0
  51. data/test/fixtures/helper_mailer/use_helper.erb +1 -0
  52. data/test/fixtures/helper_mailer/use_helper.rhtml +0 -1
  53. data/test/fixtures/helper_mailer/use_helper_method.erb +1 -0
  54. data/test/fixtures/helper_mailer/use_helper_method.rhtml +0 -1
  55. data/test/fixtures/helper_mailer/use_mail_helper.erb +5 -0
  56. data/test/fixtures/helper_mailer/use_mail_helper.rhtml +0 -5
  57. data/test/fixtures/helpers/{test_helper.rb → example_helper.rb} +2 -2
  58. data/test/fixtures/path.with.dots/funky_path_mailer/multipart_with_template_path_with_dots.erb +1 -0
  59. data/test/fixtures/path.with.dots/funky_path_mailer/multipart_with_template_path_with_dots.rhtml +0 -1
  60. data/test/fixtures/raw_base64_decoded_string +0 -0
  61. data/test/fixtures/raw_base64_encoded_string +1 -0
  62. data/test/fixtures/raw_email_with_invalid_characters_in_content_type +104 -0
  63. data/test/fixtures/raw_email_with_nested_attachment +100 -0
  64. data/test/fixtures/second_mailer/share.erb +1 -0
  65. data/test/fixtures/second_mailer/share.rhtml +0 -1
  66. data/test/fixtures/templates/signed_up.erb +3 -0
  67. data/test/fixtures/templates/signed_up.rhtml +0 -3
  68. data/test/fixtures/test_mailer/_subtemplate.text.plain.erb +1 -0
  69. data/test/fixtures/test_mailer/custom_templating_extension.text.html.haml +6 -0
  70. data/test/fixtures/test_mailer/custom_templating_extension.text.plain.haml +6 -0
  71. data/test/fixtures/test_mailer/implicitly_multipart_example.ignored.erb +1 -0
  72. data/test/fixtures/test_mailer/implicitly_multipart_example.ignored.rhtml +0 -1
  73. data/test/fixtures/test_mailer/implicitly_multipart_example.text.html.erb +10 -0
  74. data/test/fixtures/test_mailer/implicitly_multipart_example.text.html.rhtml +0 -10
  75. data/test/fixtures/test_mailer/implicitly_multipart_example.text.plain.erb +2 -0
  76. data/test/fixtures/test_mailer/implicitly_multipart_example.text.plain.rhtml +0 -2
  77. data/test/fixtures/test_mailer/implicitly_multipart_example.text.yaml.erb +1 -0
  78. data/test/fixtures/test_mailer/implicitly_multipart_example.text.yaml.rhtml +0 -1
  79. data/test/fixtures/test_mailer/included_subtemplate.text.plain.erb +1 -0
  80. data/test/fixtures/test_mailer/rxml_template.builder +2 -0
  81. data/test/fixtures/test_mailer/rxml_template.rxml +2 -0
  82. data/test/fixtures/test_mailer/signed_up.erb +3 -0
  83. data/test/fixtures/test_mailer/signed_up.rhtml +0 -3
  84. data/test/fixtures/test_mailer/signed_up_with_url.erb +5 -0
  85. data/test/fixtures/test_mailer/signed_up_with_url.rhtml +0 -3
  86. data/test/mail_helper_test.rb +10 -6
  87. data/test/mail_render_test.rb +45 -2
  88. data/test/mail_service_test.rb +150 -27
  89. data/test/quoting_test.rb +57 -3
  90. data/test/test_helper_test.rb +117 -0
  91. data/test/tmail_test.rb +9 -0
  92. data/test/url_test.rb +10 -2
  93. metadata +69 -32
  94. data/lib/action_mailer/vendor/tmail.rb +0 -3
  95. data/test/fixtures/helper_mailer/use_test_helper.rhtml +0 -1
  96. data/test/fixtures/raw_email11 +0 -34
@@ -0,0 +1 @@
1
+ second mail
@@ -1 +0,0 @@
1
- second mail
@@ -0,0 +1,3 @@
1
+ Hello there,
2
+
3
+ Mr. <%= @recipient %>
@@ -1,3 +0,0 @@
1
- Hello there,
2
-
3
- Mr. <%= @recipient %>
@@ -0,0 +1,6 @@
1
+ %p Hello there,
2
+
3
+ %p
4
+ Mr.
5
+ = @recipient
6
+ from haml
@@ -0,0 +1,6 @@
1
+ %p Hello there,
2
+
3
+ %p
4
+ Mr.
5
+ = @recipient
6
+ from haml
@@ -0,0 +1 @@
1
+ Ignored when searching for implicitly multipart parts.
@@ -1 +0,0 @@
1
- Ignored when searching for implicitly multipart parts.
@@ -0,0 +1,10 @@
1
+ <html>
2
+ <body>
3
+ HTML formatted message to <strong><%= @recipient %></strong>.
4
+ </body>
5
+ </html>
6
+ <html>
7
+ <body>
8
+ HTML formatted message to <strong><%= @recipient %></strong>.
9
+ </body>
10
+ </html>
@@ -1,10 +0,0 @@
1
- <html>
2
- <body>
3
- HTML formatted message to <strong><%= @recipient %></strong>.
4
- </body>
5
- </html>
6
- <html>
7
- <body>
8
- HTML formatted message to <strong><%= @recipient %></strong>.
9
- </body>
10
- </html>
@@ -0,0 +1,2 @@
1
+ Plain text to <%= @recipient %>.
2
+ Plain text to <%= @recipient %>.
@@ -1,2 +0,0 @@
1
- Plain text to <%= @recipient %>.
2
- Plain text to <%= @recipient %>.
@@ -1 +0,0 @@
1
- yaml to: <%= @recipient %>
@@ -0,0 +1 @@
1
+ Hey Ho, <%= render :partial => "subtemplate" %>
@@ -0,0 +1,2 @@
1
+ xml.instruct!
2
+ xml.test
@@ -0,0 +1,2 @@
1
+ xml.instruct!
2
+ xml.test
@@ -0,0 +1,3 @@
1
+ Hello there,
2
+
3
+ Mr. <%= @recipient %>
@@ -1,3 +0,0 @@
1
- Hello there,
2
-
3
- Mr. <%= @recipient %>
@@ -0,0 +1,5 @@
1
+ Hello there,
2
+
3
+ Mr. <%= @recipient %>. Please see our greeting at <%= @welcome_url %> <%= welcome_url %>
4
+
5
+ <%= image_tag "somelogo.png" %>
@@ -1,3 +0,0 @@
1
- Hello there,
2
-
3
- Mr. <%= @recipient %>. Please see our greeting at <%= @welcome_url %>
@@ -8,7 +8,7 @@ end
8
8
 
9
9
  class HelperMailer < ActionMailer::Base
10
10
  helper MailerHelper
11
- helper :test
11
+ helper :example
12
12
 
13
13
  def use_helper(recipient)
14
14
  recipients recipient
@@ -16,7 +16,7 @@ class HelperMailer < ActionMailer::Base
16
16
  from "tester@example.com"
17
17
  end
18
18
 
19
- def use_test_helper(recipient)
19
+ def use_example_helper(recipient)
20
20
  recipients recipient
21
21
  subject "using helpers"
22
22
  from "tester@example.com"
@@ -60,20 +60,24 @@ class MailerHelperTest < Test::Unit::TestCase
60
60
  end
61
61
 
62
62
  def setup
63
- ActionMailer::Base.delivery_method = :test
63
+ set_delivery_method :test
64
64
  ActionMailer::Base.perform_deliveries = true
65
65
  ActionMailer::Base.deliveries = []
66
66
 
67
67
  @recipient = 'test@localhost'
68
68
  end
69
-
69
+
70
+ def teardown
71
+ restore_delivery_method
72
+ end
73
+
70
74
  def test_use_helper
71
75
  mail = HelperMailer.create_use_helper(@recipient)
72
76
  assert_match %r{Mr. Joe Person}, mail.encoded
73
77
  end
74
78
 
75
- def test_use_test_helper
76
- mail = HelperMailer.create_use_test_helper(@recipient)
79
+ def test_use_example_helper
80
+ mail = HelperMailer.create_use_example_helper(@recipient)
77
81
  assert_match %r{<em><strong><small>emphasize me!}, mail.encoded
78
82
  end
79
83
 
@@ -15,6 +15,25 @@ class RenderMailer < ActionMailer::Base
15
15
  body render(:file => "signed_up", :body => { :recipient => recipient })
16
16
  end
17
17
 
18
+ def rxml_template(recipient)
19
+ recipients recipient
20
+ subject "rendering rxml template"
21
+ from "tester@example.com"
22
+ end
23
+
24
+ def included_subtemplate(recipient)
25
+ recipients recipient
26
+ subject "Including another template in the one being rendered"
27
+ from "tester@example.com"
28
+ end
29
+
30
+ def included_old_subtemplate(recipient)
31
+ recipients recipient
32
+ subject "Including another template in the one being rendered"
33
+ from "tester@example.com"
34
+ body render(:inline => "Hello, <%= render \"subtemplate\" %>", :body => { :world => "Earth" })
35
+ end
36
+
18
37
  def initialize_defaults(method_name)
19
38
  super
20
39
  mailer_name "test_mailer"
@@ -39,13 +58,17 @@ end
39
58
 
40
59
  class RenderHelperTest < Test::Unit::TestCase
41
60
  def setup
42
- ActionMailer::Base.delivery_method = :test
61
+ set_delivery_method :test
43
62
  ActionMailer::Base.perform_deliveries = true
44
63
  ActionMailer::Base.deliveries = []
45
64
 
46
65
  @recipient = 'test@localhost'
47
66
  end
48
67
 
68
+ def teardown
69
+ restore_delivery_method
70
+ end
71
+
49
72
  def test_inline_template
50
73
  mail = RenderMailer.create_inline_template(@recipient)
51
74
  assert_equal "Hello, Earth", mail.body.strip
@@ -55,17 +78,37 @@ class RenderHelperTest < Test::Unit::TestCase
55
78
  mail = RenderMailer.create_file_template(@recipient)
56
79
  assert_equal "Hello there, \n\nMr. test@localhost", mail.body.strip
57
80
  end
81
+
82
+ def test_rxml_template
83
+ mail = RenderMailer.deliver_rxml_template(@recipient)
84
+ assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test/>", mail.body.strip
85
+ end
86
+
87
+ def test_included_subtemplate
88
+ mail = RenderMailer.deliver_included_subtemplate(@recipient)
89
+ assert_equal "Hey Ho, let's go!", mail.body.strip
90
+ end
91
+
92
+ def test_deprecated_old_subtemplate
93
+ assert_raises ActionView::ActionViewError do
94
+ RenderMailer.deliver_included_old_subtemplate(@recipient)
95
+ end
96
+ end
58
97
  end
59
98
 
60
99
  class FirstSecondHelperTest < Test::Unit::TestCase
61
100
  def setup
62
- ActionMailer::Base.delivery_method = :test
101
+ set_delivery_method :test
63
102
  ActionMailer::Base.perform_deliveries = true
64
103
  ActionMailer::Base.deliveries = []
65
104
 
66
105
  @recipient = 'test@localhost'
67
106
  end
68
107
 
108
+ def teardown
109
+ restore_delivery_method
110
+ end
111
+
69
112
  def test_ordering
70
113
  mail = FirstMailer.create_share(@recipient)
71
114
  assert_equal "first mail", mail.body.strip
@@ -172,6 +172,15 @@ class TestMailer < ActionMailer::Base
172
172
  body["recipient"] = recipient
173
173
  end
174
174
 
175
+ def custom_templating_extension(recipient)
176
+ recipients recipient
177
+ subject "[Signed up] Welcome #{recipient}"
178
+ from "system@loudthinking.com"
179
+ sent_on Time.local(2004, 12, 12)
180
+
181
+ body["recipient"] = recipient
182
+ end
183
+
175
184
  def various_newlines(recipient)
176
185
  recipients recipient
177
186
  subject "various newlines"
@@ -201,6 +210,16 @@ class TestMailer < ActionMailer::Base
201
210
  attachment :content_type => "application/octet-stream",:filename => "test.txt", :body => "test abcdefghijklmnopqstuvwxyz"
202
211
  end
203
212
 
213
+ def nested_multipart_with_body(recipient)
214
+ recipients recipient
215
+ subject "nested multipart with body"
216
+ from "test@example.com"
217
+ content_type "multipart/mixed"
218
+ part :content_type => "multipart/alternative", :content_disposition => "inline", :body => "Nothing to see here." do |p|
219
+ p.part :content_type => "text/html", :body => "<b>test</b> HTML<br/>"
220
+ end
221
+ end
222
+
204
223
  def attachment_with_custom_header(recipient)
205
224
  recipients recipient
206
225
  subject "custom header in attachment"
@@ -236,6 +255,14 @@ class TestMailer < ActionMailer::Base
236
255
  body "testing"
237
256
  end
238
257
 
258
+ def return_path
259
+ recipients "no.one@nowhere.test"
260
+ subject "return path test"
261
+ from "some.one@somewhere.test"
262
+ body "testing"
263
+ headers "return-path" => "another@somewhere.test"
264
+ end
265
+
239
266
  class <<self
240
267
  attr_accessor :received_body
241
268
  end
@@ -245,6 +272,8 @@ class TestMailer < ActionMailer::Base
245
272
  end
246
273
  end
247
274
 
275
+ uses_mocha 'ActionMailerTest' do
276
+
248
277
  class ActionMailerTest < Test::Unit::TestCase
249
278
  include ActionMailer::Quoting
250
279
 
@@ -261,14 +290,22 @@ class ActionMailerTest < Test::Unit::TestCase
261
290
  mail
262
291
  end
263
292
 
293
+ # Replacing logger work around for mocha bug. Should be fixed in mocha 0.3.3
264
294
  def setup
265
- ActionMailer::Base.delivery_method = :test
295
+ set_delivery_method :test
266
296
  ActionMailer::Base.perform_deliveries = true
297
+ ActionMailer::Base.raise_delivery_errors = true
267
298
  ActionMailer::Base.deliveries = []
268
299
 
300
+ @original_logger = TestMailer.logger
269
301
  @recipient = 'test@localhost'
270
302
  end
271
303
 
304
+ def teardown
305
+ TestMailer.logger = @original_logger
306
+ restore_delivery_method
307
+ end
308
+
272
309
  def test_nested_parts
273
310
  created = nil
274
311
  assert_nothing_raised { created = TestMailer.create_nested_multipart(@recipient)}
@@ -283,6 +320,19 @@ class ActionMailerTest < Test::Unit::TestCase
283
320
  assert_equal "application/octet-stream", created.parts[1].content_type
284
321
  end
285
322
 
323
+ def test_nested_parts_with_body
324
+ created = nil
325
+ assert_nothing_raised { created = TestMailer.create_nested_multipart_with_body(@recipient)}
326
+ assert_equal 1,created.parts.size
327
+ assert_equal 2,created.parts.first.parts.size
328
+
329
+ assert_equal "multipart/mixed", created.content_type
330
+ assert_equal "multipart/alternative", created.parts.first.content_type
331
+ assert_equal "Nothing to see here.", created.parts.first.parts.first.body
332
+ assert_equal "text/plain", created.parts.first.parts.first.content_type
333
+ assert_equal "text/html", created.parts.first.parts[1].content_type
334
+ end
335
+
286
336
  def test_attachment_with_custom_header
287
337
  created = nil
288
338
  assert_nothing_raised { created = TestMailer.create_attachment_with_custom_header(@recipient)}
@@ -320,7 +370,37 @@ class ActionMailerTest < Test::Unit::TestCase
320
370
  assert_not_nil created
321
371
  assert_equal expected.encoded, created.encoded
322
372
  end
323
-
373
+
374
+ def test_custom_templating_extension
375
+ #
376
+ # N.b., custom_templating_extension.text.plain.haml is expected to be in fixtures/test_mailer directory
377
+ expected = new_mail
378
+ expected.to = @recipient
379
+ expected.subject = "[Signed up] Welcome #{@recipient}"
380
+ expected.body = "Hello there, \n\nMr. #{@recipient}"
381
+ expected.from = "system@loudthinking.com"
382
+ expected.date = Time.local(2004, 12, 12)
383
+
384
+ # Stub the render method so no alternative renderers need be present.
385
+ ActionView::Base.any_instance.stubs(:render).returns("Hello there, \n\nMr. #{@recipient}")
386
+
387
+ # If the template is not registered, there should be no parts.
388
+ created = nil
389
+ assert_nothing_raised { created = TestMailer.create_custom_templating_extension(@recipient) }
390
+ assert_not_nil created
391
+ assert_equal 0, created.parts.length
392
+
393
+ ActionMailer::Base.register_template_extension('haml')
394
+
395
+ # Now that the template is registered, there should be one part. The text/plain part.
396
+ created = nil
397
+ assert_nothing_raised { created = TestMailer.create_custom_templating_extension(@recipient) }
398
+ assert_not_nil created
399
+ assert_equal 2, created.parts.length
400
+ assert_equal 'text/plain', created.parts[0].content_type
401
+ assert_equal 'text/html', created.parts[1].content_type
402
+ end
403
+
324
404
  def test_cancelled_account
325
405
  expected = new_mail
326
406
  expected.to = @recipient
@@ -435,6 +515,29 @@ class ActionMailerTest < Test::Unit::TestCase
435
515
  TestMailer.deliver_signed_up(@recipient)
436
516
  assert_equal 1, ActionMailer::Base.deliveries.size
437
517
  end
518
+
519
+ def test_doesnt_raise_errors_when_raise_delivery_errors_is_false
520
+ ActionMailer::Base.raise_delivery_errors = false
521
+ TestMailer.any_instance.expects(:perform_delivery_test).raises(Exception)
522
+ assert_nothing_raised { TestMailer.deliver_signed_up(@recipient) }
523
+ end
524
+
525
+ def test_performs_delivery_via_sendmail
526
+ sm = mock()
527
+ sm.expects(:print).with(anything)
528
+ sm.expects(:flush)
529
+ IO.expects(:popen).once.with('/usr/sbin/sendmail -i -t', 'w+').yields(sm)
530
+ ActionMailer::Base.delivery_method = :sendmail
531
+ TestMailer.deliver_signed_up(@recipient)
532
+ end
533
+
534
+ def test_delivery_logs_sent_mail
535
+ mail = TestMailer.create_signed_up(@recipient)
536
+ logger = mock()
537
+ logger.expects(:info).with("Sent mail:\n #{mail.encoded}")
538
+ TestMailer.logger = logger
539
+ TestMailer.deliver_signed_up(@recipient)
540
+ end
438
541
 
439
542
  def test_unquote_quoted_printable_subject
440
543
  msg = <<EOF
@@ -663,23 +766,23 @@ EOF
663
766
 
664
767
  def test_implicitly_multipart_messages
665
768
  mail = TestMailer.create_implicitly_multipart_example(@recipient)
666
- assert_equal 3, mail.parts.length
769
+ assert_equal 6, mail.parts.length
667
770
  assert_equal "1.0", mail.mime_version
668
771
  assert_equal "multipart/alternative", mail.content_type
669
772
  assert_equal "text/yaml", mail.parts[0].content_type
670
773
  assert_equal "utf-8", mail.parts[0].sub_header("content-type", "charset")
671
- assert_equal "text/plain", mail.parts[1].content_type
672
- assert_equal "utf-8", mail.parts[1].sub_header("content-type", "charset")
673
- assert_equal "text/html", mail.parts[2].content_type
774
+ assert_equal "text/plain", mail.parts[2].content_type
674
775
  assert_equal "utf-8", mail.parts[2].sub_header("content-type", "charset")
776
+ assert_equal "text/html", mail.parts[4].content_type
777
+ assert_equal "utf-8", mail.parts[4].sub_header("content-type", "charset")
675
778
  end
676
779
 
677
780
  def test_implicitly_multipart_messages_with_custom_order
678
781
  mail = TestMailer.create_implicitly_multipart_example(@recipient, nil, ["text/yaml", "text/plain"])
679
- assert_equal 3, mail.parts.length
782
+ assert_equal 6, mail.parts.length
680
783
  assert_equal "text/html", mail.parts[0].content_type
681
- assert_equal "text/plain", mail.parts[1].content_type
682
- assert_equal "text/yaml", mail.parts[2].content_type
784
+ assert_equal "text/plain", mail.parts[2].content_type
785
+ assert_equal "text/yaml", mail.parts[4].content_type
683
786
  end
684
787
 
685
788
  def test_implicitly_multipart_messages_with_charset
@@ -749,12 +852,6 @@ EOF
749
852
  assert_nothing_raised { mail.body }
750
853
  end
751
854
 
752
- def test_decode_message_with_unquoted_atchar_in_header
753
- fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email11")
754
- mail = TMail::Mail.parse(fixture)
755
- assert_not_nil mail.from
756
- end
757
-
758
855
  def test_empty_header_values_omitted
759
856
  result = TestMailer.create_unnamed_attachment(@recipient).encoded
760
857
  assert_match %r{Content-Type: application/octet-stream[^;]}, result
@@ -787,21 +884,21 @@ EOF
787
884
  assert_match %r{format=flowed}, mail['content-type'].to_s
788
885
  assert_match %r{charset=utf-8}, mail['content-type'].to_s
789
886
  end
790
-
791
- def test_deprecated_server_settings
792
- old_smtp_settings = ActionMailer::Base.smtp_settings
793
- assert_deprecated do
794
- ActionMailer::Base.server_settings
795
- end
796
- assert_deprecated do
797
- ActionMailer::Base.server_settings={}
798
- assert_equal Hash.new, ActionMailer::Base.smtp_settings
799
- end
800
- ensure
801
- ActionMailer::Base.smtp_settings=old_smtp_settings
887
+
888
+ def test_return_path_with_create
889
+ mail = TestMailer.create_return_path
890
+ assert_equal "<another@somewhere.test>", mail['return-path'].to_s
891
+ end
892
+
893
+ def test_return_path_with_deliver
894
+ ActionMailer::Base.delivery_method = :smtp
895
+ TestMailer.deliver_return_path
896
+ assert_match %r{^Return-Path: <another@somewhere.test>}, MockSMTP.deliveries[0][0]
802
897
  end
803
898
  end
804
899
 
900
+ end # uses_mocha
901
+
805
902
  class InheritableTemplateRootTest < Test::Unit::TestCase
806
903
  def test_attr
807
904
  expected = "#{File.dirname(__FILE__)}/fixtures/path.with.dots"
@@ -814,3 +911,29 @@ class InheritableTemplateRootTest < Test::Unit::TestCase
814
911
  assert_equal expected, FunkyPathMailer.template_root
815
912
  end
816
913
  end
914
+
915
+ class MethodNamingTest < Test::Unit::TestCase
916
+ class TestMailer < ActionMailer::Base
917
+ def send
918
+ body 'foo'
919
+ end
920
+ end
921
+
922
+ def setup
923
+ set_delivery_method :test
924
+ ActionMailer::Base.perform_deliveries = true
925
+ ActionMailer::Base.deliveries = []
926
+ end
927
+
928
+ def teardown
929
+ restore_delivery_method
930
+ end
931
+
932
+ def test_send_method
933
+ assert_nothing_raised do
934
+ assert_emails 1 do
935
+ TestMailer.deliver_send
936
+ end
937
+ end
938
+ end
939
+ end