提交 1fd9a46d 编写于 作者: J Jeremy Kemper

Resolve conflict among mailer actions with the same name. Closes #5520.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4509 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 5b866f75
*SVN*
* Resolve conflict among mailer actions with the same name. #5520 [ssinghi@kreeti.com]
* ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, Marcel Molina Jr.]
* Replace alias method chaining with Module#alias_method_chain. [Marcel Molina Jr.]
......
......@@ -353,7 +353,7 @@ def create!(method_name, *parameters) #:nodoc:
content_type = md.captures[1].gsub('.', '/')
@parts << Part.new(:content_type => content_type,
:disposition => "inline", :charset => charset,
:body => render_message(template_name, @body))
:body => render_message("#{mailer_name}/#{template_name}", @body))
end
unless @parts.empty?
@content_type = "multipart/alternative"
......@@ -367,7 +367,7 @@ def create!(method_name, *parameters) #:nodoc:
# it.
template_exists = @parts.empty?
template_exists ||= Dir.glob("#{template_path}/#{@template}.*").any? { |i| File.basename(i).split(".").length == 2 }
@body = render_message(@template, @body) if template_exists
@body = render_message("#{mailer_name}/#{@template}", @body) if template_exists
# Finally, if there are other message parts and a textual body exists,
# we shift it onto the front of the parts and set the body to nil (so
......@@ -432,7 +432,7 @@ def template_path
end
def initialize_template_class(assigns)
ActionView::Base.new(template_path, assigns, self)
ActionView::Base.new(template_root, assigns, self)
end
def sort_parts(parts, order = [])
......
......@@ -15,7 +15,7 @@ def file_template(recipient)
recipients recipient
subject "using helpers"
from "tester@example.com"
body render(:file => "signed_up", :body => { :recipient => recipient })
body render(:file => "#{mailer_name}/signed_up", :body => { :recipient => recipient })
end
def initialize_defaults(method_name)
......@@ -24,6 +24,22 @@ def initialize_defaults(method_name)
end
end
class FirstMailer < ActionMailer::Base
def share(recipient)
recipients recipient
subject "using helpers"
from "tester@example.com"
end
end
class SecondMailer < ActionMailer::Base
def share(recipient)
recipients recipient
subject "using helpers"
from "tester@example.com"
end
end
RenderMailer.template_root = File.dirname(__FILE__) + "/fixtures"
class RenderHelperTest < Test::Unit::TestCase
......@@ -46,3 +62,23 @@ def test_file_template
end
end
class FirstSecondHelperTest < Test::Unit::TestCase
def setup
ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.deliveries = []
@recipient = 'test@localhost'
end
def test_ordering
mail = FirstMailer.create_share(@recipient)
assert_equal "first mail", mail.body.strip
mail = SecondMailer.create_share(@recipient)
assert_equal "second mail", mail.body.strip
mail = FirstMailer.create_share(@recipient)
assert_equal "first mail", mail.body.strip
mail = SecondMailer.create_share(@recipient)
assert_equal "second mail", mail.body.strip
end
end
......@@ -32,7 +32,7 @@ def multipart_with_template_path_with_dots(recipient)
:body => "not really a jpeg, we're only testing, after all"
end
def template_path
def template_root
"#{File.dirname(__FILE__)}/fixtures/path.with.dots"
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册