From 118920c4f589d62b0e6427784710367f8c87b17b Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Sun, 4 Jan 2009 15:15:37 -0500 Subject: [PATCH] added tests for multipart mixed patch --- actionmailer/test/mail_layout_test.rb | 31 ++++++++++++++++++++++++++++++- 1 files changed, 30 insertions(+), 1 deletions(-) diff --git a/actionmailer/test/mail_layout_test.rb b/actionmailer/test/mail_layout_test.rb index c185bd5..f5c816c 100644 --- a/actionmailer/test/mail_layout_test.rb +++ b/actionmailer/test/mail_layout_test.rb @@ -21,10 +21,13 @@ class AutoLayoutMailer < ActionMailer::Base body render(:inline => "Hello, <%= @world %>", :layout => false, :body => { :world => "Earth" }) end - def multipart(recipient) + def multipart(recipient, type=nil) recipients recipient subject "You have a mail" from "tester@example.com" + if type + content_type type + end end end @@ -64,6 +67,7 @@ class LayoutMailerTest < Test::Unit::TestCase def test_should_pickup_multipart_layout mail = AutoLayoutMailer.create_multipart(@recipient) + assert_equal "multipart/alternative", mail.content_type assert_equal 2, mail.parts.size assert_equal 'text/plain', mail.parts.first.content_type @@ -73,6 +77,31 @@ class LayoutMailerTest < Test::Unit::TestCase assert_equal "Hello from layout text/html multipart", mail.parts.last.body end + def test_should_pickup_multipartmixed_layout + mail = AutoLayoutMailer.create_multipart(@recipient, "multipart/mixed") + assert_equal "multipart/mixed", mail.content_type + assert_equal 2, mail.parts.size + + assert_equal 'text/plain', mail.parts.first.content_type + assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body + + assert_equal 'text/html', mail.parts.last.content_type + assert_equal "Hello from layout text/html multipart", mail.parts.last.body + end + + def test_should_fix_multipart_layout + mail = AutoLayoutMailer.create_multipart(@recipient, "text/plain") + assert_equal "multipart/alternative", mail.content_type + assert_equal 2, mail.parts.size + + assert_equal 'text/plain', mail.parts.first.content_type + assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body + + assert_equal 'text/html', mail.parts.last.content_type + assert_equal "Hello from layout text/html multipart", mail.parts.last.body + end + + def test_should_pickup_layout_given_to_render mail = AutoLayoutMailer.create_spam(@recipient) assert_equal "Spammer layout Hello, Earth", mail.body.strip -- 1.5.6.3