actionmailer 1.0.1 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionmailer might be problematic. Click here for more details.
- data/CHANGELOG +34 -0
- data/lib/action_mailer.rb +2 -4
- data/lib/action_mailer/adv_attr_accessor.rb +0 -29
- data/lib/action_mailer/base.rb +141 -44
- data/lib/action_mailer/helpers.rb +3 -3
- data/lib/action_mailer/mail_helper.rb +5 -3
- data/lib/action_mailer/part.rb +35 -3
- data/lib/action_mailer/part_container.rb +18 -1
- data/lib/action_mailer/quoting.rb +8 -48
- data/lib/action_mailer/vendor/text/format.rb +33 -14
- data/lib/action_mailer/vendor/tmail/address.rb +22 -3
- data/lib/action_mailer/vendor/tmail/attachments.rb +3 -1
- data/lib/action_mailer/vendor/tmail/base64.rb +22 -3
- data/lib/action_mailer/vendor/tmail/config.rb +22 -3
- data/lib/action_mailer/vendor/tmail/encode.rb +22 -3
- data/lib/action_mailer/vendor/tmail/facade.rb +22 -3
- data/lib/action_mailer/vendor/tmail/header.rb +27 -6
- data/lib/action_mailer/vendor/tmail/info.rb +22 -3
- data/lib/action_mailer/vendor/tmail/mail.rb +22 -3
- data/lib/action_mailer/vendor/tmail/mailbox.rb +22 -3
- data/lib/action_mailer/vendor/tmail/net.rb +22 -3
- data/lib/action_mailer/vendor/tmail/obsolete.rb +22 -3
- data/lib/action_mailer/vendor/tmail/parser.rb +22 -3
- data/lib/action_mailer/vendor/tmail/port.rb +22 -3
- data/lib/action_mailer/vendor/tmail/quoting.rb +6 -5
- data/lib/action_mailer/vendor/tmail/scanner.rb +22 -3
- data/lib/action_mailer/vendor/tmail/scanner_r.rb +22 -3
- data/lib/action_mailer/vendor/tmail/stringio.rb +22 -5
- data/lib/action_mailer/vendor/tmail/utils.rb +22 -3
- data/lib/action_mailer/version.rb +9 -0
- data/rakefile +5 -4
- data/test/fixtures/raw_email12 +32 -0
- data/test/mail_render_test.rb +48 -0
- data/test/mail_service_test.rb +62 -5
- data/test/quoting_test.rb +48 -0
- data/test/tmail_test.rb +17 -0
- metadata +8 -3
data/test/mail_service_test.rb
CHANGED
@@ -94,6 +94,23 @@ class TestMailer < ActionMailer::Base
|
|
94
94
|
@charset = "utf-8"
|
95
95
|
end
|
96
96
|
|
97
|
+
def multipart_with_mime_version(recipient)
|
98
|
+
recipients recipient
|
99
|
+
subject "multipart with mime_version"
|
100
|
+
from "test@example.com"
|
101
|
+
sent_on Time.local(2004, 12, 12)
|
102
|
+
mime_version "1.1"
|
103
|
+
content_type "multipart/alternative"
|
104
|
+
|
105
|
+
part "text/plain" do |p|
|
106
|
+
p.body = "blah"
|
107
|
+
end
|
108
|
+
|
109
|
+
part "text/html" do |p|
|
110
|
+
p.body = "<b>blah</b>"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
97
114
|
def explicitly_multipart_example(recipient, ct=nil)
|
98
115
|
recipients recipient
|
99
116
|
subject "multipart example"
|
@@ -111,13 +128,14 @@ class TestMailer < ActionMailer::Base
|
|
111
128
|
:body => "123456789"
|
112
129
|
end
|
113
130
|
|
114
|
-
def implicitly_multipart_example(recipient, order = nil)
|
131
|
+
def implicitly_multipart_example(recipient, cs = nil, order = nil)
|
115
132
|
@recipients = recipient
|
116
133
|
@subject = "multipart example"
|
117
134
|
@from = "test@example.com"
|
118
135
|
@sent_on = Time.local 2004, 12, 12
|
119
136
|
@body = { "recipient" => recipient }
|
120
|
-
@
|
137
|
+
@charset = cs if cs
|
138
|
+
@implicit_parts_order = order if order
|
121
139
|
end
|
122
140
|
|
123
141
|
def html_mail(recipient)
|
@@ -128,6 +146,11 @@ class TestMailer < ActionMailer::Base
|
|
128
146
|
content_type "text/html"
|
129
147
|
end
|
130
148
|
|
149
|
+
def html_mail_with_underscores(recipient)
|
150
|
+
subject "html mail with underscores"
|
151
|
+
body %{<a href="http://google.com" target="_blank">_Google</a>}
|
152
|
+
end
|
153
|
+
|
131
154
|
def custom_template(recipient)
|
132
155
|
recipients recipient
|
133
156
|
subject "[Signed up] Welcome #{recipient}"
|
@@ -239,6 +262,7 @@ class ActionMailerTest < Test::Unit::TestCase
|
|
239
262
|
expected.body = "Hello there, \n\nMr. #{@recipient}"
|
240
263
|
expected.from = "system@loudthinking.com"
|
241
264
|
expected.date = Time.local(2004, 12, 12)
|
265
|
+
expected.mime_version = nil
|
242
266
|
|
243
267
|
created = nil
|
244
268
|
assert_nothing_raised { created = TestMailer.create_signed_up(@recipient) }
|
@@ -527,6 +551,13 @@ EOF
|
|
527
551
|
assert_equal 1026, attachment.read.length
|
528
552
|
end
|
529
553
|
|
554
|
+
def test_attachment_using_content_location
|
555
|
+
fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email12")
|
556
|
+
mail = TMail::Mail.parse(fixture)
|
557
|
+
assert_equal 1, mail.attachments.length
|
558
|
+
assert_equal "Photo25.jpg", mail.attachments.first.original_filename
|
559
|
+
end
|
560
|
+
|
530
561
|
def test_decode_part_without_content_type
|
531
562
|
fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email4")
|
532
563
|
mail = TMail::Mail.parse(fixture)
|
@@ -545,6 +576,11 @@ EOF
|
|
545
576
|
assert_nothing_raised { mail.body }
|
546
577
|
end
|
547
578
|
|
579
|
+
def test_multipart_with_mime_version
|
580
|
+
mail = TestMailer.create_multipart_with_mime_version(@recipient)
|
581
|
+
assert_equal "1.1", mail.mime_version
|
582
|
+
end
|
583
|
+
|
548
584
|
def test_explicitly_multipart_messages
|
549
585
|
mail = TestMailer.create_explicitly_multipart_example(@recipient)
|
550
586
|
assert_equal 3, mail.parts.length
|
@@ -563,8 +599,7 @@ EOF
|
|
563
599
|
end
|
564
600
|
|
565
601
|
def test_explicitly_multipart_with_content_type
|
566
|
-
mail = TestMailer.create_explicitly_multipart_example(@recipient,
|
567
|
-
"multipart/alternative")
|
602
|
+
mail = TestMailer.create_explicitly_multipart_example(@recipient, "multipart/alternative")
|
568
603
|
assert_equal 3, mail.parts.length
|
569
604
|
assert_equal "multipart/alternative", mail.content_type
|
570
605
|
end
|
@@ -578,6 +613,7 @@ EOF
|
|
578
613
|
def test_implicitly_multipart_messages
|
579
614
|
mail = TestMailer.create_implicitly_multipart_example(@recipient)
|
580
615
|
assert_equal 3, mail.parts.length
|
616
|
+
assert_equal "1.0", mail.mime_version
|
581
617
|
assert_equal "multipart/alternative", mail.content_type
|
582
618
|
assert_equal "text/yaml", mail.parts[0].content_type
|
583
619
|
assert_equal "utf-8", mail.parts[0].sub_header("content-type", "charset")
|
@@ -588,18 +624,33 @@ EOF
|
|
588
624
|
end
|
589
625
|
|
590
626
|
def test_implicitly_multipart_messages_with_custom_order
|
591
|
-
mail = TestMailer.create_implicitly_multipart_example(@recipient, ["text/yaml", "text/plain"])
|
627
|
+
mail = TestMailer.create_implicitly_multipart_example(@recipient, nil, ["text/yaml", "text/plain"])
|
592
628
|
assert_equal 3, mail.parts.length
|
593
629
|
assert_equal "text/html", mail.parts[0].content_type
|
594
630
|
assert_equal "text/plain", mail.parts[1].content_type
|
595
631
|
assert_equal "text/yaml", mail.parts[2].content_type
|
596
632
|
end
|
597
633
|
|
634
|
+
def test_implicitly_multipart_messages_with_charset
|
635
|
+
mail = TestMailer.create_implicitly_multipart_example(@recipient, 'iso-8859-1')
|
636
|
+
|
637
|
+
assert_equal "multipart/alternative", mail.header['content-type'].body
|
638
|
+
|
639
|
+
assert_equal 'iso-8859-1', mail.parts[0].sub_header("content-type", "charset")
|
640
|
+
assert_equal 'iso-8859-1', mail.parts[1].sub_header("content-type", "charset")
|
641
|
+
assert_equal 'iso-8859-1', mail.parts[2].sub_header("content-type", "charset")
|
642
|
+
end
|
643
|
+
|
598
644
|
def test_html_mail
|
599
645
|
mail = TestMailer.create_html_mail(@recipient)
|
600
646
|
assert_equal "text/html", mail.content_type
|
601
647
|
end
|
602
648
|
|
649
|
+
def test_html_mail_with_underscores
|
650
|
+
mail = TestMailer.create_html_mail_with_underscores(@recipient)
|
651
|
+
assert_equal %{<a href="http://google.com" target="_blank">_Google</a>}, mail.body
|
652
|
+
end
|
653
|
+
|
603
654
|
def test_various_newlines
|
604
655
|
mail = TestMailer.create_various_newlines(@recipient)
|
605
656
|
assert_equal("line #1\nline #2\nline #3\nline #4\n\n" +
|
@@ -668,5 +719,11 @@ EOF
|
|
668
719
|
assert_match(/:/, mail.cc_addrs.to_s)
|
669
720
|
assert_match(/:/, mail.bcc_addrs.to_s)
|
670
721
|
end
|
722
|
+
|
723
|
+
def test_deliver_with_mail_object
|
724
|
+
mail = TestMailer::create_headers_with_nonalpha_chars(@recipient)
|
725
|
+
assert_nothing_raised { TestMailer.deliver(mail) }
|
726
|
+
assert_equal 1, TestMailer.deliveries.length
|
727
|
+
end
|
671
728
|
end
|
672
729
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + "/../lib/")
|
2
|
+
$:.unshift(File.dirname(__FILE__) + "/../lib/action_mailer/vendor")
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'tmail'
|
6
|
+
require 'tempfile'
|
7
|
+
|
8
|
+
class QuotingTest < Test::Unit::TestCase
|
9
|
+
def test_quote_multibyte_chars
|
10
|
+
original = "\303\246 \303\270 and \303\245"
|
11
|
+
|
12
|
+
result = execute_in_sandbox(<<-CODE)
|
13
|
+
$:.unshift(File.dirname(__FILE__) + "/../lib/")
|
14
|
+
$KCODE = 'u'
|
15
|
+
require 'jcode'
|
16
|
+
require 'action_mailer/quoting'
|
17
|
+
include ActionMailer::Quoting
|
18
|
+
quoted_printable(#{original.inspect}, "UTF-8")
|
19
|
+
CODE
|
20
|
+
|
21
|
+
unquoted = TMail::Unquoter.unquote_and_convert_to(result, nil)
|
22
|
+
assert_equal unquoted, original
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
# This whole thing *could* be much simpler, but I don't think Tempfile,
|
28
|
+
# popen and others exist on all platforms (like Windows).
|
29
|
+
def execute_in_sandbox(code)
|
30
|
+
test_name = "#{File.dirname(__FILE__)}/am-quoting-test.#{$$}.rb"
|
31
|
+
res_name = "#{File.dirname(__FILE__)}/am-quoting-test.#{$$}.out"
|
32
|
+
|
33
|
+
File.open(test_name, "w+") do |file|
|
34
|
+
file.write(<<-CODE)
|
35
|
+
block = Proc.new do
|
36
|
+
#{code}
|
37
|
+
end
|
38
|
+
puts block.call
|
39
|
+
CODE
|
40
|
+
end
|
41
|
+
|
42
|
+
system("ruby #{test_name} > #{res_name}") or raise "could not run test in sandbox"
|
43
|
+
File.read(res_name)
|
44
|
+
ensure
|
45
|
+
File.delete(test_name) rescue nil
|
46
|
+
File.delete(res_name) rescue nil
|
47
|
+
end
|
48
|
+
end
|
data/test/tmail_test.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + "/../lib/")
|
2
|
+
$:.unshift File.dirname(__FILE__) + "/fixtures/helpers"
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'action_mailer'
|
6
|
+
|
7
|
+
class TMailMailTest < Test::Unit::TestCase
|
8
|
+
def test_body
|
9
|
+
m = TMail::Mail.new
|
10
|
+
expected = 'something_with_underscores'
|
11
|
+
m.encoding = 'quoted-printable'
|
12
|
+
quoted_body = [expected].pack('*M')
|
13
|
+
m.body = quoted_body
|
14
|
+
assert_equal "something_with_underscores=\n", m.quoted_body
|
15
|
+
assert_equal expected, m.body
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.10
|
|
3
3
|
specification_version: 1
|
4
4
|
name: actionmailer
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.
|
7
|
-
date: 2005-
|
6
|
+
version: 1.1.1
|
7
|
+
date: 2005-10-19
|
8
8
|
summary: Service layer for easy email delivery and testing.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -43,6 +43,7 @@ files:
|
|
43
43
|
- lib/action_mailer/quoting.rb
|
44
44
|
- lib/action_mailer/utils.rb
|
45
45
|
- lib/action_mailer/vendor
|
46
|
+
- lib/action_mailer/version.rb
|
46
47
|
- lib/action_mailer/vendor/text
|
47
48
|
- lib/action_mailer/vendor/tmail
|
48
49
|
- lib/action_mailer/vendor/tmail.rb
|
@@ -71,12 +72,16 @@ files:
|
|
71
72
|
- lib/action_mailer/vendor/tmail/utils.rb
|
72
73
|
- test/fixtures
|
73
74
|
- test/mail_helper_test.rb
|
75
|
+
- test/mail_render_test.rb
|
74
76
|
- test/mail_service_test.rb
|
77
|
+
- test/quoting_test.rb
|
78
|
+
- test/tmail_test.rb
|
75
79
|
- test/fixtures/helper_mailer
|
76
80
|
- test/fixtures/helpers
|
77
81
|
- test/fixtures/raw_email
|
78
82
|
- test/fixtures/raw_email10
|
79
83
|
- test/fixtures/raw_email11
|
84
|
+
- test/fixtures/raw_email12
|
80
85
|
- test/fixtures/raw_email2
|
81
86
|
- test/fixtures/raw_email3
|
82
87
|
- test/fixtures/raw_email4
|
@@ -113,5 +118,5 @@ dependencies:
|
|
113
118
|
-
|
114
119
|
- "="
|
115
120
|
- !ruby/object:Gem::Version
|
116
|
-
version: 1.
|
121
|
+
version: 1.10.1
|
117
122
|
version:
|