Mercurial > p > roundup > code
changeset 4498:8df9492c2746
Fix file-unlink bug in mailgw
(Ralfs oversight when refactoring the mail gateway code) -- if a
message is sent that contains no attachments, all previous files of
the issue are unlinked, thanks to Rafal Bisingier for reporting and
proposing a fix.
I've now added a regression test that catches this issue.
| author | Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net> |
|---|---|
| date | Sun, 29 May 2011 18:25:49 +0000 |
| parents | 29576edb45d5 |
| children | 431bf4e7d3d7 |
| files | CHANGES.txt doc/acknowledgements.txt roundup/mailgw.py test/test_mailgw.py |
| diffstat | 4 files changed, 44 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGES.txt Mon May 23 12:15:23 2011 +0000 +++ b/CHANGES.txt Sun May 29 18:25:49 2011 +0000 @@ -2,13 +2,21 @@ are given with the most recent entry first. If no other name is given, Richard Jones did the change. -2011-XX-XX 1.X.XX (rXXXX) +2011-05-29 1.4.18 (rXXXX) Features: - Norwegian Bokmal translation by Christian Aastorp - Allow to specify additional cc and bcc emails (not roundup users) for - nosymessage used by the nosyreaction reactor. + nosymessage used by the nosyreaction reactor. (Ralf) + +Fixed: + +- Fix file-unlink bug in mailgw (Ralfs oversight when refactoring the mail + gateway code) -- if a message is sent that contains no attachments, + all previous files of the issue are unlinked, thanks to Rafal + Bisingier for reporting and proposing a fix. + I've now added a regression test that catches this issue. 2011-05-13 1.4.17 (r4605)
--- a/doc/acknowledgements.txt Mon May 23 12:15:23 2011 +0000 +++ b/doc/acknowledgements.txt Sun May 29 18:25:49 2011 +0000 @@ -14,6 +14,7 @@ Marlon van den Berg, Bo Berglund, Stéphane Bidoul, +Rafal Bisingier, Cameron Blackwood, Jeff Blaine, Duncan Booth,
--- a/roundup/mailgw.py Mon May 23 12:15:23 2011 +0000 +++ b/roundup/mailgw.py Sun May 29 18:25:49 2011 +0000 @@ -1058,7 +1058,7 @@ fileprop.extend(files) files = fileprop - self.props['files'] = files + self.props['files'] = files def create_msg(self): ''' Create msg containing all the relevant information from the message @@ -1093,7 +1093,8 @@ try: message_id = self.db.msg.create(author=self.author, recipients=self.recipients, date=date.Date('.'), - summary=summary, content=content, files=self.props['files'], + summary=summary, content=content, + files=self.props.get('files',[]), messageid=messageid, inreplyto=inreplyto, **msg_props) except exceptions.Reject, error: raise MailUsageError, _("""
--- a/test/test_mailgw.py Mon May 23 12:15:23 2011 +0000 +++ b/test/test_mailgw.py Sun May 29 18:25:49 2011 +0000 @@ -625,6 +625,36 @@ self.assertEqual(f.content, content [n]) self.assertEqual(msg.content, 'test attachment second text/plain') + def testMultipartKeepFiles(self): + self.doNewIssue() + self._handle_mail(self.multipart_msg) + messages = self.db.issue.get('1', 'messages') + messages.sort() + msg = self.db.msg.getnode (messages[-1]) + assert(len(msg.files) == 5) + issue = self.db.issue.getnode ('1') + assert(len(issue.files) == 5) + names = {0 : 'first.dvi', 4 : 'second.dvi'} + content = {3 : 'test attachment third text/plain\n', + 4 : 'Just a test\n'} + for n, id in enumerate (msg.files): + f = self.db.file.getnode (id) + self.assertEqual(f.name, names.get (n, 'unnamed')) + if n in content : + self.assertEqual(f.content, content [n]) + self.assertEqual(msg.content, 'test attachment second text/plain') + self._handle_mail('''From: mary <mary@test.test> +To: issue_tracker@your.tracker.email.domain.example +Message-Id: <followup_dummy_id2> +In-Reply-To: <dummy_test_message_id> +Subject: [issue1] Testing... + +This ist a message without attachment +''') + issue = self.db.issue.getnode ('1') + assert(len(issue.files) == 5) + self.assertEqual(issue.files, ['1', '2', '3', '4', '5']) + def testMultipartDropAlternatives(self): self.doNewIssue() self.db.config.MAILGW_IGNORE_ALTERNATIVES = True
