##// END OF EJS Templates
test: replace "should_route" of "documents" to "assert_routing" at integration/routing_test.rb...
Toshi MARUYAMA -
r8100:f968acbfacc8
parent child
Show More
@@ -1,597 +1,619
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 context "documents" do
127 should_route :get, "/projects/567/documents", :controller => 'documents', :action => 'index', :project_id => '567'
128 should_route :get, "/projects/567/documents/new", :controller => 'documents', :action => 'new', :project_id => '567'
129 should_route :get, "/documents/22", :controller => 'documents', :action => 'show', :id => '22'
130 should_route :get, "/documents/22/edit", :controller => 'documents', :action => 'edit', :id => '22'
131
132 should_route :post, "/projects/567/documents", :controller => 'documents', :action => 'create', :project_id => '567'
133 should_route :put, "/documents/22", :controller => 'documents', :action => 'update', :id => '22'
134 should_route :delete, "/documents/22", :controller => 'documents', :action => 'destroy', :id => '22'
135
136 should_route :post, "/documents/22/add_attachment", :controller => 'documents', :action => 'add_attachment', :id => '22'
126 def test_documents
127 assert_routing(
128 { :method => 'get', :path => "/projects/567/documents" },
129 { :controller => 'documents', :action => 'index', :project_id => '567' }
130 )
131 assert_routing(
132 { :method => 'get', :path => "/projects/567/documents/new" },
133 { :controller => 'documents', :action => 'new', :project_id => '567' }
134 )
135 assert_routing(
136 { :method => 'get', :path => "/documents/22" },
137 { :controller => 'documents', :action => 'show', :id => '22' }
138 )
139 assert_routing(
140 { :method => 'get', :path => "/documents/22/edit" },
141 { :controller => 'documents', :action => 'edit', :id => '22' }
142 )
143 assert_routing(
144 { :method => 'post', :path => "/projects/567/documents" },
145 { :controller => 'documents', :action => 'create', :project_id => '567' }
146 )
147 assert_routing(
148 { :method => 'put', :path => "/documents/22" },
149 { :controller => 'documents', :action => 'update', :id => '22' }
150 )
151 assert_routing(
152 { :method => 'delete', :path => "/documents/22" },
153 { :controller => 'documents', :action => 'destroy', :id => '22' }
154 )
155 assert_routing(
156 { :method => 'post', :path => "/documents/22/add_attachment" },
157 { :controller => 'documents', :action => 'add_attachment', :id => '22' }
158 )
137 159 end
138 160
139 161 context "roles" do
140 162 should_route :get, "/enumerations", :controller => 'enumerations', :action => 'index'
141 163 should_route :get, "/enumerations/new", :controller => 'enumerations', :action => 'new'
142 164 should_route :post, "/enumerations", :controller => 'enumerations', :action => 'create'
143 165 should_route :get, "/enumerations/2/edit", :controller => 'enumerations', :action => 'edit', :id => 2
144 166 should_route :put, "/enumerations/2", :controller => 'enumerations', :action => 'update', :id => 2
145 167 should_route :delete, "/enumerations/2", :controller => 'enumerations', :action => 'destroy', :id => 2
146 168 end
147 169
148 170 context "groups" do
149 171 should_route :post, "/groups/567/users", :controller => 'groups', :action => 'add_users', :id => '567'
150 172 should_route :delete, "/groups/567/users/12", :controller => 'groups', :action => 'remove_user', :id => '567', :user_id => '12'
151 173 end
152 174
153 175 def test_issues_rest_actions
154 176 assert_routing(
155 177 { :method => 'get', :path => "/issues" },
156 178 { :controller => 'issues', :action => 'index' }
157 179 )
158 180 assert_routing(
159 181 { :method => 'get', :path => "/issues.pdf" },
160 182 { :controller => 'issues', :action => 'index', :format => 'pdf' }
161 183 )
162 184 assert_routing(
163 185 { :method => 'get', :path => "/issues.atom" },
164 186 { :controller => 'issues', :action => 'index', :format => 'atom' }
165 187 )
166 188 assert_routing(
167 189 { :method => 'get', :path => "/issues.xml" },
168 190 { :controller => 'issues', :action => 'index', :format => 'xml' }
169 191 )
170 192 assert_routing(
171 193 { :method => 'get', :path => "/projects/23/issues" },
172 194 { :controller => 'issues', :action => 'index', :project_id => '23' }
173 195 )
174 196 assert_routing(
175 197 { :method => 'get', :path => "/projects/23/issues.pdf" },
176 198 { :controller => 'issues', :action => 'index', :project_id => '23',
177 199 :format => 'pdf' }
178 200 )
179 201 assert_routing(
180 202 { :method => 'get', :path => "/projects/23/issues.atom" },
181 203 { :controller => 'issues', :action => 'index', :project_id => '23',
182 204 :format => 'atom' }
183 205 )
184 206 assert_routing(
185 207 { :method => 'get', :path => "/projects/23/issues.xml" },
186 208 { :controller => 'issues', :action => 'index', :project_id => '23',
187 209 :format => 'xml' }
188 210 )
189 211 assert_routing(
190 212 { :method => 'get', :path => "/issues/64" },
191 213 { :controller => 'issues', :action => 'show', :id => '64' }
192 214 )
193 215 assert_routing(
194 216 { :method => 'get', :path => "/issues/64.pdf" },
195 217 { :controller => 'issues', :action => 'show', :id => '64',
196 218 :format => 'pdf' }
197 219 )
198 220 assert_routing(
199 221 { :method => 'get', :path => "/issues/64.atom" },
200 222 { :controller => 'issues', :action => 'show', :id => '64',
201 223 :format => 'atom' }
202 224 )
203 225 assert_routing(
204 226 { :method => 'get', :path => "/issues/64.xml" },
205 227 { :controller => 'issues', :action => 'show', :id => '64',
206 228 :format => 'xml' }
207 229 )
208 230 assert_routing(
209 231 { :method => 'get', :path => "/projects/23/issues/new" },
210 232 { :controller => 'issues', :action => 'new', :project_id => '23' }
211 233 )
212 234 end
213 235
214 236 context "issues" do
215 237 # issue form update
216 238 should_route :post, "/projects/23/issues/new", :controller => 'issues', :action => 'new', :project_id => '23'
217 239 should_route :post, "/projects/23/issues", :controller => 'issues', :action => 'create', :project_id => '23'
218 240 should_route :post, "/issues.xml", :controller => 'issues', :action => 'create', :format => 'xml'
219 241
220 242 should_route :get, "/issues/64/edit", :controller => 'issues', :action => 'edit', :id => '64'
221 243 should_route :put, "/issues/1.xml", :controller => 'issues', :action => 'update', :id => '1', :format => 'xml'
222 244
223 245 should_route :delete, "/issues/1.xml", :controller => 'issues', :action => 'destroy', :id => '1', :format => 'xml'
224 246
225 247 # Extra actions
226 248 should_route :get, "/projects/23/issues/64/copy", :controller => 'issues', :action => 'new', :project_id => '23', :copy_from => '64'
227 249
228 250 should_route :get, "/issues/move/new", :controller => 'issue_moves', :action => 'new'
229 251 should_route :post, "/issues/move", :controller => 'issue_moves', :action => 'create'
230 252
231 253 should_route :post, "/issues/1/quoted", :controller => 'journals', :action => 'new', :id => '1'
232 254
233 255 should_route :get, "/issues/calendar", :controller => 'calendars', :action => 'show'
234 256 should_route :get, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'show', :project_id => 'project-name'
235 257
236 258 should_route :get, "/issues/gantt", :controller => 'gantts', :action => 'show'
237 259 should_route :get, "/issues/gantt.pdf", :controller => 'gantts', :action => 'show', :format => 'pdf'
238 260 should_route :get, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'show', :project_id => 'project-name'
239 261 should_route :get, "/projects/project-name/issues/gantt.pdf", :controller => 'gantts', :action => 'show', :project_id => 'project-name', :format => 'pdf'
240 262
241 263 should_route :get, "/issues/auto_complete", :controller => 'auto_completes', :action => 'issues'
242 264
243 265 should_route :get, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123'
244 266 should_route :post, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123'
245 267 should_route :get, "/issues/context_menu", :controller => 'context_menus', :action => 'issues'
246 268 should_route :post, "/issues/context_menu", :controller => 'context_menus', :action => 'issues'
247 269
248 270 should_route :get, "/issues/changes", :controller => 'journals', :action => 'index'
249 271
250 272 should_route :get, "/issues/bulk_edit", :controller => 'issues', :action => 'bulk_edit'
251 273 should_route :post, "/issues/bulk_update", :controller => 'issues', :action => 'bulk_update'
252 274 end
253 275
254 276 context "issue categories" do
255 277 should_route :get, "/projects/foo/issue_categories", :controller => 'issue_categories', :action => 'index', :project_id => 'foo'
256 278 should_route :get, "/projects/foo/issue_categories.xml", :controller => 'issue_categories', :action => 'index', :project_id => 'foo', :format => 'xml'
257 279 should_route :get, "/projects/foo/issue_categories.json", :controller => 'issue_categories', :action => 'index', :project_id => 'foo', :format => 'json'
258 280
259 281 should_route :get, "/projects/foo/issue_categories/new", :controller => 'issue_categories', :action => 'new', :project_id => 'foo'
260 282
261 283 should_route :post, "/projects/foo/issue_categories", :controller => 'issue_categories', :action => 'create', :project_id => 'foo'
262 284 should_route :post, "/projects/foo/issue_categories.xml", :controller => 'issue_categories', :action => 'create', :project_id => 'foo', :format => 'xml'
263 285 should_route :post, "/projects/foo/issue_categories.json", :controller => 'issue_categories', :action => 'create', :project_id => 'foo', :format => 'json'
264 286
265 287 should_route :get, "/issue_categories/1", :controller => 'issue_categories', :action => 'show', :id => '1'
266 288 should_route :get, "/issue_categories/1.xml", :controller => 'issue_categories', :action => 'show', :id => '1', :format => 'xml'
267 289 should_route :get, "/issue_categories/1.json", :controller => 'issue_categories', :action => 'show', :id => '1', :format => 'json'
268 290
269 291 should_route :get, "/issue_categories/1/edit", :controller => 'issue_categories', :action => 'edit', :id => '1'
270 292
271 293 should_route :put, "/issue_categories/1", :controller => 'issue_categories', :action => 'update', :id => '1'
272 294 should_route :put, "/issue_categories/1.xml", :controller => 'issue_categories', :action => 'update', :id => '1', :format => 'xml'
273 295 should_route :put, "/issue_categories/1.json", :controller => 'issue_categories', :action => 'update', :id => '1', :format => 'json'
274 296
275 297 should_route :delete, "/issue_categories/1", :controller => 'issue_categories', :action => 'destroy', :id => '1'
276 298 should_route :delete, "/issue_categories/1.xml", :controller => 'issue_categories', :action => 'destroy', :id => '1', :format => 'xml'
277 299 should_route :delete, "/issue_categories/1.json", :controller => 'issue_categories', :action => 'destroy', :id => '1', :format => 'json'
278 300 end
279 301
280 302 context "issue relations" do
281 303 should_route :get, "/issues/1/relations", :controller => 'issue_relations', :action => 'index', :issue_id => '1'
282 304 should_route :get, "/issues/1/relations.xml", :controller => 'issue_relations', :action => 'index', :issue_id => '1', :format => 'xml'
283 305 should_route :get, "/issues/1/relations.json", :controller => 'issue_relations', :action => 'index', :issue_id => '1', :format => 'json'
284 306
285 307 should_route :post, "/issues/1/relations", :controller => 'issue_relations', :action => 'create', :issue_id => '1'
286 308 should_route :post, "/issues/1/relations.xml", :controller => 'issue_relations', :action => 'create', :issue_id => '1', :format => 'xml'
287 309 should_route :post, "/issues/1/relations.json", :controller => 'issue_relations', :action => 'create', :issue_id => '1', :format => 'json'
288 310
289 311 should_route :get, "/relations/23", :controller => 'issue_relations', :action => 'show', :id => '23'
290 312 should_route :get, "/relations/23.xml", :controller => 'issue_relations', :action => 'show', :id => '23', :format => 'xml'
291 313 should_route :get, "/relations/23.json", :controller => 'issue_relations', :action => 'show', :id => '23', :format => 'json'
292 314
293 315 should_route :delete, "/relations/23", :controller => 'issue_relations', :action => 'destroy', :id => '23'
294 316 should_route :delete, "/relations/23.xml", :controller => 'issue_relations', :action => 'destroy', :id => '23', :format => 'xml'
295 317 should_route :delete, "/relations/23.json", :controller => 'issue_relations', :action => 'destroy', :id => '23', :format => 'json'
296 318 end
297 319
298 320 def test_issue_reports
299 321 assert_routing(
300 322 { :method => 'get', :path => "/projects/567/issues/report" },
301 323 { :controller => 'reports', :action => 'issue_report', :id => '567' }
302 324 )
303 325 assert_routing(
304 326 { :method => 'get', :path => "/projects/567/issues/report/assigned_to" },
305 327 { :controller => 'reports', :action => 'issue_report_details',
306 328 :id => '567', :detail => 'assigned_to' }
307 329 )
308 330 end
309 331
310 332 def test_members
311 333 assert_routing(
312 334 { :method => 'post', :path => "/projects/5234/members/new" },
313 335 { :controller => 'members', :action => 'new', :id => '5234' }
314 336 )
315 337 end
316 338
317 339 context "messages" do
318 340 should_route :get, "/boards/22/topics/2", :controller => 'messages', :action => 'show', :id => '2', :board_id => '22'
319 341 should_route :get, "/boards/lala/topics/new", :controller => 'messages', :action => 'new', :board_id => 'lala'
320 342 should_route :get, "/boards/lala/topics/22/edit", :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala'
321 343
322 344 should_route :post, "/boards/lala/topics/new", :controller => 'messages', :action => 'new', :board_id => 'lala'
323 345 should_route :post, "/boards/lala/topics/22/edit", :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala'
324 346 should_route :post, "/boards/22/topics/555/replies", :controller => 'messages', :action => 'reply', :id => '555', :board_id => '22'
325 347 should_route :post, "/boards/22/topics/555/destroy", :controller => 'messages', :action => 'destroy', :id => '555', :board_id => '22'
326 348 end
327 349
328 350 context "news" do
329 351 should_route :get, "/news", :controller => 'news', :action => 'index'
330 352 should_route :get, "/news.atom", :controller => 'news', :action => 'index', :format => 'atom'
331 353 should_route :get, "/news.xml", :controller => 'news', :action => 'index', :format => 'xml'
332 354 should_route :get, "/news.json", :controller => 'news', :action => 'index', :format => 'json'
333 355 should_route :get, "/projects/567/news", :controller => 'news', :action => 'index', :project_id => '567'
334 356 should_route :get, "/projects/567/news.atom", :controller => 'news', :action => 'index', :format => 'atom', :project_id => '567'
335 357 should_route :get, "/projects/567/news.xml", :controller => 'news', :action => 'index', :format => 'xml', :project_id => '567'
336 358 should_route :get, "/projects/567/news.json", :controller => 'news', :action => 'index', :format => 'json', :project_id => '567'
337 359 should_route :get, "/news/2", :controller => 'news', :action => 'show', :id => '2'
338 360 should_route :get, "/projects/567/news/new", :controller => 'news', :action => 'new', :project_id => '567'
339 361 should_route :get, "/news/234", :controller => 'news', :action => 'show', :id => '234'
340 362 should_route :get, "/news/567/edit", :controller => 'news', :action => 'edit', :id => '567'
341 363 should_route :get, "/news/preview", :controller => 'previews', :action => 'news'
342 364
343 365 should_route :post, "/projects/567/news", :controller => 'news', :action => 'create', :project_id => '567'
344 366 should_route :post, "/news/567/comments", :controller => 'comments', :action => 'create', :id => '567'
345 367
346 368 should_route :put, "/news/567", :controller => 'news', :action => 'update', :id => '567'
347 369
348 370 should_route :delete, "/news/567", :controller => 'news', :action => 'destroy', :id => '567'
349 371 should_route :delete, "/news/567/comments/15", :controller => 'comments', :action => 'destroy', :id => '567', :comment_id => '15'
350 372 end
351 373
352 374 context "projects" do
353 375 should_route :get, "/projects", :controller => 'projects', :action => 'index'
354 376 should_route :get, "/projects.atom", :controller => 'projects', :action => 'index', :format => 'atom'
355 377 should_route :get, "/projects.xml", :controller => 'projects', :action => 'index', :format => 'xml'
356 378 should_route :get, "/projects/new", :controller => 'projects', :action => 'new'
357 379 should_route :get, "/projects/test", :controller => 'projects', :action => 'show', :id => 'test'
358 380 should_route :get, "/projects/1.xml", :controller => 'projects', :action => 'show', :id => '1', :format => 'xml'
359 381 should_route :get, "/projects/4223/settings", :controller => 'projects', :action => 'settings', :id => '4223'
360 382 should_route :get, "/projects/4223/settings/members", :controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members'
361 383 should_route :get, "/projects/33/files", :controller => 'files', :action => 'index', :project_id => '33'
362 384 should_route :get, "/projects/33/files/new", :controller => 'files', :action => 'new', :project_id => '33'
363 385 should_route :get, "/projects/33/roadmap", :controller => 'versions', :action => 'index', :project_id => '33'
364 386 should_route :get, "/projects/33/activity", :controller => 'activities', :action => 'index', :id => '33'
365 387 should_route :get, "/projects/33/activity.atom", :controller => 'activities', :action => 'index', :id => '33', :format => 'atom'
366 388
367 389 should_route :post, "/projects", :controller => 'projects', :action => 'create'
368 390 should_route :post, "/projects.xml", :controller => 'projects', :action => 'create', :format => 'xml'
369 391 should_route :post, "/projects/33/files", :controller => 'files', :action => 'create', :project_id => '33'
370 392 should_route :post, "/projects/64/archive", :controller => 'projects', :action => 'archive', :id => '64'
371 393 should_route :post, "/projects/64/unarchive", :controller => 'projects', :action => 'unarchive', :id => '64'
372 394
373 395 should_route :put, "/projects/64/enumerations", :controller => 'project_enumerations', :action => 'update', :project_id => '64'
374 396 should_route :put, "/projects/4223", :controller => 'projects', :action => 'update', :id => '4223'
375 397 should_route :put, "/projects/1.xml", :controller => 'projects', :action => 'update', :id => '1', :format => 'xml'
376 398
377 399 should_route :delete, "/projects/64", :controller => 'projects', :action => 'destroy', :id => '64'
378 400 should_route :delete, "/projects/1.xml", :controller => 'projects', :action => 'destroy', :id => '1', :format => 'xml'
379 401 should_route :delete, "/projects/64/enumerations", :controller => 'project_enumerations', :action => 'destroy', :project_id => '64'
380 402 end
381 403
382 404 context "queries" do
383 405 should_route :get, "/queries.xml", :controller => 'queries', :action => 'index', :format => 'xml'
384 406 should_route :get, "/queries.json", :controller => 'queries', :action => 'index', :format => 'json'
385 407
386 408 should_route :get, "/queries/new", :controller => 'queries', :action => 'new'
387 409 should_route :get, "/projects/redmine/queries/new", :controller => 'queries', :action => 'new', :project_id => 'redmine'
388 410
389 411 should_route :post, "/queries", :controller => 'queries', :action => 'create'
390 412 should_route :post, "/projects/redmine/queries", :controller => 'queries', :action => 'create', :project_id => 'redmine'
391 413
392 414 should_route :get, "/queries/1/edit", :controller => 'queries', :action => 'edit', :id => '1'
393 415
394 416 should_route :put, "/queries/1", :controller => 'queries', :action => 'update', :id => '1'
395 417
396 418 should_route :delete, "/queries/1", :controller => 'queries', :action => 'destroy', :id => '1'
397 419 end
398 420
399 421 context "repositories" do
400 422 should_route :get, "/projects/redmine/repository", :controller => 'repositories', :action => 'show', :id => 'redmine'
401 423 should_route :get, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine'
402 424 should_route :get, "/projects/redmine/repository/revisions", :controller => 'repositories', :action => 'revisions', :id => 'redmine'
403 425 should_route :get, "/projects/redmine/repository/revisions.atom", :controller => 'repositories', :action => 'revisions', :id => 'redmine', :format => 'atom'
404 426 should_route :get, "/projects/redmine/repository/revisions/2457", :controller => 'repositories', :action => 'revision', :id => 'redmine', :rev => '2457'
405 427 should_route :get, "/projects/redmine/repository/revisions/2457/diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457'
406 428 should_route :get, "/projects/redmine/repository/revisions/2457/diff.diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457', :format => 'diff'
407 429 should_route :get, "/projects/redmine/repository/diff/path/to/file.c", :controller => 'repositories', :action => 'diff', :id => 'redmine', :path => %w[path to file.c]
408 430 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'
409 431 should_route :get, "/projects/redmine/repository/browse/path/to/file.c", :controller => 'repositories', :action => 'browse', :id => 'redmine', :path => %w[path to file.c]
410 432 should_route :get, "/projects/redmine/repository/entry/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c]
411 433 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'
412 434 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'
413 435 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'
414 436 should_route :get, "/projects/redmine/repository/annotate/path/to/file.c", :controller => 'repositories', :action => 'annotate', :id => 'redmine', :path => %w[path to file.c]
415 437 should_route :get, "/projects/redmine/repository/changes/path/to/file.c", :controller => 'repositories', :action => 'changes', :id => 'redmine', :path => %w[path to file.c]
416 438 should_route :get, "/projects/redmine/repository/statistics", :controller => 'repositories', :action => 'stats', :id => 'redmine'
417 439
418 440 should_route :post, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine'
419 441 end
420 442
421 443 context "roles" do
422 444 should_route :get, "/roles", :controller => 'roles', :action => 'index'
423 445 should_route :get, "/roles/new", :controller => 'roles', :action => 'new'
424 446 should_route :post, "/roles", :controller => 'roles', :action => 'create'
425 447 should_route :get, "/roles/2/edit", :controller => 'roles', :action => 'edit', :id => 2
426 448 should_route :put, "/roles/2", :controller => 'roles', :action => 'update', :id => 2
427 449 should_route :delete, "/roles/2", :controller => 'roles', :action => 'destroy', :id => 2
428 450 should_route :get, "/roles/permissions", :controller => 'roles', :action => 'permissions'
429 451 should_route :post, "/roles/permissions", :controller => 'roles', :action => 'permissions'
430 452 end
431 453
432 454 context "timelogs (global)" do
433 455 should_route :get, "/time_entries", :controller => 'timelog', :action => 'index'
434 456 should_route :get, "/time_entries.csv", :controller => 'timelog', :action => 'index', :format => 'csv'
435 457 should_route :get, "/time_entries.atom", :controller => 'timelog', :action => 'index', :format => 'atom'
436 458 should_route :get, "/time_entries/new", :controller => 'timelog', :action => 'new'
437 459 should_route :get, "/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22'
438 460
439 461 should_route :post, "/time_entries", :controller => 'timelog', :action => 'create'
440 462
441 463 should_route :put, "/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22'
442 464
443 465 should_route :delete, "/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55'
444 466 end
445 467
446 468 context "timelogs (scoped under project)" do
447 469 should_route :get, "/projects/567/time_entries", :controller => 'timelog', :action => 'index', :project_id => '567'
448 470 should_route :get, "/projects/567/time_entries.csv", :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'csv'
449 471 should_route :get, "/projects/567/time_entries.atom", :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'atom'
450 472 should_route :get, "/projects/567/time_entries/new", :controller => 'timelog', :action => 'new', :project_id => '567'
451 473 should_route :get, "/projects/567/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22', :project_id => '567'
452 474
453 475 should_route :post, "/projects/567/time_entries", :controller => 'timelog', :action => 'create', :project_id => '567'
454 476
455 477 should_route :put, "/projects/567/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :project_id => '567'
456 478
457 479 should_route :delete, "/projects/567/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :project_id => '567'
458 480 end
459 481
460 482 context "timelogs (scoped under issues)" do
461 483 should_route :get, "/issues/234/time_entries", :controller => 'timelog', :action => 'index', :issue_id => '234'
462 484 should_route :get, "/issues/234/time_entries.csv", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'csv'
463 485 should_route :get, "/issues/234/time_entries.atom", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'atom'
464 486 should_route :get, "/issues/234/time_entries/new", :controller => 'timelog', :action => 'new', :issue_id => '234'
465 487 should_route :get, "/issues/234/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22', :issue_id => '234'
466 488
467 489 should_route :post, "/issues/234/time_entries", :controller => 'timelog', :action => 'create', :issue_id => '234'
468 490
469 491 should_route :put, "/issues/234/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :issue_id => '234'
470 492
471 493 should_route :delete, "/issues/234/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :issue_id => '234'
472 494 end
473 495
474 496 context "timelogs (scoped under project and issues)" do
475 497 should_route :get, "/projects/ecookbook/issues/234/time_entries", :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook'
476 498 should_route :get, "/projects/ecookbook/issues/234/time_entries.csv", :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook', :format => 'csv'
477 499 should_route :get, "/projects/ecookbook/issues/234/time_entries.atom", :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook', :format => 'atom'
478 500 should_route :get, "/projects/ecookbook/issues/234/time_entries/new", :controller => 'timelog', :action => 'new', :issue_id => '234', :project_id => 'ecookbook'
479 501 should_route :get, "/projects/ecookbook/issues/234/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22', :issue_id => '234', :project_id => 'ecookbook'
480 502
481 503 should_route :post, "/projects/ecookbook/issues/234/time_entries", :controller => 'timelog', :action => 'create', :issue_id => '234', :project_id => 'ecookbook'
482 504
483 505 should_route :put, "/projects/ecookbook/issues/234/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :issue_id => '234', :project_id => 'ecookbook'
484 506
485 507 should_route :delete, "/projects/ecookbook/issues/234/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :issue_id => '234', :project_id => 'ecookbook'
486 508
487 509 should_route :get, "/time_entries/report", :controller => 'timelog', :action => 'report'
488 510 should_route :get, "/projects/567/time_entries/report", :controller => 'timelog', :action => 'report', :project_id => '567'
489 511 should_route :get, "/projects/567/time_entries/report.csv", :controller => 'timelog', :action => 'report', :project_id => '567', :format => 'csv'
490 512 end
491 513
492 514 context "users" do
493 515 should_route :get, "/users", :controller => 'users', :action => 'index'
494 516 should_route :get, "/users.xml", :controller => 'users', :action => 'index', :format => 'xml'
495 517 should_route :get, "/users/44", :controller => 'users', :action => 'show', :id => '44'
496 518 should_route :get, "/users/44.xml", :controller => 'users', :action => 'show', :id => '44', :format => 'xml'
497 519 should_route :get, "/users/current", :controller => 'users', :action => 'show', :id => 'current'
498 520 should_route :get, "/users/current.xml", :controller => 'users', :action => 'show', :id => 'current', :format => 'xml'
499 521 should_route :get, "/users/new", :controller => 'users', :action => 'new'
500 522 should_route :get, "/users/444/edit", :controller => 'users', :action => 'edit', :id => '444'
501 523
502 524 should_route :post, "/users", :controller => 'users', :action => 'create'
503 525 should_route :post, "/users.xml", :controller => 'users', :action => 'create', :format => 'xml'
504 526
505 527 should_route :put, "/users/444", :controller => 'users', :action => 'update', :id => '444'
506 528 should_route :put, "/users/444.xml", :controller => 'users', :action => 'update', :id => '444', :format => 'xml'
507 529
508 530 should_route :delete, "/users/44", :controller => 'users', :action => 'destroy', :id => '44'
509 531 should_route :delete, "/users/44.xml", :controller => 'users', :action => 'destroy', :id => '44', :format => 'xml'
510 532
511 533 should_route :post, "/users/123/memberships", :controller => 'users', :action => 'edit_membership', :id => '123'
512 534 should_route :put, "/users/123/memberships/55", :controller => 'users', :action => 'edit_membership', :id => '123', :membership_id => '55'
513 535 should_route :delete, "/users/123/memberships/55", :controller => 'users', :action => 'destroy_membership', :id => '123', :membership_id => '55'
514 536 end
515 537
516 538 context "versions" do
517 539 # /projects/foo/versions is /projects/foo/roadmap
518 540 should_route :get, "/projects/foo/versions.xml", :controller => 'versions', :action => 'index', :project_id => 'foo', :format => 'xml'
519 541 should_route :get, "/projects/foo/versions.json", :controller => 'versions', :action => 'index', :project_id => 'foo', :format => 'json'
520 542
521 543 should_route :get, "/projects/foo/versions/new", :controller => 'versions', :action => 'new', :project_id => 'foo'
522 544
523 545 should_route :post, "/projects/foo/versions", :controller => 'versions', :action => 'create', :project_id => 'foo'
524 546 should_route :post, "/projects/foo/versions.xml", :controller => 'versions', :action => 'create', :project_id => 'foo', :format => 'xml'
525 547 should_route :post, "/projects/foo/versions.json", :controller => 'versions', :action => 'create', :project_id => 'foo', :format => 'json'
526 548
527 549 should_route :get, "/versions/1", :controller => 'versions', :action => 'show', :id => '1'
528 550 should_route :get, "/versions/1.xml", :controller => 'versions', :action => 'show', :id => '1', :format => 'xml'
529 551 should_route :get, "/versions/1.json", :controller => 'versions', :action => 'show', :id => '1', :format => 'json'
530 552
531 553 should_route :get, "/versions/1/edit", :controller => 'versions', :action => 'edit', :id => '1'
532 554
533 555 should_route :put, "/versions/1", :controller => 'versions', :action => 'update', :id => '1'
534 556 should_route :put, "/versions/1.xml", :controller => 'versions', :action => 'update', :id => '1', :format => 'xml'
535 557 should_route :put, "/versions/1.json", :controller => 'versions', :action => 'update', :id => '1', :format => 'json'
536 558
537 559 should_route :delete, "/versions/1", :controller => 'versions', :action => 'destroy', :id => '1'
538 560 should_route :delete, "/versions/1.xml", :controller => 'versions', :action => 'destroy', :id => '1', :format => 'xml'
539 561 should_route :delete, "/versions/1.json", :controller => 'versions', :action => 'destroy', :id => '1', :format => 'json'
540 562
541 563 should_route :put, "/projects/foo/versions/close_completed", :controller => 'versions', :action => 'close_completed', :project_id => 'foo'
542 564 should_route :post, "/versions/1/status_by", :controller => 'versions', :action => 'status_by', :id => '1'
543 565 end
544 566
545 567 def test_welcome
546 568 assert_routing(
547 569 { :method => 'get', :path => "/robots.txt" },
548 570 { :controller => 'welcome', :action => 'robots' }
549 571 )
550 572 end
551 573
552 574 context "wiki (singular, project's pages)" do
553 575 should_route :get, "/projects/567/wiki", :controller => 'wiki', :action => 'show', :project_id => '567'
554 576 should_route :get, "/projects/567/wiki/lalala", :controller => 'wiki', :action => 'show', :project_id => '567', :id => 'lalala'
555 577 should_route :get, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :project_id => '567', :id => 'my_page'
556 578 should_route :get, "/projects/1/wiki/CookBook_documentation/history", :controller => 'wiki', :action => 'history', :project_id => '1', :id => 'CookBook_documentation'
557 579 should_route :get, "/projects/1/wiki/CookBook_documentation/diff", :controller => 'wiki', :action => 'diff', :project_id => '1', :id => 'CookBook_documentation'
558 580 should_route :get, "/projects/1/wiki/CookBook_documentation/diff/2", :controller => 'wiki', :action => 'diff', :project_id => '1', :id => 'CookBook_documentation', :version => '2'
559 581 should_route :get, "/projects/1/wiki/CookBook_documentation/diff/2/vs/1", :controller => 'wiki', :action => 'diff', :project_id => '1', :id => 'CookBook_documentation', :version => '2', :version_from => '1'
560 582 should_route :get, "/projects/1/wiki/CookBook_documentation/annotate/2", :controller => 'wiki', :action => 'annotate', :project_id => '1', :id => 'CookBook_documentation', :version => '2'
561 583 should_route :get, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :project_id => '22', :id => 'ladida'
562 584 should_route :get, "/projects/567/wiki/index", :controller => 'wiki', :action => 'index', :project_id => '567'
563 585 should_route :get, "/projects/567/wiki/date_index", :controller => 'wiki', :action => 'date_index', :project_id => '567'
564 586 should_route :get, "/projects/567/wiki/export", :controller => 'wiki', :action => 'export', :project_id => '567'
565 587
566 588 should_route :post, "/projects/567/wiki/CookBook_documentation/preview", :controller => 'wiki', :action => 'preview', :project_id => '567', :id => 'CookBook_documentation'
567 589 should_route :post, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :project_id => '22', :id => 'ladida'
568 590 should_route :post, "/projects/22/wiki/ladida/protect", :controller => 'wiki', :action => 'protect', :project_id => '22', :id => 'ladida'
569 591 should_route :post, "/projects/22/wiki/ladida/add_attachment", :controller => 'wiki', :action => 'add_attachment', :project_id => '22', :id => 'ladida'
570 592
571 593 should_route :put, "/projects/567/wiki/my_page", :controller => 'wiki', :action => 'update', :project_id => '567', :id => 'my_page'
572 594
573 595 should_route :delete, "/projects/22/wiki/ladida", :controller => 'wiki', :action => 'destroy', :project_id => '22', :id => 'ladida'
574 596 end
575 597
576 598 def test_wikis_plural_admin_setup
577 599 assert_routing(
578 600 { :method => 'get', :path => "/projects/ladida/wiki/destroy" },
579 601 { :controller => 'wikis', :action => 'destroy', :id => 'ladida' }
580 602 )
581 603 assert_routing(
582 604 { :method => 'post', :path => "/projects/ladida/wiki" },
583 605 { :controller => 'wikis', :action => 'edit', :id => 'ladida' }
584 606 )
585 607 assert_routing(
586 608 { :method => 'post', :path => "/projects/ladida/wiki/destroy" },
587 609 { :controller => 'wikis', :action => 'destroy', :id => 'ladida' }
588 610 )
589 611 end
590 612
591 613 def test_administration_panel
592 614 assert_routing(
593 615 { :method => 'get', :path => "/admin/projects" },
594 616 { :controller => 'admin', :action => 'projects' }
595 617 )
596 618 end
597 619 end
General Comments 0
You need to be logged in to leave comments. Login now