Commit 13cfb0cf authored by Arkadiusz Hiler's avatar Arkadiusz Hiler

parsemail: Use new cover letter if provided

Due to complex handling of incoming series all the new cover letters
were not used.

parsemail creates new, transient revision that is later discarded.
Everything that should get persistent in the proper revision has to be
copied over explicitly in on_revision_complete signal handler.

So let's do that for all the cover_letter fields, but only if they are
present.
Signed-off-by: Arkadiusz Hiler's avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
parent 67a63377
Pipeline #16528 passed with stage
in 2 minutes and 42 seconds
...@@ -727,6 +727,14 @@ def on_revision_complete(sender, revision, **kwargs): ...@@ -727,6 +727,14 @@ def on_revision_complete(sender, revision, **kwargs):
new_revision = previous_series.latest_revision().duplicate_meta() new_revision = previous_series.latest_revision().duplicate_meta()
new_revision.root_msgid = revision.root_msgid new_revision.root_msgid = revision.root_msgid
new_revision.n_patches = revision.n_patches new_revision.n_patches = revision.n_patches
if revision.cover_letter:
new_revision.cover_letter = revision.cover_letter
if revision.raw_cover_letter:
new_revision.raw_cover_letter = revision.raw_cover_letter
if revision.raw_cover_letter_headers:
new_revision.raw_cover_letter_headers = \
revision.raw_cover_letter_headers
new_revision.save() new_revision.save()
i = 1 i = 1
for patch in revision.ordered_patches(): for patch in revision.ordered_patches():
......
...@@ -924,3 +924,33 @@ class StateChangeEventLogTest(Series0010): ...@@ -924,3 +924,33 @@ class StateChangeEventLogTest(Series0010):
update_count += 1 update_count += 1
stateChangeLogCount = EventLog.objects.filter(event_id=2).count() stateChangeLogCount = EventLog.objects.filter(event_id=2).count()
self.assertEquals(update_count, stateChangeLogCount) self.assertEquals(update_count, stateChangeLogCount)
class CoverLetterUpdates(IntelGfxTest):
raw_cover_letter = "This is new cover letter\n-- \n2.2"
cover_letter = "This is new cover letter"
def testNewCoverLetterShouldBeStored(self):
test_series = TestSeries(3, project=self.project,
has_cover_letter=True)
test_series.insert()
test_series_updated = TestSeries(3, project=self.project,
has_cover_letter=True)
updated_mails = test_series_updated.create_mails()
updated_mails[0].set_payload(self.raw_cover_letter)
test_series_updated.insert(updated_mails)
revisions = list(SeriesRevision.objects.all())
self.assertEquals(len(revisions), 2)
original = revisions[0]
updated = revisions[1]
self.assertNotEqual(original.cover_letter, updated.cover_letter)
self.assertNotEqual(original.raw_cover_letter,
updated.raw_cover_letter)
self.assertEqual(updated.cover_letter, self.cover_letter)
self.assertEqual(updated.raw_cover_letter, self.raw_cover_letter)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment