test/unit/test_rmail_message.rb (1095B) - raw
1 require "test_helper"
2
3 require "sup"
4
5 class TestRMailMessage < Minitest::Test
6 def setup
7 @path = Dir.mktmpdir
8 end
9
10 def teardown
11 FileUtils.rm_r @path
12 end
13
14 def test_make_file_attachment
15 filename = File.join @path, "test.html"
16 File.write filename, "<html></html>"
17
18 a = RMail::Message.make_file_attachment(filename)
19 assert_equal "text/html; name=\"test.html\"", a.header["Content-Type"]
20 assert_equal "attachment; filename=\"test.html\"", a.header["Content-Disposition"]
21 assert_equal "8bit", a.header["Content-Transfer-Encoding"]
22 end
23
24 def test_make_file_attachment_text_with_long_lines
25 filename = File.join @path, "test.html"
26 File.write filename, "a" * 1023
27
28 a = RMail::Message.make_file_attachment(filename)
29 assert_equal "text/html; name=\"test.html\"", a.header["Content-Type"]
30 assert_equal "attachment; filename=\"test.html\"", a.header["Content-Disposition"]
31 assert_equal "quoted-printable", a.header["Content-Transfer-Encoding"]
32
33 qp_encoded = ("a" * 73 + "=\n") * 14 + "a=\n"
34 assert_equal qp_encoded, a.body
35 end
36 end