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
data/CHANGELOG CHANGED
@@ -1,15 +1,47 @@
1
- *1.3.6* (October 12th, 2007)
1
+ *2.0.0* (December 6th, 2007)
2
2
 
3
- * Depend on Action Pack 1.13.6
3
+ * Update ActionMailer so it treats ActionView the same way that ActionController does. Closes #10244 [rick]
4
4
 
5
- *1.3.5* (October 12th, 2007)
5
+ * Pass the template_root as an array as ActionView's view_path
6
+ * Request templates with the "#{mailer_name}/#{action}" as opposed to just "#{action}"
6
7
 
7
- * Depend on Action Pack 1.13.5
8
+ * Fixed that partials would be broken when using text.plain.erb as the extension #10130 [java]
8
9
 
10
+ * Update README to use new smtp settings configuration API. Closes #10060 [psq]
9
11
 
10
- *1.3.4* (October 4th, 2007)
12
+ * Allow ActionMailer subclasses to individually set their delivery method (so two subclasses can have different delivery methods) #10033 [zdennis]
11
13
 
12
- * Depend on Action Pack 1.13.4
14
+ * Update TMail to v1.1.0. Use an updated version of TMail if available. [mikel]
15
+
16
+ * Introduce a new base test class for testing Mailers. ActionMailer::TestCase [Koz]
17
+
18
+ * Fix silent failure of rxml templates. #9879 [jstewart]
19
+
20
+
21
+ *2.0.0 [Preview Release]* (September 29th, 2007)
22
+
23
+ * Fix attachment decoding when using the TMail C extension. #7861 [orangechicken]
24
+
25
+ * Increase mail delivery test coverage. #8692 [kamal]
26
+
27
+ * Register alternative template engines using ActionMailer::Base.register_template_extension('haml'). #7534 [cwd, Josh Peek]
28
+
29
+ * Only load ActionController::UrlWriter if ActionController is present [Rick Olson]
30
+
31
+ * Make sure parsed emails recognized attachments nested inside multipart parts. #6714 [Jamis Buck]
32
+
33
+ * Allow mailer actions named send by using __send__ internally. #6467 [iGEL]
34
+
35
+ * Add assert_emails and assert_no_emails to test the number of emails delivered. #6479 [Jonathan Viney]
36
+ # Assert total number of emails delivered:
37
+ assert_emails 0
38
+ ContactMailer.deliver_contact
39
+ assert_emails 1
40
+
41
+ # Assert number of emails delivered within a block:
42
+ assert_emails 1 do
43
+ post :signup, :name => 'Jonathan'
44
+ end
13
45
 
14
46
 
15
47
  *1.3.3* (March 12th, 2007)
@@ -43,6 +75,8 @@
43
75
 
44
76
  * Replace Reloadable with Reloadable::Deprecated. [Nicholas Seckar]
45
77
 
78
+ * Mailer template root applies to a class and its subclasses rather than acting globally. #5555 [somekool@gmail.com]
79
+
46
80
  * Resolve action naming collision. #5520 [ssinghi@kreeti.com]
47
81
 
48
82
  * ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, Marcel Molina Jr.]
@@ -51,30 +85,8 @@
51
85
 
52
86
  * Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.]
53
87
 
54
-
55
- *1.2.5* (August 10th, 2006)
56
-
57
- * Depend on Action Pack 1.12.5
58
-
59
-
60
- *1.2.4* (August 8th, 2006)
61
-
62
- * Backport of documentation enhancements. [Kevin Clark, Marcel Molina Jr]
63
-
64
88
  * Correct spurious documentation example code which results in a SyntaxError. [Marcel Molina Jr.]
65
89
 
66
- * Mailer template root applies to a class and its subclasses rather than acting globally. #5555 [somekool@gmail.com]
67
-
68
-
69
- *1.2.3* (June 29th, 2006)
70
-
71
- * Depend on Action Pack 1.12.3
72
-
73
-
74
- *1.2.2* (June 27th, 2006)
75
-
76
- * Depend on Action Pack 1.12.2
77
-
78
90
 
79
91
  *1.2.1* (April 6th, 2006)
80
92
 
@@ -1,4 +1,4 @@
1
- Copyright (c) 2004-2006 David Heinemeier Hansson
1
+ Copyright (c) 2004-2007 David Heinemeier Hansson
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README CHANGED
@@ -86,7 +86,7 @@ This Mailman can be the target for Postfix. In Rails, you would use the runner l
86
86
 
87
87
  The Base class has the full list of configuration options. Here's an example:
88
88
 
89
- ActionMailer::Base.server_settings = {
89
+ ActionMailer::Base.smtp_settings = {
90
90
  :address=>'smtp.yourserver.com', # default: localhost
91
91
  :port=>'25', # default: 25
92
92
  :user_name=>'user',
@@ -142,4 +142,4 @@ And as Jim from Rake says:
142
142
 
143
143
  Feel free to submit commits or feature requests. If you send a patch,
144
144
  remember to update the corresponding unit tests. If fact, I prefer
145
- new feature to be submitted in the form of new unit tests.
145
+ new feature to be submitted in the form of new unit tests.
data/Rakefile CHANGED
@@ -29,11 +29,12 @@ Rake::TestTask.new { |t|
29
29
  }
30
30
 
31
31
 
32
- # Genereate the RDoc documentation
32
+ # Generate the RDoc documentation
33
33
  Rake::RDocTask.new { |rdoc|
34
34
  rdoc.rdoc_dir = 'doc'
35
35
  rdoc.title = "Action Mailer -- Easy email delivery and testing"
36
36
  rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
37
+ rdoc.options << '--charset' << 'utf-8'
37
38
  rdoc.template = "#{ENV['template']}.rb" if ENV['template']
38
39
  rdoc.rdoc_files.include('README', 'CHANGELOG')
39
40
  rdoc.rdoc_files.include('lib/action_mailer.rb')
@@ -54,7 +55,7 @@ spec = Gem::Specification.new do |s|
54
55
  s.rubyforge_project = "actionmailer"
55
56
  s.homepage = "http://www.rubyonrails.org"
56
57
 
57
- s.add_dependency('actionpack', '= 1.13.6' + PKG_BUILD)
58
+ s.add_dependency('actionpack', '= 2.0.0' + PKG_BUILD)
58
59
 
59
60
  s.has_rdoc = true
60
61
  s.requirements << 'none'
@@ -92,4 +93,4 @@ task :release => [ :package ] do
92
93
  rubyforge = RubyForge.new
93
94
  rubyforge.login
94
95
  rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages)
95
- end
96
+ end
data/install.rb CHANGED
@@ -18,7 +18,7 @@ unless $sitedir
18
18
  end
19
19
  end
20
20
 
21
- # the acual gruntwork
21
+ # the actual gruntwork
22
22
  Dir.chdir("lib")
23
23
 
24
24
  Find.find("action_mailer", "action_mailer.rb") { |f|
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2004-2006 David Heinemeier Hansson
2
+ # Copyright (c) 2004-2007 David Heinemeier Hansson
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining
5
5
  # a copy of this software and associated documentation files (the
@@ -31,13 +31,15 @@ unless defined?(ActionController)
31
31
  end
32
32
  end
33
33
 
34
- $:.unshift(File.dirname(__FILE__) + "/action_mailer/vendor/")
34
+ require 'action_mailer/vendor'
35
+ require 'tmail'
35
36
 
36
37
  require 'action_mailer/base'
37
38
  require 'action_mailer/helpers'
38
39
  require 'action_mailer/mail_helper'
39
40
  require 'action_mailer/quoting'
40
- require 'tmail'
41
+ require 'action_mailer/test_helper'
42
+
41
43
  require 'net/smtp'
42
44
 
43
45
  ActionMailer::Base.class_eval do
@@ -52,9 +52,9 @@ module ActionMailer #:nodoc:
52
52
  #
53
53
  # Like ActionController, each mailer class has a corresponding view directory
54
54
  # in which each method of the class looks for a template with its name.
55
- # To define a template to be used with a mailing, create an <tt>.rhtml</tt> file with the same name as the method
55
+ # To define a template to be used with a mailing, create an <tt>.erb</tt> file with the same name as the method
56
56
  # in your mailer model. For example, in the mailer defined above, the template at
57
- # <tt>app/views/notifier/signup_notification.rhtml</tt> would be used to generate the email.
57
+ # <tt>app/views/notifier/signup_notification.erb</tt> would be used to generate the email.
58
58
  #
59
59
  # Variables defined in the model are accessible as instance variables in the view.
60
60
  #
@@ -103,7 +103,7 @@ module ActionMailer #:nodoc:
103
103
  #
104
104
  # = HTML email
105
105
  #
106
- # To send mail as HTML, make sure your view (the <tt>.rhtml</tt> file) generates HTML and
106
+ # To send mail as HTML, make sure your view (the <tt>.erb</tt> file) generates HTML and
107
107
  # set the content type to html.
108
108
  #
109
109
  # class MyMailer < ActionMailer::Base
@@ -142,10 +142,10 @@ module ActionMailer #:nodoc:
142
142
  # by the content type. Each such detected template will be added as separate part to the message.
143
143
  #
144
144
  # For example, if the following templates existed:
145
- # * signup_notification.text.plain.rhtml
146
- # * signup_notification.text.html.rhtml
147
- # * signup_notification.text.xml.rxml
148
- # * signup_notification.text.x-yaml.rhtml
145
+ # * signup_notification.text.plain.erb
146
+ # * signup_notification.text.html.erb
147
+ # * signup_notification.text.xml.builder
148
+ # * signup_notification.text.x-yaml.erb
149
149
  #
150
150
  # Each would be rendered and added as a separate part to the message,
151
151
  # with the corresponding content type. The same body hash is passed to
@@ -219,17 +219,16 @@ module ActionMailer #:nodoc:
219
219
  # <tt>@implicit_parts_order</tt>.
220
220
  class Base
221
221
  include AdvAttrAccessor, PartContainer
222
- include ActionController::UrlWriter
222
+ include ActionController::UrlWriter if Object.const_defined?(:ActionController)
223
223
 
224
- # Action Mailer subclasses should be reloaded by the dispatcher in Rails
225
- # when Dependencies.mechanism = :load.
226
- include Reloadable::Deprecated
227
-
228
224
  private_class_method :new #:nodoc:
229
225
 
230
226
  class_inheritable_accessor :template_root
231
227
  cattr_accessor :logger
232
228
 
229
+ cattr_accessor :template_extensions
230
+ @@template_extensions = ['erb', 'builder', 'rhtml', 'rxml']
231
+
233
232
  @@smtp_settings = {
234
233
  :address => "localhost",
235
234
  :port => 25,
@@ -249,8 +248,8 @@ module ActionMailer #:nodoc:
249
248
  @@raise_delivery_errors = true
250
249
  cattr_accessor :raise_delivery_errors
251
250
 
252
- @@delivery_method = :smtp
253
- cattr_accessor :delivery_method
251
+ superclass_delegating_accessor :delivery_method
252
+ self.delivery_method = :smtp
254
253
 
255
254
  @@perform_deliveries = true
256
255
  cattr_accessor :perform_deliveries
@@ -299,11 +298,6 @@ module ActionMailer #:nodoc:
299
298
  # This defaults to the value for the +default_implicit_parts_order+.
300
299
  adv_attr_accessor :implicit_parts_order
301
300
 
302
- # Override the mailer name, which defaults to an inflected version of the
303
- # mailer's class name. If you want to use a template in a non-standard
304
- # location, you can use this to specify that location.
305
- adv_attr_accessor :mailer_name
306
-
307
301
  # Defaults to "1.0", but may be explicitly given if needed.
308
302
  adv_attr_accessor :mime_version
309
303
 
@@ -323,10 +317,35 @@ module ActionMailer #:nodoc:
323
317
  # have multiple mailer methods share the same template.
324
318
  adv_attr_accessor :template
325
319
 
320
+ # Override the mailer name, which defaults to an inflected version of the
321
+ # mailer's class name. If you want to use a template in a non-standard
322
+ # location, you can use this to specify that location.
323
+ def mailer_name(value = nil)
324
+ if value
325
+ self.mailer_name = value
326
+ else
327
+ self.class.mailer_name
328
+ end
329
+ end
330
+
331
+ def mailer_name=(value)
332
+ self.class.mailer_name = value
333
+ end
334
+
326
335
  # The mail object instance referenced by this mailer.
327
336
  attr_reader :mail
328
337
 
329
338
  class << self
339
+ attr_writer :mailer_name
340
+
341
+ def mailer_name
342
+ @mailer_name ||= name.underscore
343
+ end
344
+
345
+ # for ActionView compatibility
346
+ alias_method :controller_name, :mailer_name
347
+ alias_method :controller_path, :mailer_name
348
+
330
349
  def method_missing(method_symbol, *parameters)#:nodoc:
331
350
  case method_symbol.id2name
332
351
  when /^create_([_a-z]\w*)/ then new($1, *parameters).mail
@@ -363,18 +382,17 @@ module ActionMailer #:nodoc:
363
382
  def deliver(mail)
364
383
  new.deliver!(mail)
365
384
  end
366
-
367
- # Server Settings is the old name for <tt>smtp_settings</tt>
368
- def server_settings
369
- smtp_settings
370
- end
371
- deprecate :server_settings=>"It's now named smtp_settings"
372
-
373
- def server_settings=(settings)
374
- ActiveSupport::Deprecation.warn("server_settings has been renamed smtp_settings, this warning will be removed with rails 2.0", caller)
375
- self.smtp_settings=settings
385
+
386
+ # Register a template extension so mailer templates written in a
387
+ # templating language other than rhtml or rxml are supported.
388
+ # To use this, include in your template-language plugin's init
389
+ # code or on a per-application basis, this can be invoked from
390
+ # config/environment.rb:
391
+ #
392
+ # ActionMailer::Base.register_template_extension('haml')
393
+ def register_template_extension(extension)
394
+ template_extensions << extension
376
395
  end
377
-
378
396
  end
379
397
 
380
398
  # Instantiate a new mailer object. If +method_name+ is not +nil+, the mailer
@@ -389,20 +407,20 @@ module ActionMailer #:nodoc:
389
407
  # rendered and a new TMail::Mail object created.
390
408
  def create!(method_name, *parameters) #:nodoc:
391
409
  initialize_defaults(method_name)
392
- send(method_name, *parameters)
410
+ __send__(method_name, *parameters)
393
411
 
394
412
  # If an explicit, textual body has not been set, we check assumptions.
395
413
  unless String === @body
396
414
  # First, we look to see if there are any likely templates that match,
397
415
  # which include the content-type in their file name (i.e.,
398
- # "the_template_file.text.html.rhtml", etc.). Only do this if parts
416
+ # "the_template_file.text.html.erb", etc.). Only do this if parts
399
417
  # have not already been specified manually.
400
418
  if @parts.empty?
401
419
  templates = Dir.glob("#{template_path}/#{@template}.*")
402
420
  templates.each do |path|
403
- # TODO: don't hardcode rhtml|rxml
404
421
  basename = File.basename(path)
405
- next unless md = /^([^\.]+)\.([^\.]+\.[^\.]+)\.(rhtml|rxml)$/.match(basename)
422
+ template_regex = Regexp.new("^([^\\\.]+)\\\.([^\\\.]+\\\.[^\\\.]+)\\\.(" + template_extensions.join('|') + ")$")
423
+ next unless md = template_regex.match(basename)
406
424
  template_name = basename
407
425
  content_type = md.captures[1].gsub('.', '/')
408
426
  @parts << Part.new(:content_type => content_type,
@@ -448,7 +466,7 @@ module ActionMailer #:nodoc:
448
466
  logger.info "Sent mail:\n #{mail.encoded}" unless logger.nil?
449
467
 
450
468
  begin
451
- send("perform_delivery_#{delivery_method}", mail) if perform_deliveries
469
+ __send__("perform_delivery_#{delivery_method}", mail) if perform_deliveries
452
470
  rescue Exception => e # Net::SMTP errors or sendmail pipe errors
453
471
  raise e if raise_delivery_errors
454
472
  end
@@ -478,6 +496,9 @@ module ActionMailer #:nodoc:
478
496
 
479
497
  def render(opts)
480
498
  body = opts.delete(:body)
499
+ if opts[:file] && opts[:file] !~ /\//
500
+ opts[:file] = "#{mailer_name}/#{opts[:file]}"
501
+ end
481
502
  initialize_template_class(body).render(opts)
482
503
  end
483
504
 
@@ -486,7 +507,7 @@ module ActionMailer #:nodoc:
486
507
  end
487
508
 
488
509
  def initialize_template_class(assigns)
489
- ActionView::Base.new(template_path, assigns, self)
510
+ ActionView::Base.new([template_root], assigns, self)
490
511
  end
491
512
 
492
513
  def sort_parts(parts, order = [])
@@ -49,7 +49,7 @@ module ActionMailer
49
49
  begin
50
50
  require_dependency(file_name)
51
51
  rescue LoadError => load_error
52
- requiree = / -- (.*?)(\.rb)?$/.match(load_error).to_a[1]
52
+ requiree = / -- (.*?)(\.rb)?$/.match(load_error.message).to_a[1]
53
53
  msg = (requiree == file_name) ? "Missing helper file helpers/#{file_name}.rb" : "Can't load file: #{requiree}"
54
54
  raise LoadError.new(msg).copy_blame!(load_error)
55
55
  end
@@ -72,7 +72,7 @@ module ActionMailer
72
72
  methods.flatten.each do |method|
73
73
  master_helper_module.module_eval <<-end_eval
74
74
  def #{method}(*args, &block)
75
- controller.send(%(#{method}), *args, &block)
75
+ controller.send!(%(#{method}), *args, &block)
76
76
  end
77
77
  end_eval
78
78
  end
@@ -92,7 +92,7 @@ module ActionMailer
92
92
  inherited_without_helper(child)
93
93
  begin
94
94
  child.master_helper_module = Module.new
95
- child.master_helper_module.send :include, master_helper_module
95
+ child.master_helper_module.send! :include, master_helper_module
96
96
  child.helper child.name.underscore
97
97
  rescue MissingSourceFile => e
98
98
  raise unless e.is_missing?("helpers/#{child.name.underscore}_helper")
@@ -108,4 +108,4 @@ module ActionMailer
108
108
  end
109
109
  end
110
110
  end
111
- end
111
+ end
@@ -84,11 +84,8 @@ module ActionMailer
84
84
  end
85
85
  else
86
86
  if String === body
87
- part = TMail::Mail.new
88
- part.body = body
89
- part.set_content_type(real_content_type, nil, ctype_attrs)
90
- part.set_content_disposition "inline"
91
- m.parts << part
87
+ @parts.unshift Part.new(:charset => charset, :body => @body, :content_type => 'text/plain')
88
+ @body = nil
92
89
  end
93
90
 
94
91
  @parts.each do |p|
@@ -0,0 +1,59 @@
1
+ require 'active_support/test_case'
2
+
3
+ module ActionMailer
4
+ class NonInferrableMailerError < ::StandardError
5
+ def initialize(name)
6
+ super "Unable to determine the mailer to test from #{name}. " +
7
+ "You'll need to specify it using tests YourMailer in your " +
8
+ "test case definition"
9
+ end
10
+ end
11
+ # New Test Super class for forward compatibility.
12
+ # To override
13
+ class TestCase < ActiveSupport::TestCase
14
+ include ActionMailer::Quoting
15
+
16
+ class << self
17
+ def tests(mailer)
18
+ write_inheritable_attribute(:mailer_class, mailer)
19
+ end
20
+
21
+ def mailer_class
22
+ if mailer = read_inheritable_attribute(:mailer_class)
23
+ mailer
24
+ else
25
+ tests determine_default_mailer(name)
26
+ end
27
+ end
28
+
29
+ def determine_default_mailer(name)
30
+ name.sub(/Test$/, '').constantize
31
+ rescue NameError => e
32
+ raise NonInferrableMailerError.new(name)
33
+ end
34
+ end
35
+
36
+ def setup
37
+ ActionMailer::Base.delivery_method = :test
38
+ ActionMailer::Base.perform_deliveries = true
39
+ ActionMailer::Base.deliveries = []
40
+
41
+ @expected = TMail::Mail.new
42
+ @expected.set_content_type "text", "plain", { "charset" => charset }
43
+ @expected.mime_version = '1.0'
44
+ end
45
+
46
+ private
47
+ def charset
48
+ "utf-8"
49
+ end
50
+
51
+ def encode(subject)
52
+ quoted_printable(subject, charset)
53
+ end
54
+
55
+ def read_fixture(action)
56
+ IO.readlines(File.join(RAILS_ROOT, 'test', 'fixtures', self.class.mailer_class.name.underscore, action))
57
+ end
58
+ end
59
+ end