提交 28bf2fa0 编写于 作者: J Joshua Peek

Protect body ivar from being clobbered by the mailer template assigns

上级 ea609b26
......@@ -296,6 +296,9 @@ class Base
@@default_implicit_parts_order = [ "text/html", "text/enriched", "text/plain" ]
cattr_accessor :default_implicit_parts_order
cattr_reader :protected_instance_variables
@@protected_instance_variables = %w(@body)
# Specify the BCC addresses for the message
adv_attr_accessor :bcc
......
body: <%= @body %>
bar: <%= @bar %>
\ No newline at end of file
......@@ -273,6 +273,13 @@ def return_path
headers "return-path" => "another@somewhere.test"
end
def body_ivar(recipient)
recipients recipient
subject "Body as a local variable"
from "test@example.com"
body :body => "foo", :bar => "baz"
end
class <<self
attr_accessor :received_body
end
......@@ -926,6 +933,11 @@ def test_return_path_with_deliver
TestMailer.deliver_return_path
assert_match %r{^Return-Path: <another@somewhere.test>}, MockSMTP.deliveries[0][0]
end
def test_body_is_stored_as_an_ivar
mail = TestMailer.create_body_ivar(@recipient)
assert_equal "body: foo\nbar: baz", mail.body
end
end
end # uses_mocha
......
......@@ -296,9 +296,9 @@ def _evaluate_assigns_and_ivars #:nodoc:
@assigns.each { |key, value| instance_variable_set("@#{key}", value) }
if @controller
variables = @controller.instance_variables
variables = @controller.instance_variable_names
variables -= @controller.protected_instance_variables if @controller.respond_to?(:protected_instance_variables)
variables.each {|name| instance_variable_set(name, @controller.instance_variable_get(name)) }
variables.each { |name| instance_variable_set(name, @controller.instance_variable_get(name)) }
end
@assigns_added = true
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册