actionmailer 1.2.5 → 1.3.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.

data/CHANGELOG CHANGED
@@ -1,3 +1,28 @@
1
+ *1.3.0* (January 16th, 2007)
2
+
3
+ * Make mime version default to 1.0. closes #2323 [ror@andreas-s.net]
4
+
5
+ * Make sure quoted-printable text is decoded correctly when only portions of the text are encoded. closes #3154. [jon@siliconcircus.com]
6
+
7
+ * Make sure DOS newlines in quoted-printable text are normalized to unix newlines before unquoting. closes #4166 and #4452. [Jamis Buck]
8
+
9
+ * Fixed that iconv decoding should catch InvalidEncoding #3153 [jon@siliconcircus.com]
10
+
11
+ * Tighten rescue clauses. #5985 [james@grayproductions.net]
12
+
13
+ * Automatically included ActionController::UrlWriter, such that URL generation can happen within ActionMailer controllers. [DHH]
14
+
15
+ * Replace Reloadable with Reloadable::Deprecated. [Nicholas Seckar]
16
+
17
+ * Resolve action naming collision. #5520 [ssinghi@kreeti.com]
18
+
19
+ * ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, Marcel Molina Jr.]
20
+
21
+ * Replace alias method chaining with Module#alias_method_chain. [Marcel Molina Jr.]
22
+
23
+ * Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.]
24
+
25
+
1
26
  *1.2.5* (August 10th, 2006)
2
27
 
3
28
  * Depend on Action Pack 1.12.5
@@ -22,12 +47,12 @@
22
47
  * Depend on Action Pack 1.12.2
23
48
 
24
49
 
25
- *1.2.1* (April 6th, 2005)
50
+ *1.2.1* (April 6th, 2006)
26
51
 
27
52
  * Be part of Rails 1.1.1
28
53
 
29
54
 
30
- *1.2.0* (March 27th, 2005)
55
+ *1.2.0* (March 27th, 2006)
31
56
 
32
57
  * Nil charset caused subject line to be improperly quoted in implicitly multipart messages #2662 [ehalvorsen+rails@runbox.com]
33
58
 
@@ -1,4 +1,4 @@
1
- Copyright (c) 2004 David Heinemeier Hansson
1
+ Copyright (c) 2004-2006 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
@@ -1,7 +1,7 @@
1
1
  = Action Mailer -- Easy email delivery and testing
2
2
 
3
3
  Action Mailer is a framework for designing email-service layers. These layers
4
- are used to consolidate code for sending out forgotten passwords, welcoming
4
+ are used to consolidate code for sending out forgotten passwords, welcome
5
5
  wishes on signup, invoices for billing, and any other use case that requires
6
6
  a written notification to either a person or another system.
7
7
 
@@ -136,13 +136,10 @@ Action Mailer is released under the MIT license.
136
136
 
137
137
  == Support
138
138
 
139
- The Action Mailer homepage is http://actionmailer.rubyonrails.org. You can find
139
+ The Action Mailer homepage is http://www.rubyonrails.org. You can find
140
140
  the Action Mailer RubyForge page at http://rubyforge.org/projects/actionmailer.
141
141
  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.
146
-
147
- For other information, feel free to ask on the ruby-talk mailing list (which
148
- is mirrored to comp.lang.ruby) or contact mailto:david@loudthinking.com.
145
+ new feature to be submitted in the form of new unit tests.
data/Rakefile CHANGED
@@ -54,7 +54,7 @@ spec = Gem::Specification.new do |s|
54
54
  s.rubyforge_project = "actionmailer"
55
55
  s.homepage = "http://www.rubyonrails.org"
56
56
 
57
- s.add_dependency('actionpack', '= 1.12.5' + PKG_BUILD)
57
+ s.add_dependency('actionpack', '= 1.13.0' + PKG_BUILD)
58
58
 
59
59
  s.has_rdoc = true
60
60
  s.requirements << 'none'
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2004 David Heinemeier Hansson
2
+ # Copyright (c) 2004-2006 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
@@ -21,14 +21,13 @@
21
21
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  #++
23
23
 
24
- begin
25
- require 'action_controller'
26
- rescue LoadError
24
+ unless defined?(ActionController)
27
25
  begin
28
- require File.dirname(__FILE__) + '/../../actionpack/lib/action_controller'
26
+ $:.unshift "#{File.dirname(__FILE__)}/../../actionpack/lib"
27
+ require 'action_controller'
29
28
  rescue LoadError
30
29
  require 'rubygems'
31
- require_gem 'actionpack', '>= 1.9.1'
30
+ require_gem 'actionpack', '>= 1.12.5'
32
31
  end
33
32
  end
34
33
 
@@ -48,4 +47,4 @@ ActionMailer::Base.class_eval do
48
47
  helper MailHelper
49
48
  end
50
49
 
51
- silence_warnings { TMail::Encoder.const_set("MAX_LINE_LEN", 200) }
50
+ silence_warnings { TMail::Encoder.const_set("MAX_LINE_LEN", 200) }
@@ -1,7 +1,6 @@
1
1
  module ActionMailer
2
2
  module AdvAttrAccessor #:nodoc:
3
- def self.append_features(base)
4
- super
3
+ def self.included(base)
5
4
  base.extend(ClassMethods)
6
5
  end
7
6
 
@@ -7,7 +7,9 @@ require 'tmail/net'
7
7
  module ActionMailer #:nodoc:
8
8
  # ActionMailer allows you to send email from your application using a mailer model and views.
9
9
  #
10
+ #
10
11
  # = Mailer Models
12
+ #
11
13
  # To use ActionMailer, you need to create a mailer model.
12
14
  #
13
15
  # $ script/generate mailer Notifier
@@ -23,7 +25,7 @@ module ActionMailer #:nodoc:
23
25
  # recipients recipient.email_address_with_name
24
26
  # from "system@example.com"
25
27
  # subject "New account information"
26
- # body "account" => recipient
28
+ # body :account => recipient
27
29
  # end
28
30
  # end
29
31
  #
@@ -45,7 +47,9 @@ module ActionMailer #:nodoc:
45
47
  # in an instance variable <tt>@account</tt> with the value of <tt>recipient</tt> being accessible in the
46
48
  # view.
47
49
  #
48
- # = Mailer Views
50
+ #
51
+ # = Mailer views
52
+ #
49
53
  # Like ActionController, each mailer class has a corresponding view directory
50
54
  # in which each method of the class looks for a template with its name.
51
55
  # To define a template to be used with a mailing, create an <tt>.rhtml</tt> file with the same name as the method
@@ -59,7 +63,30 @@ module ActionMailer #:nodoc:
59
63
  # Hi <%= @account.name %>,
60
64
  # Thanks for joining our service! Please check back often.
61
65
  #
62
- # = Sending Mail
66
+ # You can even use Action Pack helpers in these views. For example:
67
+ #
68
+ # You got a new note!
69
+ # <%= truncate(note.body, 25) %>
70
+ #
71
+ #
72
+ # = Generating URLs for mailer views
73
+ #
74
+ # If your view includes URLs from the application, you need to use url_for in the mailing method instead of the view.
75
+ # Unlike controllers from Action Pack, the mailer instance doesn't have any context about the incoming request. That's
76
+ # why you need to jump this little hoop and supply all the details needed for the URL. Example:
77
+ #
78
+ # def signup_notification(recipient)
79
+ # recipients recipient.email_address_with_name
80
+ # from "system@example.com"
81
+ # subject "New account information"
82
+ # body :account => recipient,
83
+ # :home_page => url_for(:host => "example.com", :controller => "welcome", :action => "greeting")
84
+ # end
85
+ #
86
+ # You can now access @home_page in the template and get http://example.com/welcome/greeting.
87
+ #
88
+ # = Sending mail
89
+ #
63
90
  # Once a mailer action and template are defined, you can deliver your message or create it and save it
64
91
  # for delivery later:
65
92
  #
@@ -73,7 +100,9 @@ module ActionMailer #:nodoc:
73
100
  # like to deliver. The <tt>signup_notification</tt> method defined above is
74
101
  # delivered by invoking <tt>Notifier.deliver_signup_notification</tt>.
75
102
  #
76
- # = HTML Email
103
+ #
104
+ # = HTML email
105
+ #
77
106
  # To send mail as HTML, make sure your view (the <tt>.rhtml</tt> file) generates HTML and
78
107
  # set the content type to html.
79
108
  #
@@ -87,7 +116,9 @@ module ActionMailer #:nodoc:
87
116
  # end
88
117
  # end
89
118
  #
90
- # = Multipart Email
119
+ #
120
+ # = Multipart email
121
+ #
91
122
  # You can explicitly specify multipart messages:
92
123
  #
93
124
  # class ApplicationMailer < ActionMailer::Base
@@ -120,7 +151,9 @@ module ActionMailer #:nodoc:
120
151
  # with the corresponding content type. The same body hash is passed to
121
152
  # each template.
122
153
  #
154
+ #
123
155
  # = Attachments
156
+ #
124
157
  # Attachments can be added by using the +attachment+ method.
125
158
  #
126
159
  # Example:
@@ -141,6 +174,7 @@ module ActionMailer #:nodoc:
141
174
  # end
142
175
  # end
143
176
  #
177
+ #
144
178
  # = Configuration options
145
179
  #
146
180
  # These options are specified on the class level, like <tt>ActionMailer::Base.template_root = "/my/templates"</tt>
@@ -174,9 +208,8 @@ module ActionMailer #:nodoc:
174
208
  # pick a different charset from inside a method with <tt>@charset</tt>.
175
209
  # * <tt>default_content_type</tt> - The default content type used for the main part of the message. Defaults to "text/plain". You
176
210
  # can also pick a different content type from inside a method with <tt>@content_type</tt>.
177
- # * <tt>default_mime_version</tt> - The default mime version used for the message. Defaults to nil. You
178
- # can also pick a different value from inside a method with <tt>@mime_version</tt>. When multipart messages are in
179
- # use, <tt>@mime_version</tt> will be set to "1.0" if it is not set inside a method.
211
+ # * <tt>default_mime_version</tt> - The default mime version used for the message. Defaults to "1.0". You
212
+ # can also pick a different value from inside a method with <tt>@mime_version</tt>.
180
213
  # * <tt>default_implicit_parts_order</tt> - When a message is built implicitly (i.e. multiple parts are assembled from templates
181
214
  # which specify the content type in their filenames) this variable controls how the parts are ordered. Defaults to
182
215
  # ["text/html", "text/enriched", "text/plain"]. Items that appear first in the array have higher priority in the mail client
@@ -184,10 +217,11 @@ module ActionMailer #:nodoc:
184
217
  # <tt>@implicit_parts_order</tt>.
185
218
  class Base
186
219
  include AdvAttrAccessor, PartContainer
220
+ include ActionController::UrlWriter
187
221
 
188
222
  # Action Mailer subclasses should be reloaded by the dispatcher in Rails
189
223
  # when Dependencies.mechanism = :load.
190
- include Reloadable::Subclasses
224
+ include Reloadable::Deprecated
191
225
 
192
226
  private_class_method :new #:nodoc:
193
227
 
@@ -222,7 +256,7 @@ module ActionMailer #:nodoc:
222
256
  @@default_content_type = "text/plain"
223
257
  cattr_accessor :default_content_type
224
258
 
225
- @@default_mime_version = nil
259
+ @@default_mime_version = "1.0"
226
260
  cattr_accessor :default_mime_version
227
261
 
228
262
  @@default_implicit_parts_order = [ "text/html", "text/enriched", "text/plain" ]
@@ -348,7 +382,7 @@ module ActionMailer #:nodoc:
348
382
  templates.each do |path|
349
383
  # TODO: don't hardcode rhtml|rxml
350
384
  basename = File.basename(path)
351
- next unless md = /^([^\.]+)\.([^\.]+\.[^\+]+)\.(rhtml|rxml)$/.match(basename)
385
+ next unless md = /^([^\.]+)\.([^\.]+\.[^\.]+)\.(rhtml|rxml)$/.match(basename)
352
386
  template_name = basename
353
387
  content_type = md.captures[1].gsub('.', '/')
354
388
  @parts << Part.new(:content_type => content_type,
@@ -395,7 +429,7 @@ module ActionMailer #:nodoc:
395
429
 
396
430
  begin
397
431
  send("perform_delivery_#{delivery_method}", mail) if perform_deliveries
398
- rescue Object => e
432
+ rescue Exception => e # Net::SMTP errors or sendmail pipe errors
399
433
  raise e if raise_delivery_errors
400
434
  end
401
435
 
@@ -1,8 +1,6 @@
1
1
  module ActionMailer
2
2
  module Helpers #:nodoc:
3
- def self.append_features(base) #:nodoc:
4
- super
5
-
3
+ def self.included(base) #:nodoc:
6
4
  # Initialize the base module to aggregate its helpers.
7
5
  base.class_inheritable_accessor :master_helper_module
8
6
  base.master_helper_module = Module.new
@@ -13,14 +11,12 @@ module ActionMailer
13
11
  base.class_eval do
14
12
  # Wrap inherited to create a new master helper module for subclasses.
15
13
  class << self
16
- alias_method :inherited_without_helper, :inherited
17
- alias_method :inherited, :inherited_with_helper
14
+ alias_method_chain :inherited, :helper
18
15
  end
19
16
 
20
17
  # Wrap initialize_template_class to extend new template class
21
18
  # instances with the master helper module.
22
- alias_method :initialize_template_class_without_helper, :initialize_template_class
23
- alias_method :initialize_template_class, :initialize_template_class_with_helper
19
+ alias_method_chain :initialize_template_class, :helper
24
20
  end
25
21
  end
26
22
 
@@ -49,25 +49,31 @@ module TMail
49
49
  class << self
50
50
  def unquote_and_convert_to(text, to_charset, from_charset = "iso-8859-1", preserve_underscores=false)
51
51
  return "" if text.nil?
52
- if text =~ /^=\?(.*?)\?(.)\?(.*)\?=$/
53
- from_charset = $1
54
- quoting_method = $2
55
- text = $3
56
- case quoting_method.upcase
57
- when "Q" then
58
- unquote_quoted_printable_and_convert_to(text, to_charset, from_charset, preserve_underscores)
59
- when "B" then
60
- unquote_base64_and_convert_to(text, to_charset, from_charset)
61
- else
62
- raise "unknown quoting method #{quoting_method.inspect}"
63
- end
64
- else
65
- convert_to(text, to_charset, from_charset)
52
+ text.gsub(/(.*?)(?:(?:=\?(.*?)\?(.)\?(.*?)\?=)|$)/) do
53
+ before = $1
54
+ from_charset = $2
55
+ quoting_method = $3
56
+ text = $4
57
+
58
+ before = convert_to(before, to_charset, from_charset) if before.length > 0
59
+ before + case quoting_method
60
+ when "q", "Q" then
61
+ unquote_quoted_printable_and_convert_to(text, to_charset, from_charset, preserve_underscores)
62
+ when "b", "B" then
63
+ unquote_base64_and_convert_to(text, to_charset, from_charset)
64
+ when nil then
65
+ # will be nil at the end of the string, due to the nature of
66
+ # the regex used.
67
+ ""
68
+ else
69
+ raise "unknown quoting method #{quoting_method.inspect}"
70
+ end
66
71
  end
67
72
  end
68
73
 
69
74
  def unquote_quoted_printable_and_convert_to(text, to, from, preserve_underscores=false)
70
75
  text = text.gsub(/_/, " ") unless preserve_underscores
76
+ text = text.gsub(/\r\n|\r/, "\n") # normalize newlines
71
77
  convert_to(text.unpack("M*").first, to, from)
72
78
  end
73
79
 
@@ -80,7 +86,7 @@ module TMail
80
86
  def convert_to(text, to, from)
81
87
  return text unless to && from
82
88
  text ? Iconv.iconv(to, from, text).first : ""
83
- rescue Iconv::IllegalSequence, Errno::EINVAL
89
+ rescue Iconv::IllegalSequence, Iconv::InvalidEncoding, Errno::EINVAL
84
90
  # the 'from' parameter specifies a charset other than what the text
85
91
  # actually is...not much we can do in this case but just return the
86
92
  # unconverted text.
@@ -1,8 +1,8 @@
1
1
  module ActionMailer
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
- MINOR = 2
5
- TINY = 5
4
+ MINOR = 3
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -0,0 +1,30 @@
1
+ require 'test/unit'
2
+
3
+ $:.unshift "#{File.dirname(__FILE__)}/../lib"
4
+ require 'action_mailer'
5
+
6
+ # Show backtraces for deprecated behavior for quicker cleanup.
7
+ ActiveSupport::Deprecation.debug = true
8
+
9
+ $:.unshift "#{File.dirname(__FILE__)}/fixtures/helpers"
10
+ ActionMailer::Base.template_root = "#{File.dirname(__FILE__)}/fixtures"
11
+
12
+ class MockSMTP
13
+ def self.deliveries
14
+ @@deliveries
15
+ end
16
+
17
+ def initialize
18
+ @@deliveries = []
19
+ end
20
+
21
+ def sendmail(mail, from, to)
22
+ @@deliveries << [mail, from, to]
23
+ end
24
+ end
25
+
26
+ class Net::SMTP
27
+ def self.start(*args)
28
+ yield MockSMTP.new
29
+ end
30
+ end
@@ -0,0 +1 @@
1
+ first mail
@@ -1 +0,0 @@
1
- Have a lovely picture, from me. Enjoy!
@@ -0,0 +1,14 @@
1
+ Mime-Version: 1.0 (Apple Message framework v730)
2
+ Message-Id: <9169D984-4E0B-45EF-82D4-8F5E53AD7012@example.com>
3
+ From: foo@example.com
4
+ Subject: testing
5
+ Date: Mon, 6 Jun 2005 22:21:22 +0200
6
+ To: blah@example.com
7
+ Content-Transfer-Encoding: quoted-printable
8
+ Content-Type: text/plain
9
+
10
+ A fax has arrived from remote ID ''.=0D=0A-----------------------=
11
+ -------------------------------------=0D=0ATime: 3/9/2006 3:50:52=
12
+ PM=0D=0AReceived from remote ID: =0D=0AInbound user ID XXXXXXXXXX, r=
13
+ outing code XXXXXXXXX=0D=0AResult: (0/352;0/0) Successful Send=0D=0AP=
14
+ age record: 1 - 1=0D=0AElapsed time: 00:58 on channel 11=0D=0A
@@ -0,0 +1,14 @@
1
+ From jamis@37signals.com Mon May 2 16:07:05 2005
2
+ Mime-Version: 1.0 (Apple Message framework v622)
3
+ Content-Transfer-Encoding: base64
4
+ Message-Id: <d3b8cf8e49f04480850c28713a1f473e@37signals.com>
5
+ Content-Type: text/plain;
6
+ charset=EUC-KR;
7
+ format=flowed
8
+ To: jamis@37signals.com
9
+ From: Jamis Buck <jamis@37signals.com>
10
+ Subject: Re: Test: =?UTF-8?B?Iua8ouWtlyI=?= mid =?UTF-8?B?Iua8ouWtlyI=?= tail
11
+ Date: Mon, 2 May 2005 16:07:05 -0600
12
+
13
+ tOu6zrrQwMcguLbC+bChwfa3ziwgv+y4rrTCIMfPs6q01MC7ILnPvcC0z7TZLg0KDQrBpiDAzLin
14
+ wLogSmFtaXPA1LTPtNku
@@ -0,0 +1 @@
1
+ second mail
@@ -0,0 +1,3 @@
1
+ Hello there,
2
+
3
+ Mr. <%= @recipient %>. Please see our greeting at <%= @welcome_url %>
@@ -1,8 +1,4 @@
1
- $:.unshift(File.dirname(__FILE__) + "/../lib/")
2
- $:.unshift File.dirname(__FILE__) + "/fixtures/helpers"
3
-
4
- require 'test/unit'
5
- require 'action_mailer'
1
+ require "#{File.dirname(__FILE__)}/abstract_unit"
6
2
 
7
3
  module MailerHelper
8
4
  def person_name
@@ -56,8 +52,6 @@ class HelperMailer < ActionMailer::Base
56
52
  helper_method :name_of_the_mailer_class
57
53
  end
58
54
 
59
- HelperMailer.template_root = File.dirname(__FILE__) + "/fixtures"
60
-
61
55
  class MailerHelperTest < Test::Unit::TestCase
62
56
  def new_mail( charset="utf-8" )
63
57
  mail = TMail::Mail.new
@@ -1,7 +1,4 @@
1
- $:.unshift(File.dirname(__FILE__) + "/../lib/")
2
-
3
- require 'test/unit'
4
- require 'action_mailer'
1
+ require "#{File.dirname(__FILE__)}/abstract_unit"
5
2
 
6
3
  class RenderMailer < ActionMailer::Base
7
4
  def inline_template(recipient)
@@ -24,7 +21,21 @@ class RenderMailer < ActionMailer::Base
24
21
  end
25
22
  end
26
23
 
27
- RenderMailer.template_root = File.dirname(__FILE__) + "/fixtures"
24
+ class FirstMailer < ActionMailer::Base
25
+ def share(recipient)
26
+ recipients recipient
27
+ subject "using helpers"
28
+ from "tester@example.com"
29
+ end
30
+ end
31
+
32
+ class SecondMailer < ActionMailer::Base
33
+ def share(recipient)
34
+ recipients recipient
35
+ subject "using helpers"
36
+ from "tester@example.com"
37
+ end
38
+ end
28
39
 
29
40
  class RenderHelperTest < Test::Unit::TestCase
30
41
  def setup
@@ -46,3 +57,23 @@ class RenderHelperTest < Test::Unit::TestCase
46
57
  end
47
58
  end
48
59
 
60
+ class FirstSecondHelperTest < Test::Unit::TestCase
61
+ def setup
62
+ ActionMailer::Base.delivery_method = :test
63
+ ActionMailer::Base.perform_deliveries = true
64
+ ActionMailer::Base.deliveries = []
65
+
66
+ @recipient = 'test@localhost'
67
+ end
68
+
69
+ def test_ordering
70
+ mail = FirstMailer.create_share(@recipient)
71
+ assert_equal "first mail", mail.body.strip
72
+ mail = SecondMailer.create_share(@recipient)
73
+ assert_equal "second mail", mail.body.strip
74
+ mail = FirstMailer.create_share(@recipient)
75
+ assert_equal "first mail", mail.body.strip
76
+ mail = SecondMailer.create_share(@recipient)
77
+ assert_equal "second mail", mail.body.strip
78
+ end
79
+ end
@@ -1,31 +1,8 @@
1
- $:.unshift(File.dirname(__FILE__) + "/../lib/")
2
-
3
- require 'test/unit'
4
- require 'action_mailer'
5
-
6
- class MockSMTP
7
- def self.deliveries
8
- @@deliveries
9
- end
10
-
11
- def initialize
12
- @@deliveries = []
13
- end
14
-
15
- def sendmail(mail, from, to)
16
- @@deliveries << [mail, from, to]
17
- end
18
- end
19
-
20
- class Net::SMTP
21
- def self.start(*args)
22
- yield MockSMTP.new
23
- end
24
- end
1
+ require "#{File.dirname(__FILE__)}/abstract_unit"
25
2
 
26
3
  class FunkyPathMailer < ActionMailer::Base
27
- self.template_root = "#{File.dirname(__FILE__)}/fixtures/path.with.dots"
28
-
4
+ self.template_root = "#{File.dirname(__FILE__)}/fixtures/path.with.dots"
5
+
29
6
  def multipart_with_template_path_with_dots(recipient)
30
7
  recipients recipient
31
8
  subject "Have a lovely picture"
@@ -33,14 +10,9 @@ class FunkyPathMailer < ActionMailer::Base
33
10
  attachment :content_type => "image/jpeg",
34
11
  :body => "not really a jpeg, we're only testing, after all"
35
12
  end
36
-
37
- def template_path
38
- "#{File.dirname(__FILE__)}/fixtures/path.with.dots"
39
- end
40
13
  end
41
14
 
42
15
  class TestMailer < ActionMailer::Base
43
-
44
16
  def signed_up(recipient)
45
17
  @recipients = recipient
46
18
  @subject = "[Signed up] Welcome #{recipient}"
@@ -222,7 +194,7 @@ class TestMailer < ActionMailer::Base
222
194
  subject "nested multipart"
223
195
  from "test@example.com"
224
196
  content_type "multipart/mixed"
225
- part :content_type => "multipart/alternative", :content_disposition => "inline" do |p|
197
+ part :content_type => "multipart/alternative", :content_disposition => "inline", :headers => { "foo" => "bar" } do |p|
226
198
  p.part :content_type => "text/plain", :body => "test text\nline #2"
227
199
  p.part :content_type => "text/html", :body => "<b>test</b> HTML<br/>\nline #2"
228
200
  end
@@ -273,8 +245,6 @@ class TestMailer < ActionMailer::Base
273
245
  end
274
246
  end
275
247
 
276
- TestMailer.template_root = File.dirname(__FILE__) + "/fixtures"
277
-
278
248
  class ActionMailerTest < Test::Unit::TestCase
279
249
  include ActionMailer::Quoting
280
250
 
@@ -284,6 +254,7 @@ class ActionMailerTest < Test::Unit::TestCase
284
254
 
285
255
  def new_mail( charset="utf-8" )
286
256
  mail = TMail::Mail.new
257
+ mail.mime_version = "1.0"
287
258
  if charset
288
259
  mail.set_content_type "text", "plain", { "charset" => charset }
289
260
  end
@@ -306,6 +277,7 @@ class ActionMailerTest < Test::Unit::TestCase
306
277
 
307
278
  assert_equal "multipart/mixed", created.content_type
308
279
  assert_equal "multipart/alternative", created.parts.first.content_type
280
+ assert_equal "bar", created.parts.first.header['foo'].to_s
309
281
  assert_equal "text/plain", created.parts.first.parts.first.content_type
310
282
  assert_equal "text/html", created.parts.first.parts[1].content_type
311
283
  assert_equal "application/octet-stream", created.parts[1].content_type
@@ -324,7 +296,6 @@ class ActionMailerTest < Test::Unit::TestCase
324
296
  expected.body = "Hello there, \n\nMr. #{@recipient}"
325
297
  expected.from = "system@loudthinking.com"
326
298
  expected.date = Time.local(2004, 12, 12)
327
- expected.mime_version = nil
328
299
 
329
300
  created = nil
330
301
  assert_nothing_raised { created = TestMailer.create_signed_up(@recipient) }
@@ -818,15 +789,15 @@ EOF
818
789
  end
819
790
  end
820
791
 
821
- class InheritableTemplateRootTest < Test::Unit::TestCase
822
- def test_attr
823
- expected = "#{File.dirname(__FILE__)}/fixtures/path.with.dots"
824
- assert_equal expected, FunkyPathMailer.template_root
825
-
826
- sub = Class.new(FunkyPathMailer)
827
- sub.template_root = 'test/path'
828
-
829
- assert_equal 'test/path', sub.template_root
830
- assert_equal expected, FunkyPathMailer.template_root
831
- end
832
- end
792
+ class InheritableTemplateRootTest < Test::Unit::TestCase
793
+ def test_attr
794
+ expected = "#{File.dirname(__FILE__)}/fixtures/path.with.dots"
795
+ assert_equal expected, FunkyPathMailer.template_root
796
+
797
+ sub = Class.new(FunkyPathMailer)
798
+ sub.template_root = 'test/path'
799
+
800
+ assert_equal 'test/path', sub.template_root
801
+ assert_equal expected, FunkyPathMailer.template_root
802
+ end
803
+ end
@@ -1,7 +1,4 @@
1
- $:.unshift(File.dirname(__FILE__) + "/../lib/")
2
- $:.unshift(File.dirname(__FILE__) + "/../lib/action_mailer/vendor")
3
-
4
- require 'test/unit'
1
+ require "#{File.dirname(__FILE__)}/abstract_unit"
5
2
  require 'tmail'
6
3
  require 'tempfile'
7
4
 
@@ -22,6 +19,18 @@ class QuotingTest < Test::Unit::TestCase
22
19
  assert_equal unquoted, original
23
20
  end
24
21
 
22
+ # test an email that has been created using \r\n newlines, instead of
23
+ # \n newlines.
24
+ def test_email_quoted_with_0d0a
25
+ mail = TMail::Mail.parse(IO.read("#{File.dirname(__FILE__)}/fixtures/raw_email_quoted_with_0d0a"))
26
+ assert_match %r{Elapsed time}, mail.body
27
+ end
28
+
29
+ def test_email_with_partially_quoted_subject
30
+ mail = TMail::Mail.parse(IO.read("#{File.dirname(__FILE__)}/fixtures/raw_email_with_partially_quoted_subject"))
31
+ assert_equal "Re: Test: \"\346\274\242\345\255\227\" mid \"\346\274\242\345\255\227\" tail", mail.subject
32
+ end
33
+
25
34
  private
26
35
 
27
36
  # This whole thing *could* be much simpler, but I don't think Tempfile,
@@ -40,7 +49,7 @@ class QuotingTest < Test::Unit::TestCase
40
49
  end
41
50
 
42
51
  system("ruby #{test_name} > #{res_name}") or raise "could not run test in sandbox"
43
- File.read(res_name)
52
+ File.read(res_name).chomp
44
53
  ensure
45
54
  File.delete(test_name) rescue nil
46
55
  File.delete(res_name) rescue nil
@@ -1,8 +1,4 @@
1
- $:.unshift(File.dirname(__FILE__) + "/../lib/")
2
- $:.unshift File.dirname(__FILE__) + "/fixtures/helpers"
3
-
4
- require 'test/unit'
5
- require 'action_mailer'
1
+ require "#{File.dirname(__FILE__)}/abstract_unit"
6
2
 
7
3
  class TMailMailTest < Test::Unit::TestCase
8
4
  def test_body
@@ -0,0 +1,68 @@
1
+ require "#{File.dirname(__FILE__)}/abstract_unit"
2
+
3
+ class TestMailer < ActionMailer::Base
4
+ def signed_up_with_url(recipient)
5
+ @recipients = recipient
6
+ @subject = "[Signed up] Welcome #{recipient}"
7
+ @from = "system@loudthinking.com"
8
+ @sent_on = Time.local(2004, 12, 12)
9
+
10
+ @body["recipient"] = recipient
11
+ @body["welcome_url"] = url_for :host => "example.com", :controller => "welcome", :action => "greeting"
12
+ end
13
+
14
+ class <<self
15
+ attr_accessor :received_body
16
+ end
17
+
18
+ def receive(mail)
19
+ self.class.received_body = mail.body
20
+ end
21
+ end
22
+
23
+ class ActionMailerUrlTest < Test::Unit::TestCase
24
+ include ActionMailer::Quoting
25
+
26
+ def encode( text, charset="utf-8" )
27
+ quoted_printable( text, charset )
28
+ end
29
+
30
+ def new_mail( charset="utf-8" )
31
+ mail = TMail::Mail.new
32
+ mail.mime_version = "1.0"
33
+ if charset
34
+ mail.set_content_type "text", "plain", { "charset" => charset }
35
+ end
36
+ mail
37
+ end
38
+
39
+ def setup
40
+ ActionMailer::Base.delivery_method = :test
41
+ ActionMailer::Base.perform_deliveries = true
42
+ ActionMailer::Base.deliveries = []
43
+
44
+ @recipient = 'test@localhost'
45
+ end
46
+
47
+ def test_signed_up_with_url
48
+ ActionController::Routing::Routes.draw do |map|
49
+ map.connect ':controller/:action/:id'
50
+ end
51
+
52
+ expected = new_mail
53
+ expected.to = @recipient
54
+ expected.subject = "[Signed up] Welcome #{@recipient}"
55
+ expected.body = "Hello there, \n\nMr. #{@recipient}. Please see our greeting at http://example.com/welcome/greeting"
56
+ expected.from = "system@loudthinking.com"
57
+ expected.date = Time.local(2004, 12, 12)
58
+
59
+ created = nil
60
+ assert_nothing_raised { created = TestMailer.create_signed_up_with_url(@recipient) }
61
+ assert_not_nil created
62
+ assert_equal expected.encoded, created.encoded
63
+
64
+ assert_nothing_raised { TestMailer.deliver_signed_up_with_url(@recipient) }
65
+ assert_not_nil ActionMailer::Base.deliveries.first
66
+ assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded
67
+ end
68
+ end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
2
+ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: actionmailer
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.2.5
7
- date: 2006-08-10 00:00:00 -05:00
6
+ version: 1.3.0
7
+ date: 2007-01-17 00:00:00 -06:00
8
8
  summary: Service layer for easy email delivery and testing.
9
9
  require_paths:
10
10
  - lib
@@ -25,6 +25,7 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
25
25
  platform: ruby
26
26
  signing_key:
27
27
  cert_chain:
28
+ post_install_message:
28
29
  authors:
29
30
  - David Heinemeier Hansson
30
31
  files:
@@ -71,12 +72,15 @@ files:
71
72
  - lib/action_mailer/vendor/tmail/stringio.rb
72
73
  - lib/action_mailer/vendor/tmail/tmail.rb
73
74
  - lib/action_mailer/vendor/tmail/utils.rb
75
+ - test/abstract_unit.rb
74
76
  - test/fixtures
75
77
  - test/mail_helper_test.rb
76
78
  - test/mail_render_test.rb
77
79
  - test/mail_service_test.rb
78
80
  - test/quoting_test.rb
79
81
  - test/tmail_test.rb
82
+ - test/url_test.rb
83
+ - test/fixtures/first_mailer
80
84
  - test/fixtures/helper_mailer
81
85
  - test/fixtures/helpers
82
86
  - test/fixtures/path.with.dots
@@ -93,14 +97,21 @@ files:
93
97
  - test/fixtures/raw_email7
94
98
  - test/fixtures/raw_email8
95
99
  - test/fixtures/raw_email9
100
+ - test/fixtures/raw_email_quoted_with_0d0a
101
+ - test/fixtures/raw_email_with_partially_quoted_subject
102
+ - test/fixtures/second_mailer
96
103
  - test/fixtures/templates
97
104
  - test/fixtures/test_mailer
105
+ - test/fixtures/first_mailer/share.rhtml
98
106
  - test/fixtures/helper_mailer/use_helper.rhtml
99
107
  - test/fixtures/helper_mailer/use_helper_method.rhtml
100
108
  - test/fixtures/helper_mailer/use_mail_helper.rhtml
101
109
  - test/fixtures/helper_mailer/use_test_helper.rhtml
102
110
  - test/fixtures/helpers/test_helper.rb
111
+ - test/fixtures/path.with.dots/funky_path_mailer
103
112
  - test/fixtures/path.with.dots/multipart_with_template_path_with_dots.rhtml
113
+ - test/fixtures/path.with.dots/funky_path_mailer/multipart_with_template_path_with_dots.rhtml
114
+ - test/fixtures/second_mailer/share.rhtml
104
115
  - test/fixtures/templates/signed_up.rhtml
105
116
  - test/fixtures/test_mailer/implicitly_multipart_example.ignored.rhtml
106
117
  - test/fixtures/test_mailer/implicitly_multipart_example.rhtml.bak
@@ -108,6 +119,7 @@ files:
108
119
  - test/fixtures/test_mailer/implicitly_multipart_example.text.plain.rhtml
109
120
  - test/fixtures/test_mailer/implicitly_multipart_example.text.yaml.rhtml
110
121
  - test/fixtures/test_mailer/signed_up.rhtml
122
+ - test/fixtures/test_mailer/signed_up_with_url.rhtml
111
123
  test_files: []
112
124
 
113
125
  rdoc_options: []
@@ -128,5 +140,5 @@ dependencies:
128
140
  requirements:
129
141
  - - "="
130
142
  - !ruby/object:Gem::Version
131
- version: 1.12.5
143
+ version: 1.13.0
132
144
  version: