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.

repositories_test.rb 5.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 RoutingRepositoriesTest < Redmine::RoutingTest
  20. def setup
  21. @paths = ['path/to/index.html',
  22. 'path/to/file.c', 'path/to/file.yaml', 'path/to/file.txt',
  23. 'raw/file.c']
  24. end
  25. def test_repositories_resources
  26. should_route 'GET /projects/foo/repositories/new' => 'repositories#new', :project_id => 'foo'
  27. should_route 'POST /projects/foo/repositories' => 'repositories#create', :project_id => 'foo'
  28. should_route 'GET /repositories/1/edit' => 'repositories#edit', :id => '1'
  29. should_route 'PUT /repositories/1' => 'repositories#update', :id => '1'
  30. should_route 'DELETE /repositories/1' => 'repositories#destroy', :id => '1'
  31. should_route 'GET /repositories/1/committers' => 'repositories#committers', :id => '1'
  32. should_route 'POST /repositories/1/committers' => 'repositories#committers', :id => '1'
  33. end
  34. def test_repositories
  35. should_route 'GET /projects/foo/repository' => 'repositories#show', :id => 'foo'
  36. end
  37. def test_repositories_with_repository_id
  38. should_route 'GET /projects/foo/repository/svn' => 'repositories#show', :id => 'foo', :repository_id => 'svn'
  39. should_route 'GET /projects/foo/repository/svn/statistics' => 'repositories#stats', :id => 'foo', :repository_id => 'svn'
  40. should_route 'GET /projects/foo/repository/svn/graph' => 'repositories#graph', :id => 'foo', :repository_id => 'svn'
  41. end
  42. def test_repositories_revisions_with_repository_id
  43. should_route 'GET /projects/foo/repository/foo/revision' => 'repositories#revision', :id => 'foo', :repository_id => 'foo'
  44. should_route 'GET /projects/foo/repository/foo/revisions' => 'repositories#revisions', :id => 'foo', :repository_id => 'foo'
  45. should_route 'GET /projects/foo/repository/foo/revisions.atom' => 'repositories#revisions', :id => 'foo', :repository_id => 'foo', :format => 'atom'
  46. should_route 'GET /projects/foo/repository/foo/revisions/2457' => 'repositories#revision', :id => 'foo', :repository_id => 'foo', :rev => '2457'
  47. should_route 'GET /projects/foo/repository/foo/revisions/2457/show' => 'repositories#show', :id => 'foo', :repository_id => 'foo', :rev => '2457', :format => 'html'
  48. should_route 'GET /projects/foo/repository/foo/revisions/2457/diff' => 'repositories#diff', :id => 'foo', :repository_id => 'foo', :rev => '2457', :format => 'html'
  49. %w(show entry raw annotate).each do |action|
  50. @paths.each do |path|
  51. should_route "GET /projects/foo/repository/foo/revisions/2457/#{action}/#{path}" => "repositories##{action}",
  52. :id => 'foo', :repository_id => 'foo', :rev => '2457', :path => path, :format => 'html'
  53. end
  54. end
  55. @paths.each do |path|
  56. should_route "GET /projects/foo/repository/foo/revisions/2457/diff/#{path}" => "repositories#diff",
  57. :id => 'foo', :repository_id => 'foo', :rev => '2457', :path => path, :format => 'html'
  58. end
  59. end
  60. def test_repositories_fetch_changesets_with_repository_id
  61. should_route 'POST /projects/foo/repository/bar/fetch_changesets' => 'repositories#fetch_changesets', :id => 'foo', :repository_id => 'bar'
  62. end
  63. def test_repositories_non_revisions_path_with_repository_id
  64. should_route 'GET /projects/foo/repository/svn/changes' => 'repositories#changes', :id => 'foo', :repository_id => 'svn', :format => 'html'
  65. %w(changes browse entry raw annotate).each do |action|
  66. @paths.each do |path|
  67. should_route "GET /projects/foo/repository/svn/#{action}/#{path}" => "repositories##{action}",
  68. :id => 'foo', :repository_id => 'svn', :path => path, :format => 'html'
  69. end
  70. end
  71. @paths.each do |path|
  72. should_route "GET /projects/foo/repository/svn/diff/#{path}" => "repositories#diff",
  73. :id => 'foo', :repository_id => 'svn', :path => path, :format => 'html'
  74. end
  75. end
  76. def test_repositories_related_issues_with_repository_id
  77. should_route 'POST /projects/foo/repository/svn/revisions/123/issues' => 'repositories#add_related_issue',
  78. :id => 'foo', :repository_id => 'svn', :rev => '123'
  79. should_route 'DELETE /projects/foo/repository/svn/revisions/123/issues/25' => 'repositories#remove_related_issue',
  80. :id => 'foo', :repository_id => 'svn', :rev => '123', :issue_id => '25'
  81. end
  82. end