Merge lp:~thumper/launchpad/code-review-email-attachment-fix into lp:launchpad

Proposed by Tim Penhey
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: not available
Merged at revision: 10368
Proposed branch: lp:~thumper/launchpad/code-review-email-attachment-fix
Merge into: lp:launchpad
Diff against target: 31 lines (+9/-1)
2 files modified
lib/lp/code/mail/codereviewcomment.py (+1/-1)
lib/lp/code/mail/tests/test_codereviewcomment.py (+8/-0)
To merge this branch: bzr merge lp:~thumper/launchpad/code-review-email-attachment-fix
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle Approve
Review via email: mp+19924@code.launchpad.net

Commit message

Fix the content type and filename for code review attachments passed through.

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

Attachment content type and filenames were extracted the wrong way around.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Doh!

Fix looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/mail/codereviewcomment.py'
2--- lib/lp/code/mail/codereviewcomment.py 2009-10-29 23:51:35 +0000
3+++ lib/lp/code/mail/codereviewcomment.py 2010-02-22 23:20:40 +0000
4@@ -133,7 +133,7 @@
5 def _addAttachments(self, ctrl, email):
6 """Add the attachments from the original message."""
7 # Only reattach the display_aliases.
8- for content, content_type, filename in self.attachments:
9+ for content, filename, content_type in self.attachments:
10 # Append directly to the controller's list.
11 ctrl.addAttachment(
12 content, content_type=content_type, filename=filename)
13
14=== modified file 'lib/lp/code/mail/tests/test_codereviewcomment.py'
15--- lib/lp/code/mail/tests/test_codereviewcomment.py 2009-11-01 23:13:29 +0000
16+++ lib/lp/code/mail/tests/test_codereviewcomment.py 2010-02-22 23:20:40 +0000
17@@ -215,6 +215,14 @@
18 [outgoing_attachment] = mailer.attachments
19 self.assertEqual('inc.diff', outgoing_attachment[1])
20 self.assertEqual('text/x-diff', outgoing_attachment[2])
21+ # The attachments are attached to the outgoing message.
22+ person = bmp.target_branch.owner
23+ message = mailer.generateEmail(
24+ person.preferredemail.email, person).makeMessage()
25+ self.assertTrue(message.is_multipart())
26+ attachment = message.get_payload()[1]
27+ self.assertEqual('inc.diff', attachment.get_filename())
28+ self.assertEqual('text/x-diff', attachment['content-type'])
29
30 def makeCommentAndParticipants(self):
31 """Create a merge proposal and comment.