actionmailer 2.2.3 → 2.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1,12 +1,20 @@
1
- *2.2.3 (September 4th, 2009)*
1
+ *2.3.2 [Final] (March 15, 2009)*
2
2
 
3
- Version bump.
3
+ * Fixed that ActionMailer should send correctly formatted Return-Path in MAIL FROM for SMTP #1842 [Matt Jones]
4
4
 
5
- *2.2 (November 21st, 2008)*
5
+ * Fixed RFC-2045 quoted-printable bug #1421 [squadette]
6
+
7
+ * Fixed that no body charset would be set when there are attachments present #740 [Paweł Kondzior]
8
+
9
+
10
+ *2.2.1 [RC2] (November 14th, 2008)*
6
11
 
7
12
  * Turn on STARTTLS if it is available in Net::SMTP (added in Ruby 1.8.7) and the SMTP server supports it (This is required for Gmail's SMTP server) #1336 [Grant Hollingworth]
8
13
 
9
- * Add layout functionality to mailers [Pratik]
14
+
15
+ *2.2.0 [RC1] (October 24th, 2008)*
16
+
17
+ * Add layout functionality to mailers [Pratik Naik]
10
18
 
11
19
  Mailer layouts behaves just like controller layouts, except layout names need to
12
20
  have '_mailer' postfix for them to be automatically picked up.
@@ -18,7 +26,7 @@ Version bump.
18
26
 
19
27
  * Less verbose mail logging: just recipients for :info log level; the whole email for :debug only. #8000 [iaddict, Tarmo Tänav]
20
28
 
21
- * Updated TMail to version 1.2.1 [raasdnil]
29
+ * Updated TMail to version 1.2.1 [Mikel Lindsaar]
22
30
 
23
31
  * Fixed that you don't have to call super in ActionMailer::TestCase#setup #10406 [jamesgolick]
24
32
 
@@ -30,7 +38,7 @@ Version bump.
30
38
 
31
39
  *2.0.1* (December 7th, 2007)
32
40
 
33
- * Update ActionMailer so it treats ActionView the same way that ActionController does. Closes #10244 [rick]
41
+ * Update ActionMailer so it treats ActionView the same way that ActionController does. Closes #10244 [Rick Olson]
34
42
 
35
43
  * Pass the template_root as an array as ActionView's view_path
36
44
  * Request templates with the "#{mailer_name}/#{action}" as opposed to just "#{action}"
@@ -39,11 +47,11 @@ Version bump.
39
47
 
40
48
  * Update README to use new smtp settings configuration API. Closes #10060 [psq]
41
49
 
42
- * Allow ActionMailer subclasses to individually set their delivery method (so two subclasses can have different delivery methods) #10033 [zdennis]
50
+ * Allow ActionMailer subclasses to individually set their delivery method (so two subclasses can have different delivery methods) #10033 [Zach Dennis]
43
51
 
44
- * Update TMail to v1.1.0. Use an updated version of TMail if available. [mikel]
52
+ * Update TMail to v1.1.0. Use an updated version of TMail if available. [Mikel Lindsaar]
45
53
 
46
- * Introduce a new base test class for testing Mailers. ActionMailer::TestCase [Koz]
54
+ * Introduce a new base test class for testing Mailers. ActionMailer::TestCase [Michael Koziarski]
47
55
 
48
56
  * Fix silent failure of rxml templates. #9879 [jstewart]
49
57
 
@@ -78,7 +86,7 @@ Version bump.
78
86
 
79
87
  *1.3.2* (February 5th, 2007)
80
88
 
81
- * Deprecate server_settings renaming it to smtp_settings, add sendmail_settings to allow you to override the arguments to and location of the sendmail executable. [Koz]
89
+ * Deprecate server_settings renaming it to smtp_settings, add sendmail_settings to allow you to override the arguments to and location of the sendmail executable. [Michael Koziarski]
82
90
 
83
91
 
84
92
  *1.3.1* (January 16th, 2007)
@@ -98,7 +106,7 @@ Version bump.
98
106
 
99
107
  * Tighten rescue clauses. #5985 [james@grayproductions.net]
100
108
 
101
- * Automatically included ActionController::UrlWriter, such that URL generation can happen within ActionMailer controllers. [DHH]
109
+ * Automatically included ActionController::UrlWriter, such that URL generation can happen within ActionMailer controllers. [David Heinemeier Hansson]
102
110
 
103
111
  * Replace Reloadable with Reloadable::Deprecated. [Nicholas Seckar]
104
112
 
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2004-2008 David Heinemeier Hansson
1
+ Copyright (c) 2004-2009 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/Rakefile CHANGED
@@ -55,7 +55,7 @@ spec = Gem::Specification.new do |s|
55
55
  s.rubyforge_project = "actionmailer"
56
56
  s.homepage = "http://www.rubyonrails.org"
57
57
 
58
- s.add_dependency('actionpack', '= 2.2.3' + PKG_BUILD)
58
+ s.add_dependency('actionpack', '= 2.3.2' + PKG_BUILD)
59
59
 
60
60
  s.has_rdoc = true
61
61
  s.requirements << 'none'
data/lib/action_mailer.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2004-2008 David Heinemeier Hansson
2
+ # Copyright (c) 2004-2009 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,22 +31,32 @@ rescue LoadError
31
31
  end
32
32
  end
33
33
 
34
- require 'action_mailer/vendor'
35
- require 'tmail'
34
+ require 'action_view'
36
35
 
37
- require 'action_mailer/base'
38
- require 'action_mailer/helpers'
39
- require 'action_mailer/mail_helper'
40
- require 'action_mailer/quoting'
41
- require 'action_mailer/test_helper'
36
+ module ActionMailer
37
+ def self.load_all!
38
+ [Base, Part, ::Text::Format, ::Net::SMTP]
39
+ end
42
40
 
43
- require 'net/smtp'
41
+ autoload :AdvAttrAccessor, 'action_mailer/adv_attr_accessor'
42
+ autoload :Base, 'action_mailer/base'
43
+ autoload :Helpers, 'action_mailer/helpers'
44
+ autoload :Part, 'action_mailer/part'
45
+ autoload :PartContainer, 'action_mailer/part_container'
46
+ autoload :Quoting, 'action_mailer/quoting'
47
+ autoload :TestCase, 'action_mailer/test_case'
48
+ autoload :TestHelper, 'action_mailer/test_helper'
49
+ autoload :Utils, 'action_mailer/utils'
50
+ end
44
51
 
45
- ActionMailer::Base.class_eval do
46
- include ActionMailer::Quoting
47
- include ActionMailer::Helpers
52
+ module Text
53
+ autoload :Format, 'action_mailer/vendor/text_format'
54
+ end
48
55
 
49
- helper MailHelper
56
+ module Net
57
+ autoload :SMTP, 'net/smtp'
50
58
  end
51
59
 
52
- silence_warnings { TMail::Encoder.const_set("MAX_LINE_LEN", 200) }
60
+ autoload :MailHelper, 'action_mailer/mail_helper'
61
+
62
+ require 'action_mailer/vendor/tmail'
@@ -1,9 +1,3 @@
1
- require 'action_mailer/adv_attr_accessor'
2
- require 'action_mailer/part'
3
- require 'action_mailer/part_container'
4
- require 'action_mailer/utils'
5
- require 'tmail/net'
6
-
7
1
  module ActionMailer #:nodoc:
8
2
  # Action Mailer allows you to send email from your application using a mailer model and views.
9
3
  #
@@ -23,6 +17,7 @@ module ActionMailer #:nodoc:
23
17
  # class Notifier < ActionMailer::Base
24
18
  # def signup_notification(recipient)
25
19
  # recipients recipient.email_address_with_name
20
+ # bcc ["bcc@example.com", "Order Watcher <watcher@example.com>"]
26
21
  # from "system@example.com"
27
22
  # subject "New account information"
28
23
  # body :account => recipient
@@ -218,6 +213,8 @@ module ActionMailer #:nodoc:
218
213
  # * <tt>:password</tt> - If your mail server requires authentication, set the password in this setting.
219
214
  # * <tt>:authentication</tt> - If your mail server requires authentication, you need to specify the authentication type here.
220
215
  # This is a symbol and one of <tt>:plain</tt>, <tt>:login</tt>, <tt>:cram_md5</tt>.
216
+ # * <tt>:enable_starttls_auto</tt> - When set to true, detects if STARTTLS is enabled in your SMTP server and starts to use it.
217
+ # It works only on Ruby >= 1.8.7 and Ruby >= 1.9. Default is true.
221
218
  #
222
219
  # * <tt>sendmail_settings</tt> - Allows you to override options for the <tt>:sendmail</tt> delivery method.
223
220
  # * <tt>:location</tt> - The location of the sendmail executable. Defaults to <tt>/usr/sbin/sendmail</tt>.
@@ -235,17 +232,20 @@ module ActionMailer #:nodoc:
235
232
  #
236
233
  # * <tt>default_charset</tt> - The default charset used for the body and to encode the subject. Defaults to UTF-8. You can also
237
234
  # pick a different charset from inside a method with +charset+.
235
+ #
238
236
  # * <tt>default_content_type</tt> - The default content type used for the main part of the message. Defaults to "text/plain". You
239
237
  # can also pick a different content type from inside a method with +content_type+.
238
+ #
240
239
  # * <tt>default_mime_version</tt> - The default mime version used for the message. Defaults to <tt>1.0</tt>. You
241
240
  # can also pick a different value from inside a method with +mime_version+.
241
+ #
242
242
  # * <tt>default_implicit_parts_order</tt> - When a message is built implicitly (i.e. multiple parts are assembled from templates
243
243
  # which specify the content type in their filenames) this variable controls how the parts are ordered. Defaults to
244
244
  # <tt>["text/html", "text/enriched", "text/plain"]</tt>. Items that appear first in the array have higher priority in the mail client
245
245
  # and appear last in the mime encoded message. You can also pick a different order from inside a method with
246
246
  # +implicit_parts_order+.
247
247
  class Base
248
- include AdvAttrAccessor, PartContainer
248
+ include AdvAttrAccessor, PartContainer, Quoting, Utils
249
249
  if Object.const_defined?(:ActionController)
250
250
  include ActionController::UrlWriter
251
251
  include ActionController::Layout
@@ -254,15 +254,18 @@ module ActionMailer #:nodoc:
254
254
  private_class_method :new #:nodoc:
255
255
 
256
256
  class_inheritable_accessor :view_paths
257
+ self.view_paths = []
258
+
257
259
  cattr_accessor :logger
258
260
 
259
261
  @@smtp_settings = {
260
- :address => "localhost",
261
- :port => 25,
262
- :domain => 'localhost.localdomain',
263
- :user_name => nil,
264
- :password => nil,
265
- :authentication => nil
262
+ :address => "localhost",
263
+ :port => 25,
264
+ :domain => 'localhost.localdomain',
265
+ :user_name => nil,
266
+ :password => nil,
267
+ :authentication => nil,
268
+ :enable_starttls_auto => true,
266
269
  }
267
270
  cattr_accessor :smtp_settings
268
271
 
@@ -426,12 +429,6 @@ module ActionMailer #:nodoc:
426
429
  new.deliver!(mail)
427
430
  end
428
431
 
429
- def register_template_extension(extension)
430
- ActiveSupport::Deprecation.warn(
431
- "ActionMailer::Base.register_template_extension has been deprecated." +
432
- "Use ActionView::Template.register_template_handler instead", caller)
433
- end
434
-
435
432
  def template_root
436
433
  self.view_paths && self.view_paths.first
437
434
  end
@@ -482,7 +479,7 @@ module ActionMailer #:nodoc:
482
479
  )
483
480
  end
484
481
  unless @parts.empty?
485
- @content_type = "multipart/alternative"
482
+ @content_type = "multipart/alternative" if @content_type !~ /^multipart/
486
483
  @parts = sort_parts(@parts, @implicit_parts_order)
487
484
  end
488
485
  end
@@ -581,7 +578,9 @@ module ActionMailer #:nodoc:
581
578
  end
582
579
 
583
580
  def candidate_for_layout?(options)
584
- !@template.send(:_exempt_from_layout?, default_template_name)
581
+ !self.view_paths.find_template(default_template_name, default_template_format).exempt_from_layout?
582
+ rescue ActionView::MissingTemplate
583
+ return true
585
584
  end
586
585
 
587
586
  def template_root
@@ -597,7 +596,7 @@ module ActionMailer #:nodoc:
597
596
  end
598
597
 
599
598
  def initialize_template_class(assigns)
600
- template = ActionView::Base.new(view_paths, assigns, self)
599
+ template = ActionView::Base.new(self.class.view_paths, assigns, self)
601
600
  template.template_format = default_template_format
602
601
  template
603
602
  end
@@ -648,11 +647,11 @@ module ActionMailer #:nodoc:
648
647
 
649
648
  if @parts.empty?
650
649
  m.set_content_type(real_content_type, nil, ctype_attrs)
651
- m.body = Utils.normalize_new_lines(body)
650
+ m.body = normalize_new_lines(body)
652
651
  else
653
652
  if String === body
654
653
  part = TMail::Mail.new
655
- part.body = Utils.normalize_new_lines(body)
654
+ part.body = normalize_new_lines(body)
656
655
  part.set_content_type(real_content_type, nil, ctype_attrs)
657
656
  part.set_content_disposition "inline"
658
657
  m.parts << part
@@ -675,10 +674,10 @@ module ActionMailer #:nodoc:
675
674
  def perform_delivery_smtp(mail)
676
675
  destinations = mail.destinations
677
676
  mail.ready_to_send
678
- sender = mail['return-path'] || mail.from
677
+ sender = (mail['return-path'] && mail['return-path'].spec) || mail.from
679
678
 
680
679
  smtp = Net::SMTP.new(smtp_settings[:address], smtp_settings[:port])
681
- smtp.enable_starttls_auto if smtp.respond_to?(:enable_starttls_auto)
680
+ smtp.enable_starttls_auto if smtp_settings[:enable_starttls_auto] && smtp.respond_to?(:enable_starttls_auto)
682
681
  smtp.start(smtp_settings[:domain], smtp_settings[:user_name], smtp_settings[:password],
683
682
  smtp_settings[:authentication]) do |smtp|
684
683
  smtp.sendmail(mail.encoded, sender, destinations)
@@ -698,4 +697,9 @@ module ActionMailer #:nodoc:
698
697
  deliveries << mail
699
698
  end
700
699
  end
700
+
701
+ Base.class_eval do
702
+ include Helpers
703
+ helper MailHelper
704
+ end
701
705
  end
@@ -1,3 +1,5 @@
1
+ require 'active_support/dependencies'
2
+
1
3
  module ActionMailer
2
4
  module Helpers #:nodoc:
3
5
  def self.included(base) #:nodoc:
@@ -1,5 +1,3 @@
1
- require 'text/format'
2
-
3
1
  module MailHelper
4
2
  # Uses Text::Format to take the text and format it, indented two spaces for
5
3
  # each line, and wrapped at 72 columns.
@@ -1,15 +1,10 @@
1
- require 'action_mailer/adv_attr_accessor'
2
- require 'action_mailer/part_container'
3
- require 'action_mailer/utils'
4
-
5
1
  module ActionMailer
6
2
  # Represents a subpart of an email message. It shares many similar
7
3
  # attributes of ActionMailer::Base. Although you can create parts manually
8
4
  # and add them to the +parts+ list of the mailer, it is easier
9
5
  # to use the helper methods in ActionMailer::PartContainer.
10
6
  class Part
11
- include ActionMailer::AdvAttrAccessor
12
- include ActionMailer::PartContainer
7
+ include AdvAttrAccessor, PartContainer, Utils
13
8
 
14
9
  # Represents the body of the part, as a string. This should not be a
15
10
  # Hash (like ActionMailer::Base), but if you want a template to be rendered
@@ -64,7 +59,7 @@ module ActionMailer
64
59
  when "base64" then
65
60
  part.body = TMail::Base64.folding_encode(body)
66
61
  when "quoted-printable"
67
- part.body = [Utils.normalize_new_lines(body)].pack("M*")
62
+ part.body = [normalize_new_lines(body)].pack("M*")
68
63
  else
69
64
  part.body = body
70
65
  end
@@ -93,7 +88,10 @@ module ActionMailer
93
88
  part.parts << prt
94
89
  end
95
90
 
96
- part.set_content_type(real_content_type, nil, ctype_attrs) if real_content_type =~ /multipart/
91
+ if real_content_type =~ /multipart/
92
+ ctype_attrs.delete 'charset'
93
+ part.set_content_type(real_content_type, nil, ctype_attrs)
94
+ end
97
95
  end
98
96
 
99
97
  headers.each { |k,v| part[k] = v }
@@ -102,7 +100,6 @@ module ActionMailer
102
100
  end
103
101
 
104
102
  private
105
-
106
103
  def squish(values={})
107
104
  values.delete_if { |k,v| v.nil? }
108
105
  end
@@ -41,7 +41,11 @@ module ActionMailer
41
41
  private
42
42
 
43
43
  def parse_content_type(defaults=nil)
44
- return [defaults && defaults.content_type, {}] if content_type.blank?
44
+ if content_type.blank?
45
+ return defaults ?
46
+ [ defaults.content_type, { 'charset' => defaults.charset } ] :
47
+ [ nil, {} ]
48
+ end
45
49
  ctype, *attrs = content_type.split(/;\s*/)
46
50
  attrs = attrs.inject({}) { |h,s| k,v = s.split(/=/, 2); h[k] = v; h }
47
51
  [ctype, {"charset" => charset || defaults && defaults.charset}.merge(attrs)]
@@ -12,7 +12,7 @@ module ActionMailer
12
12
  # account multi-byte characters (if executing with $KCODE="u", for instance)
13
13
  def quoted_printable_encode(character)
14
14
  result = ""
15
- character.each_byte { |b| result << "=%02x" % b }
15
+ character.each_byte { |b| result << "=%02X" % b }
16
16
  result
17
17
  end
18
18
 
@@ -10,7 +10,7 @@ module ActionMailer
10
10
  end
11
11
 
12
12
  class TestCase < ActiveSupport::TestCase
13
- include ActionMailer::Quoting
13
+ include Quoting, TestHelper
14
14
 
15
15
  setup :initialize_test_deliveries
16
16
  setup :set_expected_mail
@@ -58,6 +58,7 @@ module ActionMailer
58
58
  end
59
59
  end
60
60
 
61
+ # TODO: Deprecate this
61
62
  module Test
62
63
  module Unit
63
64
  class TestCase
@@ -3,6 +3,5 @@ module ActionMailer
3
3
  def normalize_new_lines(text)
4
4
  text.to_s.gsub(/\r\n?/, "\n")
5
5
  end
6
- module_function :normalize_new_lines
7
6
  end
8
7
  end
@@ -1150,7 +1150,7 @@ if __FILE__ == $0
1150
1150
  assert_equal(Text::Format::JUSTIFY, @format_o.format_style)
1151
1151
  assert_match(/^of freedom, and that government of the people, by the people, for the$/,
1152
1152
  @format_o.format(GETTYSBURG).split("\n")[-3])
1153
- assert_raises(ArgumentError) { @format_o.format_style = 33 }
1153
+ assert_raise(ArgumentError) { @format_o.format_style = 33 }
1154
1154
  end
1155
1155
 
1156
1156
  def test_tag_paragraph
@@ -0,0 +1,10 @@
1
+ # Prefer gems to the bundled libs.
2
+ require 'rubygems'
3
+
4
+ begin
5
+ gem 'text-format', '>= 0.6.3'
6
+ rescue Gem::LoadError
7
+ $:.unshift "#{File.dirname(__FILE__)}/text-format-0.6.3"
8
+ end
9
+
10
+ require 'text/format'
@@ -0,0 +1,17 @@
1
+ # Prefer gems to the bundled libs.
2
+ require 'rubygems'
3
+
4
+ begin
5
+ gem 'tmail', '~> 1.2.3'
6
+ rescue Gem::LoadError
7
+ $:.unshift "#{File.dirname(__FILE__)}/tmail-1.2.3"
8
+ end
9
+
10
+ module TMail
11
+ end
12
+
13
+ require 'tmail'
14
+
15
+ silence_warnings do
16
+ TMail::Encoder.const_set("MAX_LINE_LEN", 200)
17
+ end
@@ -1,8 +1,8 @@
1
1
  module ActionMailer
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 2
4
- MINOR = 2
5
- TINY = 3
4
+ MINOR = 3
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -1,5 +1,9 @@
1
+ require 'rubygems'
1
2
  require 'test/unit'
2
3
 
4
+ gem 'mocha', '>= 0.9.5'
5
+ require 'mocha'
6
+
3
7
  $:.unshift "#{File.dirname(__FILE__)}/../lib"
4
8
  $:.unshift "#{File.dirname(__FILE__)}/../../activesupport/lib"
5
9
  $:.unshift "#{File.dirname(__FILE__)}/../../actionpack/lib"
@@ -9,8 +13,15 @@ require 'action_mailer/test_case'
9
13
  # Show backtraces for deprecated behavior for quicker cleanup.
10
14
  ActiveSupport::Deprecation.debug = true
11
15
 
16
+ # Bogus template processors
17
+ ActionView::Template.register_template_handler :haml, lambda { |template| "Look its HAML!".inspect }
18
+ ActionView::Template.register_template_handler :bak, lambda { |template| "Lame backup".inspect }
19
+
12
20
  $:.unshift "#{File.dirname(__FILE__)}/fixtures/helpers"
13
- ActionMailer::Base.template_root = "#{File.dirname(__FILE__)}/fixtures"
21
+
22
+ ActionView::Base.cache_template_loading = true
23
+ FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures')
24
+ ActionMailer::Base.template_root = FIXTURE_LOAD_PATH
14
25
 
15
26
  class MockSMTP
16
27
  def self.deliveries
@@ -37,7 +48,6 @@ class Net::SMTP
37
48
  end
38
49
 
39
50
  def uses_gem(gem_name, test_name, version = '> 0')
40
- require 'rubygems'
41
51
  gem gem_name.to_s, version
42
52
  require gem_name.to_s
43
53
  yield
@@ -45,13 +55,6 @@ rescue LoadError
45
55
  $stderr.puts "Skipping #{test_name} tests. `gem install #{gem_name}` and try again."
46
56
  end
47
57
 
48
- # Wrap tests that use Mocha and skip if unavailable.
49
- unless defined? uses_mocha
50
- def uses_mocha(test_name, &block)
51
- uses_gem('mocha', test_name, '>= 0.5.5', &block)
52
- end
53
- end
54
-
55
58
  def set_delivery_method(delivery_method)
56
59
  @old_delivery_method = ActionMailer::Base.delivery_method
57
60
  ActionMailer::Base.delivery_method = delivery_method
@@ -0,0 +1,54 @@
1
+ require 'abstract_unit'
2
+
3
+ class AssetHostMailer < ActionMailer::Base
4
+ def email_with_asset(recipient)
5
+ recipients recipient
6
+ subject "testing email containing asset path while asset_host is set"
7
+ from "tester@example.com"
8
+ end
9
+ end
10
+
11
+ class AssetHostTest < Test::Unit::TestCase
12
+ def setup
13
+ set_delivery_method :test
14
+ ActionMailer::Base.perform_deliveries = true
15
+ ActionMailer::Base.deliveries = []
16
+
17
+ @recipient = 'test@localhost'
18
+ end
19
+
20
+ def teardown
21
+ restore_delivery_method
22
+ end
23
+
24
+ def test_asset_host_as_string
25
+ ActionController::Base.asset_host = "http://www.example.com"
26
+ mail = AssetHostMailer.deliver_email_with_asset(@recipient)
27
+ assert_equal "<img alt=\"Somelogo\" src=\"http://www.example.com/images/somelogo.png\" />", mail.body.strip
28
+ end
29
+
30
+ def test_asset_host_as_one_arguement_proc
31
+ ActionController::Base.asset_host = Proc.new { |source|
32
+ if source.starts_with?('/images')
33
+ "http://images.example.com"
34
+ else
35
+ "http://assets.example.com"
36
+ end
37
+ }
38
+ mail = AssetHostMailer.deliver_email_with_asset(@recipient)
39
+ assert_equal "<img alt=\"Somelogo\" src=\"http://images.example.com/images/somelogo.png\" />", mail.body.strip
40
+ end
41
+
42
+ def test_asset_host_as_two_arguement_proc
43
+ ActionController::Base.asset_host = Proc.new {|source,request|
44
+ if request && request.ssl?
45
+ "https://www.example.com"
46
+ else
47
+ "http://www.example.com"
48
+ end
49
+ }
50
+ mail = nil
51
+ assert_nothing_raised { mail = AssetHostMailer.deliver_email_with_asset(@recipient) }
52
+ assert_equal "<img alt=\"Somelogo\" src=\"http://www.example.com/images/somelogo.png\" />", mail.body.strip
53
+ end
54
+ end
@@ -0,0 +1 @@
1
+ <%= image_tag "somelogo.png" %>
@@ -21,10 +21,12 @@ class AutoLayoutMailer < ActionMailer::Base
21
21
  body render(:inline => "Hello, <%= @world %>", :layout => false, :body => { :world => "Earth" })
22
22
  end
23
23
 
24
- def multipart(recipient)
24
+ def multipart(recipient, type = nil)
25
25
  recipients recipient
26
26
  subject "You have a mail"
27
27
  from "tester@example.com"
28
+
29
+ content_type(type) if type
28
30
  end
29
31
  end
30
32
 
@@ -64,6 +66,19 @@ class LayoutMailerTest < Test::Unit::TestCase
64
66
 
65
67
  def test_should_pickup_multipart_layout
66
68
  mail = AutoLayoutMailer.create_multipart(@recipient)
69
+ assert_equal "multipart/alternative", mail.content_type
70
+ assert_equal 2, mail.parts.size
71
+
72
+ assert_equal 'text/plain', mail.parts.first.content_type
73
+ assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body
74
+
75
+ assert_equal 'text/html', mail.parts.last.content_type
76
+ assert_equal "Hello from layout text/html multipart", mail.parts.last.body
77
+ end
78
+
79
+ def test_should_pickup_multipartmixed_layout
80
+ mail = AutoLayoutMailer.create_multipart(@recipient, "multipart/mixed")
81
+ assert_equal "multipart/mixed", mail.content_type
67
82
  assert_equal 2, mail.parts.size
68
83
 
69
84
  assert_equal 'text/plain', mail.parts.first.content_type
@@ -73,6 +88,19 @@ class LayoutMailerTest < Test::Unit::TestCase
73
88
  assert_equal "Hello from layout text/html multipart", mail.parts.last.body
74
89
  end
75
90
 
91
+ def test_should_fix_multipart_layout
92
+ mail = AutoLayoutMailer.create_multipart(@recipient, "text/plain")
93
+ assert_equal "multipart/alternative", mail.content_type
94
+ assert_equal 2, mail.parts.size
95
+
96
+ assert_equal 'text/plain', mail.parts.first.content_type
97
+ assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body
98
+
99
+ assert_equal 'text/html', mail.parts.last.content_type
100
+ assert_equal "Hello from layout text/html multipart", mail.parts.last.body
101
+ end
102
+
103
+
76
104
  def test_should_pickup_layout_given_to_render
77
105
  mail = AutoLayoutMailer.create_spam(@recipient)
78
106
  assert_equal "Spammer layout Hello, Earth", mail.body.strip
@@ -289,8 +289,6 @@ class TestMailer < ActionMailer::Base
289
289
  end
290
290
  end
291
291
 
292
- uses_mocha 'ActionMailerTest' do
293
-
294
292
  class ActionMailerTest < Test::Unit::TestCase
295
293
  include ActionMailer::Quoting
296
294
 
@@ -332,6 +330,7 @@ class ActionMailerTest < Test::Unit::TestCase
332
330
  assert_equal "multipart/mixed", created.content_type
333
331
  assert_equal "multipart/alternative", created.parts.first.content_type
334
332
  assert_equal "bar", created.parts.first.header['foo'].to_s
333
+ assert_nil created.parts.first.charset
335
334
  assert_equal "text/plain", created.parts.first.parts.first.content_type
336
335
  assert_equal "text/html", created.parts.first.parts[1].content_type
337
336
  assert_equal "application/octet-stream", created.parts[1].content_type
@@ -389,6 +388,8 @@ class ActionMailerTest < Test::Unit::TestCase
389
388
  end
390
389
 
391
390
  def test_custom_templating_extension
391
+ assert ActionView::Template.template_handler_extensions.include?("haml"), "haml extension was not registered"
392
+
392
393
  # N.b., custom_templating_extension.text.plain.haml is expected to be in fixtures/test_mailer directory
393
394
  expected = new_mail
394
395
  expected.to = @recipient
@@ -799,6 +800,8 @@ EOF
799
800
  end
800
801
 
801
802
  def test_implicitly_multipart_messages
803
+ assert ActionView::Template.template_handler_extensions.include?("bak"), "bak extension was not registered"
804
+
802
805
  mail = TestMailer.create_implicitly_multipart_example(@recipient)
803
806
  assert_equal 3, mail.parts.length
804
807
  assert_equal "1.0", mail.mime_version
@@ -812,6 +815,8 @@ EOF
812
815
  end
813
816
 
814
817
  def test_implicitly_multipart_messages_with_custom_order
818
+ assert ActionView::Template.template_handler_extensions.include?("bak"), "bak extension was not registered"
819
+
815
820
  mail = TestMailer.create_implicitly_multipart_example(@recipient, nil, ["text/yaml", "text/plain"])
816
821
  assert_equal 3, mail.parts.length
817
822
  assert_equal "text/html", mail.parts[0].content_type
@@ -915,6 +920,8 @@ EOF
915
920
  def test_multipart_with_template_path_with_dots
916
921
  mail = FunkyPathMailer.create_multipart_with_template_path_with_dots(@recipient)
917
922
  assert_equal 2, mail.parts.length
923
+ assert_equal 'text/plain', mail.parts[0].content_type
924
+ assert_equal 'utf-8', mail.parts[0].charset
918
925
  end
919
926
 
920
927
  def test_custom_content_type_attributes
@@ -932,6 +939,7 @@ EOF
932
939
  ActionMailer::Base.delivery_method = :smtp
933
940
  TestMailer.deliver_return_path
934
941
  assert_match %r{^Return-Path: <another@somewhere.test>}, MockSMTP.deliveries[0][0]
942
+ assert_equal "another@somewhere.test", MockSMTP.deliveries[0][1].to_s
935
943
  end
936
944
 
937
945
  def test_body_is_stored_as_an_ivar
@@ -940,6 +948,7 @@ EOF
940
948
  end
941
949
 
942
950
  def test_starttls_is_enabled_if_supported
951
+ ActionMailer::Base.smtp_settings[:enable_starttls_auto] = true
943
952
  MockSMTP.any_instance.expects(:respond_to?).with(:enable_starttls_auto).returns(true)
944
953
  MockSMTP.any_instance.expects(:enable_starttls_auto)
945
954
  ActionMailer::Base.delivery_method = :smtp
@@ -947,25 +956,34 @@ EOF
947
956
  end
948
957
 
949
958
  def test_starttls_is_disabled_if_not_supported
959
+ ActionMailer::Base.smtp_settings[:enable_starttls_auto] = true
950
960
  MockSMTP.any_instance.expects(:respond_to?).with(:enable_starttls_auto).returns(false)
951
961
  MockSMTP.any_instance.expects(:enable_starttls_auto).never
952
962
  ActionMailer::Base.delivery_method = :smtp
953
963
  TestMailer.deliver_signed_up(@recipient)
954
964
  end
955
- end
956
965
 
957
- end # uses_mocha
966
+ def test_starttls_is_not_enabled
967
+ ActionMailer::Base.smtp_settings[:enable_starttls_auto] = false
968
+ MockSMTP.any_instance.expects(:respond_to?).never
969
+ MockSMTP.any_instance.expects(:enable_starttls_auto).never
970
+ ActionMailer::Base.delivery_method = :smtp
971
+ TestMailer.deliver_signed_up(@recipient)
972
+ ensure
973
+ ActionMailer::Base.smtp_settings[:enable_starttls_auto] = true
974
+ end
975
+ end
958
976
 
959
977
  class InheritableTemplateRootTest < Test::Unit::TestCase
960
978
  def test_attr
961
979
  expected = "#{File.dirname(__FILE__)}/fixtures/path.with.dots"
962
- assert_equal expected, FunkyPathMailer.template_root
980
+ assert_equal expected, FunkyPathMailer.template_root.to_s
963
981
 
964
982
  sub = Class.new(FunkyPathMailer)
965
983
  sub.template_root = 'test/path'
966
984
 
967
- assert_equal 'test/path', sub.template_root
968
- assert_equal expected, FunkyPathMailer.template_root
985
+ assert_equal 'test/path', sub.template_root.to_s
986
+ assert_equal expected, FunkyPathMailer.template_root.to_s
969
987
  end
970
988
  end
971
989
 
@@ -1051,7 +1069,7 @@ class RespondToTest < Test::Unit::TestCase
1051
1069
  end
1052
1070
 
1053
1071
  def test_should_still_raise_exception_with_expected_message_when_calling_an_undefined_method
1054
- error = assert_raises NoMethodError do
1072
+ error = assert_raise NoMethodError do
1055
1073
  RespondToMailer.not_a_method
1056
1074
  end
1057
1075
 
data/test/quoting_test.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  # encoding: utf-8
2
2
  require 'abstract_unit'
3
- require 'tmail'
4
3
  require 'tempfile'
5
4
 
6
5
  class QuotingTest < Test::Unit::TestCase
@@ -49,8 +48,10 @@ class QuotingTest < Test::Unit::TestCase
49
48
 
50
49
  result = execute_in_sandbox(<<-CODE)
51
50
  $:.unshift(File.dirname(__FILE__) + "/../lib/")
52
- $KCODE = 'u'
53
- require 'jcode'
51
+ if RUBY_VERSION < '1.9'
52
+ $KCODE = 'u'
53
+ require 'jcode'
54
+ end
54
55
  require 'action_mailer/quoting'
55
56
  include ActionMailer::Quoting
56
57
  quoted_printable(#{original.inspect}, "UTF-8")
@@ -26,7 +26,7 @@ class TestHelperMailerTest < ActionMailer::TestCase
26
26
  end
27
27
 
28
28
  def test_determine_default_mailer_raises_correct_error
29
- assert_raises(ActionMailer::NonInferrableMailerError) do
29
+ assert_raise(ActionMailer::NonInferrableMailerError) do
30
30
  self.class.determine_default_mailer("NotAMailerTest")
31
31
  end
32
32
  end
@@ -36,7 +36,7 @@ class TestHelperMailerTest < ActionMailer::TestCase
36
36
  end
37
37
 
38
38
  def test_encode
39
- assert_equal "=?utf-8?Q?=0aasdf=0a?=", encode("\nasdf\n")
39
+ assert_equal "=?utf-8?Q?=0Aasdf=0A?=", encode("\nasdf\n")
40
40
  end
41
41
 
42
42
  def test_assert_emails
@@ -84,7 +84,7 @@ class TestHelperMailerTest < ActionMailer::TestCase
84
84
  end
85
85
 
86
86
  def test_assert_emails_too_few_sent
87
- error = assert_raises Test::Unit::AssertionFailedError do
87
+ error = assert_raise ActiveSupport::TestCase::Assertion do
88
88
  assert_emails 2 do
89
89
  TestHelperMailer.deliver_test
90
90
  end
@@ -94,7 +94,7 @@ class TestHelperMailerTest < ActionMailer::TestCase
94
94
  end
95
95
 
96
96
  def test_assert_emails_too_many_sent
97
- error = assert_raises Test::Unit::AssertionFailedError do
97
+ error = assert_raise ActiveSupport::TestCase::Assertion do
98
98
  assert_emails 1 do
99
99
  TestHelperMailer.deliver_test
100
100
  TestHelperMailer.deliver_test
@@ -105,7 +105,7 @@ class TestHelperMailerTest < ActionMailer::TestCase
105
105
  end
106
106
 
107
107
  def test_assert_no_emails_failure
108
- error = assert_raises Test::Unit::AssertionFailedError do
108
+ error = assert_raise ActiveSupport::TestCase::Assertion do
109
109
  assert_no_emails do
110
110
  TestHelperMailer.deliver_test
111
111
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionmailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
@@ -9,7 +9,7 @@ autorequire: action_mailer
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-28 00:00:00 +13:00
12
+ date: 2009-03-15 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - "="
22
22
  - !ruby/object:Gem::Version
23
- version: 2.2.3
23
+ version: 2.3.2
24
24
  version:
25
25
  description: Makes it trivial to test and deliver emails sent from a single service layer.
26
26
  email: david@loudthinking.com
@@ -36,6 +36,7 @@ files:
36
36
  - README
37
37
  - CHANGELOG
38
38
  - MIT-LICENSE
39
+ - lib/action_mailer
39
40
  - lib/action_mailer/adv_attr_accessor.rb
40
41
  - lib/action_mailer/base.rb
41
42
  - lib/action_mailer/helpers.rb
@@ -46,7 +47,13 @@ files:
46
47
  - lib/action_mailer/test_case.rb
47
48
  - lib/action_mailer/test_helper.rb
48
49
  - lib/action_mailer/utils.rb
50
+ - lib/action_mailer/vendor
51
+ - lib/action_mailer/vendor/text-format-0.6.3
52
+ - lib/action_mailer/vendor/text-format-0.6.3/text
49
53
  - lib/action_mailer/vendor/text-format-0.6.3/text/format.rb
54
+ - lib/action_mailer/vendor/text_format.rb
55
+ - lib/action_mailer/vendor/tmail-1.2.3
56
+ - lib/action_mailer/vendor/tmail-1.2.3/tmail
50
57
  - lib/action_mailer/vendor/tmail-1.2.3/tmail/address.rb
51
58
  - lib/action_mailer/vendor/tmail-1.2.3/tmail/attachments.rb
52
59
  - lib/action_mailer/vendor/tmail-1.2.3/tmail/base64.rb
@@ -74,26 +81,38 @@ files:
74
81
  - lib/action_mailer/vendor/tmail-1.2.3/tmail/utils.rb
75
82
  - lib/action_mailer/vendor/tmail-1.2.3/tmail/version.rb
76
83
  - lib/action_mailer/vendor/tmail-1.2.3/tmail.rb
77
- - lib/action_mailer/vendor.rb
84
+ - lib/action_mailer/vendor/tmail.rb
78
85
  - lib/action_mailer/version.rb
79
86
  - lib/action_mailer.rb
80
87
  - lib/actionmailer.rb
81
88
  - test/abstract_unit.rb
89
+ - test/asset_host_test.rb
82
90
  - test/delivery_method_test.rb
91
+ - test/fixtures
92
+ - test/fixtures/asset_host_mailer
93
+ - test/fixtures/asset_host_mailer/email_with_asset.html.erb
94
+ - test/fixtures/auto_layout_mailer
83
95
  - test/fixtures/auto_layout_mailer/hello.html.erb
84
96
  - test/fixtures/auto_layout_mailer/multipart.text.html.erb
85
97
  - test/fixtures/auto_layout_mailer/multipart.text.plain.erb
98
+ - test/fixtures/explicit_layout_mailer
86
99
  - test/fixtures/explicit_layout_mailer/logout.html.erb
87
100
  - test/fixtures/explicit_layout_mailer/signup.html.erb
101
+ - test/fixtures/first_mailer
88
102
  - test/fixtures/first_mailer/share.erb
103
+ - test/fixtures/helper_mailer
89
104
  - test/fixtures/helper_mailer/use_example_helper.erb
90
105
  - test/fixtures/helper_mailer/use_helper.erb
91
106
  - test/fixtures/helper_mailer/use_helper_method.erb
92
107
  - test/fixtures/helper_mailer/use_mail_helper.erb
108
+ - test/fixtures/helpers
93
109
  - test/fixtures/helpers/example_helper.rb
110
+ - test/fixtures/layouts
94
111
  - test/fixtures/layouts/auto_layout_mailer.html.erb
95
112
  - test/fixtures/layouts/auto_layout_mailer.text.erb
96
113
  - test/fixtures/layouts/spam.html.erb
114
+ - test/fixtures/path.with.dots
115
+ - test/fixtures/path.with.dots/funky_path_mailer
97
116
  - test/fixtures/path.with.dots/funky_path_mailer/multipart_with_template_path_with_dots.erb
98
117
  - test/fixtures/raw_email
99
118
  - test/fixtures/raw_email10
@@ -111,8 +130,11 @@ files:
111
130
  - test/fixtures/raw_email_with_invalid_characters_in_content_type
112
131
  - test/fixtures/raw_email_with_nested_attachment
113
132
  - test/fixtures/raw_email_with_partially_quoted_subject
133
+ - test/fixtures/second_mailer
114
134
  - test/fixtures/second_mailer/share.erb
135
+ - test/fixtures/templates
115
136
  - test/fixtures/templates/signed_up.erb
137
+ - test/fixtures/test_mailer
116
138
  - test/fixtures/test_mailer/_subtemplate.text.plain.erb
117
139
  - test/fixtures/test_mailer/body_ivar.erb
118
140
  - test/fixtures/test_mailer/custom_templating_extension.text.html.haml
@@ -138,8 +160,6 @@ files:
138
160
  - test/url_test.rb
139
161
  has_rdoc: true
140
162
  homepage: http://www.rubyonrails.org
141
- licenses: []
142
-
143
163
  post_install_message:
144
164
  rdoc_options: []
145
165
 
@@ -160,9 +180,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
180
  requirements:
161
181
  - none
162
182
  rubyforge_project: actionmailer
163
- rubygems_version: 1.3.2
183
+ rubygems_version: 1.3.1
164
184
  signing_key:
165
- specification_version: 3
185
+ specification_version: 2
166
186
  summary: Service layer for easy email delivery and testing.
167
187
  test_files: []
168
188
 
@@ -1,14 +0,0 @@
1
- # Prefer gems to the bundled libs.
2
- require 'rubygems'
3
-
4
- begin
5
- gem 'tmail', '~> 1.2.3'
6
- rescue Gem::LoadError
7
- $:.unshift "#{File.dirname(__FILE__)}/vendor/tmail-1.2.3"
8
- end
9
-
10
- begin
11
- gem 'text-format', '>= 0.6.3'
12
- rescue Gem::LoadError
13
- $:.unshift "#{File.dirname(__FILE__)}/vendor/text-format-0.6.3"
14
- end