launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #21596
[Merge] lp:~cjwatson/launchpad/git-mp-better-title into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/git-mp-better-title into lp:launchpad.
Commit message:
Add source ref name to breadcrumbs for Git-based merge proposals.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/git-mp-better-title/+merge/324533
The main purpose of this is to get the ref name into the page title, which makes it easier to find Git-based MPs in browser history.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/git-mp-better-title into lp:launchpad.
=== modified file 'lib/lp/code/browser/branchmergeproposal.py'
--- lib/lp/code/browser/branchmergeproposal.py 2017-04-13 14:11:17 +0000
+++ lib/lp/code/browser/branchmergeproposal.py 2017-05-24 12:34:45 +0000
@@ -156,6 +156,10 @@
def text(self):
return 'Merge into %s' % self.context.merge_target.name
+ @property
+ def inside(self):
+ return self.context.merge_source
+
def notify(func):
"""Decorate a view method to send a notification."""
=== modified file 'lib/lp/code/browser/tests/test_branchmergeproposal.py'
--- lib/lp/code/browser/tests/test_branchmergeproposal.py 2017-04-24 14:23:36 +0000
+++ lib/lp/code/browser/tests/test_branchmergeproposal.py 2017-05-24 12:34:45 +0000
@@ -22,6 +22,7 @@
from soupmatchers import (
HTMLContains,
Tag,
+ Within,
)
from testtools.matchers import (
ContainsDict,
@@ -109,7 +110,10 @@
first_tag_by_class,
get_feedback_messages,
)
-from lp.testing.views import create_initialized_view
+from lp.testing.views import (
+ create_initialized_view,
+ create_view,
+ )
class GitHostingClientMixin:
@@ -1620,6 +1624,74 @@
bmp.source_git_repository.unique_name),
}))
+ def test_breadcrumbs_bzr(self):
+ bmp = self.factory.makeBranchMergeProposal()
+ view = create_view(bmp, '+index', principal=self.user)
+ # To test the breadcrumbs we need a correct traversal stack.
+ view.request.traversed_objects = [bmp.source_branch, bmp, view]
+ view.initialize()
+ breadcrumbs_tag = Tag(
+ 'breadcrumbs', 'ol', attrs={'class': 'breadcrumbs'})
+ self.assertThat(
+ view(),
+ HTMLContains(
+ Within(
+ breadcrumbs_tag,
+ Tag(
+ 'branch breadcrumb', 'a', text=bmp.source_branch.name,
+ attrs={
+ 'href': 'http://code.launchpad.dev/%s' % (
+ bmp.source_branch.unique_name)})),
+ Within(
+ breadcrumbs_tag,
+ Tag(
+ 'merge proposal breadcrumb', 'li',
+ text=re.compile(
+ '\sMerge into %s\s' %
+ re.escape(bmp.target_branch.name))))))
+
+ def test_breadcrumbs_git(self):
+ self.useFixture(GitHostingFixture())
+ bmp = self.factory.makeBranchMergeProposalForGit()
+ view = create_view(bmp, '+index', principal=self.user)
+ # To test the breadcrumbs we need a correct traversal stack.
+ view.request.traversed_objects = [bmp.source_git_repository, bmp, view]
+ view.initialize()
+ breadcrumbs_tag = Tag(
+ 'breadcrumbs', 'ol', attrs={'class': 'breadcrumbs'})
+ self.assertThat(
+ view(),
+ HTMLContains(
+ Within(
+ breadcrumbs_tag,
+ Tag(
+ 'git collection breadcrumb', 'a', text='Git',
+ attrs={'href': re.compile(r'/\+git$')})),
+ Within(
+ breadcrumbs_tag,
+ Tag(
+ 'git repository breadcrumb', 'a',
+ text=bmp.source_git_repository.git_identity,
+ attrs={
+ 'href': 'http://code.launchpad.dev/%s' % (
+ bmp.source_git_repository.unique_name)})),
+ Within(
+ breadcrumbs_tag,
+ Tag(
+ 'git ref breadcrumb', 'a',
+ text=bmp.source_git_ref.name,
+ attrs={
+ 'href': 'http://code.launchpad.dev/%s/+ref/%s' % (
+ bmp.source_git_repository.unique_name,
+ bmp.source_git_ref.name)})),
+ Within(
+ breadcrumbs_tag,
+ Tag(
+ 'merge proposal breadcrumb', 'li',
+ text=re.compile(
+ '\sMerge into %s\s' %
+ re.escape(bmp.target_git_ref.name))))))
+
class TestBranchMergeProposalBrowserView(BrowserTestCase):
Follow ups