from patchwork.tests.utils import create_patch
from patchwork.tests.utils import create_project
from patchwork.tests.utils import create_person
+from patchwork.tests.utils import create_series_patch
from patchwork.tests.utils import create_user
self.assertContains(response, content)
self.assertNotContains(response, content + '\n')
+
+
+class MboxSeriesDependencies(TestCase):
+
+ def test_patch_with_dependencies(self):
+ patch_a = create_series_patch()
+ patch_b = create_series_patch(series=patch_a.series)
+
+ response = self.client.get('%s?series=*' % reverse(
+ 'patch-mbox', args=[patch_b.patch.id]))
+
+ self.assertContains(response, patch_a.patch.content)
+ self.assertContains(response, patch_b.patch.content)
+
+ def test_legacy_patch(self):
+ """Validate a patch with non-existent dependencies raises a 404."""
+ # we're explicitly creating a patch without a series
+ patch = create_patch()
+
+ response = self.client.get('%s?series=*' % reverse(
+ 'patch-mbox', args=[patch.id]))
+
+ self.assertEqual(response.status_code, 404)
response = HttpResponse(content_type='text/plain')
if series_id:
+ if not patch.series.count():
+ raise Http404('Patch does not have an associated series. This is '
+ 'because the patch was processed with an older '
+ 'version of Patchwork. It is not possible to '
+ 'provide dependencies for this patch.')
response.write(series_patch_to_mbox(patch, series_id))
else:
response.write(patch_to_mbox(patch))
--- /dev/null
+---
+fixes:
+ - |
+ If a patch was processed by Patchwork before series support was added, it
+ will not have a series associated with it. As a result, it is not possible
+ to extract the dependencies for that patch from the series. This was not
+ previously handled correctly. A 404 is now raised if this occurs.