← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Ivo Kracht has proposed merging lp:~ivo-kracht/launchpad/bug-921901 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #921901 in Launchpad itself: "bug column tags links link to task context not search context"
  https://bugs.launchpad.net/launchpad/+bug/921901

For more details, see:
https://code.launchpad.net/~ivo-kracht/launchpad/bug-921901/+merge/113234

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

-- 
https://code.launchpad.net/~ivo-kracht/launchpad/bug-921901/+merge/113234
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~ivo-kracht/launchpad/bug-921901 into lp:launchpad.
=== modified file 'lib/lp/bugs/browser/bugtask.py'
--- lib/lp/bugs/browser/bugtask.py	2012-06-27 19:42:03 +0000
+++ lib/lp/bugs/browser/bugtask.py	2012-07-03 15:12:25 +0000
@@ -2215,7 +2215,7 @@
         reporter = self.people[self.bug.ownerID]
 
         base_tag_url = "%s/?field.tag=" % canonical_url(
-            self.bugtask.target,
+            self.target_context,
             view_name="+bugs")
 
         flattened = {

=== modified file 'lib/lp/bugs/browser/tests/test_bugtask.py'
--- lib/lp/bugs/browser/tests/test_bugtask.py	2012-06-26 10:19:37 +0000
+++ lib/lp/bugs/browser/tests/test_bugtask.py	2012-07-03 15:12:25 +0000
@@ -306,6 +306,7 @@
             view = create_initialized_view(bugtask, name="+index")
             self.assertEqual('Private', view.information_type)
 
+
 class TestBugTasksAndNominationsView(TestCaseWithFactory):
 
     layer = DatabaseFunctionalLayer
@@ -1875,7 +1876,7 @@
             batched_view.activity_and_comments)
 
 
-def make_bug_task_listing_item(factory, bugtask=None):
+def make_bug_task_listing_item(factory, bugtask=None, target_context=None):
     if bugtask is None:
         owner = factory.makePerson()
         bug = factory.makeBug(
@@ -1893,6 +1894,8 @@
     if tags != {}:
         tags = tags[bugtask.id]
     people = bug_task_set.getBugTaskPeople([bugtask])
+    if target_context is None:
+        target_context = bugtask.target
     return owner, BugTaskListingItem(
         bugtask,
         badge_property['has_branch'],
@@ -1900,7 +1903,7 @@
         badge_property['has_patch'],
         tags,
         people,
-        target_context=bugtask.target)
+        target_context=target_context)
 
 
 @contextmanager
@@ -2441,6 +2444,18 @@
             milestone_name = item.milestone.displayname
             self.assertEqual(milestone_name, item.model['milestone_name'])
 
+    def test_tag_urls_use_view_context(self):
+        project_group = self.factory.makeProject()
+        product = self.factory.makeProduct(project=project_group)
+        bug = self.factory.makeBug(product=product)
+        with person_logged_in(bug.owner):
+            bug.tags = ['foo']
+        owner, item = make_bug_task_listing_item(
+            self.factory, bug.default_bugtask, target_context=project_group)
+        url = item.model['tags'][0]['url']
+        self.assertTrue(url.startswith(
+            canonical_url(project_group, view_name="+bugs")))
+
     def test_model_assignee(self):
         """Model contains expected fields with expected values."""
         assignee = self.factory.makePerson(displayname='Example Person')


Follow ups