Project

General

Profile

Patch #3970 ยป 0001-proper-content-type-for-plain-text-mails.patch

patch to use CT: text/plain for plain text mails. - Nobuhiro IMAI, 2009-10-05 05:43

View differences:

app/models/mailer.rb
352 352
  # https://rails.lighthouseapp.com/projects/8994/tickets/1799-actionmailer-doesnt-set-template_format-when-rendering-layouts
353 353
  
354 354
  def render_multipart(method_name, body)
355
    content_type "multipart/alternative"
356
    part :content_type => "text/plain", :body => render(:file => "#{method_name}.text.plain.rhtml", :body => body, :layout => 'mailer.text.plain.erb')
357
    part :content_type => "text/html", :body => render_message("#{method_name}.text.html.rhtml", body) unless Setting.plain_text_mail?
355
    if Setting.plain_text_mail?
356
      content_type "text/plain"
357
      body render(:file => "#{method_name}.text.plain.rhtml", :body => body, :layout => 'mailer.text.plain.erb')
358
    else
359
      content_type "multipart/alternative"
360
      part :content_type => "text/plain", :body => render(:file => "#{method_name}.text.plain.rhtml", :body => body, :layout => 'mailer.text.plain.erb')
361
      part :content_type => "text/html", :body => render_message("#{method_name}.text.html.rhtml", body)
362
    end
358 363
  end
359 364

  
360 365
  # Makes partial rendering work with Rails 1.2 (retro-compatibility)
test/unit/mailer_test.rb
103 103
    journal = Journal.find(2)
104 104
    Mailer.deliver_issue_edit(journal)
105 105
    mail = ActionMailer::Base.deliveries.last
106
    assert_equal 1, mail.parts.size
106
    assert_equal "text/plain", mail.content_type
107
    assert_equal 0, mail.parts.size
107 108
    assert !mail.encoded.include?('href')
108 109
  end
109 110

  
    (1-1/1)