Commit 70435e50 authored by Arkadiusz Hiler's avatar Arkadiusz Hiler

models: Copy cover letter when duplicating revision

Cover letter is also a part of revision "metadata". Coping it over makes
the overall experience better - all the meta tags included in the cover
are preserved and user can see it on revisions caused by a rerun or a
single patch bump.

The difference between duplicate_meta and duplicate is that duplicate
also copies over patches, this may need a better naming.
Signed-off-by: Arkadiusz Hiler's avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
parent 3b6f48cc
Pipeline #13772 passed with stage
in 11 minutes and 34 seconds
...@@ -726,7 +726,6 @@ def on_revision_complete(sender, revision, **kwargs): ...@@ -726,7 +726,6 @@ def on_revision_complete(sender, revision, **kwargs):
previous_series = previous_series[0] previous_series = previous_series[0]
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.cover_letter = revision.cover_letter
new_revision.n_patches = revision.n_patches new_revision.n_patches = revision.n_patches
new_revision.save() new_revision.save()
i = 1 i = 1
......
...@@ -666,7 +666,9 @@ class SeriesRevision(models.Model): ...@@ -666,7 +666,9 @@ class SeriesRevision(models.Model):
def duplicate_meta(self): def duplicate_meta(self):
new = SeriesRevision.objects.get(pk=self.pk) new = SeriesRevision.objects.get(pk=self.pk)
new.pk = None new.pk = None
new.cover_letter = None new.cover_letter = self.cover_letter
new.raw_cover_letter = self.raw_cover_letter
new.raw_cover_letter_headers = self.raw_cover_letter_headers
new.version = self.version + 1 new.version = self.version + 1
new.test_state = None new.test_state = None
new.save() new.save()
......
...@@ -500,7 +500,7 @@ class SinglePatchUpdateTest(GeneratedSeriesTest): ...@@ -500,7 +500,7 @@ class SinglePatchUpdateTest(GeneratedSeriesTest):
r = revisions[1] r = revisions[1]
self.check_revision(series, r) self.check_revision(series, r)
self.assertTrue(r.cover_letter is None) self.assertEquals(r.cover_letter, self.cover_letter)
p = r.ordered_patches()[n - 1] p = r.ordered_patches()[n - 1]
self.assertEquals(p.msgid, patch_v2_mail.get('Message-Id')) self.assertEquals(p.msgid, patch_v2_mail.get('Message-Id'))
...@@ -825,6 +825,28 @@ class SeriesStateTest(GeneratedSeriesTest): ...@@ -825,6 +825,28 @@ class SeriesStateTest(GeneratedSeriesTest):
self.check_revision_summary(revision, {'Accepted': 2, 'Rejected': 1}) self.check_revision_summary(revision, {'Accepted': 2, 'Rejected': 1})
class SeriesRevisionTest(GeneratedSeriesTest):
def testDuplicateMetaShouldCopyCoverLetter(self):
(test_series, mails) = self._create_series(1)
test_series.insert(mails)
series = Series.objects.all()[0]
org = series.revisions()[0]
org.save()
dup = org.duplicate_meta()
print(dup.pk)
self.assertTrue(dup.test_state is None)
self.assertNotEqual(dup.pk, org.pk)
self.assertEquals(dup.version, org.version + 1)
self.assertEquals(dup.cover_letter, org.cover_letter)
self.assertEquals(dup.raw_cover_letter, org.raw_cover_letter)
self.assertEquals(dup.raw_cover_letter_headers,
org.raw_cover_letter_headers)
# #
# series-new-revision event tests # series-new-revision event tests
# #
......
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