##// END OF EJS Templates
test: replace "should_route" of "timelogs (scoped under project)" to "assert_routing" at integration/routing_test.rb...
Toshi MARUYAMA -
r8124:0ef34804e857
parent child
Show More
@@ -1,774 +1,801
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../test_helper', __FILE__)
19 19
20 20 class RoutingTest < ActionController::IntegrationTest
21 21 def test_activities
22 22 assert_routing(
23 23 { :method => 'get', :path => "/activity" },
24 24 { :controller => 'activities', :action => 'index', :id => nil }
25 25 )
26 26 assert_routing(
27 27 { :method => 'get', :path => "/activity.atom" },
28 28 { :controller => 'activities', :action => 'index', :id => nil, :format => 'atom' }
29 29 )
30 30 end
31 31
32 32 def test_attachments
33 33 assert_routing(
34 34 { :method => 'get', :path => "/attachments/1" },
35 35 { :controller => 'attachments', :action => 'show', :id => '1' }
36 36 )
37 37 assert_routing(
38 38 { :method => 'get', :path => "/attachments/1.xml" },
39 39 { :controller => 'attachments', :action => 'show', :id => '1', :format => 'xml' }
40 40 )
41 41 assert_routing(
42 42 { :method => 'get', :path => "/attachments/1.json" },
43 43 { :controller => 'attachments', :action => 'show', :id => '1', :format => 'json' }
44 44 )
45 45 assert_routing(
46 46 { :method => 'get', :path => "/attachments/1/filename.ext" },
47 47 { :controller => 'attachments', :action => 'show', :id => '1',
48 48 :filename => 'filename.ext' }
49 49 )
50 50 assert_routing(
51 51 { :method => 'get', :path => "/attachments/download/1" },
52 52 { :controller => 'attachments', :action => 'download', :id => '1' }
53 53 )
54 54 assert_routing(
55 55 { :method => 'get', :path => "/attachments/download/1/filename.ext" },
56 56 { :controller => 'attachments', :action => 'download', :id => '1',
57 57 :filename => 'filename.ext' }
58 58 )
59 59 end
60 60
61 61 def test_boards
62 62 assert_routing(
63 63 { :method => 'get', :path => "/projects/world_domination/boards" },
64 64 { :controller => 'boards', :action => 'index', :project_id => 'world_domination' }
65 65 )
66 66 assert_routing(
67 67 { :method => 'get', :path => "/projects/world_domination/boards/new" },
68 68 { :controller => 'boards', :action => 'new', :project_id => 'world_domination' }
69 69 )
70 70 assert_routing(
71 71 { :method => 'get', :path => "/projects/world_domination/boards/44" },
72 72 { :controller => 'boards', :action => 'show', :project_id => 'world_domination',
73 73 :id => '44' }
74 74 )
75 75 assert_routing(
76 76 { :method => 'get', :path => "/projects/world_domination/boards/44.atom" },
77 77 { :controller => 'boards', :action => 'show', :project_id => 'world_domination',
78 78 :id => '44', :format => 'atom' }
79 79 )
80 80 assert_routing(
81 81 { :method => 'get', :path => "/projects/world_domination/boards/44/edit" },
82 82 { :controller => 'boards', :action => 'edit', :project_id => 'world_domination',
83 83 :id => '44' }
84 84 )
85 85 assert_routing(
86 86 { :method => 'post', :path => "/projects/world_domination/boards" },
87 87 { :controller => 'boards', :action => 'create', :project_id => 'world_domination' }
88 88 )
89 89 assert_routing(
90 90 { :method => 'put', :path => "/projects/world_domination/boards/44" },
91 91 { :controller => 'boards', :action => 'update', :project_id => 'world_domination', :id => '44' }
92 92 )
93 93 assert_routing(
94 94 { :method => 'delete', :path => "/projects/world_domination/boards/44" },
95 95 { :controller => 'boards', :action => 'destroy', :project_id => 'world_domination', :id => '44' }
96 96 )
97 97 end
98 98
99 99 def test_custom_fields
100 100 assert_routing(
101 101 { :method => 'get', :path => "/custom_fields" },
102 102 { :controller => 'custom_fields', :action => 'index' }
103 103 )
104 104 assert_routing(
105 105 { :method => 'get', :path => "/custom_fields/new" },
106 106 { :controller => 'custom_fields', :action => 'new' }
107 107 )
108 108 assert_routing(
109 109 { :method => 'post', :path => "/custom_fields" },
110 110 { :controller => 'custom_fields', :action => 'create' }
111 111 )
112 112 assert_routing(
113 113 { :method => 'get', :path => "/custom_fields/2/edit" },
114 114 { :controller => 'custom_fields', :action => 'edit', :id => '2' }
115 115 )
116 116 assert_routing(
117 117 { :method => 'put', :path => "/custom_fields/2" },
118 118 { :controller => 'custom_fields', :action => 'update', :id => '2' }
119 119 )
120 120 assert_routing(
121 121 { :method => 'delete', :path => "/custom_fields/2" },
122 122 { :controller => 'custom_fields', :action => 'destroy', :id => '2' }
123 123 )
124 124 end
125 125
126 126 def test_documents
127 127 assert_routing(
128 128 { :method => 'get', :path => "/projects/567/documents" },
129 129 { :controller => 'documents', :action => 'index', :project_id => '567' }
130 130 )
131 131 assert_routing(
132 132 { :method => 'get', :path => "/projects/567/documents/new" },
133 133 { :controller => 'documents', :action => 'new', :project_id => '567' }
134 134 )
135 135 assert_routing(
136 136 { :method => 'get', :path => "/documents/22" },
137 137 { :controller => 'documents', :action => 'show', :id => '22' }
138 138 )
139 139 assert_routing(
140 140 { :method => 'get', :path => "/documents/22/edit" },
141 141 { :controller => 'documents', :action => 'edit', :id => '22' }
142 142 )
143 143 assert_routing(
144 144 { :method => 'post', :path => "/projects/567/documents" },
145 145 { :controller => 'documents', :action => 'create', :project_id => '567' }
146 146 )
147 147 assert_routing(
148 148 { :method => 'put', :path => "/documents/22" },
149 149 { :controller => 'documents', :action => 'update', :id => '22' }
150 150 )
151 151 assert_routing(
152 152 { :method => 'delete', :path => "/documents/22" },
153 153 { :controller => 'documents', :action => 'destroy', :id => '22' }
154 154 )
155 155 assert_routing(
156 156 { :method => 'post', :path => "/documents/22/add_attachment" },
157 157 { :controller => 'documents', :action => 'add_attachment', :id => '22' }
158 158 )
159 159 end
160 160
161 161 def test_roles
162 162 assert_routing(
163 163 { :method => 'get', :path => "/enumerations" },
164 164 { :controller => 'enumerations', :action => 'index' }
165 165 )
166 166 assert_routing(
167 167 { :method => 'get', :path => "/enumerations/new" },
168 168 { :controller => 'enumerations', :action => 'new' }
169 169 )
170 170 assert_routing(
171 171 { :method => 'post', :path => "/enumerations" },
172 172 { :controller => 'enumerations', :action => 'create' }
173 173 )
174 174 assert_routing(
175 175 { :method => 'get', :path => "/enumerations/2/edit" },
176 176 { :controller => 'enumerations', :action => 'edit', :id => '2' }
177 177 )
178 178 assert_routing(
179 179 { :method => 'put', :path => "/enumerations/2" },
180 180 { :controller => 'enumerations', :action => 'update', :id => '2' }
181 181 )
182 182 assert_routing(
183 183 { :method => 'delete', :path => "/enumerations/2" },
184 184 { :controller => 'enumerations', :action => 'destroy', :id => '2' }
185 185 )
186 186 end
187 187
188 188 def test_groups
189 189 assert_routing(
190 190 { :method => 'post', :path => "/groups/567/users" },
191 191 { :controller => 'groups', :action => 'add_users', :id => '567' }
192 192 )
193 193 assert_routing(
194 194 { :method => 'delete', :path => "/groups/567/users/12" },
195 195 { :controller => 'groups', :action => 'remove_user', :id => '567',
196 196 :user_id => '12' }
197 197 )
198 198 end
199 199
200 200 def test_issues_rest_actions
201 201 assert_routing(
202 202 { :method => 'get', :path => "/issues" },
203 203 { :controller => 'issues', :action => 'index' }
204 204 )
205 205 assert_routing(
206 206 { :method => 'get', :path => "/issues.pdf" },
207 207 { :controller => 'issues', :action => 'index', :format => 'pdf' }
208 208 )
209 209 assert_routing(
210 210 { :method => 'get', :path => "/issues.atom" },
211 211 { :controller => 'issues', :action => 'index', :format => 'atom' }
212 212 )
213 213 assert_routing(
214 214 { :method => 'get', :path => "/issues.xml" },
215 215 { :controller => 'issues', :action => 'index', :format => 'xml' }
216 216 )
217 217 assert_routing(
218 218 { :method => 'get', :path => "/projects/23/issues" },
219 219 { :controller => 'issues', :action => 'index', :project_id => '23' }
220 220 )
221 221 assert_routing(
222 222 { :method => 'get', :path => "/projects/23/issues.pdf" },
223 223 { :controller => 'issues', :action => 'index', :project_id => '23',
224 224 :format => 'pdf' }
225 225 )
226 226 assert_routing(
227 227 { :method => 'get', :path => "/projects/23/issues.atom" },
228 228 { :controller => 'issues', :action => 'index', :project_id => '23',
229 229 :format => 'atom' }
230 230 )
231 231 assert_routing(
232 232 { :method => 'get', :path => "/projects/23/issues.xml" },
233 233 { :controller => 'issues', :action => 'index', :project_id => '23',
234 234 :format => 'xml' }
235 235 )
236 236 assert_routing(
237 237 { :method => 'get', :path => "/issues/64" },
238 238 { :controller => 'issues', :action => 'show', :id => '64' }
239 239 )
240 240 assert_routing(
241 241 { :method => 'get', :path => "/issues/64.pdf" },
242 242 { :controller => 'issues', :action => 'show', :id => '64',
243 243 :format => 'pdf' }
244 244 )
245 245 assert_routing(
246 246 { :method => 'get', :path => "/issues/64.atom" },
247 247 { :controller => 'issues', :action => 'show', :id => '64',
248 248 :format => 'atom' }
249 249 )
250 250 assert_routing(
251 251 { :method => 'get', :path => "/issues/64.xml" },
252 252 { :controller => 'issues', :action => 'show', :id => '64',
253 253 :format => 'xml' }
254 254 )
255 255 assert_routing(
256 256 { :method => 'get', :path => "/projects/23/issues/new" },
257 257 { :controller => 'issues', :action => 'new', :project_id => '23' }
258 258 )
259 259 end
260 260
261 261 def test_issues_form_update
262 262 assert_routing(
263 263 { :method => 'post', :path => "/projects/23/issues/new" },
264 264 { :controller => 'issues', :action => 'new', :project_id => '23' }
265 265 )
266 266 assert_routing(
267 267 { :method => 'post', :path => "/projects/23/issues" },
268 268 { :controller => 'issues', :action => 'create', :project_id => '23' }
269 269 )
270 270 assert_routing(
271 271 { :method => 'post', :path => "/issues.xml" },
272 272 { :controller => 'issues', :action => 'create', :format => 'xml' }
273 273 )
274 274 assert_routing(
275 275 { :method => 'get', :path => "/issues/64/edit" },
276 276 { :controller => 'issues', :action => 'edit', :id => '64' }
277 277 )
278 278 assert_routing(
279 279 { :method => 'put', :path => "/issues/1.xml" },
280 280 { :controller => 'issues', :action => 'update', :id => '1',
281 281 :format => 'xml' }
282 282 )
283 283 assert_routing(
284 284 { :method => 'delete', :path => "/issues/1.xml" },
285 285 { :controller => 'issues', :action => 'destroy', :id => '1',
286 286 :format => 'xml' }
287 287 )
288 288 end
289 289
290 290 context "issues" do
291 291 # Extra actions
292 292 should_route :get, "/projects/23/issues/64/copy", :controller => 'issues', :action => 'new', :project_id => '23', :copy_from => '64'
293 293
294 294 should_route :get, "/issues/move/new", :controller => 'issue_moves', :action => 'new'
295 295 should_route :post, "/issues/move", :controller => 'issue_moves', :action => 'create'
296 296
297 297 should_route :post, "/issues/1/quoted", :controller => 'journals', :action => 'new', :id => '1'
298 298
299 299 should_route :get, "/issues/calendar", :controller => 'calendars', :action => 'show'
300 300 should_route :get, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'show', :project_id => 'project-name'
301 301
302 302 should_route :get, "/issues/gantt", :controller => 'gantts', :action => 'show'
303 303 should_route :get, "/issues/gantt.pdf", :controller => 'gantts', :action => 'show', :format => 'pdf'
304 304 should_route :get, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'show', :project_id => 'project-name'
305 305 should_route :get, "/projects/project-name/issues/gantt.pdf", :controller => 'gantts', :action => 'show', :project_id => 'project-name', :format => 'pdf'
306 306
307 307 should_route :get, "/issues/auto_complete", :controller => 'auto_completes', :action => 'issues'
308 308
309 309 should_route :get, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123'
310 310 should_route :post, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123'
311 311 should_route :get, "/issues/context_menu", :controller => 'context_menus', :action => 'issues'
312 312 should_route :post, "/issues/context_menu", :controller => 'context_menus', :action => 'issues'
313 313
314 314 should_route :get, "/issues/changes", :controller => 'journals', :action => 'index'
315 315
316 316 should_route :get, "/issues/bulk_edit", :controller => 'issues', :action => 'bulk_edit'
317 317 should_route :post, "/issues/bulk_update", :controller => 'issues', :action => 'bulk_update'
318 318 end
319 319
320 320 context "issue categories" do
321 321 should_route :get, "/projects/foo/issue_categories", :controller => 'issue_categories', :action => 'index', :project_id => 'foo'
322 322 should_route :get, "/projects/foo/issue_categories.xml", :controller => 'issue_categories', :action => 'index', :project_id => 'foo', :format => 'xml'
323 323 should_route :get, "/projects/foo/issue_categories.json", :controller => 'issue_categories', :action => 'index', :project_id => 'foo', :format => 'json'
324 324
325 325 should_route :get, "/projects/foo/issue_categories/new", :controller => 'issue_categories', :action => 'new', :project_id => 'foo'
326 326
327 327 should_route :post, "/projects/foo/issue_categories", :controller => 'issue_categories', :action => 'create', :project_id => 'foo'
328 328 should_route :post, "/projects/foo/issue_categories.xml", :controller => 'issue_categories', :action => 'create', :project_id => 'foo', :format => 'xml'
329 329 should_route :post, "/projects/foo/issue_categories.json", :controller => 'issue_categories', :action => 'create', :project_id => 'foo', :format => 'json'
330 330
331 331 should_route :get, "/issue_categories/1", :controller => 'issue_categories', :action => 'show', :id => '1'
332 332 should_route :get, "/issue_categories/1.xml", :controller => 'issue_categories', :action => 'show', :id => '1', :format => 'xml'
333 333 should_route :get, "/issue_categories/1.json", :controller => 'issue_categories', :action => 'show', :id => '1', :format => 'json'
334 334
335 335 should_route :get, "/issue_categories/1/edit", :controller => 'issue_categories', :action => 'edit', :id => '1'
336 336
337 337 should_route :put, "/issue_categories/1", :controller => 'issue_categories', :action => 'update', :id => '1'
338 338 should_route :put, "/issue_categories/1.xml", :controller => 'issue_categories', :action => 'update', :id => '1', :format => 'xml'
339 339 should_route :put, "/issue_categories/1.json", :controller => 'issue_categories', :action => 'update', :id => '1', :format => 'json'
340 340
341 341 should_route :delete, "/issue_categories/1", :controller => 'issue_categories', :action => 'destroy', :id => '1'
342 342 should_route :delete, "/issue_categories/1.xml", :controller => 'issue_categories', :action => 'destroy', :id => '1', :format => 'xml'
343 343 should_route :delete, "/issue_categories/1.json", :controller => 'issue_categories', :action => 'destroy', :id => '1', :format => 'json'
344 344 end
345 345
346 346 context "issue relations" do
347 347 should_route :get, "/issues/1/relations", :controller => 'issue_relations', :action => 'index', :issue_id => '1'
348 348 should_route :get, "/issues/1/relations.xml", :controller => 'issue_relations', :action => 'index', :issue_id => '1', :format => 'xml'
349 349 should_route :get, "/issues/1/relations.json", :controller => 'issue_relations', :action => 'index', :issue_id => '1', :format => 'json'
350 350
351 351 should_route :post, "/issues/1/relations", :controller => 'issue_relations', :action => 'create', :issue_id => '1'
352 352 should_route :post, "/issues/1/relations.xml", :controller => 'issue_relations', :action => 'create', :issue_id => '1', :format => 'xml'
353 353 should_route :post, "/issues/1/relations.json", :controller => 'issue_relations', :action => 'create', :issue_id => '1', :format => 'json'
354 354
355 355 should_route :get, "/relations/23", :controller => 'issue_relations', :action => 'show', :id => '23'
356 356 should_route :get, "/relations/23.xml", :controller => 'issue_relations', :action => 'show', :id => '23', :format => 'xml'
357 357 should_route :get, "/relations/23.json", :controller => 'issue_relations', :action => 'show', :id => '23', :format => 'json'
358 358
359 359 should_route :delete, "/relations/23", :controller => 'issue_relations', :action => 'destroy', :id => '23'
360 360 should_route :delete, "/relations/23.xml", :controller => 'issue_relations', :action => 'destroy', :id => '23', :format => 'xml'
361 361 should_route :delete, "/relations/23.json", :controller => 'issue_relations', :action => 'destroy', :id => '23', :format => 'json'
362 362 end
363 363
364 364 def test_issue_reports
365 365 assert_routing(
366 366 { :method => 'get', :path => "/projects/567/issues/report" },
367 367 { :controller => 'reports', :action => 'issue_report', :id => '567' }
368 368 )
369 369 assert_routing(
370 370 { :method => 'get', :path => "/projects/567/issues/report/assigned_to" },
371 371 { :controller => 'reports', :action => 'issue_report_details',
372 372 :id => '567', :detail => 'assigned_to' }
373 373 )
374 374 end
375 375
376 376 def test_members
377 377 assert_routing(
378 378 { :method => 'post', :path => "/projects/5234/members/new" },
379 379 { :controller => 'members', :action => 'new', :id => '5234' }
380 380 )
381 381 end
382 382
383 383 def test_messages
384 384 assert_routing(
385 385 { :method => 'get', :path => "/boards/22/topics/2" },
386 386 { :controller => 'messages', :action => 'show', :id => '2',
387 387 :board_id => '22' }
388 388 )
389 389 assert_routing(
390 390 { :method => 'get', :path => "/boards/lala/topics/new" },
391 391 { :controller => 'messages', :action => 'new', :board_id => 'lala' }
392 392 )
393 393 assert_routing(
394 394 { :method => 'get', :path => "/boards/lala/topics/22/edit" },
395 395 { :controller => 'messages', :action => 'edit', :id => '22',
396 396 :board_id => 'lala' }
397 397 )
398 398 assert_routing(
399 399 { :method => 'post', :path => "/boards/lala/topics/new" },
400 400 { :controller => 'messages', :action => 'new', :board_id => 'lala' }
401 401 )
402 402 assert_routing(
403 403 { :method => 'post', :path => "/boards/lala/topics/22/edit" },
404 404 { :controller => 'messages', :action => 'edit', :id => '22',
405 405 :board_id => 'lala' }
406 406 )
407 407 assert_routing(
408 408 { :method => 'post', :path => "/boards/22/topics/555/replies" },
409 409 { :controller => 'messages', :action => 'reply', :id => '555',
410 410 :board_id => '22' }
411 411 )
412 412 assert_routing(
413 413 { :method => 'post', :path => "/boards/22/topics/555/destroy" },
414 414 { :controller => 'messages', :action => 'destroy', :id => '555',
415 415 :board_id => '22' }
416 416 )
417 417 end
418 418
419 419 context "news" do
420 420 should_route :get, "/news", :controller => 'news', :action => 'index'
421 421 should_route :get, "/news.atom", :controller => 'news', :action => 'index', :format => 'atom'
422 422 should_route :get, "/news.xml", :controller => 'news', :action => 'index', :format => 'xml'
423 423 should_route :get, "/news.json", :controller => 'news', :action => 'index', :format => 'json'
424 424 should_route :get, "/projects/567/news", :controller => 'news', :action => 'index', :project_id => '567'
425 425 should_route :get, "/projects/567/news.atom", :controller => 'news', :action => 'index', :format => 'atom', :project_id => '567'
426 426 should_route :get, "/projects/567/news.xml", :controller => 'news', :action => 'index', :format => 'xml', :project_id => '567'
427 427 should_route :get, "/projects/567/news.json", :controller => 'news', :action => 'index', :format => 'json', :project_id => '567'
428 428 should_route :get, "/news/2", :controller => 'news', :action => 'show', :id => '2'
429 429 should_route :get, "/projects/567/news/new", :controller => 'news', :action => 'new', :project_id => '567'
430 430 should_route :get, "/news/234", :controller => 'news', :action => 'show', :id => '234'
431 431 should_route :get, "/news/567/edit", :controller => 'news', :action => 'edit', :id => '567'
432 432 should_route :get, "/news/preview", :controller => 'previews', :action => 'news'
433 433
434 434 should_route :post, "/projects/567/news", :controller => 'news', :action => 'create', :project_id => '567'
435 435 should_route :post, "/news/567/comments", :controller => 'comments', :action => 'create', :id => '567'
436 436
437 437 should_route :put, "/news/567", :controller => 'news', :action => 'update', :id => '567'
438 438
439 439 should_route :delete, "/news/567", :controller => 'news', :action => 'destroy', :id => '567'
440 440 should_route :delete, "/news/567/comments/15", :controller => 'comments', :action => 'destroy', :id => '567', :comment_id => '15'
441 441 end
442 442
443 443 context "projects" do
444 444 should_route :get, "/projects", :controller => 'projects', :action => 'index'
445 445 should_route :get, "/projects.atom", :controller => 'projects', :action => 'index', :format => 'atom'
446 446 should_route :get, "/projects.xml", :controller => 'projects', :action => 'index', :format => 'xml'
447 447 should_route :get, "/projects/new", :controller => 'projects', :action => 'new'
448 448 should_route :get, "/projects/test", :controller => 'projects', :action => 'show', :id => 'test'
449 449 should_route :get, "/projects/1.xml", :controller => 'projects', :action => 'show', :id => '1', :format => 'xml'
450 450 should_route :get, "/projects/4223/settings", :controller => 'projects', :action => 'settings', :id => '4223'
451 451 should_route :get, "/projects/4223/settings/members", :controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members'
452 452 should_route :get, "/projects/33/files", :controller => 'files', :action => 'index', :project_id => '33'
453 453 should_route :get, "/projects/33/files/new", :controller => 'files', :action => 'new', :project_id => '33'
454 454 should_route :get, "/projects/33/roadmap", :controller => 'versions', :action => 'index', :project_id => '33'
455 455 should_route :get, "/projects/33/activity", :controller => 'activities', :action => 'index', :id => '33'
456 456 should_route :get, "/projects/33/activity.atom", :controller => 'activities', :action => 'index', :id => '33', :format => 'atom'
457 457
458 458 should_route :post, "/projects", :controller => 'projects', :action => 'create'
459 459 should_route :post, "/projects.xml", :controller => 'projects', :action => 'create', :format => 'xml'
460 460 should_route :post, "/projects/33/files", :controller => 'files', :action => 'create', :project_id => '33'
461 461 should_route :post, "/projects/64/archive", :controller => 'projects', :action => 'archive', :id => '64'
462 462 should_route :post, "/projects/64/unarchive", :controller => 'projects', :action => 'unarchive', :id => '64'
463 463
464 464 should_route :put, "/projects/64/enumerations", :controller => 'project_enumerations', :action => 'update', :project_id => '64'
465 465 should_route :put, "/projects/4223", :controller => 'projects', :action => 'update', :id => '4223'
466 466 should_route :put, "/projects/1.xml", :controller => 'projects', :action => 'update', :id => '1', :format => 'xml'
467 467
468 468 should_route :delete, "/projects/64", :controller => 'projects', :action => 'destroy', :id => '64'
469 469 should_route :delete, "/projects/1.xml", :controller => 'projects', :action => 'destroy', :id => '1', :format => 'xml'
470 470 should_route :delete, "/projects/64/enumerations", :controller => 'project_enumerations', :action => 'destroy', :project_id => '64'
471 471 end
472 472
473 473 context "queries" do
474 474 should_route :get, "/queries.xml", :controller => 'queries', :action => 'index', :format => 'xml'
475 475 should_route :get, "/queries.json", :controller => 'queries', :action => 'index', :format => 'json'
476 476
477 477 should_route :get, "/queries/new", :controller => 'queries', :action => 'new'
478 478 should_route :get, "/projects/redmine/queries/new", :controller => 'queries', :action => 'new', :project_id => 'redmine'
479 479
480 480 should_route :post, "/queries", :controller => 'queries', :action => 'create'
481 481 should_route :post, "/projects/redmine/queries", :controller => 'queries', :action => 'create', :project_id => 'redmine'
482 482
483 483 should_route :get, "/queries/1/edit", :controller => 'queries', :action => 'edit', :id => '1'
484 484
485 485 should_route :put, "/queries/1", :controller => 'queries', :action => 'update', :id => '1'
486 486
487 487 should_route :delete, "/queries/1", :controller => 'queries', :action => 'destroy', :id => '1'
488 488 end
489 489
490 490 context "repositories" do
491 491 should_route :get, "/projects/redmine/repository", :controller => 'repositories', :action => 'show', :id => 'redmine'
492 492 should_route :get, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine'
493 493 should_route :get, "/projects/redmine/repository/revisions", :controller => 'repositories', :action => 'revisions', :id => 'redmine'
494 494 should_route :get, "/projects/redmine/repository/revisions.atom", :controller => 'repositories', :action => 'revisions', :id => 'redmine', :format => 'atom'
495 495 should_route :get, "/projects/redmine/repository/revisions/2457", :controller => 'repositories', :action => 'revision', :id => 'redmine', :rev => '2457'
496 496 should_route :get, "/projects/redmine/repository/revisions/2457/diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457'
497 497 should_route :get, "/projects/redmine/repository/revisions/2457/diff.diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457', :format => 'diff'
498 498 should_route :get, "/projects/redmine/repository/diff/path/to/file.c", :controller => 'repositories', :action => 'diff', :id => 'redmine', :path => %w[path to file.c]
499 499 should_route :get, "/projects/redmine/repository/revisions/2/diff/path/to/file.c", :controller => 'repositories', :action => 'diff', :id => 'redmine', :path => %w[path to file.c], :rev => '2'
500 500 should_route :get, "/projects/redmine/repository/browse/path/to/file.c", :controller => 'repositories', :action => 'browse', :id => 'redmine', :path => %w[path to file.c]
501 501 should_route :get, "/projects/redmine/repository/entry/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c]
502 502 should_route :get, "/projects/redmine/repository/revisions/2/entry/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :rev => '2'
503 503 should_route :get, "/projects/redmine/repository/raw/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :format => 'raw'
504 504 should_route :get, "/projects/redmine/repository/revisions/2/raw/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :rev => '2', :format => 'raw'
505 505 should_route :get, "/projects/redmine/repository/annotate/path/to/file.c", :controller => 'repositories', :action => 'annotate', :id => 'redmine', :path => %w[path to file.c]
506 506 should_route :get, "/projects/redmine/repository/changes/path/to/file.c", :controller => 'repositories', :action => 'changes', :id => 'redmine', :path => %w[path to file.c]
507 507 should_route :get, "/projects/redmine/repository/statistics", :controller => 'repositories', :action => 'stats', :id => 'redmine'
508 508
509 509 should_route :post, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine'
510 510 end
511 511
512 512 context "roles" do
513 513 should_route :get, "/roles", :controller => 'roles', :action => 'index'
514 514 should_route :get, "/roles/new", :controller => 'roles', :action => 'new'
515 515 should_route :post, "/roles", :controller => 'roles', :action => 'create'
516 516 should_route :get, "/roles/2/edit", :controller => 'roles', :action => 'edit', :id => 2
517 517 should_route :put, "/roles/2", :controller => 'roles', :action => 'update', :id => 2
518 518 should_route :delete, "/roles/2", :controller => 'roles', :action => 'destroy', :id => 2
519 519 should_route :get, "/roles/permissions", :controller => 'roles', :action => 'permissions'
520 520 should_route :post, "/roles/permissions", :controller => 'roles', :action => 'permissions'
521 521 end
522 522
523 523 def test_timelogs_global
524 524 assert_routing(
525 525 { :method => 'get', :path => "/time_entries" },
526 526 { :controller => 'timelog', :action => 'index' }
527 527 )
528 528 assert_routing(
529 529 { :method => 'get', :path => "/time_entries.csv" },
530 530 { :controller => 'timelog', :action => 'index', :format => 'csv' }
531 531 )
532 532 assert_routing(
533 533 { :method => 'get', :path => "/time_entries.atom" },
534 534 { :controller => 'timelog', :action => 'index', :format => 'atom' }
535 535 )
536 536 assert_routing(
537 537 { :method => 'get', :path => "/time_entries/new" },
538 538 { :controller => 'timelog', :action => 'new' }
539 539 )
540 540 assert_routing(
541 541 { :method => 'get', :path => "/time_entries/22/edit" },
542 542 { :controller => 'timelog', :action => 'edit', :id => '22' }
543 543 )
544 544 assert_routing(
545 545 { :method => 'post', :path => "/time_entries" },
546 546 { :controller => 'timelog', :action => 'create' }
547 547 )
548 548 assert_routing(
549 549 { :method => 'put', :path => "/time_entries/22" },
550 550 { :controller => 'timelog', :action => 'update', :id => '22' }
551 551 )
552 552 assert_routing(
553 553 { :method => 'delete', :path => "/time_entries/55" },
554 554 { :controller => 'timelog', :action => 'destroy', :id => '55' }
555 555 )
556 556 end
557 557
558 context "timelogs (scoped under project)" do
559 should_route :get, "/projects/567/time_entries", :controller => 'timelog', :action => 'index', :project_id => '567'
560 should_route :get, "/projects/567/time_entries.csv", :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'csv'
561 should_route :get, "/projects/567/time_entries.atom", :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'atom'
562 should_route :get, "/projects/567/time_entries/new", :controller => 'timelog', :action => 'new', :project_id => '567'
563 should_route :get, "/projects/567/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22', :project_id => '567'
564
565 should_route :post, "/projects/567/time_entries", :controller => 'timelog', :action => 'create', :project_id => '567'
566
567 should_route :put, "/projects/567/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :project_id => '567'
568
569 should_route :delete, "/projects/567/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :project_id => '567'
558 def test_timelogs_scoped_under_project
559 assert_routing(
560 { :method => 'get', :path => "/projects/567/time_entries" },
561 { :controller => 'timelog', :action => 'index', :project_id => '567' }
562 )
563 assert_routing(
564 { :method => 'get', :path => "/projects/567/time_entries.csv" },
565 { :controller => 'timelog', :action => 'index', :project_id => '567',
566 :format => 'csv' }
567 )
568 assert_routing(
569 { :method => 'get', :path => "/projects/567/time_entries.atom" },
570 { :controller => 'timelog', :action => 'index', :project_id => '567',
571 :format => 'atom' }
572 )
573 assert_routing(
574 { :method => 'get', :path => "/projects/567/time_entries/new" },
575 { :controller => 'timelog', :action => 'new', :project_id => '567' }
576 )
577 assert_routing(
578 { :method => 'get', :path => "/projects/567/time_entries/22/edit" },
579 { :controller => 'timelog', :action => 'edit',
580 :id => '22', :project_id => '567' }
581 )
582 assert_routing(
583 { :method => 'post', :path => "/projects/567/time_entries" },
584 { :controller => 'timelog', :action => 'create',
585 :project_id => '567' }
586 )
587 assert_routing(
588 { :method => 'put', :path => "/projects/567/time_entries/22" },
589 { :controller => 'timelog', :action => 'update',
590 :id => '22', :project_id => '567' }
591 )
592 assert_routing(
593 { :method => 'delete', :path => "/projects/567/time_entries/55" },
594 { :controller => 'timelog', :action => 'destroy',
595 :id => '55', :project_id => '567' }
596 )
570 597 end
571 598
572 599 context "timelogs (scoped under issues)" do
573 600 should_route :get, "/issues/234/time_entries", :controller => 'timelog', :action => 'index', :issue_id => '234'
574 601 should_route :get, "/issues/234/time_entries.csv", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'csv'
575 602 should_route :get, "/issues/234/time_entries.atom", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'atom'
576 603 should_route :get, "/issues/234/time_entries/new", :controller => 'timelog', :action => 'new', :issue_id => '234'
577 604 should_route :get, "/issues/234/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22', :issue_id => '234'
578 605
579 606 should_route :post, "/issues/234/time_entries", :controller => 'timelog', :action => 'create', :issue_id => '234'
580 607
581 608 should_route :put, "/issues/234/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :issue_id => '234'
582 609
583 610 should_route :delete, "/issues/234/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :issue_id => '234'
584 611 end
585 612
586 613 context "timelogs (scoped under project and issues)" do
587 614 should_route :get, "/projects/ecookbook/issues/234/time_entries", :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook'
588 615 should_route :get, "/projects/ecookbook/issues/234/time_entries.csv", :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook', :format => 'csv'
589 616 should_route :get, "/projects/ecookbook/issues/234/time_entries.atom", :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook', :format => 'atom'
590 617 should_route :get, "/projects/ecookbook/issues/234/time_entries/new", :controller => 'timelog', :action => 'new', :issue_id => '234', :project_id => 'ecookbook'
591 618 should_route :get, "/projects/ecookbook/issues/234/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22', :issue_id => '234', :project_id => 'ecookbook'
592 619
593 620 should_route :post, "/projects/ecookbook/issues/234/time_entries", :controller => 'timelog', :action => 'create', :issue_id => '234', :project_id => 'ecookbook'
594 621
595 622 should_route :put, "/projects/ecookbook/issues/234/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :issue_id => '234', :project_id => 'ecookbook'
596 623
597 624 should_route :delete, "/projects/ecookbook/issues/234/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :issue_id => '234', :project_id => 'ecookbook'
598 625
599 626 should_route :get, "/time_entries/report", :controller => 'timelog', :action => 'report'
600 627 should_route :get, "/projects/567/time_entries/report", :controller => 'timelog', :action => 'report', :project_id => '567'
601 628 should_route :get, "/projects/567/time_entries/report.csv", :controller => 'timelog', :action => 'report', :project_id => '567', :format => 'csv'
602 629 end
603 630
604 631 context "users" do
605 632 should_route :get, "/users", :controller => 'users', :action => 'index'
606 633 should_route :get, "/users.xml", :controller => 'users', :action => 'index', :format => 'xml'
607 634 should_route :get, "/users/44", :controller => 'users', :action => 'show', :id => '44'
608 635 should_route :get, "/users/44.xml", :controller => 'users', :action => 'show', :id => '44', :format => 'xml'
609 636 should_route :get, "/users/current", :controller => 'users', :action => 'show', :id => 'current'
610 637 should_route :get, "/users/current.xml", :controller => 'users', :action => 'show', :id => 'current', :format => 'xml'
611 638 should_route :get, "/users/new", :controller => 'users', :action => 'new'
612 639 should_route :get, "/users/444/edit", :controller => 'users', :action => 'edit', :id => '444'
613 640
614 641 should_route :post, "/users", :controller => 'users', :action => 'create'
615 642 should_route :post, "/users.xml", :controller => 'users', :action => 'create', :format => 'xml'
616 643
617 644 should_route :put, "/users/444", :controller => 'users', :action => 'update', :id => '444'
618 645 should_route :put, "/users/444.xml", :controller => 'users', :action => 'update', :id => '444', :format => 'xml'
619 646
620 647 should_route :delete, "/users/44", :controller => 'users', :action => 'destroy', :id => '44'
621 648 should_route :delete, "/users/44.xml", :controller => 'users', :action => 'destroy', :id => '44', :format => 'xml'
622 649
623 650 should_route :post, "/users/123/memberships", :controller => 'users', :action => 'edit_membership', :id => '123'
624 651 should_route :put, "/users/123/memberships/55", :controller => 'users', :action => 'edit_membership', :id => '123', :membership_id => '55'
625 652 should_route :delete, "/users/123/memberships/55", :controller => 'users', :action => 'destroy_membership', :id => '123', :membership_id => '55'
626 653 end
627 654
628 655 context "versions" do
629 656 # /projects/foo/versions is /projects/foo/roadmap
630 657 should_route :get, "/projects/foo/versions.xml", :controller => 'versions', :action => 'index', :project_id => 'foo', :format => 'xml'
631 658 should_route :get, "/projects/foo/versions.json", :controller => 'versions', :action => 'index', :project_id => 'foo', :format => 'json'
632 659
633 660 should_route :get, "/projects/foo/versions/new", :controller => 'versions', :action => 'new', :project_id => 'foo'
634 661
635 662 should_route :post, "/projects/foo/versions", :controller => 'versions', :action => 'create', :project_id => 'foo'
636 663 should_route :post, "/projects/foo/versions.xml", :controller => 'versions', :action => 'create', :project_id => 'foo', :format => 'xml'
637 664 should_route :post, "/projects/foo/versions.json", :controller => 'versions', :action => 'create', :project_id => 'foo', :format => 'json'
638 665
639 666 should_route :get, "/versions/1", :controller => 'versions', :action => 'show', :id => '1'
640 667 should_route :get, "/versions/1.xml", :controller => 'versions', :action => 'show', :id => '1', :format => 'xml'
641 668 should_route :get, "/versions/1.json", :controller => 'versions', :action => 'show', :id => '1', :format => 'json'
642 669
643 670 should_route :get, "/versions/1/edit", :controller => 'versions', :action => 'edit', :id => '1'
644 671
645 672 should_route :put, "/versions/1", :controller => 'versions', :action => 'update', :id => '1'
646 673 should_route :put, "/versions/1.xml", :controller => 'versions', :action => 'update', :id => '1', :format => 'xml'
647 674 should_route :put, "/versions/1.json", :controller => 'versions', :action => 'update', :id => '1', :format => 'json'
648 675
649 676 should_route :delete, "/versions/1", :controller => 'versions', :action => 'destroy', :id => '1'
650 677 should_route :delete, "/versions/1.xml", :controller => 'versions', :action => 'destroy', :id => '1', :format => 'xml'
651 678 should_route :delete, "/versions/1.json", :controller => 'versions', :action => 'destroy', :id => '1', :format => 'json'
652 679
653 680 should_route :put, "/projects/foo/versions/close_completed", :controller => 'versions', :action => 'close_completed', :project_id => 'foo'
654 681 should_route :post, "/versions/1/status_by", :controller => 'versions', :action => 'status_by', :id => '1'
655 682 end
656 683
657 684 def test_welcome
658 685 assert_routing(
659 686 { :method => 'get', :path => "/robots.txt" },
660 687 { :controller => 'welcome', :action => 'robots' }
661 688 )
662 689 end
663 690
664 691 def test_wiki_singular_projects_pages
665 692 assert_routing(
666 693 { :method => 'get', :path => "/projects/567/wiki" },
667 694 { :controller => 'wiki', :action => 'show', :project_id => '567' }
668 695 )
669 696 assert_routing(
670 697 { :method => 'get', :path => "/projects/567/wiki/lalala" },
671 698 { :controller => 'wiki', :action => 'show', :project_id => '567',
672 699 :id => 'lalala' }
673 700 )
674 701 assert_routing(
675 702 { :method => 'get', :path => "/projects/567/wiki/my_page/edit" },
676 703 { :controller => 'wiki', :action => 'edit', :project_id => '567',
677 704 :id => 'my_page' }
678 705 )
679 706 assert_routing(
680 707 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/history" },
681 708 { :controller => 'wiki', :action => 'history', :project_id => '1',
682 709 :id => 'CookBook_documentation' }
683 710 )
684 711 assert_routing(
685 712 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/diff" },
686 713 { :controller => 'wiki', :action => 'diff', :project_id => '1',
687 714 :id => 'CookBook_documentation' }
688 715 )
689 716 assert_routing(
690 717 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/diff/2" },
691 718 { :controller => 'wiki', :action => 'diff', :project_id => '1',
692 719 :id => 'CookBook_documentation', :version => '2' }
693 720 )
694 721 assert_routing(
695 722 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/diff/2/vs/1" },
696 723 { :controller => 'wiki', :action => 'diff', :project_id => '1',
697 724 :id => 'CookBook_documentation', :version => '2', :version_from => '1' }
698 725 )
699 726 assert_routing(
700 727 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/annotate/2" },
701 728 { :controller => 'wiki', :action => 'annotate', :project_id => '1',
702 729 :id => 'CookBook_documentation', :version => '2' }
703 730 )
704 731 assert_routing(
705 732 { :method => 'get', :path => "/projects/22/wiki/ladida/rename" },
706 733 { :controller => 'wiki', :action => 'rename', :project_id => '22',
707 734 :id => 'ladida' }
708 735 )
709 736 assert_routing(
710 737 { :method => 'get', :path => "/projects/567/wiki/index" },
711 738 { :controller => 'wiki', :action => 'index', :project_id => '567' }
712 739 )
713 740 assert_routing(
714 741 { :method => 'get', :path => "/projects/567/wiki/date_index" },
715 742 { :controller => 'wiki', :action => 'date_index', :project_id => '567' }
716 743 )
717 744 assert_routing(
718 745 { :method => 'get', :path => "/projects/567/wiki/export" },
719 746 { :controller => 'wiki', :action => 'export', :project_id => '567' }
720 747 )
721 748 assert_routing(
722 749 { :method => 'post', :path => "/projects/567/wiki/CookBook_documentation/preview" },
723 750 { :controller => 'wiki', :action => 'preview', :project_id => '567',
724 751 :id => 'CookBook_documentation' }
725 752 )
726 753 assert_routing(
727 754 { :method => 'post', :path => "/projects/22/wiki/ladida/rename" },
728 755 { :controller => 'wiki', :action => 'rename', :project_id => '22',
729 756 :id => 'ladida' }
730 757 )
731 758 assert_routing(
732 759 { :method => 'post', :path => "/projects/22/wiki/ladida/protect" },
733 760 { :controller => 'wiki', :action => 'protect', :project_id => '22',
734 761 :id => 'ladida' }
735 762 )
736 763 assert_routing(
737 764 { :method => 'post', :path => "/projects/22/wiki/ladida/add_attachment" },
738 765 { :controller => 'wiki', :action => 'add_attachment', :project_id => '22',
739 766 :id => 'ladida' }
740 767 )
741 768 assert_routing(
742 769 { :method => 'put', :path => "/projects/567/wiki/my_page" },
743 770 { :controller => 'wiki', :action => 'update', :project_id => '567',
744 771 :id => 'my_page' }
745 772 )
746 773 assert_routing(
747 774 { :method => 'delete', :path => "/projects/22/wiki/ladida" },
748 775 { :controller => 'wiki', :action => 'destroy', :project_id => '22',
749 776 :id => 'ladida' }
750 777 )
751 778 end
752 779
753 780 def test_wikis_plural_admin_setup
754 781 assert_routing(
755 782 { :method => 'get', :path => "/projects/ladida/wiki/destroy" },
756 783 { :controller => 'wikis', :action => 'destroy', :id => 'ladida' }
757 784 )
758 785 assert_routing(
759 786 { :method => 'post', :path => "/projects/ladida/wiki" },
760 787 { :controller => 'wikis', :action => 'edit', :id => 'ladida' }
761 788 )
762 789 assert_routing(
763 790 { :method => 'post', :path => "/projects/ladida/wiki/destroy" },
764 791 { :controller => 'wikis', :action => 'destroy', :id => 'ladida' }
765 792 )
766 793 end
767 794
768 795 def test_administration_panel
769 796 assert_routing(
770 797 { :method => 'get', :path => "/admin/projects" },
771 798 { :controller => 'admin', :action => 'projects' }
772 799 )
773 800 end
774 801 end
General Comments 0
You need to be logged in to leave comments. Login now