annotate test/integration/routing/wiki_test.rb @ 1621:3a510bf6a9bc

Merge from live branch
author Chris Cannam
date Fri, 13 Jul 2018 10:44:33 +0100
parents e248c7af89ec
children
rev   line source
Chris@1115 1 # Redmine - project management software
Chris@1494 2 # Copyright (C) 2006-2014 Jean-Philippe Lang
Chris@1115 3 #
Chris@1115 4 # This program is free software; you can redistribute it and/or
Chris@1115 5 # modify it under the terms of the GNU General Public License
Chris@1115 6 # as published by the Free Software Foundation; either version 2
Chris@1115 7 # of the License, or (at your option) any later version.
Chris@1115 8 #
Chris@1115 9 # This program is distributed in the hope that it will be useful,
Chris@1115 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1115 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1115 12 # GNU General Public License for more details.
Chris@1115 13 #
Chris@1115 14 # You should have received a copy of the GNU General Public License
Chris@1115 15 # along with this program; if not, write to the Free Software
Chris@1115 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1115 17
Chris@1115 18 require File.expand_path('../../../test_helper', __FILE__)
Chris@1115 19
Chris@1115 20 class RoutingWikiTest < ActionController::IntegrationTest
Chris@1115 21 def test_wiki_matching
Chris@1115 22 assert_routing(
Chris@1115 23 { :method => 'get', :path => "/projects/567/wiki" },
Chris@1115 24 { :controller => 'wiki', :action => 'show', :project_id => '567' }
Chris@1115 25 )
Chris@1115 26 assert_routing(
Chris@1115 27 { :method => 'get', :path => "/projects/567/wiki/lalala" },
Chris@1115 28 { :controller => 'wiki', :action => 'show', :project_id => '567',
Chris@1115 29 :id => 'lalala' }
Chris@1115 30 )
Chris@1115 31 assert_routing(
Chris@1115 32 { :method => 'get', :path => "/projects/567/wiki/lalala.pdf" },
Chris@1115 33 { :controller => 'wiki', :action => 'show', :project_id => '567',
Chris@1115 34 :id => 'lalala', :format => 'pdf' }
Chris@1115 35 )
Chris@1115 36 assert_routing(
Chris@1115 37 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/diff" },
Chris@1115 38 { :controller => 'wiki', :action => 'diff', :project_id => '1',
Chris@1115 39 :id => 'CookBook_documentation' }
Chris@1115 40 )
Chris@1115 41 assert_routing(
Chris@1115 42 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2" },
Chris@1115 43 { :controller => 'wiki', :action => 'show', :project_id => '1',
Chris@1115 44 :id => 'CookBook_documentation', :version => '2' }
Chris@1115 45 )
Chris@1115 46 assert_routing(
Chris@1115 47 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2/diff" },
Chris@1115 48 { :controller => 'wiki', :action => 'diff', :project_id => '1',
Chris@1115 49 :id => 'CookBook_documentation', :version => '2' }
Chris@1115 50 )
Chris@1115 51 assert_routing(
Chris@1115 52 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2/annotate" },
Chris@1115 53 { :controller => 'wiki', :action => 'annotate', :project_id => '1',
Chris@1115 54 :id => 'CookBook_documentation', :version => '2' }
Chris@1115 55 )
Chris@1464 56 # Make sure we don't route wiki page sub-uris to let plugins handle them
Chris@1464 57 assert_raise(ActionController::RoutingError) do
Chris@1464 58 assert_recognizes({}, {:method => 'get', :path => "/projects/1/wiki/CookBook_documentation/whatever"})
Chris@1464 59 end
Chris@1115 60 end
Chris@1115 61
Chris@1115 62 def test_wiki_misc
Chris@1115 63 assert_routing(
Chris@1115 64 { :method => 'get', :path => "/projects/567/wiki/date_index" },
Chris@1115 65 { :controller => 'wiki', :action => 'date_index', :project_id => '567' }
Chris@1115 66 )
Chris@1115 67 assert_routing(
Chris@1115 68 { :method => 'get', :path => "/projects/567/wiki/export" },
Chris@1115 69 { :controller => 'wiki', :action => 'export', :project_id => '567' }
Chris@1115 70 )
Chris@1115 71 assert_routing(
Chris@1115 72 { :method => 'get', :path => "/projects/567/wiki/export.pdf" },
Chris@1115 73 { :controller => 'wiki', :action => 'export', :project_id => '567', :format => 'pdf' }
Chris@1115 74 )
Chris@1115 75 assert_routing(
Chris@1115 76 { :method => 'get', :path => "/projects/567/wiki/index" },
Chris@1115 77 { :controller => 'wiki', :action => 'index', :project_id => '567' }
Chris@1115 78 )
Chris@1115 79 end
Chris@1115 80
Chris@1115 81 def test_wiki_resources
Chris@1115 82 assert_routing(
Chris@1115 83 { :method => 'get', :path => "/projects/567/wiki/my_page/edit" },
Chris@1115 84 { :controller => 'wiki', :action => 'edit', :project_id => '567',
Chris@1115 85 :id => 'my_page' }
Chris@1115 86 )
Chris@1115 87 assert_routing(
Chris@1115 88 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/history" },
Chris@1115 89 { :controller => 'wiki', :action => 'history', :project_id => '1',
Chris@1115 90 :id => 'CookBook_documentation' }
Chris@1115 91 )
Chris@1115 92 assert_routing(
Chris@1115 93 { :method => 'get', :path => "/projects/22/wiki/ladida/rename" },
Chris@1115 94 { :controller => 'wiki', :action => 'rename', :project_id => '22',
Chris@1115 95 :id => 'ladida' }
Chris@1115 96 )
Chris@1115 97 ["post", "put"].each do |method|
Chris@1115 98 assert_routing(
Chris@1115 99 { :method => method, :path => "/projects/567/wiki/CookBook_documentation/preview" },
Chris@1115 100 { :controller => 'wiki', :action => 'preview', :project_id => '567',
Chris@1115 101 :id => 'CookBook_documentation' }
Chris@1115 102 )
Chris@1115 103 end
Chris@1115 104 assert_routing(
Chris@1115 105 { :method => 'post', :path => "/projects/22/wiki/ladida/rename" },
Chris@1115 106 { :controller => 'wiki', :action => 'rename', :project_id => '22',
Chris@1115 107 :id => 'ladida' }
Chris@1115 108 )
Chris@1115 109 assert_routing(
Chris@1115 110 { :method => 'post', :path => "/projects/22/wiki/ladida/protect" },
Chris@1115 111 { :controller => 'wiki', :action => 'protect', :project_id => '22',
Chris@1115 112 :id => 'ladida' }
Chris@1115 113 )
Chris@1115 114 assert_routing(
Chris@1115 115 { :method => 'post', :path => "/projects/22/wiki/ladida/add_attachment" },
Chris@1115 116 { :controller => 'wiki', :action => 'add_attachment', :project_id => '22',
Chris@1115 117 :id => 'ladida' }
Chris@1115 118 )
Chris@1115 119 assert_routing(
Chris@1115 120 { :method => 'put', :path => "/projects/567/wiki/my_page" },
Chris@1115 121 { :controller => 'wiki', :action => 'update', :project_id => '567',
Chris@1115 122 :id => 'my_page' }
Chris@1115 123 )
Chris@1115 124 assert_routing(
Chris@1115 125 { :method => 'delete', :path => "/projects/22/wiki/ladida" },
Chris@1115 126 { :controller => 'wiki', :action => 'destroy', :project_id => '22',
Chris@1115 127 :id => 'ladida' }
Chris@1115 128 )
Chris@1115 129 assert_routing(
Chris@1115 130 { :method => 'delete', :path => "/projects/22/wiki/ladida/3" },
Chris@1115 131 { :controller => 'wiki', :action => 'destroy_version', :project_id => '22',
Chris@1115 132 :id => 'ladida', :version => '3' }
Chris@1115 133 )
Chris@1115 134 end
Chris@1115 135
Chris@1115 136 def test_api
Chris@1115 137 assert_routing(
Chris@1115 138 { :method => 'get', :path => "/projects/567/wiki/my_page.xml" },
Chris@1115 139 { :controller => 'wiki', :action => 'show', :project_id => '567',
Chris@1115 140 :id => 'my_page', :format => 'xml' }
Chris@1115 141 )
Chris@1115 142 assert_routing(
Chris@1115 143 { :method => 'get', :path => "/projects/567/wiki/my_page.json" },
Chris@1115 144 { :controller => 'wiki', :action => 'show', :project_id => '567',
Chris@1115 145 :id => 'my_page', :format => 'json' }
Chris@1115 146 )
Chris@1115 147 assert_routing(
Chris@1115 148 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2.xml" },
Chris@1115 149 { :controller => 'wiki', :action => 'show', :project_id => '1',
Chris@1115 150 :id => 'CookBook_documentation', :version => '2', :format => 'xml' }
Chris@1115 151 )
Chris@1115 152 assert_routing(
Chris@1115 153 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2.json" },
Chris@1115 154 { :controller => 'wiki', :action => 'show', :project_id => '1',
Chris@1115 155 :id => 'CookBook_documentation', :version => '2', :format => 'json' }
Chris@1115 156 )
Chris@1115 157 assert_routing(
Chris@1115 158 { :method => 'get', :path => "/projects/567/wiki/index.xml" },
Chris@1115 159 { :controller => 'wiki', :action => 'index', :project_id => '567', :format => 'xml' }
Chris@1115 160 )
Chris@1115 161 assert_routing(
Chris@1115 162 { :method => 'get', :path => "/projects/567/wiki/index.json" },
Chris@1115 163 { :controller => 'wiki', :action => 'index', :project_id => '567', :format => 'json' }
Chris@1115 164 )
Chris@1115 165 assert_routing(
Chris@1115 166 { :method => 'put', :path => "/projects/567/wiki/my_page.xml" },
Chris@1115 167 { :controller => 'wiki', :action => 'update', :project_id => '567',
Chris@1115 168 :id => 'my_page', :format => 'xml' }
Chris@1115 169 )
Chris@1115 170 assert_routing(
Chris@1115 171 { :method => 'put', :path => "/projects/567/wiki/my_page.json" },
Chris@1115 172 { :controller => 'wiki', :action => 'update', :project_id => '567',
Chris@1115 173 :id => 'my_page', :format => 'json' }
Chris@1115 174 )
Chris@1115 175 assert_routing(
Chris@1115 176 { :method => 'delete', :path => "/projects/567/wiki/my_page.xml" },
Chris@1115 177 { :controller => 'wiki', :action => 'destroy', :project_id => '567',
Chris@1115 178 :id => 'my_page', :format => 'xml' }
Chris@1115 179 )
Chris@1115 180 assert_routing(
Chris@1115 181 { :method => 'delete', :path => "/projects/567/wiki/my_page.json" },
Chris@1115 182 { :controller => 'wiki', :action => 'destroy', :project_id => '567',
Chris@1115 183 :id => 'my_page', :format => 'json' }
Chris@1115 184 )
Chris@1115 185 end
Chris@1115 186 end