public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Search Repo:
 Allow body to be specified for nested parts with action mailer.  Closes 
 #10271 [redinger]


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8238 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
NZKoz (author)
Wed Nov 28 18:52:49 -0800 2007
commit  1d32cec17d768ac78d52903f5ed8b19cc37c7f78
tree    f8149c5e29a8ad85eed0332c79b76fa62e15d899
parent  fd3f048f6dda74193644e2bbb23044e64df84449
...
84
85
86
87
88
89
90
91
 
 
92
93
94
...
84
85
86
 
 
 
 
 
87
88
89
90
91
0
@@ -84,11 +84,8 @@
0
         end
0
       else
0
         if String === body
0
- part = TMail::Mail.new
0
- part.body = body
0
- part.set_content_type(real_content_type, nil, ctype_attrs)
0
- part.set_content_disposition "inline"
0
- m.parts << part
0
+ @parts.unshift Part.new(:charset => charset, :body => @body, :content_type => 'text/plain')
0
+ @body = nil
0
         end
0
           
0
         @parts.each do |p|
...
210
211
212
 
 
 
 
 
 
 
 
 
 
213
214
215
...
308
309
310
 
 
 
 
 
 
 
 
 
 
 
 
 
311
312
313
...
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
...
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
0
@@ -210,6 +210,16 @@
0
     attachment :content_type => "application/octet-stream",:filename => "test.txt", :body => "test abcdefghijklmnopqstuvwxyz"
0
   end
0
   
0
+ def nested_multipart_with_body(recipient)
0
+ recipients recipient
0
+ subject "nested multipart with body"
0
+ from "test@example.com"
0
+ content_type "multipart/mixed"
0
+ part :content_type => "multipart/alternative", :content_disposition => "inline", :body => "Nothing to see here." do |p|
0
+ p.part :content_type => "text/html", :body => "<b>test</b> HTML<br/>"
0
+ end
0
+ end
0
+
0
   def attachment_with_custom_header(recipient)
0
     recipients recipient
0
     subject "custom header in attachment"
0
@@ -308,6 +318,19 @@
0
     assert_equal "text/plain", created.parts.first.parts.first.content_type
0
     assert_equal "text/html", created.parts.first.parts[1].content_type
0
     assert_equal "application/octet-stream", created.parts[1].content_type
0
+ end
0
+
0
+ def test_nested_parts_with_body
0
+ created = nil
0
+ assert_nothing_raised { created = TestMailer.create_nested_multipart_with_body(@recipient)}
0
+ assert_equal 1,created.parts.size
0
+ assert_equal 2,created.parts.first.parts.size
0
+
0
+ assert_equal "multipart/mixed", created.content_type
0
+ assert_equal "multipart/alternative", created.parts.first.content_type
0
+ assert_equal "Nothing to see here.", created.parts.first.parts.first.body
0
+ assert_equal "text/plain", created.parts.first.parts.first.content_type
0
+ assert_equal "text/html", created.parts.first.parts[1].content_type
0
   end
0
 
0
   def test_attachment_with_custom_header

Comments

    No one has commented yet.