From f3b63120aa7c7610cf691f31e5998988ff813586 Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: Sun, 7 Jul 2024 18:14:05 +1000 Subject: [PATCH] add a test case for 8bit attachment without GPG This is the opposite behaviour to the test case added in the previous commit (the attachment goes in unmodified). --- test/unit/test_edit_message_mode.rb | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/test/unit/test_edit_message_mode.rb b/test/unit/test_edit_message_mode.rb index 0466f010..5077e0e5 100644 --- a/test/unit/test_edit_message_mode.rb +++ b/test/unit/test_edit_message_mode.rb @@ -36,9 +36,34 @@ def teardown $config = nil end - def test_attachment_content_transfer_encoding_signed + def test_attachment_content_transfer_encoding ## RMail::Message#make_attachment will choose ## Content-Transfer-Encoding: 8bit for a CSV file. + ## If we're not GPG signing or encrypting then the attachment will be sent + ## as is. Note this assumes the SMTP servers in the delivery path all + ## support the 8BITMIME extension. + attachment_content = "löl,\ntest,\n" + attachment_filename = File.join @path, "dummy.csv" + File.write attachment_filename, attachment_content + + opts = { + :header => { + "From" => "sender@example.invalid", + "To" => "recip@example.invalid", + }, + :attachments => { + "dummy.csv" => RMail::Message.make_file_attachment(attachment_filename), + }, + } + mode = Redwood::EditMessageMode.new opts + + msg = mode.send :build_message, Time.now + attachment = msg.part(1) + assert_equal attachment_content, attachment.body + assert_equal "8bit", attachment.header["Content-Transfer-Encoding"] + end + + def test_attachment_content_transfer_encoding_signed attachment_filename = File.join @path, "dummy.csv" ## Include some high bytes in the attachment contents in order to ## exercise quote-printable transfer encoding.