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
=== 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 @@
1# Copyright 2009-2012 Canonical Ltd. This software is licensed under the1# Copyright 2009-2015 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Unit tests for CodeReviewComments."""4"""Unit tests for CodeReviewComments."""
@@ -110,14 +110,14 @@
110 self.assertThat(recorder, HasQueryCount(Equals(0)))110 self.assertThat(recorder, HasQueryCount(Equals(0)))
111111
112112
113class TestCodeReviewCommentHtml(BrowserTestCase):113class TestCodeReviewCommentHtmlMixin:
114114
115 layer = DatabaseFunctionalLayer115 layer = DatabaseFunctionalLayer
116116
117 def test_comment_page_has_meta_description(self):117 def test_comment_page_has_meta_description(self):
118 # The CodeReviewDisplayComment class provides IComment.118 # The CodeReviewDisplayComment class provides IComment.
119 with person_logged_in(self.factory.makePerson()):119 with person_logged_in(self.factory.makePerson()):
120 comment = self.factory.makeCodeReviewComment()120 comment = self.makeCodeReviewComment()
121121
122 display_comment = CodeReviewDisplayComment(comment)122 display_comment = CodeReviewDisplayComment(comment)
123 browser = self.getViewBrowser(display_comment)123 browser = self.getViewBrowser(display_comment)
@@ -131,14 +131,14 @@
131131
132 def test_long_comments_not_truncated(self):132 def test_long_comments_not_truncated(self):
133 """Long comments displayed by themselves are not truncated."""133 """Long comments displayed by themselves are not truncated."""
134 comment = self.factory.makeCodeReviewComment(body='x y' * 2000)134 comment = self.makeCodeReviewComment(body='x y' * 2000)
135 browser = self.getViewBrowser(comment)135 browser = self.getViewBrowser(comment)
136 body = Tag('Body text', 'p', text='x y' * 2000)136 body = Tag('Body text', 'p', text='x y' * 2000)
137 self.assertThat(browser.contents, HTMLContains(body))137 self.assertThat(browser.contents, HTMLContains(body))
138138
139 def test_excessive_comments_redirect_to_download(self):139 def test_excessive_comments_redirect_to_download(self):
140 """View for excessive comments redirects to download page."""140 """View for excessive comments redirects to download page."""
141 comment = self.factory.makeCodeReviewComment(body='x ' * 5001)141 comment = self.makeCodeReviewComment(body='x ' * 5001)
142 view_url = canonical_url(comment)142 view_url = canonical_url(comment)
143 download_url = canonical_url(comment, view_name='+download')143 download_url = canonical_url(comment, view_name='+download')
144 browser = self.getUserBrowser(view_url)144 browser = self.getUserBrowser(view_url)
@@ -148,7 +148,7 @@
148148
149 def test_short_comment_no_download_link(self):149 def test_short_comment_no_download_link(self):
150 """Long comments displayed by themselves are not truncated."""150 """Long comments displayed by themselves are not truncated."""
151 comment = self.factory.makeCodeReviewComment(body='x ' * 5000)151 comment = self.makeCodeReviewComment(body='x ' * 5000)
152 download_url = canonical_url(comment, view_name='+download')152 download_url = canonical_url(comment, view_name='+download')
153 browser = self.getViewBrowser(comment)153 browser = self.getViewBrowser(comment)
154 body = Tag(154 body = Tag(
@@ -158,7 +158,7 @@
158158
159 def test_download_view(self):159 def test_download_view(self):
160 """The download view has the expected contents and header."""160 """The download view has the expected contents and header."""
161 comment = self.factory.makeCodeReviewComment(body=u'\u1234')161 comment = self.makeCodeReviewComment(body=u'\u1234')
162 browser = self.getViewBrowser(comment, view_name='+download')162 browser = self.getViewBrowser(comment, view_name='+download')
163 contents = u'\u1234'.encode('utf-8')163 contents = u'\u1234'.encode('utf-8')
164 self.assertEqual(contents, browser.contents)164 self.assertEqual(contents, browser.contents)
@@ -168,3 +168,17 @@
168 '%d' % len(contents), browser.headers['Content-length'])168 '%d' % len(contents), browser.headers['Content-length'])
169 disposition = 'attachment; filename="comment-%d.txt"' % comment.id169 disposition = 'attachment; filename="comment-%d.txt"' % comment.id
170 self.assertEqual(disposition, browser.headers['Content-disposition'])170 self.assertEqual(disposition, browser.headers['Content-disposition'])
171
172
173class TestCodeReviewCommentHtmlBzr(
174 TestCodeReviewCommentHtmlMixin, BrowserTestCase):
175
176 def makeCodeReviewComment(self, **kwargs):
177 return self.factory.makeCodeReviewComment(**kwargs)
178
179
180class TestCodeReviewCommentHtmlGit(
181 TestCodeReviewCommentHtmlMixin, BrowserTestCase):
182
183 def makeCodeReviewComment(self, **kwargs):
184 return self.factory.makeCodeReviewComment(git=True, **kwargs)
171185
=== 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 @@
9<body>9<body>
1010
11 <h1 metal:fill-slot="heading"11 <h1 metal:fill-slot="heading"
12 tal:define="branch context/branch_merge_proposal/source_branch">12 tal:define="source context/branch_merge_proposal/merge_source">
13 Code review comment for <tal:source content="branch/bzr_identity"/>13 Code review comment for <tal:source content="source/identity"/>
14 </h1>14 </h1>
1515
16 <div metal:fill-slot="main">16 <div metal:fill-slot="main">