1 require 'abstract_unit'
3 class RenderMailer
< ActionMailer
::Base
4 def inline_template(recipient
)
6 subject
"using helpers"
7 from
"tester@example.com"
8 body
render(:inline => "Hello, <%= @world %>", :body => { :world => "Earth" })
11 def file_template(recipient
)
13 subject
"using helpers"
14 from
"tester@example.com"
15 body
render(:file => "signed_up", :body => { :recipient => recipient
})
18 def rxml_template(recipient
)
20 subject
"rendering rxml template"
21 from
"tester@example.com"
24 def included_subtemplate(recipient
)
26 subject
"Including another template in the one being rendered"
27 from
"tester@example.com"
30 def included_old_subtemplate(recipient
)
32 subject
"Including another template in the one being rendered"
33 from
"tester@example.com"
34 body
render(:inline => "Hello, <%= render \"subtemplate\" %>", :body => { :world => "Earth" })
37 def initialize_defaults(method_name
)
39 mailer_name
"test_mailer"
43 class FirstMailer
< ActionMailer
::Base
46 subject
"using helpers"
47 from
"tester@example.com"
51 class SecondMailer
< ActionMailer
::Base
54 subject
"using helpers"
55 from
"tester@example.com"
59 class RenderHelperTest
< Test
::Unit::TestCase
61 set_delivery_method
:test
62 ActionMailer
::Base.perform_deliveries
= true
63 ActionMailer
::Base.deliveries
= []
65 @recipient = 'test@localhost'
69 restore_delivery_method
72 def test_inline_template
73 mail
= RenderMailer
.create_inline_template(@recipient)
74 assert_equal
"Hello, Earth", mail
.body
.strip
77 def test_file_template
78 mail
= RenderMailer
.create_file_template(@recipient)
79 assert_equal
"Hello there, \n\nMr. test@localhost", mail
.body
.strip
82 def test_rxml_template
83 mail
= RenderMailer
.deliver_rxml_template(@recipient)
84 assert_equal
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test/>", mail
.body
.strip
87 def test_included_subtemplate
88 mail
= RenderMailer
.deliver_included_subtemplate(@recipient)
89 assert_equal
"Hey Ho, let's go!", mail
.body
.strip
93 class FirstSecondHelperTest
< Test
::Unit::TestCase
95 set_delivery_method
:test
96 ActionMailer
::Base.perform_deliveries
= true
97 ActionMailer
::Base.deliveries
= []
99 @recipient = 'test@localhost'
103 restore_delivery_method
107 mail
= FirstMailer
.create_share(@recipient)
108 assert_equal
"first mail", mail
.body
.strip
109 mail
= SecondMailer
.create_share(@recipient)
110 assert_equal
"second mail", mail
.body
.strip
111 mail
= FirstMailer
.create_share(@recipient)
112 assert_equal
"first mail", mail
.body
.strip
113 mail
= SecondMailer
.create_share(@recipient)
114 assert_equal
"second mail", mail
.body
.strip