← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/crc-index-git into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/crc-index-git into lp:launchpad.

Commit message:
Fix rendering of merge source for comments on git-based merge proposals.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1485907 in Launchpad itself: "CodeReviewComment:+index OOPSes in the git case"
  https://bugs.launchpad.net/launchpad/+bug/1485907

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/crc-index-git/+merge/268303

Fix rendering of merge source for comments on git-based merge proposals.

Demo: https://code.qastaging.launchpad.net/~cjwatson/grub/+git/qas/+merge/254313/comments/632158
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/crc-index-git into lp:launchpad.
=== modified file 'lib/lp/code/browser/tests/test_codereviewcomment.py'
--- lib/lp/code/browser/tests/test_codereviewcomment.py	2014-11-28 22:07:05 +0000
+++ lib/lp/code/browser/tests/test_codereviewcomment.py	2015-08-18 09:12:09 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2012 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2015 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Unit tests for CodeReviewComments."""
@@ -110,14 +110,14 @@
         self.assertThat(recorder, HasQueryCount(Equals(0)))
 
 
-class TestCodeReviewCommentHtml(BrowserTestCase):
+class TestCodeReviewCommentHtmlMixin:
 
     layer = DatabaseFunctionalLayer
 
     def test_comment_page_has_meta_description(self):
         # The CodeReviewDisplayComment class provides IComment.
         with person_logged_in(self.factory.makePerson()):
-            comment = self.factory.makeCodeReviewComment()
+            comment = self.makeCodeReviewComment()
 
         display_comment = CodeReviewDisplayComment(comment)
         browser = self.getViewBrowser(display_comment)
@@ -131,14 +131,14 @@
 
     def test_long_comments_not_truncated(self):
         """Long comments displayed by themselves are not truncated."""
-        comment = self.factory.makeCodeReviewComment(body='x y' * 2000)
+        comment = self.makeCodeReviewComment(body='x y' * 2000)
         browser = self.getViewBrowser(comment)
         body = Tag('Body text', 'p', text='x y' * 2000)
         self.assertThat(browser.contents, HTMLContains(body))
 
     def test_excessive_comments_redirect_to_download(self):
         """View for excessive comments redirects to download page."""
-        comment = self.factory.makeCodeReviewComment(body='x ' * 5001)
+        comment = self.makeCodeReviewComment(body='x ' * 5001)
         view_url = canonical_url(comment)
         download_url = canonical_url(comment, view_name='+download')
         browser = self.getUserBrowser(view_url)
@@ -148,7 +148,7 @@
 
     def test_short_comment_no_download_link(self):
         """Long comments displayed by themselves are not truncated."""
-        comment = self.factory.makeCodeReviewComment(body='x ' * 5000)
+        comment = self.makeCodeReviewComment(body='x ' * 5000)
         download_url = canonical_url(comment, view_name='+download')
         browser = self.getViewBrowser(comment)
         body = Tag(
@@ -158,7 +158,7 @@
 
     def test_download_view(self):
         """The download view has the expected contents and header."""
-        comment = self.factory.makeCodeReviewComment(body=u'\u1234')
+        comment = self.makeCodeReviewComment(body=u'\u1234')
         browser = self.getViewBrowser(comment, view_name='+download')
         contents = u'\u1234'.encode('utf-8')
         self.assertEqual(contents, browser.contents)
@@ -168,3 +168,17 @@
             '%d' % len(contents), browser.headers['Content-length'])
         disposition = 'attachment; filename="comment-%d.txt"' % comment.id
         self.assertEqual(disposition, browser.headers['Content-disposition'])
+
+
+class TestCodeReviewCommentHtmlBzr(
+    TestCodeReviewCommentHtmlMixin, BrowserTestCase):
+
+    def makeCodeReviewComment(self, **kwargs):
+        return self.factory.makeCodeReviewComment(**kwargs)
+
+
+class TestCodeReviewCommentHtmlGit(
+    TestCodeReviewCommentHtmlMixin, BrowserTestCase):
+
+    def makeCodeReviewComment(self, **kwargs):
+        return self.factory.makeCodeReviewComment(git=True, **kwargs)

=== modified file 'lib/lp/code/templates/codereviewcomment-index.pt'
--- lib/lp/code/templates/codereviewcomment-index.pt	2009-08-24 02:17:22 +0000
+++ lib/lp/code/templates/codereviewcomment-index.pt	2015-08-18 09:12:09 +0000
@@ -9,8 +9,8 @@
 <body>
 
   <h1 metal:fill-slot="heading"
-      tal:define="branch context/branch_merge_proposal/source_branch">
-    Code review comment for <tal:source content="branch/bzr_identity"/>
+      tal:define="source context/branch_merge_proposal/merge_source">
+    Code review comment for <tal:source content="source/identity"/>
   </h1>
 
   <div metal:fill-slot="main">


Follow ups