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

Proposed by Colin Watson
Status: Merged
Merged at revision: 17691
Proposed branch: lp:~cjwatson/launchpad/crc-index-git
Merge into: lp:launchpad
Diff against target: 94 lines (+23/-9)
2 files modified
lib/lp/code/browser/tests/test_codereviewcomment.py (+21/-7)
lib/lp/code/templates/codereviewcomment-index.pt (+2/-2)
To merge this branch: bzr merge lp:~cjwatson/launchpad/crc-index-git
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+268303@code.launchpad.net

Commit message

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

Description of the change

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

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/browser/tests/test_codereviewcomment.py'
2--- lib/lp/code/browser/tests/test_codereviewcomment.py 2014-11-28 22:07:05 +0000
3+++ lib/lp/code/browser/tests/test_codereviewcomment.py 2015-08-18 09:12:09 +0000
4@@ -1,4 +1,4 @@
5-# Copyright 2009-2012 Canonical Ltd. This software is licensed under the
6+# Copyright 2009-2015 Canonical Ltd. This software is licensed under the
7 # GNU Affero General Public License version 3 (see the file LICENSE).
8
9 """Unit tests for CodeReviewComments."""
10@@ -110,14 +110,14 @@
11 self.assertThat(recorder, HasQueryCount(Equals(0)))
12
13
14-class TestCodeReviewCommentHtml(BrowserTestCase):
15+class TestCodeReviewCommentHtmlMixin:
16
17 layer = DatabaseFunctionalLayer
18
19 def test_comment_page_has_meta_description(self):
20 # The CodeReviewDisplayComment class provides IComment.
21 with person_logged_in(self.factory.makePerson()):
22- comment = self.factory.makeCodeReviewComment()
23+ comment = self.makeCodeReviewComment()
24
25 display_comment = CodeReviewDisplayComment(comment)
26 browser = self.getViewBrowser(display_comment)
27@@ -131,14 +131,14 @@
28
29 def test_long_comments_not_truncated(self):
30 """Long comments displayed by themselves are not truncated."""
31- comment = self.factory.makeCodeReviewComment(body='x y' * 2000)
32+ comment = self.makeCodeReviewComment(body='x y' * 2000)
33 browser = self.getViewBrowser(comment)
34 body = Tag('Body text', 'p', text='x y' * 2000)
35 self.assertThat(browser.contents, HTMLContains(body))
36
37 def test_excessive_comments_redirect_to_download(self):
38 """View for excessive comments redirects to download page."""
39- comment = self.factory.makeCodeReviewComment(body='x ' * 5001)
40+ comment = self.makeCodeReviewComment(body='x ' * 5001)
41 view_url = canonical_url(comment)
42 download_url = canonical_url(comment, view_name='+download')
43 browser = self.getUserBrowser(view_url)
44@@ -148,7 +148,7 @@
45
46 def test_short_comment_no_download_link(self):
47 """Long comments displayed by themselves are not truncated."""
48- comment = self.factory.makeCodeReviewComment(body='x ' * 5000)
49+ comment = self.makeCodeReviewComment(body='x ' * 5000)
50 download_url = canonical_url(comment, view_name='+download')
51 browser = self.getViewBrowser(comment)
52 body = Tag(
53@@ -158,7 +158,7 @@
54
55 def test_download_view(self):
56 """The download view has the expected contents and header."""
57- comment = self.factory.makeCodeReviewComment(body=u'\u1234')
58+ comment = self.makeCodeReviewComment(body=u'\u1234')
59 browser = self.getViewBrowser(comment, view_name='+download')
60 contents = u'\u1234'.encode('utf-8')
61 self.assertEqual(contents, browser.contents)
62@@ -168,3 +168,17 @@
63 '%d' % len(contents), browser.headers['Content-length'])
64 disposition = 'attachment; filename="comment-%d.txt"' % comment.id
65 self.assertEqual(disposition, browser.headers['Content-disposition'])
66+
67+
68+class TestCodeReviewCommentHtmlBzr(
69+ TestCodeReviewCommentHtmlMixin, BrowserTestCase):
70+
71+ def makeCodeReviewComment(self, **kwargs):
72+ return self.factory.makeCodeReviewComment(**kwargs)
73+
74+
75+class TestCodeReviewCommentHtmlGit(
76+ TestCodeReviewCommentHtmlMixin, BrowserTestCase):
77+
78+ def makeCodeReviewComment(self, **kwargs):
79+ return self.factory.makeCodeReviewComment(git=True, **kwargs)
80
81=== modified file 'lib/lp/code/templates/codereviewcomment-index.pt'
82--- lib/lp/code/templates/codereviewcomment-index.pt 2009-08-24 02:17:22 +0000
83+++ lib/lp/code/templates/codereviewcomment-index.pt 2015-08-18 09:12:09 +0000
84@@ -9,8 +9,8 @@
85 <body>
86
87 <h1 metal:fill-slot="heading"
88- tal:define="branch context/branch_merge_proposal/source_branch">
89- Code review comment for <tal:source content="branch/bzr_identity"/>
90+ tal:define="source context/branch_merge_proposal/merge_source">
91+ Code review comment for <tal:source content="source/identity"/>
92 </h1>
93
94 <div metal:fill-slot="main">