allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [07/17] git commit: [#6665] ticket:446 add MovedTicket redirects to Tracker REST API
Date Thu, 03 Oct 2013 18:05:17 GMT
[#6665] ticket:446 add MovedTicket redirects to Tracker REST API


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/2080faea
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/2080faea
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/2080faea

Branch: refs/heads/cj/5561
Commit: 2080faea451351d59b495365ffad404fd850f300
Parents: 30f5d75
Author: Yuriy Arhipov <yuriyarhipovua@yandex.ru>
Authored: Sat Sep 28 14:31:39 2013 +0400
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Wed Oct 2 15:33:48 2013 +0000

----------------------------------------------------------------------
 AlluraTest/alluratest/controller.py                     |  4 ++--
 ForgeTracker/forgetracker/tests/functional/test_rest.py | 11 +++++++++++
 ForgeTracker/forgetracker/tracker_main.py               |  6 ++++++
 3 files changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2080faea/AlluraTest/alluratest/controller.py
----------------------------------------------------------------------
diff --git a/AlluraTest/alluratest/controller.py b/AlluraTest/alluratest/controller.py
index 577088d..07f9cff 100644
--- a/AlluraTest/alluratest/controller.py
+++ b/AlluraTest/alluratest/controller.py
@@ -180,8 +180,8 @@ class TestRestApiBase(TestController):
         response = fn(
             str(path),
             params=params,
-            status=[200, 201, 302, 400, 403, 404])
-        if response.status_int == 302:
+            status=[200, 201, 301, 302, 400, 403, 404])
+        if response.status_int in [301, 302]:
             return response.follow()
         else:
             return response

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2080faea/ForgeTracker/forgetracker/tests/functional/test_rest.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/functional/test_rest.py b/ForgeTracker/forgetracker/tests/functional/test_rest.py
index 6d9a457..87e2d44 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_rest.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_rest.py
@@ -127,6 +127,17 @@ class TestRestIndex(TestTrackerApiBase):
         ticket_config = M.AppConfig.query.get(project_id=c.project._id, tool_name='tickets')
         assert_equal(ticket_config.options.get('TicketMonitoringEmail'), 'test@localhost')
 
+    @td.with_tool('test', 'Tickets', 'dummy')
+    def test_move_ticket_redirect(self):
+        p = M.Project.query.get(shortname='test')
+        dummy_tracker = p.app_instance('dummy')
+        r = self.app.post(
+            '/p/test/bugs/1/move',
+            params={'tracker': str(dummy_tracker.config._id)}).follow()
+
+        ticket = self.api_get('/rest/p/test/bugs/1/')
+        assert_equal(ticket.request.path, '/rest/p/test/dummy/1/')
+
 
 class TestRestDiscussion(TestTrackerApiBase):
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2080faea/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index ea075af..370be90 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -1666,6 +1666,12 @@ class TicketRestController(BaseController):
             self.ticket = TM.Ticket.query.get(app_config_id=c.app.config._id,
                                                     ticket_num=self.ticket_num)
             if self.ticket is None:
+                moved_ticket = TM.MovedTicket.query.get(
+                    app_config_id=c.app.config._id,
+                    ticket_num=self.ticket_num)
+                if moved_ticket:
+                    utils.permanent_redirect('/rest' + moved_ticket.moved_to_url)
+
                 raise exc.HTTPNotFound()
 
     def _check_security(self):


Mime
View raw message