aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/fixtures/incoming-request-attach-attachments.email54
-rw-r--r--spec/models/incoming_message_spec.rb20
2 files changed, 74 insertions, 0 deletions
diff --git a/spec/fixtures/incoming-request-attach-attachments.email b/spec/fixtures/incoming-request-attach-attachments.email
new file mode 100644
index 000000000..efcf1a4d1
--- /dev/null
+++ b/spec/fixtures/incoming-request-attach-attachments.email
@@ -0,0 +1,54 @@
+From francis@localhost Tue Dec 22 14:34:49 2009
+From: Francis Irving <francis@localhost>
+To: test@localhost
+Subject: This is a test
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="V0207lvV8h4k8FAm"
+Content-Disposition: inline
+X-Mutt-Fcc: =uniheap
+Status: RO
+Content-Length: 852
+Lines: 42
+
+
+--V0207lvV8h4k8FAm
+Content-Type: text/plain; charset=us-ascii
+Content-Disposition: inline
+
+Attached is an email containing attachments.
+
+Francis
+
+--V0207lvV8h4k8FAm
+Content-Type: application/octet-stream; charset=us-ascii
+Content-Disposition: attachment; filename="incoming-request-two-same-name.email"
+
+From: EMAIL_FROM
+To: FOI Person <foi_person@localhost>
+Subject: Same attachment twice
+Content-Type: multipart/mixed; boundary="Q68bSM7Ycu6FN28Q"
+Content-Disposition: inline
+
+
+--Q68bSM7Ycu6FN28Q
+Content-Type: text/plain; charset=us-ascii
+Content-Disposition: inline
+
+
+
+--Q68bSM7Ycu6FN28Q
+Content-Type: text/plain; charset=us-ascii
+Content-Disposition: attachment; filename="hello.txt"
+
+Second hello
+
+--Q68bSM7Ycu6FN28Q
+Content-Type: text/plain; charset=us-ascii
+Content-Disposition: attachment; filename="hello.txt"
+
+First hello
+
+--Q68bSM7Ycu6FN28Q--
+
+
+--V0207lvV8h4k8FAm--
diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb
index f08f1338c..71d8da647 100644
--- a/spec/models/incoming_message_spec.rb
+++ b/spec/models/incoming_message_spec.rb
@@ -228,4 +228,24 @@ describe IncomingMessage, " when uudecoding bad messages" do
end
+describe IncomingMessage, "when messages are attached to messages" do
+ it "should flatten all the attachments out" do
+ mail_body = load_file_fixture('incoming-request-attach-attachments.email')
+ mail = TMail::Mail.parse(mail_body)
+ mail.base64_decode
+
+ im = IncomingMessage.new
+ im.stub!(:mail).and_return(mail)
+ ir = InfoRequest.new
+ im.info_request = ir
+
+ attachments = im.get_attachments_for_display
+ attachments.size.should == 3
+ attachments[0].display_filename.should == 'Same attachment twice.txt'
+ attachments[1].display_filename.should == 'hello.txt'
+ attachments[2].display_filename.should == 'hello.txt'
+ end
+end
+
+