diff options
Diffstat (limited to 'actionmailer/test')
-rw-r--r-- | actionmailer/test/base_test.rb | 24 | ||||
-rw-r--r-- | actionmailer/test/mail_test.rb | 22 |
2 files changed, 24 insertions, 22 deletions
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index 14feef5a00..83707137e1 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -56,6 +56,13 @@ class BaseTest < ActiveSupport::TestCase format.any(:text, :html){ render :text => "Format with any!" } end end + + def custom_block(include_html=false) + mail(DEFAULT_HEADERS) do |format| + format.text(:content_transfer_encoding => "base64"){ render "welcome" } + format.html{ render "welcome" } if include_html + end + end end test "method call to mail does not raise error" do @@ -337,6 +344,23 @@ class BaseTest < ActiveSupport::TestCase assert_equal("Format with any!", email.parts[1].body.encoded) end + test "explicit multipart with options" do + email = BaseMailer.custom_block(true).deliver + assert_equal(2, email.parts.size) + assert_equal("multipart/alternate", email.mime_type) + assert_equal("text/plain", email.parts[0].mime_type) + assert_equal("base64", email.parts[0].content_transfer_encoding) + assert_equal("text/html", email.parts[1].mime_type) + assert_equal("7bit", email.parts[1].content_transfer_encoding) + end + + test "explicit multipart with one part is rendered as body" do + email = BaseMailer.custom_block.deliver + assert_equal(0, email.parts.size) + assert_equal("text/plain", email.mime_type) + assert_equal("base64", email.content_transfer_encoding) + end + # Class level API with method missing test "should respond to action methods" do assert BaseMailer.respond_to?(:welcome) diff --git a/actionmailer/test/mail_test.rb b/actionmailer/test/mail_test.rb deleted file mode 100644 index f18dfdc156..0000000000 --- a/actionmailer/test/mail_test.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'abstract_unit' - -class MailTest < Test::Unit::TestCase - def test_body - m = Mail.new - expected = 'something_with_underscores' - m.content_transfer_encoding = 'quoted-printable' - quoted_body = [expected].pack('*M') - m.body = quoted_body - assert_equal "something_with_underscores=\r\n", m.body.encoded - assert_equal expected, m.body.to_s - end - - def test_nested_attachments_are_recognized_correctly - fixture = File.read("#{File.dirname(__FILE__)}/fixtures/raw_email_with_nested_attachment") - mail = Mail.new(fixture) - assert_equal 2, mail.attachments.length - assert_equal "image/png", mail.attachments.first.mime_type - assert_equal 1902, mail.attachments.first.decoded.length - assert_equal "application/pkcs7-signature", mail.attachments.last.mime_type - end -end |