Merge lp:~ivo-kracht/launchpad/bug-921901 into lp:launchpad

Proposed by Ivo Kracht on 2012-07-03
Status: Merged
Approved by: Abel Deuring on 2012-07-03
Approved revision: no longer in the source branch.
Merged at revision: 15556
Proposed branch: lp:~ivo-kracht/launchpad/bug-921901
Merge into: lp:launchpad
Diff against target: 99 lines (+44/-6)
2 files modified
lib/lp/bugs/browser/bugtask.py (+10/-3)
lib/lp/bugs/browser/tests/test_bugtask.py (+34/-3)
To merge this branch: bzr merge lp:~ivo-kracht/launchpad/bug-921901
Reviewer Review Type Date Requested Status
Graham Binns (community) code Approve on 2012-07-04
Ivo Kracht (community) Resubmit on 2012-07-04
Richard Harding (community) 2012-07-03 Approve on 2012-07-03
Review via email: mp+113234@code.launchpad.net

Commit Message

bug column tags now link to project groups

Description of the Change

I changed the base_tag_url so that it links to the search context and wrote a unit test for it.

Pre-imp call with adeuring

test:
./bin/test bugs -vvt test_tag_urls_use_view_context

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/bugs/browser/bugtask.py
  lib/lp/bugs/browser/tests/test_bugtask.py

To post a comment you must log in.
Richard Harding (rharding) wrote :

Looks good, thanks!

review: Approve
Ivo Kracht (ivo-kracht) wrote :

Ec2 test failed because I overlooked the possibility that there is no target context, e.g. when you click on “bugs“ while viewing a user account. This case is now intercepted and the task context is used instead of the search context. I also had to write a seperate test for that case.

Pre-imp call with adeuring

test:
./bin/test bugs -vvt test_urls_without_target_context

review: Resubmit
Graham Binns (gmb) wrote :

Looks good to me.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/browser/bugtask.py'
2--- lib/lp/bugs/browser/bugtask.py 2012-06-27 19:42:03 +0000
3+++ lib/lp/bugs/browser/bugtask.py 2012-07-04 11:10:56 +0000
4@@ -2214,9 +2214,16 @@
5 assignee = self.people[self.assigneeID].displayname
6 reporter = self.people[self.bug.ownerID]
7
8- base_tag_url = "%s/?field.tag=" % canonical_url(
9- self.bugtask.target,
10- view_name="+bugs")
11+ # the case that there is no target context (e.g. viewing bug that
12+ # are related to a user account) is intercepted
13+ if self.target_context is None:
14+ base_tag_url = "%s/?field.tag=" % canonical_url(
15+ self.bugtask.target,
16+ view_name="+bugs")
17+ else:
18+ base_tag_url = "%s/?field.tag=" % canonical_url(
19+ self.target_context,
20+ view_name="+bugs")
21
22 flattened = {
23 'age': age,
24
25=== modified file 'lib/lp/bugs/browser/tests/test_bugtask.py'
26--- lib/lp/bugs/browser/tests/test_bugtask.py 2012-06-26 10:19:37 +0000
27+++ lib/lp/bugs/browser/tests/test_bugtask.py 2012-07-04 11:10:56 +0000
28@@ -306,6 +306,7 @@
29 view = create_initialized_view(bugtask, name="+index")
30 self.assertEqual('Private', view.information_type)
31
32+
33 class TestBugTasksAndNominationsView(TestCaseWithFactory):
34
35 layer = DatabaseFunctionalLayer
36@@ -1874,8 +1875,11 @@
37 unbatched_view.activity_and_comments[4:],
38 batched_view.activity_and_comments)
39
40-
41-def make_bug_task_listing_item(factory, bugtask=None):
42+no_target_specified = object()
43+
44+
45+def make_bug_task_listing_item(
46+ factory, bugtask=None, target_context=no_target_specified):
47 if bugtask is None:
48 owner = factory.makePerson()
49 bug = factory.makeBug(
50@@ -1893,6 +1897,8 @@
51 if tags != {}:
52 tags = tags[bugtask.id]
53 people = bug_task_set.getBugTaskPeople([bugtask])
54+ if target_context is no_target_specified:
55+ target_context = bugtask.target
56 return owner, BugTaskListingItem(
57 bugtask,
58 badge_property['has_branch'],
59@@ -1900,7 +1906,7 @@
60 badge_property['has_patch'],
61 tags,
62 people,
63- target_context=bugtask.target)
64+ target_context=target_context)
65
66
67 @contextmanager
68@@ -2441,6 +2447,31 @@
69 milestone_name = item.milestone.displayname
70 self.assertEqual(milestone_name, item.model['milestone_name'])
71
72+ def test_tag_urls_use_view_context(self):
73+ """urls contain the correct project group if target_context is None"""
74+ project_group = self.factory.makeProject()
75+ product = self.factory.makeProduct(project=project_group)
76+ bug = self.factory.makeBug(product=product)
77+ with person_logged_in(bug.owner):
78+ bug.tags = ['foo']
79+ owner, item = make_bug_task_listing_item(
80+ self.factory, bug.default_bugtask, target_context=project_group)
81+ url = item.model['tags'][0]['url']
82+ self.assertTrue(url.startswith(
83+ canonical_url(project_group, view_name="+bugs")))
84+
85+ def test_urls_without_target_context(self):
86+ """urls contain the project if target_context is not None"""
87+ product = self.factory.makeProduct()
88+ bug = self.factory.makeBug(product=product)
89+ with person_logged_in(bug.owner):
90+ bug.tags = ['foo']
91+ owner, item = make_bug_task_listing_item(
92+ self.factory, bug.default_bugtask, target_context=None)
93+ url = item.model['tags'][0]['url']
94+ self.assertTrue(url.startswith(
95+ canonical_url(product, view_name="+bugs")))
96+
97 def test_model_assignee(self):
98 """Model contains expected fields with expected values."""
99 assignee = self.factory.makePerson(displayname='Example Person')