diff options
author | Jamis Buck <jamis@37signals.com> | 2005-08-22 21:17:01 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2005-08-22 21:17:01 +0000 |
commit | ae1e85200e1480a47db7c3ccfcc7d256f37e88ba (patch) | |
tree | 11b639e34e74dfeed0adf87fe2866ed636b78584 /actionmailer/test | |
parent | 516d920dc31274962813917e8c299403dc815b6c (diff) | |
download | rails-ae1e85200e1480a47db7c3ccfcc7d256f37e88ba.tar.gz rails-ae1e85200e1480a47db7c3ccfcc7d256f37e88ba.tar.bz2 rails-ae1e85200e1480a47db7c3ccfcc7d256f37e88ba.zip |
Add a unified render method to ActionMailer (delegates to ActionView::Base#render)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2037 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionmailer/test')
-rw-r--r-- | actionmailer/test/mail_render_test.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/actionmailer/test/mail_render_test.rb b/actionmailer/test/mail_render_test.rb new file mode 100644 index 0000000000..d581965284 --- /dev/null +++ b/actionmailer/test/mail_render_test.rb @@ -0,0 +1,48 @@ +$:.unshift(File.dirname(__FILE__) + "/../lib/") + +require 'test/unit' +require 'action_mailer' + +class RenderMailer < ActionMailer::Base + def inline_template(recipient) + recipients recipient + subject "using helpers" + from "tester@example.com" + body render(:inline => "Hello, <%= @world %>", :body => { :world => "Earth" }) + end + + def file_template(recipient) + recipients recipient + subject "using helpers" + from "tester@example.com" + body render(:file => "signed_up", :body => { :recipient => recipient }) + end + + def initialize_defaults(method_name) + super + mailer_name "test_mailer" + end +end + +RenderMailer.template_root = File.dirname(__FILE__) + "/fixtures" + +class RenderHelperTest < Test::Unit::TestCase + def setup + ActionMailer::Base.delivery_method = :test + ActionMailer::Base.perform_deliveries = true + ActionMailer::Base.deliveries = [] + + @recipient = 'test@localhost' + end + + def test_inline_template + mail = RenderMailer.create_inline_template(@recipient) + assert_equal "Hello, Earth", mail.body.strip + end + + def test_file_template + mail = RenderMailer.create_file_template(@recipient) + assert_equal "Hello there, \n\nMr. test@localhost", mail.body.strip + end +end + |