提交 31b538df 编写于 作者: J Joshua Peek

Failing AM test for legacy multipart alternative rendering

上级 9f719018
<strong>foo</strong> <%= @foo %>
\ No newline at end of file
......@@ -62,6 +62,33 @@ def initialize_defaults(method_name)
super
mailer_name "test_mailer"
end
def multipart_alternative
recipients 'test@localhost'
subject 'multipart/alternative'
from 'tester@example.com'
build_multipart_message(:foo => "bar")
end
private
def build_multipart_message(assigns = {})
content_type "multipart/alternative"
part "text/plain" do |p|
p.body = build_body_part('plain', assigns, :layout => false)
end
part "text/html" do |p|
p.body = build_body_part('html', assigns)
p.transfer_encoding = "base64"
end
end
def build_body_part(content_type, assigns, options = {})
render "#{template}.#{content_type}", :body => assigns
# render options.merge(:file => "#{template}.#{content_type}", :body => assigns)
end
end
class FirstMailer < ActionMailer::Base
......@@ -129,6 +156,16 @@ def test_no_instance_variable
mail = RenderMailer.no_instance_variable.deliver
assert_equal "Look, subject.nil? is true!", mail.body.to_s.strip
end
def test_legacy_multipart_alternative
mail = RenderMailer.multipart_alternative.deliver
assert_equal(2, email.parts.size)
assert_equal("multipart/alternative", email.mime_type)
assert_equal("text/plain", email.parts[0].mime_type)
assert_equal("foo: bar", email.parts[0].body.encoded)
assert_equal("text/html", email.parts[1].mime_type)
assert_equal("<strong>foo</strong> bar", email.parts[1].body.encoded)
end
end
class FirstSecondHelperTest < Test::Unit::TestCase
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册