diff options
Diffstat (limited to 'actionmailer/test/mail_render_test.rb')
-rw-r--r-- | actionmailer/test/mail_render_test.rb | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/actionmailer/test/mail_render_test.rb b/actionmailer/test/mail_render_test.rb index 514f7ed798..09ce5e4854 100644 --- a/actionmailer/test/mail_render_test.rb +++ b/actionmailer/test/mail_render_test.rb @@ -40,13 +40,22 @@ class RenderMailer < ActionMailer::Base from "tester@example.com" end - def included_old_subtemplate(recipient) + def mailer_accessor(recipient) recipients recipient - subject "Including another template in the one being rendered" + subject "Mailer Accessor" from "tester@example.com" - @world = "Earth" - render :inline => "Hello, <%= render \"subtemplate\" %>" + render :inline => "Look, <%= mailer.subject %>!" + end + + def no_instance_variable(recipient) + recipients recipient + subject "No Instance Variable" + from "tester@example.com" + + silence_warnings do + render :inline => "Look, subject.nil? is <%= @subject.nil? %>!" + end end def initialize_defaults(method_name) @@ -71,6 +80,8 @@ class SecondMailer < ActionMailer::Base end end +# CHANGED: Those tests were changed because body returns an object now +# Instead of mail.body.strip, we should mail.body.to_s.strip class RenderHelperTest < Test::Unit::TestCase def setup set_delivery_method :test @@ -86,27 +97,37 @@ class RenderHelperTest < Test::Unit::TestCase def test_implicit_body mail = RenderMailer.create_implicit_body(@recipient) - assert_equal "Hello there, \n\nMr. test@localhost", mail.body.strip + assert_equal "Hello there, \n\nMr. test@localhost", mail.body.to_s.strip end def test_inline_template mail = RenderMailer.create_inline_template(@recipient) - assert_equal "Hello, Earth", mail.body.strip + assert_equal "Hello, Earth", mail.body.to_s.strip end def test_file_template mail = RenderMailer.create_file_template(@recipient) - assert_equal "Hello there, \n\nMr. test@localhost", mail.body.strip + assert_equal "Hello there, \n\nMr. test@localhost", mail.body.to_s.strip end def test_rxml_template mail = RenderMailer.deliver_rxml_template(@recipient) - assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test/>", mail.body.strip + assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test/>", mail.body.to_s.strip end def test_included_subtemplate mail = RenderMailer.deliver_included_subtemplate(@recipient) - assert_equal "Hey Ho, let's go!", mail.body.strip + assert_equal "Hey Ho, let's go!", mail.body.to_s.strip + end + + def test_mailer_accessor + mail = RenderMailer.deliver_mailer_accessor(@recipient) + assert_equal "Look, Mailer Accessor!", mail.body.to_s.strip + end + + def test_no_instance_variable + mail = RenderMailer.deliver_no_instance_variable(@recipient) + assert_equal "Look, subject.nil? is true!", mail.body.to_s.strip end end @@ -125,12 +146,12 @@ class FirstSecondHelperTest < Test::Unit::TestCase def test_ordering mail = FirstMailer.create_share(@recipient) - assert_equal "first mail", mail.body.strip + assert_equal "first mail", mail.body.to_s.strip mail = SecondMailer.create_share(@recipient) - assert_equal "second mail", mail.body.strip + assert_equal "second mail", mail.body.to_s.strip mail = FirstMailer.create_share(@recipient) - assert_equal "first mail", mail.body.strip + assert_equal "first mail", mail.body.to_s.strip mail = SecondMailer.create_share(@recipient) - assert_equal "second mail", mail.body.strip + assert_equal "second mail", mail.body.to_s.strip end end |