diff --git a/actionmailer/CHANGELOG b/actionmailer/CHANGELOG index 1fdc821a7c6c0b9144a3961d06c161a36a5303ff..f22880299ac17fb61d57ef6fb146a13649c2f879 100644 --- a/actionmailer/CHANGELOG +++ b/actionmailer/CHANGELOG @@ -1,5 +1,7 @@ *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.] diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 81f240e035204869507b3c23e1aadcafe887f201..a84da1866d087b5d7bb13efdf15952864a5966f4 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -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 = []) diff --git a/actionmailer/test/fixtures/first_mailer/share.rhtml b/actionmailer/test/fixtures/first_mailer/share.rhtml new file mode 100644 index 0000000000000000000000000000000000000000..da43638ceb4ed681043e4602049a379bc30cff87 --- /dev/null +++ b/actionmailer/test/fixtures/first_mailer/share.rhtml @@ -0,0 +1 @@ +first mail diff --git a/actionmailer/test/fixtures/path.with.dots/funky_path_mailer/multipart_with_template_path_with_dots.rhtml b/actionmailer/test/fixtures/path.with.dots/funky_path_mailer/multipart_with_template_path_with_dots.rhtml new file mode 100644 index 0000000000000000000000000000000000000000..897a5065cf1bb27a8f41ff8adfeb497b5472be02 --- /dev/null +++ b/actionmailer/test/fixtures/path.with.dots/funky_path_mailer/multipart_with_template_path_with_dots.rhtml @@ -0,0 +1 @@ +Have a lovely picture, from me. Enjoy! \ No newline at end of file diff --git a/actionmailer/test/fixtures/path.with.dots/multipart_with_template_path_with_dots.rhtml b/actionmailer/test/fixtures/path.with.dots/multipart_with_template_path_with_dots.rhtml index 897a5065cf1bb27a8f41ff8adfeb497b5472be02..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/actionmailer/test/fixtures/path.with.dots/multipart_with_template_path_with_dots.rhtml +++ b/actionmailer/test/fixtures/path.with.dots/multipart_with_template_path_with_dots.rhtml @@ -1 +0,0 @@ -Have a lovely picture, from me. Enjoy! \ No newline at end of file diff --git a/actionmailer/test/fixtures/second_mailer/share.rhtml b/actionmailer/test/fixtures/second_mailer/share.rhtml new file mode 100644 index 0000000000000000000000000000000000000000..9a540106720f10bcb5539c5663bbaa7997734a80 --- /dev/null +++ b/actionmailer/test/fixtures/second_mailer/share.rhtml @@ -0,0 +1 @@ +second mail diff --git a/actionmailer/test/mail_render_test.rb b/actionmailer/test/mail_render_test.rb index d581965284aed17cc0520e9ed0bb5d0c426c93b0..642e15fe60ec95b0bc531a214beaa78fa1ec6938 100644 --- a/actionmailer/test/mail_render_test.rb +++ b/actionmailer/test/mail_render_test.rb @@ -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 diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index c810cf1090ef6654b065faf0f3ed04f06a18df6b..aa9002a26241f9a0b4662accb2ada7213c157fe8 100755 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -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