actionmailer-rack-upgrade 2.3.14.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. data/CHANGELOG +387 -0
  2. data/MIT-LICENSE +21 -0
  3. data/README +149 -0
  4. data/Rakefile +97 -0
  5. data/install.rb +30 -0
  6. data/lib/action_mailer/adv_attr_accessor.rb +30 -0
  7. data/lib/action_mailer/base.rb +739 -0
  8. data/lib/action_mailer/helpers.rb +113 -0
  9. data/lib/action_mailer/mail_helper.rb +17 -0
  10. data/lib/action_mailer/part.rb +107 -0
  11. data/lib/action_mailer/part_container.rb +55 -0
  12. data/lib/action_mailer/quoting.rb +62 -0
  13. data/lib/action_mailer/test_case.rb +64 -0
  14. data/lib/action_mailer/test_helper.rb +68 -0
  15. data/lib/action_mailer/utils.rb +7 -0
  16. data/lib/action_mailer/vendor/text-format-0.6.3/text/format.rb +1466 -0
  17. data/lib/action_mailer/vendor/text_format.rb +10 -0
  18. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/Makefile +18 -0
  19. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/address.rb +392 -0
  20. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/attachments.rb +65 -0
  21. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/base64.rb +46 -0
  22. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/compat.rb +41 -0
  23. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/config.rb +67 -0
  24. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/core_extensions.rb +63 -0
  25. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/encode.rb +590 -0
  26. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/header.rb +962 -0
  27. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/index.rb +9 -0
  28. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/interface.rb +1162 -0
  29. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/loader.rb +3 -0
  30. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/mail.rb +578 -0
  31. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/mailbox.rb +496 -0
  32. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/main.rb +6 -0
  33. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/mbox.rb +3 -0
  34. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/net.rb +250 -0
  35. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/obsolete.rb +132 -0
  36. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/parser.rb +1060 -0
  37. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/parser.y +416 -0
  38. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/port.rb +379 -0
  39. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/quoting.rb +164 -0
  40. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/require_arch.rb +58 -0
  41. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/scanner.rb +49 -0
  42. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/scanner_r.rb +262 -0
  43. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/stringio.rb +280 -0
  44. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/utils.rb +362 -0
  45. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/COPYING +504 -0
  46. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/README +12 -0
  47. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/big5freq.rb +927 -0
  48. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/big5prober.rb +42 -0
  49. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/chardistribution.rb +238 -0
  50. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/charsetgroupprober.rb +112 -0
  51. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/charsetprober.rb +75 -0
  52. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/codingstatemachine.rb +64 -0
  53. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/constants.rb +42 -0
  54. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/escprober.rb +89 -0
  55. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/escsm.rb +244 -0
  56. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/eucjpprober.rb +88 -0
  57. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/euckrfreq.rb +596 -0
  58. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/euckrprober.rb +42 -0
  59. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/euctwfreq.rb +430 -0
  60. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/euctwprober.rb +42 -0
  61. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/gb2312freq.rb +474 -0
  62. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/gb2312prober.rb +42 -0
  63. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/hebrewprober.rb +289 -0
  64. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/jisfreq.rb +570 -0
  65. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/jpcntx.rb +229 -0
  66. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/langbulgarianmodel.rb +229 -0
  67. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/langcyrillicmodel.rb +330 -0
  68. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/langgreekmodel.rb +227 -0
  69. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/langhebrewmodel.rb +202 -0
  70. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/langhungarianmodel.rb +226 -0
  71. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/langthaimodel.rb +201 -0
  72. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/latin1prober.rb +147 -0
  73. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/mbcharsetprober.rb +89 -0
  74. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/mbcsgroupprober.rb +45 -0
  75. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/mbcssm.rb +542 -0
  76. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/sbcharsetprober.rb +124 -0
  77. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/sbcsgroupprober.rb +56 -0
  78. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/sjisprober.rb +88 -0
  79. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/universaldetector.rb +168 -0
  80. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/utf8prober.rb +87 -0
  81. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet.rb +67 -0
  82. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/version.rb +39 -0
  83. data/lib/action_mailer/vendor/tmail-1.2.7/tmail.rb +6 -0
  84. data/lib/action_mailer/vendor/tmail.rb +17 -0
  85. data/lib/action_mailer/version.rb +9 -0
  86. data/lib/action_mailer.rb +62 -0
  87. data/lib/actionmailer.rb +2 -0
  88. data/test/abstract_unit.rb +62 -0
  89. data/test/asset_host_test.rb +54 -0
  90. data/test/delivery_method_test.rb +51 -0
  91. data/test/fixtures/asset_host_mailer/email_with_asset.html.erb +1 -0
  92. data/test/fixtures/auto_layout_mailer/hello.html.erb +1 -0
  93. data/test/fixtures/auto_layout_mailer/multipart.text.html.erb +1 -0
  94. data/test/fixtures/auto_layout_mailer/multipart.text.plain.erb +1 -0
  95. data/test/fixtures/explicit_layout_mailer/logout.html.erb +1 -0
  96. data/test/fixtures/explicit_layout_mailer/signup.html.erb +1 -0
  97. data/test/fixtures/first_mailer/share.erb +1 -0
  98. data/test/fixtures/helper_mailer/use_example_helper.erb +1 -0
  99. data/test/fixtures/helper_mailer/use_helper.erb +1 -0
  100. data/test/fixtures/helper_mailer/use_helper_method.erb +1 -0
  101. data/test/fixtures/helper_mailer/use_mail_helper.erb +5 -0
  102. data/test/fixtures/helpers/example_helper.rb +5 -0
  103. data/test/fixtures/layouts/auto_layout_mailer.html.erb +1 -0
  104. data/test/fixtures/layouts/auto_layout_mailer.text.erb +1 -0
  105. data/test/fixtures/layouts/spam.html.erb +1 -0
  106. data/test/fixtures/path.with.dots/funky_path_mailer/multipart_with_template_path_with_dots.erb +1 -0
  107. data/test/fixtures/raw_email +14 -0
  108. data/test/fixtures/raw_email10 +20 -0
  109. data/test/fixtures/raw_email12 +32 -0
  110. data/test/fixtures/raw_email13 +29 -0
  111. data/test/fixtures/raw_email2 +114 -0
  112. data/test/fixtures/raw_email3 +70 -0
  113. data/test/fixtures/raw_email4 +59 -0
  114. data/test/fixtures/raw_email5 +19 -0
  115. data/test/fixtures/raw_email6 +20 -0
  116. data/test/fixtures/raw_email7 +66 -0
  117. data/test/fixtures/raw_email8 +47 -0
  118. data/test/fixtures/raw_email9 +28 -0
  119. data/test/fixtures/raw_email_quoted_with_0d0a +14 -0
  120. data/test/fixtures/raw_email_with_invalid_characters_in_content_type +104 -0
  121. data/test/fixtures/raw_email_with_nested_attachment +100 -0
  122. data/test/fixtures/raw_email_with_partially_quoted_subject +14 -0
  123. data/test/fixtures/second_mailer/share.erb +1 -0
  124. data/test/fixtures/templates/signed_up.erb +3 -0
  125. data/test/fixtures/test_mailer/_subtemplate.text.plain.erb +1 -0
  126. data/test/fixtures/test_mailer/body_ivar.erb +2 -0
  127. data/test/fixtures/test_mailer/custom_templating_extension.text.html.haml +6 -0
  128. data/test/fixtures/test_mailer/custom_templating_extension.text.plain.haml +6 -0
  129. data/test/fixtures/test_mailer/implicitly_multipart_example.ignored.erb +1 -0
  130. data/test/fixtures/test_mailer/implicitly_multipart_example.rhtml.bak +1 -0
  131. data/test/fixtures/test_mailer/implicitly_multipart_example.text.html.erb +10 -0
  132. data/test/fixtures/test_mailer/implicitly_multipart_example.text.html.erb~ +10 -0
  133. data/test/fixtures/test_mailer/implicitly_multipart_example.text.plain.erb +2 -0
  134. data/test/fixtures/test_mailer/implicitly_multipart_example.text.yaml.erb +1 -0
  135. data/test/fixtures/test_mailer/included_subtemplate.text.plain.erb +1 -0
  136. data/test/fixtures/test_mailer/rxml_template.builder +2 -0
  137. data/test/fixtures/test_mailer/rxml_template.rxml +2 -0
  138. data/test/fixtures/test_mailer/signed_up.html.erb +3 -0
  139. data/test/fixtures/test_mailer/signed_up_with_url.erb +5 -0
  140. data/test/mail_helper_test.rb +95 -0
  141. data/test/mail_layout_test.rb +123 -0
  142. data/test/mail_render_test.rb +116 -0
  143. data/test/mail_service_test.rb +1145 -0
  144. data/test/quoting_test.rb +105 -0
  145. data/test/test_helper_test.rb +129 -0
  146. data/test/tmail_test.rb +22 -0
  147. data/test/url_test.rb +76 -0
  148. metadata +209 -0
@@ -0,0 +1,105 @@
1
+ # encoding: utf-8
2
+ require 'abstract_unit'
3
+ require 'tempfile'
4
+
5
+ class QuotingTest < Test::Unit::TestCase
6
+ # Move some tests from TMAIL here
7
+ def test_unquote_quoted_printable
8
+ a ="=?ISO-8859-1?Q?[166417]_Bekr=E6ftelse_fra_Rejsefeber?="
9
+ b = TMail::Unquoter.unquote_and_convert_to(a, 'utf-8')
10
+ assert_equal "[166417] Bekr\303\246ftelse fra Rejsefeber", b
11
+ end
12
+
13
+ def test_unquote_base64
14
+ a ="=?ISO-8859-1?B?WzE2NjQxN10gQmVrcuZmdGVsc2UgZnJhIFJlanNlZmViZXI=?="
15
+ b = TMail::Unquoter.unquote_and_convert_to(a, 'utf-8')
16
+ assert_equal "[166417] Bekr\303\246ftelse fra Rejsefeber", b
17
+ end
18
+
19
+ def test_unquote_without_charset
20
+ a ="[166417]_Bekr=E6ftelse_fra_Rejsefeber"
21
+ b = TMail::Unquoter.unquote_and_convert_to(a, 'utf-8')
22
+ assert_equal "[166417]_Bekr=E6ftelse_fra_Rejsefeber", b
23
+ end
24
+
25
+ def test_unqoute_multiple
26
+ quoted ="=?utf-8?q?Re=3A_=5B12=5D_=23137=3A_Inkonsistente_verwendung_von_=22Hin?==?utf-8?b?enVmw7xnZW4i?="
27
+ actual = TMail::Unquoter.unquote_and_convert_to(quoted, 'utf-8')
28
+
29
+ expected = "Re: [12] #137: Inkonsistente verwendung von \"Hinzuf\303\274gen\""
30
+ expected.force_encoding 'ASCII-8BIT' if expected.respond_to?(:force_encoding)
31
+
32
+ assert_equal expected, actual
33
+ end
34
+
35
+ def test_unqoute_in_the_middle
36
+ a ="Re: Photos =?ISO-8859-1?Q?Brosch=FCre_Rand?="
37
+ b = TMail::Unquoter.unquote_and_convert_to(a, 'utf-8')
38
+ assert_equal "Re: Photos Brosch\303\274re Rand", b
39
+ end
40
+
41
+ def test_unqoute_iso
42
+ a ="=?ISO-8859-1?Q?Brosch=FCre_Rand?="
43
+ b = TMail::Unquoter.unquote_and_convert_to(a, 'iso-8859-1')
44
+ expected = "Brosch\374re Rand"
45
+ expected.force_encoding 'iso-8859-1' if expected.respond_to?(:force_encoding)
46
+ assert_equal expected, b
47
+ end
48
+
49
+ def test_quote_multibyte_chars
50
+ original = "\303\246 \303\270 and \303\245"
51
+ original.force_encoding('ASCII-8BIT') if original.respond_to?(:force_encoding)
52
+
53
+ result = execute_in_sandbox(<<-CODE)
54
+ $:.unshift(File.dirname(__FILE__) + "/../lib/")
55
+ if RUBY_VERSION < '1.9'
56
+ $KCODE = 'u'
57
+ require 'jcode'
58
+ end
59
+ require 'action_mailer/quoting'
60
+ include ActionMailer::Quoting
61
+ quoted_printable(#{original.inspect}, "UTF-8")
62
+ CODE
63
+
64
+ unquoted = TMail::Unquoter.unquote_and_convert_to(result, nil)
65
+ assert_equal unquoted, original
66
+ end
67
+
68
+
69
+ # test an email that has been created using \r\n newlines, instead of
70
+ # \n newlines.
71
+ def test_email_quoted_with_0d0a
72
+ mail = TMail::Mail.parse(IO.read("#{File.dirname(__FILE__)}/fixtures/raw_email_quoted_with_0d0a"))
73
+ assert_match %r{Elapsed time}, mail.body
74
+ end
75
+
76
+ def test_email_with_partially_quoted_subject
77
+ mail = TMail::Mail.parse(IO.read("#{File.dirname(__FILE__)}/fixtures/raw_email_with_partially_quoted_subject"))
78
+ expected = "Re: Test: \"\346\274\242\345\255\227\" mid \"\346\274\242\345\255\227\" tail"
79
+ expected.force_encoding('ASCII-8BIT') if expected.respond_to?(:force_encoding)
80
+ assert_equal expected, mail.subject
81
+ end
82
+
83
+ private
84
+ # This whole thing *could* be much simpler, but I don't think Tempfile,
85
+ # popen and others exist on all platforms (like Windows).
86
+ def execute_in_sandbox(code)
87
+ test_name = "#{File.dirname(__FILE__)}/am-quoting-test.#{$$}.rb"
88
+ res_name = "#{File.dirname(__FILE__)}/am-quoting-test.#{$$}.out"
89
+
90
+ File.open(test_name, "w+") do |file|
91
+ file.write(<<-CODE)
92
+ block = Proc.new do
93
+ #{code}
94
+ end
95
+ puts block.call
96
+ CODE
97
+ end
98
+
99
+ system("ruby #{test_name} > #{res_name}") or raise "could not run test in sandbox"
100
+ File.read(res_name).chomp
101
+ ensure
102
+ File.delete(test_name) rescue nil
103
+ File.delete(res_name) rescue nil
104
+ end
105
+ end
@@ -0,0 +1,129 @@
1
+ require 'abstract_unit'
2
+
3
+ class TestHelperMailer < ActionMailer::Base
4
+ def test
5
+ recipients "test@example.com"
6
+ from "tester@example.com"
7
+ body render(:inline => "Hello, <%= @world %>", :body => { :world => "Earth" })
8
+ end
9
+ end
10
+
11
+ class TestHelperMailerTest < ActionMailer::TestCase
12
+ def test_setup_sets_right_action_mailer_options
13
+ assert_equal :test, ActionMailer::Base.delivery_method
14
+ assert ActionMailer::Base.perform_deliveries
15
+ assert_equal [], ActionMailer::Base.deliveries
16
+ end
17
+
18
+ def test_setup_creates_the_expected_mailer
19
+ assert @expected.is_a?(TMail::Mail)
20
+ assert_equal "1.0", @expected.mime_version
21
+ assert_equal "text/plain", @expected.content_type
22
+ end
23
+
24
+ def test_mailer_class_is_correctly_inferred
25
+ assert_equal TestHelperMailer, self.class.mailer_class
26
+ end
27
+
28
+ def test_determine_default_mailer_raises_correct_error
29
+ assert_raise(ActionMailer::NonInferrableMailerError) do
30
+ self.class.determine_default_mailer("NotAMailerTest")
31
+ end
32
+ end
33
+
34
+ def test_charset_is_utf_8
35
+ assert_equal "utf-8", charset
36
+ end
37
+
38
+ def test_encode
39
+ assert_equal "=?utf-8?Q?=0Aasdf=0A?=", encode("\nasdf\n")
40
+ end
41
+
42
+ def test_assert_emails
43
+ assert_nothing_raised do
44
+ assert_emails 1 do
45
+ TestHelperMailer.deliver_test
46
+ end
47
+ end
48
+ end
49
+
50
+ def test_repeated_assert_emails_calls
51
+ assert_nothing_raised do
52
+ assert_emails 1 do
53
+ TestHelperMailer.deliver_test
54
+ end
55
+ end
56
+
57
+ assert_nothing_raised do
58
+ assert_emails 2 do
59
+ TestHelperMailer.deliver_test
60
+ TestHelperMailer.deliver_test
61
+ end
62
+ end
63
+ end
64
+
65
+ def test_assert_emails_with_no_block
66
+ assert_nothing_raised do
67
+ TestHelperMailer.deliver_test
68
+ assert_emails 1
69
+ end
70
+
71
+ assert_nothing_raised do
72
+ TestHelperMailer.deliver_test
73
+ TestHelperMailer.deliver_test
74
+ assert_emails 3
75
+ end
76
+ end
77
+
78
+ def test_assert_no_emails
79
+ assert_nothing_raised do
80
+ assert_no_emails do
81
+ TestHelperMailer.create_test
82
+ end
83
+ end
84
+ end
85
+
86
+ def test_assert_emails_too_few_sent
87
+ error = assert_raise ActiveSupport::TestCase::Assertion do
88
+ assert_emails 2 do
89
+ TestHelperMailer.deliver_test
90
+ end
91
+ end
92
+
93
+ assert_match /2 .* but 1/, error.message
94
+ end
95
+
96
+ def test_assert_emails_too_many_sent
97
+ error = assert_raise ActiveSupport::TestCase::Assertion do
98
+ assert_emails 1 do
99
+ TestHelperMailer.deliver_test
100
+ TestHelperMailer.deliver_test
101
+ end
102
+ end
103
+
104
+ assert_match /1 .* but 2/, error.message
105
+ end
106
+
107
+ def test_assert_no_emails_failure
108
+ error = assert_raise ActiveSupport::TestCase::Assertion do
109
+ assert_no_emails do
110
+ TestHelperMailer.deliver_test
111
+ end
112
+ end
113
+
114
+ assert_match /0 .* but 1/, error.message
115
+ end
116
+ end
117
+
118
+ class AnotherTestHelperMailerTest < ActionMailer::TestCase
119
+ tests TestHelperMailer
120
+
121
+ def setup
122
+ @test_var = "a value"
123
+ end
124
+
125
+ def test_setup_shouldnt_conflict_with_mailer_setup
126
+ assert @expected.is_a?(TMail::Mail)
127
+ assert_equal 'a value', @test_var
128
+ end
129
+ end
@@ -0,0 +1,22 @@
1
+ require 'abstract_unit'
2
+
3
+ class TMailMailTest < Test::Unit::TestCase
4
+ def test_body
5
+ m = TMail::Mail.new
6
+ expected = 'something_with_underscores'
7
+ m.encoding = 'quoted-printable'
8
+ quoted_body = [expected].pack('*M')
9
+ m.body = quoted_body
10
+ assert_equal "something_with_underscores=\n", m.quoted_body
11
+ assert_equal expected, m.body
12
+ end
13
+
14
+ def test_nested_attachments_are_recognized_correctly
15
+ fixture = File.read("#{File.dirname(__FILE__)}/fixtures/raw_email_with_nested_attachment")
16
+ mail = TMail::Mail.parse(fixture)
17
+ assert_equal 2, mail.attachments.length
18
+ assert_equal "image/png", mail.attachments.first.content_type
19
+ assert_equal 1902, mail.attachments.first.length
20
+ assert_equal "application/pkcs7-signature", mail.attachments.last.content_type
21
+ end
22
+ end
data/test/url_test.rb ADDED
@@ -0,0 +1,76 @@
1
+ require 'abstract_unit'
2
+
3
+ class TestMailer < ActionMailer::Base
4
+
5
+ default_url_options[:host] = 'www.basecamphq.com'
6
+
7
+ def signed_up_with_url(recipient)
8
+ @recipients = recipient
9
+ @subject = "[Signed up] Welcome #{recipient}"
10
+ @from = "system@loudthinking.com"
11
+ @sent_on = Time.local(2004, 12, 12)
12
+
13
+ @body["recipient"] = recipient
14
+ @body["welcome_url"] = url_for :host => "example.com", :controller => "welcome", :action => "greeting"
15
+ end
16
+
17
+ class <<self
18
+ attr_accessor :received_body
19
+ end
20
+
21
+ def receive(mail)
22
+ self.class.received_body = mail.body
23
+ end
24
+ end
25
+
26
+ class ActionMailerUrlTest < Test::Unit::TestCase
27
+ include ActionMailer::Quoting
28
+
29
+ def encode( text, charset="utf-8" )
30
+ quoted_printable( text, charset )
31
+ end
32
+
33
+ def new_mail( charset="utf-8" )
34
+ mail = TMail::Mail.new
35
+ mail.mime_version = "1.0"
36
+ if charset
37
+ mail.set_content_type "text", "plain", { "charset" => charset }
38
+ end
39
+ mail
40
+ end
41
+
42
+ def setup
43
+ set_delivery_method :test
44
+ ActionMailer::Base.perform_deliveries = true
45
+ ActionMailer::Base.deliveries = []
46
+
47
+ @recipient = 'test@localhost'
48
+ end
49
+
50
+ def teardown
51
+ restore_delivery_method
52
+ end
53
+
54
+ def test_signed_up_with_url
55
+ ActionController::Routing::Routes.draw do |map|
56
+ map.connect ':controller/:action/:id'
57
+ map.welcome 'welcome', :controller=>"foo", :action=>"bar"
58
+ end
59
+
60
+ expected = new_mail
61
+ expected.to = @recipient
62
+ expected.subject = "[Signed up] Welcome #{@recipient}"
63
+ expected.body = "Hello there, \n\nMr. #{@recipient}. Please see our greeting at http://example.com/welcome/greeting http://www.basecamphq.com/welcome\n\n<img alt=\"Somelogo\" src=\"/images/somelogo.png\" />"
64
+ expected.from = "system@loudthinking.com"
65
+ expected.date = Time.local(2004, 12, 12)
66
+
67
+ created = nil
68
+ assert_nothing_raised { created = TestMailer.create_signed_up_with_url(@recipient) }
69
+ assert_not_nil created
70
+ assert_equal expected.encoded, created.encoded
71
+
72
+ assert_nothing_raised { TestMailer.deliver_signed_up_with_url(@recipient) }
73
+ assert_not_nil ActionMailer::Base.deliveries.first
74
+ assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded
75
+ end
76
+ end
metadata ADDED
@@ -0,0 +1,209 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: actionmailer-rack-upgrade
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.3.14.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - David Heinemeier Hansson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: actionpack-rack-upgrade
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.3.14.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.3.14.1
30
+ description: Makes it trivial to test and deliver emails sent from a single service
31
+ layer.
32
+ email: david@loudthinking.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - Rakefile
38
+ - install.rb
39
+ - README
40
+ - CHANGELOG
41
+ - MIT-LICENSE
42
+ - lib/action_mailer/adv_attr_accessor.rb
43
+ - lib/action_mailer/base.rb
44
+ - lib/action_mailer/helpers.rb
45
+ - lib/action_mailer/mail_helper.rb
46
+ - lib/action_mailer/part.rb
47
+ - lib/action_mailer/part_container.rb
48
+ - lib/action_mailer/quoting.rb
49
+ - lib/action_mailer/test_case.rb
50
+ - lib/action_mailer/test_helper.rb
51
+ - lib/action_mailer/utils.rb
52
+ - lib/action_mailer/vendor/text-format-0.6.3/text/format.rb
53
+ - lib/action_mailer/vendor/text_format.rb
54
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/address.rb
55
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/attachments.rb
56
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/base64.rb
57
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/compat.rb
58
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/config.rb
59
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/core_extensions.rb
60
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/encode.rb
61
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/header.rb
62
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/index.rb
63
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/interface.rb
64
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/loader.rb
65
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/mail.rb
66
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/mailbox.rb
67
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/main.rb
68
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/Makefile
69
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/mbox.rb
70
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/net.rb
71
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/obsolete.rb
72
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/parser.rb
73
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/parser.y
74
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/port.rb
75
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/quoting.rb
76
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/require_arch.rb
77
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/scanner.rb
78
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/scanner_r.rb
79
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/stringio.rb
80
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/utils.rb
81
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/COPYING
82
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/big5freq.rb
83
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/big5prober.rb
84
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/chardistribution.rb
85
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/charsetgroupprober.rb
86
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/charsetprober.rb
87
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/codingstatemachine.rb
88
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/constants.rb
89
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/escprober.rb
90
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/escsm.rb
91
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/eucjpprober.rb
92
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/euckrfreq.rb
93
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/euckrprober.rb
94
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/euctwfreq.rb
95
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/euctwprober.rb
96
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/gb2312freq.rb
97
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/gb2312prober.rb
98
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/hebrewprober.rb
99
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/jisfreq.rb
100
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/jpcntx.rb
101
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/langbulgarianmodel.rb
102
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/langcyrillicmodel.rb
103
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/langgreekmodel.rb
104
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/langhebrewmodel.rb
105
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/langhungarianmodel.rb
106
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/langthaimodel.rb
107
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/latin1prober.rb
108
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/mbcharsetprober.rb
109
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/mbcsgroupprober.rb
110
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/mbcssm.rb
111
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/sbcharsetprober.rb
112
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/sbcsgroupprober.rb
113
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/sjisprober.rb
114
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/universaldetector.rb
115
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/utf8prober.rb
116
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet.rb
117
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/README
118
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail/version.rb
119
+ - lib/action_mailer/vendor/tmail-1.2.7/tmail.rb
120
+ - lib/action_mailer/vendor/tmail.rb
121
+ - lib/action_mailer/version.rb
122
+ - lib/action_mailer.rb
123
+ - lib/actionmailer.rb
124
+ - test/abstract_unit.rb
125
+ - test/asset_host_test.rb
126
+ - test/delivery_method_test.rb
127
+ - test/fixtures/asset_host_mailer/email_with_asset.html.erb
128
+ - test/fixtures/auto_layout_mailer/hello.html.erb
129
+ - test/fixtures/auto_layout_mailer/multipart.text.html.erb
130
+ - test/fixtures/auto_layout_mailer/multipart.text.plain.erb
131
+ - test/fixtures/explicit_layout_mailer/logout.html.erb
132
+ - test/fixtures/explicit_layout_mailer/signup.html.erb
133
+ - test/fixtures/first_mailer/share.erb
134
+ - test/fixtures/helper_mailer/use_example_helper.erb
135
+ - test/fixtures/helper_mailer/use_helper.erb
136
+ - test/fixtures/helper_mailer/use_helper_method.erb
137
+ - test/fixtures/helper_mailer/use_mail_helper.erb
138
+ - test/fixtures/helpers/example_helper.rb
139
+ - test/fixtures/layouts/auto_layout_mailer.html.erb
140
+ - test/fixtures/layouts/auto_layout_mailer.text.erb
141
+ - test/fixtures/layouts/spam.html.erb
142
+ - test/fixtures/path.with.dots/funky_path_mailer/multipart_with_template_path_with_dots.erb
143
+ - test/fixtures/raw_email
144
+ - test/fixtures/raw_email10
145
+ - test/fixtures/raw_email12
146
+ - test/fixtures/raw_email13
147
+ - test/fixtures/raw_email2
148
+ - test/fixtures/raw_email3
149
+ - test/fixtures/raw_email4
150
+ - test/fixtures/raw_email5
151
+ - test/fixtures/raw_email6
152
+ - test/fixtures/raw_email7
153
+ - test/fixtures/raw_email8
154
+ - test/fixtures/raw_email9
155
+ - test/fixtures/raw_email_quoted_with_0d0a
156
+ - test/fixtures/raw_email_with_invalid_characters_in_content_type
157
+ - test/fixtures/raw_email_with_nested_attachment
158
+ - test/fixtures/raw_email_with_partially_quoted_subject
159
+ - test/fixtures/second_mailer/share.erb
160
+ - test/fixtures/templates/signed_up.erb
161
+ - test/fixtures/test_mailer/_subtemplate.text.plain.erb
162
+ - test/fixtures/test_mailer/body_ivar.erb
163
+ - test/fixtures/test_mailer/custom_templating_extension.text.html.haml
164
+ - test/fixtures/test_mailer/custom_templating_extension.text.plain.haml
165
+ - test/fixtures/test_mailer/implicitly_multipart_example.ignored.erb
166
+ - test/fixtures/test_mailer/implicitly_multipart_example.rhtml.bak
167
+ - test/fixtures/test_mailer/implicitly_multipart_example.text.html.erb
168
+ - test/fixtures/test_mailer/implicitly_multipart_example.text.html.erb~
169
+ - test/fixtures/test_mailer/implicitly_multipart_example.text.plain.erb
170
+ - test/fixtures/test_mailer/implicitly_multipart_example.text.yaml.erb
171
+ - test/fixtures/test_mailer/included_subtemplate.text.plain.erb
172
+ - test/fixtures/test_mailer/rxml_template.builder
173
+ - test/fixtures/test_mailer/rxml_template.rxml
174
+ - test/fixtures/test_mailer/signed_up.html.erb
175
+ - test/fixtures/test_mailer/signed_up_with_url.erb
176
+ - test/mail_helper_test.rb
177
+ - test/mail_layout_test.rb
178
+ - test/mail_render_test.rb
179
+ - test/mail_service_test.rb
180
+ - test/quoting_test.rb
181
+ - test/test_helper_test.rb
182
+ - test/tmail_test.rb
183
+ - test/url_test.rb
184
+ homepage: http://www.rubyonrails.org
185
+ licenses: []
186
+ post_install_message:
187
+ rdoc_options: []
188
+ require_paths:
189
+ - lib
190
+ required_ruby_version: !ruby/object:Gem::Requirement
191
+ none: false
192
+ requirements:
193
+ - - ! '>='
194
+ - !ruby/object:Gem::Version
195
+ version: '0'
196
+ required_rubygems_version: !ruby/object:Gem::Requirement
197
+ none: false
198
+ requirements:
199
+ - - ! '>='
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ requirements:
203
+ - none
204
+ rubyforge_project: actionmailer
205
+ rubygems_version: 1.8.24
206
+ signing_key:
207
+ specification_version: 3
208
+ summary: Service layer for easy email delivery and testing.
209
+ test_files: []