Skip to content
Browse files

Mailer template root applies to a class and its subclasses rather tha…

…n acting globally. Closes #5555.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4523 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent bdac94e commit 5446ecd5b975890dab5f7120b25ed0e8f91279fa @jeremy jeremy committed Jun 30, 2006
View
2 actionmailer/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Mailer template root applies to a class and its subclasses rather than acting globally. #5555 [somekool@gmail.com]
+
* Resolve action naming collision. #5520 [ssinghi@kreeti.com]
* ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, Marcel Molina Jr.]
View
2 actionmailer/lib/action_mailer/base.rb
@@ -191,7 +191,7 @@ class Base
private_class_method :new #:nodoc:
- cattr_accessor :template_root
+ class_inheritable_accessor :template_root
cattr_accessor :logger
@@server_settings = {
View
8 actionmailer/test/mail_helper_test.rb
@@ -1,8 +1,4 @@
-$:.unshift(File.dirname(__FILE__) + "/../lib/")
-$:.unshift File.dirname(__FILE__) + "/fixtures/helpers"
-
-require 'test/unit'
-require 'action_mailer'
+require "#{File.dirname(__FILE__)}/abstract_unit"
module MailerHelper
def person_name
@@ -56,8 +52,6 @@ def name_of_the_mailer_class
helper_method :name_of_the_mailer_class
end
-HelperMailer.template_root = File.dirname(__FILE__) + "/fixtures"
-
class MailerHelperTest < Test::Unit::TestCase
def new_mail( charset="utf-8" )
mail = TMail::Mail.new
View
7 actionmailer/test/mail_render_test.rb
@@ -1,7 +1,4 @@
-$:.unshift(File.dirname(__FILE__) + "/../lib/")
-
-require 'test/unit'
-require 'action_mailer'
+require "#{File.dirname(__FILE__)}/abstract_unit"
class RenderMailer < ActionMailer::Base
def inline_template(recipient)
@@ -40,8 +37,6 @@ def share(recipient)
end
end
-RenderMailer.template_root = File.dirname(__FILE__) + "/fixtures"
-
class RenderHelperTest < Test::Unit::TestCase
def setup
ActionMailer::Base.delivery_method = :test
View
26 actionmailer/test/mail_service_test.rb
@@ -1,7 +1,4 @@
-$:.unshift(File.dirname(__FILE__) + "/../lib/")
-
-require 'test/unit'
-require 'action_mailer'
+require "#{File.dirname(__FILE__)}/abstract_unit"
class MockSMTP
def self.deliveries
@@ -24,21 +21,18 @@ def self.start(*args)
end
class FunkyPathMailer < ActionMailer::Base
+ self.template_root = "#{File.dirname(__FILE__)}/fixtures/path.with.dots"
+
def multipart_with_template_path_with_dots(recipient)
recipients recipient
subject "Have a lovely picture"
from "Chad Fowler <chad@chadfowler.com>"
attachment :content_type => "image/jpeg",
:body => "not really a jpeg, we're only testing, after all"
end
-
- def template_root
- "#{File.dirname(__FILE__)}/fixtures/path.with.dots"
- end
end
class TestMailer < ActionMailer::Base
-
def signed_up(recipient)
@recipients = recipient
@subject = "[Signed up] Welcome #{recipient}"
@@ -271,8 +265,6 @@ def receive(mail)
end
end
-TestMailer.template_root = File.dirname(__FILE__) + "/fixtures"
-
class ActionMailerTest < Test::Unit::TestCase
include ActionMailer::Quoting
@@ -816,3 +808,15 @@ def test_custom_content_type_attributes
end
end
+class InheritableTemplateRootTest < Test::Unit::TestCase
+ def test_attr
+ expected = "#{File.dirname(__FILE__)}/fixtures/path.with.dots"
+ assert_equal expected, FunkyPathMailer.template_root
+
+ sub = Class.new(FunkyPathMailer)
+ sub.template_root = 'test/path'
+
+ assert_equal 'test/path', sub.template_root
+ assert_equal expected, FunkyPathMailer.template_root
+ end
+end
View
5 actionmailer/test/quoting_test.rb
@@ -1,7 +1,4 @@
-$:.unshift(File.dirname(__FILE__) + "/../lib/")
-$:.unshift(File.dirname(__FILE__) + "/../lib/action_mailer/vendor")
-
-require 'test/unit'
+require "#{File.dirname(__FILE__)}/abstract_unit"
require 'tmail'
require 'tempfile'
View
6 actionmailer/test/tmail_test.rb
@@ -1,8 +1,4 @@
-$:.unshift(File.dirname(__FILE__) + "/../lib/")
-$:.unshift File.dirname(__FILE__) + "/fixtures/helpers"
-
-require 'test/unit'
-require 'action_mailer'
+require "#{File.dirname(__FILE__)}/abstract_unit"
class TMailMailTest < Test::Unit::TestCase
def test_body

0 comments on commit 5446ecd

Please sign in to comment.
Something went wrong with that request. Please try again.