1 require 'abstract_unit'
9 class HelperMailer
< ActionMailer
::Base
13 def use_helper(recipient
)
15 subject
"using helpers"
16 from
"tester@example.com"
19 def use_example_helper(recipient
)
21 subject
"using helpers"
22 from
"tester@example.com"
23 self.body
= { :text => "emphasize me!" }
26 def use_mail_helper(recipient
)
28 subject
"using mailing helpers"
29 from
"tester@example.com"
30 self.body
= { :text =>
31 "But soft! What light through yonder window breaks? It is the east, " +
32 "and Juliet is the sun. Arise, fair sun, and kill the envious moon, " +
33 "which is sick and pale with grief that thou, her maid, art far more " +
34 "fair than she. Be not her maid, for she is envious! Her vestal " +
35 "livery is but sick and green, and none but fools do wear it. Cast " +
40 def use_helper_method(recipient
)
42 subject
"using helpers"
43 from
"tester@example.com"
44 self.body
= { :text => "emphasize me!" }
49 def name_of_the_mailer_class
52 helper_method
:name_of_the_mailer_class
55 class MailerHelperTest
< Test
::Unit::TestCase
56 def new_mail( charset
="utf-8" )
57 mail
= TMail
::Mail.new
58 mail
.set_content_type
"text", "plain", { "charset" => charset
} if charset
63 set_delivery_method
:test
64 ActionMailer
::Base.perform_deliveries
= true
65 ActionMailer
::Base.deliveries
= []
67 @recipient = 'test@localhost'
71 restore_delivery_method
75 mail
= HelperMailer
.create_use_helper(@recipient)
76 assert_match
%r
{Mr
. Joe Person
}, mail
.encoded
79 def test_use_example_helper
80 mail
= HelperMailer
.create_use_example_helper(@recipient)
81 assert_match
%r
{<em
><strong
><small
>emphasize me
!}, mail
.encoded
84 def test_use_helper_method
85 mail
= HelperMailer
.create_use_helper_method(@recipient)
86 assert_match
%r
{HelperMailer
}, mail
.encoded
89 def test_use_mail_helper
90 mail
= HelperMailer
.create_use_mail_helper(@recipient)
91 assert_match
%r
{ But soft
!}, mail
.encoded
92 assert_match
%r
{east
, and\n Juliet
}, mail
.encoded