You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

api_routing_test.rb 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006-2023 Jean-Philippe Lang
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. require_relative '../../test_helper'
  19. class Redmine::ApiTest::ApiRoutingTest < Redmine::ApiTest::Routing
  20. def test_attachments
  21. should_route 'GET /attachments/1' => 'attachments#show', :id => '1'
  22. should_route 'PATCH /attachments/1' => 'attachments#update', :id => '1'
  23. should_route 'DELETE /attachments/1' => 'attachments#destroy', :id => '1'
  24. should_route 'POST /uploads' => 'attachments#upload'
  25. end
  26. def test_custom_fields
  27. should_route 'GET /custom_fields' => 'custom_fields#index'
  28. end
  29. def test_enumerations
  30. should_route 'GET /enumerations/issue_priorities' => 'enumerations#index', :type => 'issue_priorities'
  31. end
  32. def test_files
  33. should_route 'GET /projects/foo/files' => 'files#index', :project_id => 'foo'
  34. should_route 'POST /projects/foo/files' => 'files#create', :project_id => 'foo'
  35. end
  36. def test_groups
  37. should_route 'GET /groups' => 'groups#index'
  38. should_route 'POST /groups' => 'groups#create'
  39. should_route 'GET /groups/1' => 'groups#show', :id => '1'
  40. should_route 'PUT /groups/1' => 'groups#update', :id => '1'
  41. should_route 'DELETE /groups/1' => 'groups#destroy', :id => '1'
  42. end
  43. def test_group_users
  44. should_route 'POST /groups/567/users' => 'groups#add_users', :id => '567'
  45. should_route 'DELETE /groups/567/users/12' => 'groups#remove_user', :id => '567', :user_id => '12'
  46. end
  47. def test_issue_categories
  48. should_route 'GET /projects/foo/issue_categories' => 'issue_categories#index', :project_id => 'foo'
  49. should_route 'POST /projects/foo/issue_categories' => 'issue_categories#create', :project_id => 'foo'
  50. should_route 'GET /issue_categories/1' => 'issue_categories#show', :id => '1'
  51. should_route 'PUT /issue_categories/1' => 'issue_categories#update', :id => '1'
  52. should_route 'DELETE /issue_categories/1' => 'issue_categories#destroy', :id => '1'
  53. end
  54. def test_issue_relations
  55. should_route 'GET /issues/1/relations' => 'issue_relations#index', :issue_id => '1'
  56. should_route 'POST /issues/1/relations' => 'issue_relations#create', :issue_id => '1'
  57. should_route 'GET /relations/23' => 'issue_relations#show', :id => '23'
  58. should_route 'DELETE /relations/23' => 'issue_relations#destroy', :id => '23'
  59. end
  60. def test_issue_statuses
  61. should_route 'GET /issue_statuses' => 'issue_statuses#index'
  62. end
  63. def test_issues
  64. should_route 'GET /issues' => 'issues#index'
  65. should_route 'POST /issues' => 'issues#create'
  66. should_route 'GET /issues/64' => 'issues#show', :id => '64'
  67. should_route 'PUT /issues/64' => 'issues#update', :id => '64'
  68. should_route 'DELETE /issues/64' => 'issues#destroy', :id => '64'
  69. end
  70. def test_issue_watchers
  71. should_route 'POST /issues/12/watchers' => 'watchers#create', :object_type => 'issue', :object_id => '12'
  72. should_route 'DELETE /issues/12/watchers/3' => 'watchers#destroy', :object_type => 'issue', :object_id => '12', :user_id => '3'
  73. end
  74. def test_memberships
  75. should_route 'GET /projects/5234/memberships' => 'members#index', :project_id => '5234'
  76. should_route 'POST /projects/5234/memberships' => 'members#create', :project_id => '5234'
  77. should_route 'GET /memberships/5234' => 'members#show', :id => '5234'
  78. should_route 'PUT /memberships/5234' => 'members#update', :id => '5234'
  79. should_route 'DELETE /memberships/5234' => 'members#destroy', :id => '5234'
  80. end
  81. def test_news
  82. should_route 'GET /news' => 'news#index'
  83. should_route 'GET /projects/567/news' => 'news#index', :project_id => '567'
  84. end
  85. def test_projects
  86. should_route 'GET /projects' => 'projects#index'
  87. should_route 'POST /projects' => 'projects#create'
  88. should_route 'GET /projects/1' => 'projects#show', :id => '1'
  89. should_route 'PUT /projects/1' => 'projects#update', :id => '1'
  90. should_route 'DELETE /projects/1' => 'projects#destroy', :id => '1'
  91. end
  92. def test_queries
  93. should_route 'GET /queries' => 'queries#index'
  94. end
  95. def test_repositories
  96. should_route 'POST /projects/1/repository/2/revisions/3/issues' => 'repositories#add_related_issue', :id => '1', :repository_id => '2', :rev => '3'
  97. should_route 'DELETE /projects/1/repository/2/revisions/3/issues/4' => 'repositories#remove_related_issue', :id => '1', :repository_id => '2', :rev => '3', :issue_id => '4'
  98. end
  99. def test_roles
  100. should_route 'GET /roles' => 'roles#index'
  101. should_route 'GET /roles/2' => 'roles#show', :id => '2'
  102. end
  103. def test_time_entries
  104. should_route 'GET /time_entries' => 'timelog#index'
  105. should_route 'POST /time_entries' => 'timelog#create'
  106. should_route 'GET /time_entries/1' => 'timelog#show', :id => '1'
  107. should_route 'PUT /time_entries/1' => 'timelog#update', :id => '1'
  108. should_route 'DELETE /time_entries/1' => 'timelog#destroy', :id => '1'
  109. end
  110. def test_trackers
  111. should_route 'GET /trackers' => 'trackers#index'
  112. end
  113. def test_users
  114. should_route 'GET /users' => 'users#index'
  115. should_route 'POST /users' => 'users#create'
  116. should_route 'GET /users/44' => 'users#show', :id => '44'
  117. should_route 'GET /users/current' => 'users#show', :id => 'current'
  118. should_route 'PUT /users/44' => 'users#update', :id => '44'
  119. should_route 'DELETE /users/44' => 'users#destroy', :id => '44'
  120. end
  121. def test_versions
  122. should_route 'GET /projects/foo/versions' => 'versions#index', :project_id => 'foo'
  123. should_route 'POST /projects/foo/versions' => 'versions#create', :project_id => 'foo'
  124. should_route 'GET /versions/1' => 'versions#show', :id => '1'
  125. should_route 'PUT /versions/1' => 'versions#update', :id => '1'
  126. should_route 'DELETE /versions/1' => 'versions#destroy', :id => '1'
  127. end
  128. def test_wiki
  129. should_route 'GET /projects/567/wiki/index' => 'wiki#index', :project_id => '567'
  130. should_route 'GET /projects/567/wiki/my_page' => 'wiki#show', :project_id => '567', :id => 'my_page'
  131. should_route 'GET /projects/567/wiki/my_page' => 'wiki#show', :project_id => '567', :id => 'my_page'
  132. should_route 'GET /projects/1/wiki/my_page/2' => 'wiki#show', :project_id => '1', :id => 'my_page', :version => '2'
  133. should_route 'PUT /projects/567/wiki/my_page' => 'wiki#update', :project_id => '567', :id => 'my_page'
  134. should_route 'DELETE /projects/567/wiki/my_page' => 'wiki#destroy', :project_id => '567', :id => 'my_page'
  135. end
  136. end