launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #17433
[Merge] lp:~wgrant/launchpad/bug-1364451 into lp:launchpad
William Grant has proposed merging lp:~wgrant/launchpad/bug-1364451 into lp:launchpad.
Commit message:
Fix default bugtask redirect to not leave the current rootsite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1364451 in Launchpad itself: "API page redirects to web interface instead of serving JSON"
https://bugs.launchpad.net/launchpad/+bug/1364451
For more details, see:
https://code.launchpad.net/~wgrant/launchpad/bug-1364451/+merge/239276
Fix default bugtask redirect to not leave the current rootsite.
--
https://code.launchpad.net/~wgrant/launchpad/bug-1364451/+merge/239276
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/bug-1364451 into lp:launchpad.
=== modified file 'lib/lp/bugs/browser/bugtask.py'
--- lib/lp/bugs/browser/bugtask.py 2014-05-28 22:02:56 +0000
+++ lib/lp/bugs/browser/bugtask.py 2014-10-22 19:29:33 +0000
@@ -563,7 +563,8 @@
travseral_stack = self.request.getTraversalStack()
if len(travseral_stack) > 0:
raise NotFoundError
- return self.redirectSubTree(canonical_url(bug.default_bugtask))
+ return self.redirectSubTree(
+ canonical_url(bug.default_bugtask, request=self.request))
class BugTaskNavigation(Navigation):
=== modified file 'lib/lp/bugs/browser/tests/test_bugtask_navigation.py'
--- lib/lp/bugs/browser/tests/test_bugtask_navigation.py 2012-01-01 02:58:52 +0000
+++ lib/lp/bugs/browser/tests/test_bugtask_navigation.py 2014-10-22 19:29:33 +0000
@@ -17,7 +17,7 @@
from lp.testing.publication import test_traverse
-class TestBugtaskTraversal(TestCaseWithFactory):
+class TestBugTaskTraversal(TestCaseWithFactory):
layer = DatabaseFunctionalLayer
@@ -47,3 +47,16 @@
login_person(bugtask.owner)
bugtask.delete()
self.assertRaises(NotFound, test_traverse, bugtask_delete_url)
+
+ def test_traversal_to_nonexistent_bugtask_on_api(self):
+ # Traversing to a non-existent bugtask on the API redirects to
+ # the default bugtask, but also on the API.
+ bug = self.factory.makeBug()
+ product = self.factory.makeProduct()
+ obj, view, request = test_traverse(
+ 'http://api.launchpad.dev/1.0/%s/+bug/%d'
+ % (product.name, bug.default_bugtask.bug.id))
+ self.assertEqual(
+ removeSecurityProxy(view).target,
+ 'http://api.launchpad.dev/1.0/%s/+bug/%d'
+ % (bug.default_bugtask.target.name, bug.default_bugtask.bug.id))
Follow ups