Merge lp:~twom/launchpad/git-reviews-link into lp:launchpad

Proposed by Tom Wardill on 2018-08-22
Status: Merged
Merged at revision: 18756
Proposed branch: lp:~twom/launchpad/git-reviews-link
Merge into: lp:launchpad
Diff against target: 79 lines (+31/-2)
2 files modified
lib/lp/code/browser/tests/test_gitlisting.py (+23/-2)
lib/lp/code/templates/gitlisting.pt (+8/-0)
To merge this branch: bzr merge lp:~twom/launchpad/git-reviews-link
Reviewer Review Type Date Requested Status
Colin Watson 2018-08-22 Approve on 2018-08-22
Review via email: mp+353575@code.launchpad.net

Commit message

Add number of active reviews link to git Product page

Description of the change

The link to active reviews was not present on Products that have a default of a Git repository. Add it.

To post a comment you must log in.
lp:~twom/launchpad/git-reviews-link updated on 2018-08-22
18750. By Tom Wardill on 2018-08-22

Remove extra whitespace

Colin Watson (cjwatson) :
review: Approve
lp:~twom/launchpad/git-reviews-link updated on 2018-08-22
18751. By Tom Wardill on 2018-08-22

Use find_tag_by_id in test

Colin Watson (cjwatson) :
lp:~twom/launchpad/git-reviews-link updated on 2018-08-22
18752. By Tom Wardill on 2018-08-22

Tests need asserts

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_gitlisting.py'
2--- lib/lp/code/browser/tests/test_gitlisting.py 2018-08-20 23:33:01 +0000
3+++ lib/lp/code/browser/tests/test_gitlisting.py 2018-08-22 14:28:01 +0000
4@@ -10,7 +10,9 @@
5 from zope.component import getUtility
6
7 from lp.app.enums import InformationType
8+from lp.code.enums import BranchMergeProposalStatus
9 from lp.code.interfaces.gitrepository import IGitRepositorySet
10+from lp.registry.enums import VCSType
11 from lp.registry.model.persondistributionsourcepackage import (
12 PersonDistributionSourcePackage,
13 )
14@@ -24,6 +26,7 @@
15 )
16 from lp.testing.layers import DatabaseFunctionalLayer
17 from lp.testing.matchers import BrowsesWithQueryLimit
18+from lp.testing.pages import find_tag_by_id
19 from lp.testing.views import create_initialized_view
20
21
22@@ -116,7 +119,7 @@
23 repository=other_repo, user=other_repo.owner)
24
25 self.assertThat(
26- self.target, BrowsesWithQueryLimit(34, self.owner, '+git'))
27+ self.target, BrowsesWithQueryLimit(36, self.owner, '+git'))
28
29 def test_copes_with_no_default(self):
30 self.factory.makeGitRepository(
31@@ -320,10 +323,28 @@
32 def setUp(self):
33 super(TestProductGitListingView, self).setUp()
34 self.owner = self.factory.makePerson(name="foowner")
35- self.target = self.factory.makeProduct(name="foo", owner=self.owner)
36+ self.target = self.factory.makeProduct(name="foo", owner=self.owner,
37+ vcs=VCSType.GIT)
38 self.target_path = "foo"
39 self.branch_target = self.target
40
41+ def test_active_reviews_link(self):
42+ main_repo = self.factory.makeGitRepository(
43+ owner=self.owner, target=self.target, name="foo")
44+ git_refs = self.factory.makeGitRefs(
45+ main_repo,
46+ paths=["refs/heads/master", "refs/heads/1.0", "refs/tags/1.1"])
47+
48+ with admin_logged_in():
49+ getUtility(IGitRepositorySet).setDefaultRepository(
50+ target=self.target, repository=main_repo)
51+
52+ self.factory.makeBranchMergeProposalForGit(
53+ target_ref=git_refs[0],
54+ set_state=BranchMergeProposalStatus.NEEDS_REVIEW)
55+ view = create_initialized_view(self.target, '+git')
56+ self.assertIsNotNone(find_tag_by_id(view(), 'active-review-count'))
57+
58
59 class TestPersonProductGitListingView(TestPersonTargetGitListingView,
60 TestCaseWithFactory):
61
62=== modified file 'lib/lp/code/templates/gitlisting.pt'
63--- lib/lp/code/templates/gitlisting.pt 2015-12-15 23:45:52 +0000
64+++ lib/lp/code/templates/gitlisting.pt 2018-08-22 14:28:01 +0000
65@@ -63,6 +63,14 @@
66 <tal:repository-management
67 replace="structure repository/@@++repository-management" />
68 </div>
69+ <p id="active-review-count"
70+ tal:define="count context/menu:branches/active_review_count|nothing;
71+ link context/menu:branches/active_reviews|nothing"
72+ tal:condition="python: count &gt; 0">
73+ <tal:project replace="context/displayname"/> has
74+ <tal:active-count replace="count"/>
75+ <tal:link replace="structure python: link.render().lower()"/>.
76+ </p>
77 </div>
78
79 <div class="yui-g">