summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2014-11-16 10:54:33 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2014-11-16 10:54:33 +0000
commiteae9c9ab2be43c64c830a03e414b51a08571c957 (patch)
treecbe6b20000d60ad854ad8f2e245cbdfeca4b4787 /test
parentcd6b2f2268d3e02ae652d3ad37f02170e3647a72 (diff)
downloadredmine-eae9c9ab2be43c64c830a03e414b51a08571c957.tar.gz
redmine-eae9c9ab2be43c64c830a03e414b51a08571c957.zip
Isolates all API routing tests to a specific test case.
git-svn-id: http://svn.redmine.org/redmine/trunk@13604 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/integration/api_test/api_routing_test.rb162
-rw-r--r--test/integration/routing/attachments_test.rb16
-rw-r--r--test/integration/routing/custom_fields_test.rb7
-rw-r--r--test/integration/routing/enumerations_test.rb4
-rw-r--r--test/integration/routing/groups_test.rb28
-rw-r--r--test/integration/routing/issue_categories_test.rb50
-rw-r--r--test/integration/routing/issue_relations_test.rb40
-rw-r--r--test/integration/routing/issue_statuses_test.rb27
-rw-r--r--test/integration/routing/issues_test.rb32
-rw-r--r--test/integration/routing/members_test.rb20
-rw-r--r--test/integration/routing/news_test.rb18
-rw-r--r--test/integration/routing/projects_test.rb23
-rw-r--r--test/integration/routing/queries_test.rb8
-rw-r--r--test/integration/routing/roles_test.rb8
-rw-r--r--test/integration/routing/trackers_test.rb22
-rw-r--r--test/integration/routing/users_test.rb28
-rw-r--r--test/integration/routing/versions_test.rb50
-rw-r--r--test/integration/routing/watchers_test.rb10
-rw-r--r--test/integration/routing/wiki_test.rb51
-rw-r--r--test/test_helper.rb36
20 files changed, 204 insertions, 436 deletions
diff --git a/test/integration/api_test/api_routing_test.rb b/test/integration/api_test/api_routing_test.rb
new file mode 100644
index 000000000..d36dc8377
--- /dev/null
+++ b/test/integration/api_test/api_routing_test.rb
@@ -0,0 +1,162 @@
+# Redmine - project management software
+# Copyright (C) 2006-2014 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.expand_path('../../../test_helper', __FILE__)
+
+class Redmine::ApiTest::ApiRoutingTest < Redmine::ApiTest::Routing
+
+ def test_attachments
+ should_route 'GET /attachments/1' => 'attachments#show', :id => '1'
+ should_route 'POST /uploads' => 'attachments#upload'
+ end
+
+ def test_custom_fields
+ should_route 'GET /custom_fields' => 'custom_fields#index'
+ end
+
+ def test_enumerations
+ should_route 'GET /enumerations/issue_priorities' => 'enumerations#index', :type => 'issue_priorities'
+ end
+
+ def test_groups
+ should_route 'GET /groups' => 'groups#index'
+ should_route 'POST /groups' => 'groups#create'
+
+ should_route 'GET /groups/1' => 'groups#show', :id => '1'
+ should_route 'PUT /groups/1' => 'groups#update', :id => '1'
+ should_route 'DELETE /groups/1' => 'groups#destroy', :id => '1'
+ end
+
+ def test_group_users
+ should_route 'POST /groups/567/users' => 'groups#add_users', :id => '567'
+ should_route 'DELETE /groups/567/users/12' => 'groups#remove_user', :id => '567', :user_id => '12'
+ end
+
+ def test_issue_categories
+ should_route 'GET /projects/foo/issue_categories' => 'issue_categories#index', :project_id => 'foo'
+ should_route 'POST /projects/foo/issue_categories' => 'issue_categories#create', :project_id => 'foo'
+
+ should_route 'GET /issue_categories/1' => 'issue_categories#show', :id => '1'
+ should_route 'PUT /issue_categories/1' => 'issue_categories#update', :id => '1'
+ should_route 'DELETE /issue_categories/1' => 'issue_categories#destroy', :id => '1'
+ end
+
+ def test_issue_relations
+ should_route 'GET /issues/1/relations' => 'issue_relations#index', :issue_id => '1'
+ should_route 'POST /issues/1/relations' => 'issue_relations#create', :issue_id => '1'
+
+ should_route 'GET /relations/23' => 'issue_relations#show', :id => '23'
+ should_route 'DELETE /relations/23' => 'issue_relations#destroy', :id => '23'
+ end
+
+ def test_issue_statuses
+ should_route 'GET /issue_statuses' => 'issue_statuses#index'
+ should_route 'POST /issue_statuses' => 'issue_statuses#create' # NOT IMPLEMENTED
+ should_route 'GET /issue_statuses/new' => 'issue_statuses#new' # NOT IMPLEMENTED
+
+ should_route 'PUT /issue_statuses/1' => 'issue_statuses#update', :id => '1' # NOT IMPLEMENTED
+ should_route 'DELETE /issue_statuses/1' => 'issue_statuses#destroy', :id => '1' # NOT IMPLEMENTED
+ should_route 'POST /issue_statuses/update_issue_done_ratio' => 'issue_statuses#update_issue_done_ratio' # NOT IMPLEMENTED
+ end
+
+ def test_issues
+ should_route 'GET /issues' => 'issues#index'
+ should_route 'POST /issues' => 'issues#create'
+
+ should_route 'GET /projects/23/issues' => 'issues#index', :project_id => '23'
+
+ should_route 'GET /issues/64' => 'issues#show', :id => '64'
+ should_route 'PUT /issues/64' => 'issues#update', :id => '64'
+ should_route 'DELETE /issues/64' => 'issues#destroy', :id => '64'
+ end
+
+ def test_memberships
+ should_route 'GET /projects/5234/memberships' => 'members#index', :project_id => '5234'
+ should_route 'POST /projects/5234/memberships' => 'members#create', :project_id => '5234'
+
+ should_route 'GET /memberships/5234' => 'members#show', :id => '5234'
+ should_route 'PUT /memberships/5234' => 'members#update', :id => '5234'
+ should_route 'DELETE /memberships/5234' => 'members#destroy', :id => '5234'
+ end
+
+ def test_news
+ should_route 'GET /news' => 'news#index'
+ should_route 'GET /projects/567/news' => 'news#index', :project_id => '567'
+ end
+
+ def test_projects
+ should_route 'GET /projects' => 'projects#index'
+ should_route 'POST /projects' => 'projects#create'
+
+ should_route 'GET /projects/1' => 'projects#show', :id => '1'
+ should_route 'PUT /projects/1' => 'projects#update', :id => '1'
+ should_route 'DELETE /projects/1' => 'projects#destroy', :id => '1'
+ end
+
+ def test_queries
+ should_route 'GET /queries' => 'queries#index'
+ end
+
+ def test_roles
+ should_route 'GET /roles' => 'roles#index'
+ should_route 'GET /roles/2' => 'roles#show', :id => '2'
+ end
+
+ def test_trackers
+ should_route 'GET /trackers' => 'trackers#index'
+ should_route 'POST /trackers' => 'trackers#create' # NOT IMPLEMENTED
+ should_route 'GET /trackers/new' => 'trackers#new' # NOT IMPLEMENTED
+
+ should_route 'PUT /trackers/1' => 'trackers#update', :id => '1' # NOT IMPLEMENTED
+ should_route 'DELETE /trackers/1' => 'trackers#destroy', :id => '1' # NOT IMPLEMENTED
+ end
+
+ def test_users
+ should_route 'GET /users' => 'users#index'
+ should_route 'POST /users' => 'users#create'
+
+ should_route 'GET /users/44' => 'users#show', :id => '44'
+ should_route 'GET /users/current' => 'users#show', :id => 'current'
+ should_route 'PUT /users/44' => 'users#update', :id => '44'
+ should_route 'DELETE /users/44' => 'users#destroy', :id => '44'
+ end
+
+ def test_versions
+ should_route 'GET /projects/foo/versions' => 'versions#index', :project_id => 'foo'
+ should_route 'POST /projects/foo/versions' => 'versions#create', :project_id => 'foo'
+
+ should_route 'GET /versions/1' => 'versions#show', :id => '1'
+ should_route 'PUT /versions/1' => 'versions#update', :id => '1'
+ should_route 'DELETE /versions/1' => 'versions#destroy', :id => '1'
+ end
+
+ def test_watchers
+ should_route 'POST /issues/12/watchers' => 'watchers#create', :object_type => 'issue', :object_id => '12'
+ should_route 'DELETE /issues/12/watchers/3' => 'watchers#destroy', :object_type => 'issue', :object_id => '12', :user_id => '3'
+ end
+
+ def test_wiki
+ should_route 'GET /projects/567/wiki/index' => 'wiki#index', :project_id => '567'
+
+ should_route 'GET /projects/567/wiki/my_page' => 'wiki#show', :project_id => '567', :id => 'my_page'
+ should_route 'GET /projects/567/wiki/my_page' => 'wiki#show', :project_id => '567', :id => 'my_page'
+ should_route 'GET /projects/1/wiki/my_page/2' => 'wiki#show', :project_id => '1', :id => 'my_page', :version => '2'
+
+ should_route 'PUT /projects/567/wiki/my_page' => 'wiki#update', :project_id => '567', :id => 'my_page'
+ should_route 'DELETE /projects/567/wiki/my_page' => 'wiki#destroy', :project_id => '567', :id => 'my_page'
+ end
+end
diff --git a/test/integration/routing/attachments_test.rb b/test/integration/routing/attachments_test.rb
index 2d5f03241..e01fc5f20 100644
--- a/test/integration/routing/attachments_test.rb
+++ b/test/integration/routing/attachments_test.rb
@@ -24,14 +24,6 @@ class RoutingAttachmentsTest < ActionDispatch::IntegrationTest
{ :controller => 'attachments', :action => 'show', :id => '1' }
)
assert_routing(
- { :method => 'get', :path => "/attachments/1.xml" },
- { :controller => 'attachments', :action => 'show', :id => '1', :format => 'xml' }
- )
- assert_routing(
- { :method => 'get', :path => "/attachments/1.json" },
- { :controller => 'attachments', :action => 'show', :id => '1', :format => 'json' }
- )
- assert_routing(
{ :method => 'get', :path => "/attachments/1/filename.ext" },
{ :controller => 'attachments', :action => 'show', :id => '1',
:filename => 'filename.ext' }
@@ -57,13 +49,5 @@ class RoutingAttachmentsTest < ActionDispatch::IntegrationTest
{ :method => 'delete', :path => "/attachments/1" },
{ :controller => 'attachments', :action => 'destroy', :id => '1' }
)
- assert_routing(
- { :method => 'post', :path => '/uploads.xml' },
- { :controller => 'attachments', :action => 'upload', :format => 'xml' }
- )
- assert_routing(
- { :method => 'post', :path => '/uploads.json' },
- { :controller => 'attachments', :action => 'upload', :format => 'json' }
- )
end
end
diff --git a/test/integration/routing/custom_fields_test.rb b/test/integration/routing/custom_fields_test.rb
index 6649ecf01..075e28d64 100644
--- a/test/integration/routing/custom_fields_test.rb
+++ b/test/integration/routing/custom_fields_test.rb
@@ -44,11 +44,4 @@ class RoutingCustomFieldsTest < ActionDispatch::IntegrationTest
{ :controller => 'custom_fields', :action => 'destroy', :id => '2' }
)
end
-
- def test_custom_fields_api
- assert_routing(
- { :method => 'get', :path => "/custom_fields.xml" },
- { :controller => 'custom_fields', :action => 'index', :format => 'xml' }
- )
- end
end
diff --git a/test/integration/routing/enumerations_test.rb b/test/integration/routing/enumerations_test.rb
index 8b577e159..8bc88db43 100644
--- a/test/integration/routing/enumerations_test.rb
+++ b/test/integration/routing/enumerations_test.rb
@@ -43,9 +43,5 @@ class RoutingEnumerationsTest < ActionDispatch::IntegrationTest
{ :method => 'delete', :path => "/enumerations/2" },
{ :controller => 'enumerations', :action => 'destroy', :id => '2' }
)
- assert_routing(
- { :method => 'get', :path => "/enumerations/issue_priorities.xml" },
- { :controller => 'enumerations', :action => 'index', :type => 'issue_priorities', :format => 'xml' }
- )
end
end
diff --git a/test/integration/routing/groups_test.rb b/test/integration/routing/groups_test.rb
index 4171a0e25..243046c74 100644
--- a/test/integration/routing/groups_test.rb
+++ b/test/integration/routing/groups_test.rb
@@ -24,18 +24,10 @@ class RoutingGroupsTest < ActionDispatch::IntegrationTest
{ :controller => 'groups', :action => 'index' }
)
assert_routing(
- { :method => 'get', :path => "/groups.xml" },
- { :controller => 'groups', :action => 'index', :format => 'xml' }
- )
- assert_routing(
{ :method => 'post', :path => "/groups" },
{ :controller => 'groups', :action => 'create' }
)
assert_routing(
- { :method => 'post', :path => "/groups.xml" },
- { :controller => 'groups', :action => 'create', :format => 'xml' }
- )
- assert_routing(
{ :method => 'get', :path => "/groups/new" },
{ :controller => 'groups', :action => 'new' }
)
@@ -56,25 +48,13 @@ class RoutingGroupsTest < ActionDispatch::IntegrationTest
{ :controller => 'groups', :action => 'show', :id => '1' }
)
assert_routing(
- { :method => 'get', :path => "/groups/1.xml" },
- { :controller => 'groups', :action => 'show', :id => '1', :format => 'xml' }
- )
- assert_routing(
{ :method => 'put', :path => "/groups/1" },
{ :controller => 'groups', :action => 'update', :id => '1' }
)
assert_routing(
- { :method => 'put', :path => "/groups/1.xml" },
- { :controller => 'groups', :action => 'update', :id => '1', :format => 'xml' }
- )
- assert_routing(
{ :method => 'delete', :path => "/groups/1" },
{ :controller => 'groups', :action => 'destroy', :id => '1' }
)
- assert_routing(
- { :method => 'delete', :path => "/groups/1.xml" },
- { :controller => 'groups', :action => 'destroy', :id => '1', :format => 'xml' }
- )
end
def test_groups
@@ -87,16 +67,8 @@ class RoutingGroupsTest < ActionDispatch::IntegrationTest
{ :controller => 'groups', :action => 'add_users', :id => '567' }
)
assert_routing(
- { :method => 'post', :path => "/groups/567/users.xml" },
- { :controller => 'groups', :action => 'add_users', :id => '567', :format => 'xml' }
- )
- assert_routing(
{ :method => 'delete', :path => "/groups/567/users/12" },
{ :controller => 'groups', :action => 'remove_user', :id => '567', :user_id => '12' }
)
- assert_routing(
- { :method => 'delete', :path => "/groups/567/users/12.xml" },
- { :controller => 'groups', :action => 'remove_user', :id => '567', :user_id => '12', :format => 'xml' }
- )
end
end
diff --git a/test/integration/routing/issue_categories_test.rb b/test/integration/routing/issue_categories_test.rb
index 10f23bae9..fe1d732ce 100644
--- a/test/integration/routing/issue_categories_test.rb
+++ b/test/integration/routing/issue_categories_test.rb
@@ -25,16 +25,6 @@ class RoutingIssueCategoriesTest < ActionDispatch::IntegrationTest
:project_id => 'foo' }
)
assert_routing(
- { :method => 'get', :path => "/projects/foo/issue_categories.xml" },
- { :controller => 'issue_categories', :action => 'index',
- :project_id => 'foo', :format => 'xml' }
- )
- assert_routing(
- { :method => 'get', :path => "/projects/foo/issue_categories.json" },
- { :controller => 'issue_categories', :action => 'index',
- :project_id => 'foo', :format => 'json' }
- )
- assert_routing(
{ :method => 'get', :path => "/projects/foo/issue_categories/new" },
{ :controller => 'issue_categories', :action => 'new',
:project_id => 'foo' }
@@ -44,16 +34,6 @@ class RoutingIssueCategoriesTest < ActionDispatch::IntegrationTest
{ :controller => 'issue_categories', :action => 'create',
:project_id => 'foo' }
)
- assert_routing(
- { :method => 'post', :path => "/projects/foo/issue_categories.xml" },
- { :controller => 'issue_categories', :action => 'create',
- :project_id => 'foo', :format => 'xml' }
- )
- assert_routing(
- { :method => 'post', :path => "/projects/foo/issue_categories.json" },
- { :controller => 'issue_categories', :action => 'create',
- :project_id => 'foo', :format => 'json' }
- )
end
def test_issue_categories
@@ -62,16 +42,6 @@ class RoutingIssueCategoriesTest < ActionDispatch::IntegrationTest
{ :controller => 'issue_categories', :action => 'show', :id => '1' }
)
assert_routing(
- { :method => 'get', :path => "/issue_categories/1.xml" },
- { :controller => 'issue_categories', :action => 'show', :id => '1',
- :format => 'xml' }
- )
- assert_routing(
- { :method => 'get', :path => "/issue_categories/1.json" },
- { :controller => 'issue_categories', :action => 'show', :id => '1',
- :format => 'json' }
- )
- assert_routing(
{ :method => 'get', :path => "/issue_categories/1/edit" },
{ :controller => 'issue_categories', :action => 'edit', :id => '1' }
)
@@ -80,28 +50,8 @@ class RoutingIssueCategoriesTest < ActionDispatch::IntegrationTest
{ :controller => 'issue_categories', :action => 'update', :id => '1' }
)
assert_routing(
- { :method => 'put', :path => "/issue_categories/1.xml" },
- { :controller => 'issue_categories', :action => 'update', :id => '1',
- :format => 'xml' }
- )
- assert_routing(
- { :method => 'put', :path => "/issue_categories/1.json" },
- { :controller => 'issue_categories', :action => 'update', :id => '1',
- :format => 'json' }
- )
- assert_routing(
{ :method => 'delete', :path => "/issue_categories/1" },
{ :controller => 'issue_categories', :action => 'destroy', :id => '1' }
)
- assert_routing(
- { :method => 'delete', :path => "/issue_categories/1.xml" },
- { :controller => 'issue_categories', :action => 'destroy', :id => '1',
- :format => 'xml' }
- )
- assert_routing(
- { :method => 'delete', :path => "/issue_categories/1.json" },
- { :controller => 'issue_categories', :action => 'destroy', :id => '1',
- :format => 'json' }
- )
end
end
diff --git a/test/integration/routing/issue_relations_test.rb b/test/integration/routing/issue_relations_test.rb
index a9bcbf601..502dfbd79 100644
--- a/test/integration/routing/issue_relations_test.rb
+++ b/test/integration/routing/issue_relations_test.rb
@@ -25,57 +25,17 @@ class RoutingIssueRelationsTest < ActionDispatch::IntegrationTest
:issue_id => '1' }
)
assert_routing(
- { :method => 'get', :path => "/issues/1/relations.xml" },
- { :controller => 'issue_relations', :action => 'index',
- :issue_id => '1', :format => 'xml' }
- )
- assert_routing(
- { :method => 'get', :path => "/issues/1/relations.json" },
- { :controller => 'issue_relations', :action => 'index',
- :issue_id => '1', :format => 'json' }
- )
- assert_routing(
{ :method => 'post', :path => "/issues/1/relations" },
{ :controller => 'issue_relations', :action => 'create',
:issue_id => '1' }
)
assert_routing(
- { :method => 'post', :path => "/issues/1/relations.xml" },
- { :controller => 'issue_relations', :action => 'create',
- :issue_id => '1', :format => 'xml' }
- )
- assert_routing(
- { :method => 'post', :path => "/issues/1/relations.json" },
- { :controller => 'issue_relations', :action => 'create',
- :issue_id => '1', :format => 'json' }
- )
- assert_routing(
{ :method => 'get', :path => "/relations/23" },
{ :controller => 'issue_relations', :action => 'show', :id => '23' }
)
assert_routing(
- { :method => 'get', :path => "/relations/23.xml" },
- { :controller => 'issue_relations', :action => 'show', :id => '23',
- :format => 'xml' }
- )
- assert_routing(
- { :method => 'get', :path => "/relations/23.json" },
- { :controller => 'issue_relations', :action => 'show', :id => '23',
- :format => 'json' }
- )
- assert_routing(
{ :method => 'delete', :path => "/relations/23" },
{ :controller => 'issue_relations', :action => 'destroy', :id => '23' }
)
- assert_routing(
- { :method => 'delete', :path => "/relations/23.xml" },
- { :controller => 'issue_relations', :action => 'destroy', :id => '23',
- :format => 'xml' }
- )
- assert_routing(
- { :method => 'delete', :path => "/relations/23.json" },
- { :controller => 'issue_relations', :action => 'destroy', :id => '23',
- :format => 'json' }
- )
end
end
diff --git a/test/integration/routing/issue_statuses_test.rb b/test/integration/routing/issue_statuses_test.rb
index 550fe9379..8a1171332 100644
--- a/test/integration/routing/issue_statuses_test.rb
+++ b/test/integration/routing/issue_statuses_test.rb
@@ -24,26 +24,14 @@ class RoutingIssueStatusesTest < ActionDispatch::IntegrationTest
{ :controller => 'issue_statuses', :action => 'index' }
)
assert_routing(
- { :method => 'get', :path => "/issue_statuses.xml" },
- { :controller => 'issue_statuses', :action => 'index', :format => 'xml' }
- )
- assert_routing(
{ :method => 'post', :path => "/issue_statuses" },
{ :controller => 'issue_statuses', :action => 'create' }
)
assert_routing(
- { :method => 'post', :path => "/issue_statuses.xml" },
- { :controller => 'issue_statuses', :action => 'create', :format => 'xml' }
- )
- assert_routing(
{ :method => 'get', :path => "/issue_statuses/new" },
{ :controller => 'issue_statuses', :action => 'new' }
)
assert_routing(
- { :method => 'get', :path => "/issue_statuses/new.xml" },
- { :controller => 'issue_statuses', :action => 'new', :format => 'xml' }
- )
- assert_routing(
{ :method => 'get', :path => "/issue_statuses/1/edit" },
{ :controller => 'issue_statuses', :action => 'edit', :id => '1' }
)
@@ -53,28 +41,13 @@ class RoutingIssueStatusesTest < ActionDispatch::IntegrationTest
:id => '1' }
)
assert_routing(
- { :method => 'put', :path => "/issue_statuses/1.xml" },
- { :controller => 'issue_statuses', :action => 'update',
- :format => 'xml', :id => '1' }
- )
- assert_routing(
{ :method => 'delete', :path => "/issue_statuses/1" },
{ :controller => 'issue_statuses', :action => 'destroy',
:id => '1' }
)
assert_routing(
- { :method => 'delete', :path => "/issue_statuses/1.xml" },
- { :controller => 'issue_statuses', :action => 'destroy',
- :format => 'xml', :id => '1' }
- )
- assert_routing(
{ :method => 'post', :path => "/issue_statuses/update_issue_done_ratio" },
{ :controller => 'issue_statuses', :action => 'update_issue_done_ratio' }
)
- assert_routing(
- { :method => 'post', :path => "/issue_statuses/update_issue_done_ratio.xml" },
- { :controller => 'issue_statuses', :action => 'update_issue_done_ratio',
- :format => 'xml' }
- )
end
end
diff --git a/test/integration/routing/issues_test.rb b/test/integration/routing/issues_test.rb
index 0dc3c163f..6b1c83c6d 100644
--- a/test/integration/routing/issues_test.rb
+++ b/test/integration/routing/issues_test.rb
@@ -18,7 +18,7 @@
require File.expand_path('../../../test_helper', __FILE__)
class RoutingIssuesTest < ActionDispatch::IntegrationTest
- def test_issues_rest_actions
+ def test_issues
assert_routing(
{ :method => 'get', :path => "/issues" },
{ :controller => 'issues', :action => 'index' }
@@ -32,10 +32,6 @@ class RoutingIssuesTest < ActionDispatch::IntegrationTest
{ :controller => 'issues', :action => 'index', :format => 'atom' }
)
assert_routing(
- { :method => 'get', :path => "/issues.xml" },
- { :controller => 'issues', :action => 'index', :format => 'xml' }
- )
- assert_routing(
{ :method => 'get', :path => "/issues/64" },
{ :controller => 'issues', :action => 'show', :id => '64' }
)
@@ -50,31 +46,20 @@ class RoutingIssuesTest < ActionDispatch::IntegrationTest
:format => 'atom' }
)
assert_routing(
- { :method => 'get', :path => "/issues/64.xml" },
- { :controller => 'issues', :action => 'show', :id => '64',
- :format => 'xml' }
- )
- assert_routing(
- { :method => 'post', :path => "/issues.xml" },
- { :controller => 'issues', :action => 'create', :format => 'xml' }
- )
- assert_routing(
{ :method => 'get', :path => "/issues/64/edit" },
{ :controller => 'issues', :action => 'edit', :id => '64' }
)
assert_routing(
- { :method => 'put', :path => "/issues/1.xml" },
- { :controller => 'issues', :action => 'update', :id => '1',
- :format => 'xml' }
+ { :method => 'put', :path => "/issues/1" },
+ { :controller => 'issues', :action => 'update', :id => '1' }
)
assert_routing(
- { :method => 'delete', :path => "/issues/1.xml" },
- { :controller => 'issues', :action => 'destroy', :id => '1',
- :format => 'xml' }
+ { :method => 'delete', :path => "/issues/1" },
+ { :controller => 'issues', :action => 'destroy', :id => '1' }
)
end
- def test_issues_rest_actions_scoped_under_project
+ def test_issues_scoped_under_project
assert_routing(
{ :method => 'get', :path => "/projects/23/issues" },
{ :controller => 'issues', :action => 'index', :project_id => '23' }
@@ -90,11 +75,6 @@ class RoutingIssuesTest < ActionDispatch::IntegrationTest
:format => 'atom' }
)
assert_routing(
- { :method => 'get', :path => "/projects/23/issues.xml" },
- { :controller => 'issues', :action => 'index', :project_id => '23',
- :format => 'xml' }
- )
- assert_routing(
{ :method => 'post', :path => "/projects/23/issues" },
{ :controller => 'issues', :action => 'create', :project_id => '23' }
)
diff --git a/test/integration/routing/members_test.rb b/test/integration/routing/members_test.rb
index 91a98d401..cb70bd632 100644
--- a/test/integration/routing/members_test.rb
+++ b/test/integration/routing/members_test.rb
@@ -20,22 +20,10 @@ require File.expand_path('../../../test_helper', __FILE__)
class RoutingMembersTest < ActionDispatch::IntegrationTest
def test_members
assert_routing(
- { :method => 'get', :path => "/projects/5234/memberships.xml" },
- { :controller => 'members', :action => 'index', :project_id => '5234', :format => 'xml' }
- )
- assert_routing(
- { :method => 'get', :path => "/memberships/5234.xml" },
- { :controller => 'members', :action => 'show', :id => '5234', :format => 'xml' }
- )
- assert_routing(
{ :method => 'post', :path => "/projects/5234/memberships" },
{ :controller => 'members', :action => 'create', :project_id => '5234' }
)
assert_routing(
- { :method => 'post', :path => "/projects/5234/memberships.xml" },
- { :controller => 'members', :action => 'create', :project_id => '5234', :format => 'xml' }
- )
- assert_routing(
{ :method => 'get', :path => "/projects/5234/memberships/new" },
{ :controller => 'members', :action => 'new', :project_id => '5234' }
)
@@ -44,18 +32,10 @@ class RoutingMembersTest < ActionDispatch::IntegrationTest
{ :controller => 'members', :action => 'update', :id => '5234' }
)
assert_routing(
- { :method => 'put', :path => "/memberships/5234.xml" },
- { :controller => 'members', :action => 'update', :id => '5234', :format => 'xml' }
- )
- assert_routing(
{ :method => 'delete', :path => "/memberships/5234" },
{ :controller => 'members', :action => 'destroy', :id => '5234' }
)
assert_routing(
- { :method => 'delete', :path => "/memberships/5234.xml" },
- { :controller => 'members', :action => 'destroy', :id => '5234', :format => 'xml' }
- )
- assert_routing(
{ :method => 'get', :path => "/projects/5234/memberships/autocomplete" },
{ :controller => 'members', :action => 'autocomplete', :project_id => '5234' }
)
diff --git a/test/integration/routing/news_test.rb b/test/integration/routing/news_test.rb
index a1ee7b12b..c7ca04016 100644
--- a/test/integration/routing/news_test.rb
+++ b/test/integration/routing/news_test.rb
@@ -27,14 +27,6 @@ class RoutingNewsTest < ActionDispatch::IntegrationTest
{ :method => 'get', :path => "/news.atom" },
{ :controller => 'news', :action => 'index', :format => 'atom' }
)
- assert_routing(
- { :method => 'get', :path => "/news.xml" },
- { :controller => 'news', :action => 'index', :format => 'xml' }
- )
- assert_routing(
- { :method => 'get', :path => "/news.json" },
- { :controller => 'news', :action => 'index', :format => 'json' }
- )
end
def test_news
@@ -71,16 +63,6 @@ class RoutingNewsTest < ActionDispatch::IntegrationTest
:project_id => '567' }
)
assert_routing(
- { :method => 'get', :path => "/projects/567/news.xml" },
- { :controller => 'news', :action => 'index', :format => 'xml',
- :project_id => '567' }
- )
- assert_routing(
- { :method => 'get', :path => "/projects/567/news.json" },
- { :controller => 'news', :action => 'index', :format => 'json',
- :project_id => '567' }
- )
- assert_routing(
{ :method => 'get', :path => "/projects/567/news/new" },
{ :controller => 'news', :action => 'new', :project_id => '567' }
)
diff --git a/test/integration/routing/projects_test.rb b/test/integration/routing/projects_test.rb
index 392b871d1..1ad54a510 100644
--- a/test/integration/routing/projects_test.rb
+++ b/test/integration/routing/projects_test.rb
@@ -28,10 +28,6 @@ class RoutingProjectsTest < ActionDispatch::IntegrationTest
{ :controller => 'projects', :action => 'index', :format => 'atom' }
)
assert_routing(
- { :method => 'get', :path => "/projects.xml" },
- { :controller => 'projects', :action => 'index', :format => 'xml' }
- )
- assert_routing(
{ :method => 'get', :path => "/projects/new" },
{ :controller => 'projects', :action => 'new' }
)
@@ -40,11 +36,6 @@ class RoutingProjectsTest < ActionDispatch::IntegrationTest
{ :controller => 'projects', :action => 'show', :id => 'test' }
)
assert_routing(
- { :method => 'get', :path => "/projects/1.xml" },
- { :controller => 'projects', :action => 'show', :id => '1',
- :format => 'xml' }
- )
- assert_routing(
{ :method => 'get', :path => "/projects/4223/settings" },
{ :controller => 'projects', :action => 'settings', :id => '4223' }
)
@@ -58,10 +49,6 @@ class RoutingProjectsTest < ActionDispatch::IntegrationTest
{ :controller => 'projects', :action => 'create' }
)
assert_routing(
- { :method => 'post', :path => "/projects.xml" },
- { :controller => 'projects', :action => 'create', :format => 'xml' }
- )
- assert_routing(
{ :method => 'post', :path => "/projects/64/archive" },
{ :controller => 'projects', :action => 'archive', :id => '64' }
)
@@ -82,18 +69,8 @@ class RoutingProjectsTest < ActionDispatch::IntegrationTest
{ :controller => 'projects', :action => 'update', :id => '4223' }
)
assert_routing(
- { :method => 'put', :path => "/projects/1.xml" },
- { :controller => 'projects', :action => 'update', :id => '1',
- :format => 'xml' }
- )
- assert_routing(
{ :method => 'delete', :path => "/projects/64" },
{ :controller => 'projects', :action => 'destroy', :id => '64' }
)
- assert_routing(
- { :method => 'delete', :path => "/projects/1.xml" },
- { :controller => 'projects', :action => 'destroy', :id => '1',
- :format => 'xml' }
- )
end
end
diff --git a/test/integration/routing/queries_test.rb b/test/integration/routing/queries_test.rb
index ac50fbca7..226a5b50c 100644
--- a/test/integration/routing/queries_test.rb
+++ b/test/integration/routing/queries_test.rb
@@ -20,14 +20,6 @@ require File.expand_path('../../../test_helper', __FILE__)
class RoutingQueriesTest < ActionDispatch::IntegrationTest
def test_queries
assert_routing(
- { :method => 'get', :path => "/queries.xml" },
- { :controller => 'queries', :action => 'index', :format => 'xml' }
- )
- assert_routing(
- { :method => 'get', :path => "/queries.json" },
- { :controller => 'queries', :action => 'index', :format => 'json' }
- )
- assert_routing(
{ :method => 'get', :path => "/queries/new" },
{ :controller => 'queries', :action => 'new' }
)
diff --git a/test/integration/routing/roles_test.rb b/test/integration/routing/roles_test.rb
index 5541984f3..b836a1090 100644
--- a/test/integration/routing/roles_test.rb
+++ b/test/integration/routing/roles_test.rb
@@ -24,14 +24,6 @@ class RoutingRolesTest < ActionDispatch::IntegrationTest
{ :controller => 'roles', :action => 'index' }
)
assert_routing(
- { :method => 'get', :path => "/roles.xml" },
- { :controller => 'roles', :action => 'index', :format => 'xml' }
- )
- assert_routing(
- { :method => 'get', :path => "/roles/2.xml" },
- { :controller => 'roles', :action => 'show', :id => '2', :format => 'xml' }
- )
- assert_routing(
{ :method => 'get', :path => "/roles/new" },
{ :controller => 'roles', :action => 'new' }
)
diff --git a/test/integration/routing/trackers_test.rb b/test/integration/routing/trackers_test.rb
index 338197d8c..05724c92e 100644
--- a/test/integration/routing/trackers_test.rb
+++ b/test/integration/routing/trackers_test.rb
@@ -24,26 +24,14 @@ class RoutingTrackersTest < ActionDispatch::IntegrationTest
{ :controller => 'trackers', :action => 'index' }
)
assert_routing(
- { :method => 'get', :path => "/trackers.xml" },
- { :controller => 'trackers', :action => 'index', :format => 'xml' }
- )
- assert_routing(
{ :method => 'post', :path => "/trackers" },
{ :controller => 'trackers', :action => 'create' }
)
assert_routing(
- { :method => 'post', :path => "/trackers.xml" },
- { :controller => 'trackers', :action => 'create', :format => 'xml' }
- )
- assert_routing(
{ :method => 'get', :path => "/trackers/new" },
{ :controller => 'trackers', :action => 'new' }
)
assert_routing(
- { :method => 'get', :path => "/trackers/new.xml" },
- { :controller => 'trackers', :action => 'new', :format => 'xml' }
- )
- assert_routing(
{ :method => 'get', :path => "/trackers/1/edit" },
{ :controller => 'trackers', :action => 'edit', :id => '1' }
)
@@ -53,21 +41,11 @@ class RoutingTrackersTest < ActionDispatch::IntegrationTest
:id => '1' }
)
assert_routing(
- { :method => 'put', :path => "/trackers/1.xml" },
- { :controller => 'trackers', :action => 'update',
- :format => 'xml', :id => '1' }
- )
- assert_routing(
{ :method => 'delete', :path => "/trackers/1" },
{ :controller => 'trackers', :action => 'destroy',
:id => '1' }
)
assert_routing(
- { :method => 'delete', :path => "/trackers/1.xml" },
- { :controller => 'trackers', :action => 'destroy',
- :format => 'xml', :id => '1' }
- )
- assert_routing(
{ :method => 'get', :path => "/trackers/fields" },
{ :controller => 'trackers', :action => 'fields' }
)
diff --git a/test/integration/routing/users_test.rb b/test/integration/routing/users_test.rb
index 911c1de99..fad01fbbb 100644
--- a/test/integration/routing/users_test.rb
+++ b/test/integration/routing/users_test.rb
@@ -24,28 +24,14 @@ class RoutingUsersTest < ActionDispatch::IntegrationTest
{ :controller => 'users', :action => 'index' }
)
assert_routing(
- { :method => 'get', :path => "/users.xml" },
- { :controller => 'users', :action => 'index', :format => 'xml' }
- )
- assert_routing(
{ :method => 'get', :path => "/users/44" },
{ :controller => 'users', :action => 'show', :id => '44' }
)
assert_routing(
- { :method => 'get', :path => "/users/44.xml" },
- { :controller => 'users', :action => 'show', :id => '44',
- :format => 'xml' }
- )
- assert_routing(
{ :method => 'get', :path => "/users/current" },
{ :controller => 'users', :action => 'show', :id => 'current' }
)
assert_routing(
- { :method => 'get', :path => "/users/current.xml" },
- { :controller => 'users', :action => 'show', :id => 'current',
- :format => 'xml' }
- )
- assert_routing(
{ :method => 'get', :path => "/users/new" },
{ :controller => 'users', :action => 'new' }
)
@@ -58,26 +44,12 @@ class RoutingUsersTest < ActionDispatch::IntegrationTest
{ :controller => 'users', :action => 'create' }
)
assert_routing(
- { :method => 'post', :path => "/users.xml" },
- { :controller => 'users', :action => 'create', :format => 'xml' }
- )
- assert_routing(
{ :method => 'put', :path => "/users/444" },
{ :controller => 'users', :action => 'update', :id => '444' }
)
assert_routing(
- { :method => 'put', :path => "/users/444.xml" },
- { :controller => 'users', :action => 'update', :id => '444',
- :format => 'xml' }
- )
- assert_routing(
{ :method => 'delete', :path => "/users/44" },
{ :controller => 'users', :action => 'destroy', :id => '44' }
)
- assert_routing(
- { :method => 'delete', :path => "/users/44.xml" },
- { :controller => 'users', :action => 'destroy', :id => '44',
- :format => 'xml' }
- )
end
end
diff --git a/test/integration/routing/versions_test.rb b/test/integration/routing/versions_test.rb
index 28a7969c9..865bd3bb3 100644
--- a/test/integration/routing/versions_test.rb
+++ b/test/integration/routing/versions_test.rb
@@ -33,16 +33,6 @@ class RoutingVersionsTest < ActionDispatch::IntegrationTest
:project_id => 'foo' }
)
assert_routing(
- { :method => 'get', :path => "/projects/foo/versions.xml" },
- { :controller => 'versions', :action => 'index',
- :project_id => 'foo', :format => 'xml' }
- )
- assert_routing(
- { :method => 'get', :path => "/projects/foo/versions.json" },
- { :controller => 'versions', :action => 'index',
- :project_id => 'foo', :format => 'json' }
- )
- assert_routing(
{ :method => 'get', :path => "/projects/foo/versions/new" },
{ :controller => 'versions', :action => 'new',
:project_id => 'foo' }
@@ -52,16 +42,6 @@ class RoutingVersionsTest < ActionDispatch::IntegrationTest
{ :controller => 'versions', :action => 'create',
:project_id => 'foo' }
)
- assert_routing(
- { :method => 'post', :path => "/projects/foo/versions.xml" },
- { :controller => 'versions', :action => 'create',
- :project_id => 'foo', :format => 'xml' }
- )
- assert_routing(
- { :method => 'post', :path => "/projects/foo/versions.json" },
- { :controller => 'versions', :action => 'create',
- :project_id => 'foo', :format => 'json' }
- )
end
def test_versions
@@ -70,16 +50,6 @@ class RoutingVersionsTest < ActionDispatch::IntegrationTest
{ :controller => 'versions', :action => 'show', :id => '1' }
)
assert_routing(
- { :method => 'get', :path => "/versions/1.xml" },
- { :controller => 'versions', :action => 'show', :id => '1',
- :format => 'xml' }
- )
- assert_routing(
- { :method => 'get', :path => "/versions/1.json" },
- { :controller => 'versions', :action => 'show', :id => '1',
- :format => 'json' }
- )
- assert_routing(
{ :method => 'get', :path => "/versions/1/edit" },
{ :controller => 'versions', :action => 'edit', :id => '1' }
)
@@ -88,30 +58,10 @@ class RoutingVersionsTest < ActionDispatch::IntegrationTest
{ :controller => 'versions', :action => 'update', :id => '1' }
)
assert_routing(
- { :method => 'put', :path => "/versions/1.xml" },
- { :controller => 'versions', :action => 'update', :id => '1',
- :format => 'xml' }
- )
- assert_routing(
- { :method => 'put', :path => "/versions/1.json" },
- { :controller => 'versions', :action => 'update', :id => '1',
- :format => 'json' }
- )
- assert_routing(
{ :method => 'delete', :path => "/versions/1" },
{ :controller => 'versions', :action => 'destroy', :id => '1' }
)
assert_routing(
- { :method => 'delete', :path => "/versions/1.xml" },
- { :controller => 'versions', :action => 'destroy', :id => '1',
- :format => 'xml' }
- )
- assert_routing(
- { :method => 'delete', :path => "/versions/1.json" },
- { :controller => 'versions', :action => 'destroy', :id => '1',
- :format => 'json' }
- )
- assert_routing(
{ :method => 'post', :path => "/versions/1/status_by" },
{ :controller => 'versions', :action => 'status_by', :id => '1' }
)
diff --git a/test/integration/routing/watchers_test.rb b/test/integration/routing/watchers_test.rb
index be35d5667..f2f9fcb3e 100644
--- a/test/integration/routing/watchers_test.rb
+++ b/test/integration/routing/watchers_test.rb
@@ -47,15 +47,5 @@ class RoutingWatchersTest < ActionDispatch::IntegrationTest
{ :method => 'delete', :path => "/watchers/watch" },
{ :controller => 'watchers', :action => 'unwatch' }
)
- assert_routing(
- { :method => 'post', :path => "/issues/12/watchers.xml" },
- { :controller => 'watchers', :action => 'create',
- :object_type => 'issue', :object_id => '12', :format => 'xml' }
- )
- assert_routing(
- { :method => 'delete', :path => "/issues/12/watchers/3.xml" },
- { :controller => 'watchers', :action => 'destroy',
- :object_type => 'issue', :object_id => '12', :user_id => '3', :format => 'xml'}
- )
end
end
diff --git a/test/integration/routing/wiki_test.rb b/test/integration/routing/wiki_test.rb
index f677856a8..09e852497 100644
--- a/test/integration/routing/wiki_test.rb
+++ b/test/integration/routing/wiki_test.rb
@@ -132,55 +132,4 @@ class RoutingWikiTest < ActionDispatch::IntegrationTest
:id => 'ladida', :version => '3' }
)
end
-
- def test_api
- assert_routing(
- { :method => 'get', :path => "/projects/567/wiki/my_page.xml" },
- { :controller => 'wiki', :action => 'show', :project_id => '567',
- :id => 'my_page', :format => 'xml' }
- )
- assert_routing(
- { :method => 'get', :path => "/projects/567/wiki/my_page.json" },
- { :controller => 'wiki', :action => 'show', :project_id => '567',
- :id => 'my_page', :format => 'json' }
- )
- assert_routing(
- { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2.xml" },
- { :controller => 'wiki', :action => 'show', :project_id => '1',
- :id => 'CookBook_documentation', :version => '2', :format => 'xml' }
- )
- assert_routing(
- { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2.json" },
- { :controller => 'wiki', :action => 'show', :project_id => '1',
- :id => 'CookBook_documentation', :version => '2', :format => 'json' }
- )
- assert_routing(
- { :method => 'get', :path => "/projects/567/wiki/index.xml" },
- { :controller => 'wiki', :action => 'index', :project_id => '567', :format => 'xml' }
- )
- assert_routing(
- { :method => 'get', :path => "/projects/567/wiki/index.json" },
- { :controller => 'wiki', :action => 'index', :project_id => '567', :format => 'json' }
- )
- assert_routing(
- { :method => 'put', :path => "/projects/567/wiki/my_page.xml" },
- { :controller => 'wiki', :action => 'update', :project_id => '567',
- :id => 'my_page', :format => 'xml' }
- )
- assert_routing(
- { :method => 'put', :path => "/projects/567/wiki/my_page.json" },
- { :controller => 'wiki', :action => 'update', :project_id => '567',
- :id => 'my_page', :format => 'json' }
- )
- assert_routing(
- { :method => 'delete', :path => "/projects/567/wiki/my_page.xml" },
- { :controller => 'wiki', :action => 'destroy', :project_id => '567',
- :id => 'my_page', :format => 'xml' }
- )
- assert_routing(
- { :method => 'delete', :path => "/projects/567/wiki/my_page.json" },
- { :controller => 'wiki', :action => 'destroy', :project_id => '567',
- :id => 'my_page', :format => 'json' }
- )
- end
end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 3534c5746..a894a60ad 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -238,7 +238,29 @@ class ActiveSupport::TestCase
end
module Redmine
+ class RoutingTest < ActionDispatch::IntegrationTest
+ def should_route(arg)
+ arg = arg.dup
+ request = arg.keys.detect {|key| key.is_a?(String)}
+ raise ArgumentError unless request
+ options = arg.slice!(request)
+
+ raise ArgumentError unless request =~ /\A(GET|POST|PUT|PATCH|DELETE)\s+(.+)\z/
+ method, path = $1.downcase.to_sym, $2
+
+ raise ArgumentError unless arg.values.first =~ /\A(.+)#(.+)\z/
+ controller, action = $1, $2
+
+ assert_routing(
+ {:method => method, :path => path},
+ options.merge(:controller => controller, :action => action)
+ )
+ end
+ end
+
module ApiTest
+ API_FORMATS = %w(json xml).freeze
+
# Base class for API tests
class Base < ActionDispatch::IntegrationTest
# Test that a request allows the three types of API authentication
@@ -491,6 +513,20 @@ module Redmine
end
end
end
+
+ class Routing < Redmine::RoutingTest
+ def should_route(arg)
+ arg = arg.dup
+ request = arg.keys.detect {|key| key.is_a?(String)}
+ raise ArgumentError unless request
+ options = arg.slice!(request)
+
+ API_FORMATS.each do |format|
+ format_request = request.sub /$/, ".#{format}"
+ super options.merge(format_request => arg[request], :format => format)
+ end
+ end
+ end
end
end