diff options
-rw-r--r-- | spec/fixtures/files/rfc822-attachment.email | 147 | ||||
-rw-r--r-- | spec/models/incoming_message_spec.rb | 18 |
2 files changed, 165 insertions, 0 deletions
diff --git a/spec/fixtures/files/rfc822-attachment.email b/spec/fixtures/files/rfc822-attachment.email new file mode 100644 index 000000000..ae58a06af --- /dev/null +++ b/spec/fixtures/files/rfc822-attachment.email @@ -0,0 +1,147 @@ +From foi.officer@example.com Fri Mar 14 08:39:57 2008 +Return-path: <foi.officer@example.com> +Envelope-to: request-bounce-xx-xxxxx@whatdotheyknow.com +Delivery-date: Fri, 14 Mar 2008 08:39:57 +0000 +Received: from service27.mimecast.com ([213.235.63.79]:55305) + by tea.ukcod.org.uk with smtp (Exim 4.50) + id 1Ja5SH-0005iP-Jm + for xxx@whatdotheyknow.com; Fri, 14 Mar 2008 08:39:57 +0000 +Received: from mailscan.ad.example.com (mailgate.example.com [194.70.143.2]) + by service27.mimecast.com; + Fri, 14 Mar 2008 08:38:47 +0000 +Received: from exch2serv.ad.example.com ([201.234.62.4]) by mailscan.ad.example.com with InterScan Message Security Suite; Fri, 14 Mar 2008 08:38:47 -0000 +X-MIMEOLE: Produced By Microsoft Exchange V6.0.6603.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Subject: +Date: Fri, 14 Mar 2008 08:38:46 -0000 +Message-ID: <0F3951EA9DCFB246827E1F6513F6C79D096DDADB@exch2serv.ad.example.com> +X-MS-Has-Attach: yes +X-MS-TNEF-Correlator: +Thread-Index: AciFrtIeS9pyMOhuQdyxkm5305zs9g== +From: "An FOI Officer" <foi.officer@example.com> +To: "On" <request-bounce-xx-xxxxx@whatdotheyknow.com> +X-MC-Unique: 108031408384702301 +Content-Type: multipart/mixed; + boundary="----_=_NextPart_001_01C885AE.D1BF23AC" + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C885AE.D1BF23AC +Content-Type: multipart/alternative; + boundary="MCBoundary=_108031408384800401" + +--MCBoundary=_108031408384800401 +Content-Type: text/plain; charset=WINDOWS-1252 +Content-Transfer-Encoding: quoted-printable + + + <<Freedom of Information request >>=20 + + +e-mail: foi.officer@example.com=20 + + + + +***************************************************************************= +******** +The information in this Email and any attachments is personal to the +sender and the views of the author may not necessarily reflect those +of Borough Council. The information is strictly confidential +and is intended only for the named person or organisation to whom it is +addressed as it may contain privileged and confidential information. If +you are not the intended recipient do not copy, distribute or use this +Email, and please notify the sender. Please note that we cannot +guarantee that this message or any attachment is virus free or has not +been intercepted and amended. +***************************************************************************= +******** + +Disclaimer=20 +---------------------------------------------------------------------------= +---------------- +This email message has been scanned for viruses by Mimecast. +Mimecast delivers a complete managed email solution from a single web based= + platform. +For more information please visit www.mimecast.com +---------------------------------------------------------------------------= +---------------- +--MCBoundary=_108031408384800401 +Content-Type: text/html; charset=WINDOWS-1252 +Content-Transfer-Encoding: quoted-printable + +<HTML><BODY> =20 + <BR> + <<Freedom of Information request >> <BR> +<BR> +e-mail: <a href=3D"mailto:foi.officer@example.com">foi.officer@example.com</a> <BR> +<BR> +<BR> +<BR> +<BR> +***************************************************************************= +********<BR> +The information in this Email and any attachments is personal to the<B= +R> +sender and the views of the author may not necessarily reflect those<BR= +> +of Borough Council. The information is strictly confidential<B= +R> +and is intended only for the named person or organisation to whom it is<BR> +addressed as it may contain privileged and confidential information. If<B= +R> +you are not the intended recipient do not copy, distribute or use this= +<BR> +Email, and please notify the sender. Please note that we cannot<B= +R> +guarantee that this message or any attachment is virus free or has not<BR> +been intercepted and amended.<BR> +***************************************************************************= +********<BR> + + <BR> + <BR> + <span style=3D"font-family:Arial; Font-size:10.0pt"> + Disclaimer <p> + <hr width=3D"100%"> + This email message has been scanned for viruses by Mimecast.<BR> + Mimecast delivers a complete managed email solution from a single we= +b based platform.<BR> + For more information please visit <a href=3D"http://www.mimecast.com= +">http://www.mimecast.com</a> + <hr width=3D"100%"> + </span> + </BODY></HTML> + + +--MCBoundary=_108031408384800401-- +------_=_NextPart_001_01C885AE.D1BF23AC +Content-Type: message/rfc822 +Content-Transfer-Encoding: 7bit + +X-MIMEOLE: Produced By Microsoft Exchange V6.0.6603.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Subject: Freedom of Information request +Date: Thu, 13 Mar 2008 16:57:33 -0000 +Message-ID: <0F3951EA9DCFB246827E1F6513F6C79D098AC8C5@exch2serv.ad.example.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Freedom of Information request +Thread-Index: AciE9w0L7QnQlahDQS+Zjrz40mr8KAAD5KuQAADg+1AABjC9wAAAXtJgAAEHJvAAAHTxwA== +X-Priority: 1 +Priority: Urgent +Importance: high +From: "An FOI Officer" <foi.officer@example.com> +To: <request-bounce-xx-xxxxx@whatdotheyno.com> +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: base64 + +c29tZSBleGFtcGxlIHRleHQ= + +------_=_NextPart_001_01C885AE.D1BF23AC-- + + + diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb index 5a3f1a954..1278535f8 100644 --- a/spec/models/incoming_message_spec.rb +++ b/spec/models/incoming_message_spec.rb @@ -441,6 +441,24 @@ end describe IncomingMessage, "when messages are attached to messages" do + it 'should expand an RFC822 attachment' do + mail_body = load_file_fixture('rfc822-attachment.email') + mail = MailHandler.mail_from_raw_email(mail_body) + + im = incoming_messages(:useless_incoming_message) + im.stub!(:mail).and_return(mail) + + attachments = im.get_attachments_for_display + attachments.size.should == 1 + attachment = attachments.first + + attachment.content_type.should == 'text/plain' + attachment.filename.should == "Freedom of Information request.txt" + attachment.charset.should == "utf-8" + attachment.within_rfc822_subject.should == "Freedom of Information request" + attachment.hexdigest.should == 'f10fe56e4f2287685a58b71329f09639' + end + it "should flatten all the attachments out" do mail = get_fixture_mail('incoming-request-attach-attachments.email') |