From 735027e58d3000bd5d939e39deabfecef83ee20c Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Mon, 7 Jun 2010 15:30:08 -0400 Subject: Updating ActionMailer to Mail 2.2.2 (fixing two tests to suit) --- actionmailer/test/old_base/mail_service_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/old_base/mail_service_test.rb b/actionmailer/test/old_base/mail_service_test.rb index 7054e8052a..e8e8fcedc9 100644 --- a/actionmailer/test/old_base/mail_service_test.rb +++ b/actionmailer/test/old_base/mail_service_test.rb @@ -674,7 +674,7 @@ The body EOF mail = Mail.new(msg) assert_equal "testing testing \326\244", mail.subject - assert_equal "Subject: =?UTF-8?Q?testing_testing_=D6=A4?=\r\n", mail[:subject].encoded + assert_equal "Subject: testing testing =?UTF-8?Q?_=D6=A4=?=\r\n", mail[:subject].encoded end def test_unquote_7bit_subject @@ -863,7 +863,7 @@ EOF def test_multipart_with_utf8_subject mail = TestMailer.multipart_with_utf8_subject(@recipient) - regex = Regexp.escape('Subject: =?UTF-8?Q?Foo_=C3=A1=C3=AB=C3=B4_=C3=AE=C3=BC?=') + regex = Regexp.escape('Subject: Foo =?UTF-8?Q?=C3=A1=C3=AB=C3=B4=?= =?UTF-8?Q?_=C3=AE=C3=BC=?=') assert_match(/#{regex}/, mail.encoded) string = "Foo áëô îü" assert_match(string, mail.subject) @@ -871,7 +871,7 @@ EOF def test_implicitly_multipart_with_utf8 mail = TestMailer.implicitly_multipart_with_utf8 - regex = Regexp.escape('Subject: =?UTF-8?Q?Foo_=C3=A1=C3=AB=C3=B4_=C3=AE=C3=BC?=') + regex = Regexp.escape('Subject: Foo =?UTF-8?Q?=C3=A1=C3=AB=C3=B4=?= =?UTF-8?Q?_=C3=AE=C3=BC=?=') assert_match(/#{regex}/, mail.encoded) string = "Foo áëô îü" assert_match(string, mail.subject) -- cgit v1.2.3 From 311d99eef01c268cedc6e9b3bdb9abc2ba5c6bfa Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Mon, 7 Jun 2010 21:54:53 -0400 Subject: Adding inline attachment support to ActionMailer --- actionmailer/test/base_test.rb | 17 +++++++++++++++++ .../fixtures/base_mailer/inline_attachment.html.erb | 5 +++++ .../fixtures/base_mailer/inline_attachment.text.erb | 4 ++++ 3 files changed, 26 insertions(+) create mode 100644 actionmailer/test/fixtures/base_mailer/inline_attachment.html.erb create mode 100644 actionmailer/test/fixtures/base_mailer/inline_attachment.text.erb (limited to 'actionmailer/test') diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index 54bf3de6af..b9226196fd 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -33,6 +33,11 @@ class BaseTest < ActiveSupport::TestCase mail(hash) end + def inline_attachment + attachments.inline['logo.png'] = "\312\213\254\232" + mail + end + def attachment_with_content(hash = {}) attachments['invoice.pdf'] = 'This is test File content' mail(hash) @@ -264,6 +269,18 @@ class BaseTest < ActiveSupport::TestCase assert_equal("application/pdf", email.parts[1].mime_type) assert_equal("VGhpcyBpcyB0ZXN0IEZpbGUgY29udGVudA==\r\n", email.parts[1].body.encoded) end + + test "can embed an inline attachment" do + email = BaseMailer.inline_attachment + # Need to call #encoded to force the JIT sort on parts + email.encoded + assert_equal(2, email.parts.length) + assert_equal("multipart/related", email.mime_type) + assert_equal("multipart/alternative", email.parts[0].mime_type) + assert_equal("text/plain", email.parts[0].parts[0].mime_type) + assert_equal("text/html", email.parts[0].parts[1].mime_type) + assert_equal("logo.png", email.parts[1].filename) + end # Defaults values test "uses default charset from class" do diff --git a/actionmailer/test/fixtures/base_mailer/inline_attachment.html.erb b/actionmailer/test/fixtures/base_mailer/inline_attachment.html.erb new file mode 100644 index 0000000000..e200878127 --- /dev/null +++ b/actionmailer/test/fixtures/base_mailer/inline_attachment.html.erb @@ -0,0 +1,5 @@ +

Inline Image

+ +<%= image_tag attachments['logo.png'].url %> + +

This is an image that is inline

\ No newline at end of file diff --git a/actionmailer/test/fixtures/base_mailer/inline_attachment.text.erb b/actionmailer/test/fixtures/base_mailer/inline_attachment.text.erb new file mode 100644 index 0000000000..e161d244d2 --- /dev/null +++ b/actionmailer/test/fixtures/base_mailer/inline_attachment.text.erb @@ -0,0 +1,4 @@ +Inline Image + +No image for you + -- cgit v1.2.3