2008-01-05 08:32:22 -05:00
|
|
|
require 'abstract_unit'
|
2005-08-22 17:17:01 -04:00
|
|
|
|
|
|
|
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"
|
2006-06-29 16:14:33 -04:00
|
|
|
body render(:file => "signed_up", :body => { :recipient => recipient })
|
2005-08-22 17:17:01 -04:00
|
|
|
end
|
|
|
|
|
2007-10-15 16:30:48 -04:00
|
|
|
def rxml_template(recipient)
|
|
|
|
recipients recipient
|
|
|
|
subject "rendering rxml template"
|
|
|
|
from "tester@example.com"
|
|
|
|
end
|
2008-08-22 14:43:34 -04:00
|
|
|
|
2007-11-18 17:01:33 -05:00
|
|
|
def included_subtemplate(recipient)
|
|
|
|
recipients recipient
|
|
|
|
subject "Including another template in the one being rendered"
|
|
|
|
from "tester@example.com"
|
|
|
|
end
|
2008-08-22 14:43:34 -04:00
|
|
|
|
2007-11-25 22:36:28 -05:00
|
|
|
def included_old_subtemplate(recipient)
|
|
|
|
recipients recipient
|
|
|
|
subject "Including another template in the one being rendered"
|
|
|
|
from "tester@example.com"
|
|
|
|
body render(:inline => "Hello, <%= render \"subtemplate\" %>", :body => { :world => "Earth" })
|
|
|
|
end
|
2007-10-15 16:30:48 -04:00
|
|
|
|
2005-08-22 17:17:01 -04:00
|
|
|
def initialize_defaults(method_name)
|
|
|
|
super
|
|
|
|
mailer_name "test_mailer"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2006-06-28 21:54:16 -04:00
|
|
|
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
|
|
|
|
|
2005-08-22 17:17:01 -04:00
|
|
|
class RenderHelperTest < Test::Unit::TestCase
|
|
|
|
def setup
|
2007-11-07 11:05:17 -05:00
|
|
|
set_delivery_method :test
|
2005-08-22 17:17:01 -04:00
|
|
|
ActionMailer::Base.perform_deliveries = true
|
|
|
|
ActionMailer::Base.deliveries = []
|
|
|
|
|
|
|
|
@recipient = 'test@localhost'
|
|
|
|
end
|
|
|
|
|
2007-11-07 11:05:17 -05:00
|
|
|
def teardown
|
|
|
|
restore_delivery_method
|
|
|
|
end
|
|
|
|
|
2005-08-22 17:17:01 -04:00
|
|
|
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
|
2007-10-15 16:30:48 -04:00
|
|
|
|
|
|
|
def test_rxml_template
|
|
|
|
mail = RenderMailer.deliver_rxml_template(@recipient)
|
|
|
|
assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test/>", mail.body.strip
|
|
|
|
end
|
2008-08-22 14:43:34 -04:00
|
|
|
|
2007-11-18 17:01:33 -05:00
|
|
|
def test_included_subtemplate
|
|
|
|
mail = RenderMailer.deliver_included_subtemplate(@recipient)
|
|
|
|
assert_equal "Hey Ho, let's go!", mail.body.strip
|
|
|
|
end
|
2005-08-22 17:17:01 -04:00
|
|
|
end
|
|
|
|
|
2006-06-28 21:54:16 -04:00
|
|
|
class FirstSecondHelperTest < Test::Unit::TestCase
|
|
|
|
def setup
|
2007-11-07 11:05:17 -05:00
|
|
|
set_delivery_method :test
|
2006-06-28 21:54:16 -04:00
|
|
|
ActionMailer::Base.perform_deliveries = true
|
|
|
|
ActionMailer::Base.deliveries = []
|
|
|
|
|
|
|
|
@recipient = 'test@localhost'
|
|
|
|
end
|
|
|
|
|
2007-11-07 11:05:17 -05:00
|
|
|
def teardown
|
|
|
|
restore_delivery_method
|
|
|
|
end
|
|
|
|
|
2006-06-28 21:54:16 -04:00
|
|
|
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
|