Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8238

Show
Ignore:
Timestamp:
11/29/07 02:52:49 (1 year ago)
Author:
nzkoz
Message:

Allow body to be specified for nested parts with action mailer. Closes #10271 [redinger]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionmailer/lib/action_mailer/part.rb

    r3959 r8238  
    8585      else 
    8686        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 
    9289        end 
    9390           
  • trunk/actionmailer/test/mail_service_test.rb

    r8111 r8238  
    211211  end 
    212212   
     213  def nested_multipart_with_body(recipient) 
     214    recipients   recipient 
     215    subject      "nested multipart with body" 
     216    from         "test@example.com" 
     217    content_type "multipart/mixed" 
     218    part :content_type => "multipart/alternative", :content_disposition => "inline", :body => "Nothing to see here." do |p| 
     219      p.part :content_type => "text/html", :body => "<b>test</b> HTML<br/>" 
     220    end 
     221  end 
     222 
    213223  def attachment_with_custom_header(recipient) 
    214224    recipients   recipient 
     
    309319    assert_equal "text/html", created.parts.first.parts[1].content_type 
    310320    assert_equal "application/octet-stream", created.parts[1].content_type 
     321  end 
     322 
     323  def test_nested_parts_with_body 
     324    created = nil 
     325    assert_nothing_raised { created = TestMailer.create_nested_multipart_with_body(@recipient)} 
     326    assert_equal 1,created.parts.size 
     327    assert_equal 2,created.parts.first.parts.size 
     328 
     329    assert_equal "multipart/mixed", created.content_type 
     330    assert_equal "multipart/alternative", created.parts.first.content_type 
     331    assert_equal "Nothing to see here.", created.parts.first.parts.first.body 
     332    assert_equal "text/plain", created.parts.first.parts.first.content_type 
     333    assert_equal "text/html", created.parts.first.parts[1].content_type 
    311334  end 
    312335