comparison .svn/pristine/05/05bd9a477032dec0ee79cadb6f6626cf79ccae69.svn-base @ 1296:038ba2d95de8 redmine-2.2

Fix redmine-2.2 branch update (add missing svn files)
author Chris Cannam
date Fri, 14 Jun 2013 09:05:06 +0100
parents
children
comparison
equal deleted inserted replaced
1294:3e4c3460b6ca 1296:038ba2d95de8
1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 require File.expand_path('../../../test_helper', __FILE__)
19
20 class RoutingRepositoriesTest < ActionController::IntegrationTest
21 def setup
22 @path_hash = repository_path_hash(%w[path to file.c])
23 assert_equal "path/to/file.c", @path_hash[:path]
24 assert_equal "path/to/file.c", @path_hash[:param]
25 end
26
27 def test_repositories_resources
28 assert_routing(
29 { :method => 'get',
30 :path => "/projects/redmine/repositories/new" },
31 { :controller => 'repositories', :action => 'new', :project_id => 'redmine' }
32 )
33 assert_routing(
34 { :method => 'post',
35 :path => "/projects/redmine/repositories" },
36 { :controller => 'repositories', :action => 'create', :project_id => 'redmine' }
37 )
38 assert_routing(
39 { :method => 'get',
40 :path => "/repositories/1/edit" },
41 { :controller => 'repositories', :action => 'edit', :id => '1' }
42 )
43 assert_routing(
44 { :method => 'put',
45 :path => "/repositories/1" },
46 { :controller => 'repositories', :action => 'update', :id => '1' }
47 )
48 assert_routing(
49 { :method => 'delete',
50 :path => "/repositories/1" },
51 { :controller => 'repositories', :action => 'destroy', :id => '1' }
52 )
53 ["get", "post"].each do |method|
54 assert_routing(
55 { :method => method,
56 :path => "/repositories/1/committers" },
57 { :controller => 'repositories', :action => 'committers', :id => '1' }
58 )
59 end
60 end
61
62 def test_repositories_show
63 assert_routing(
64 { :method => 'get',
65 :path => "/projects/redmine/repository" },
66 { :controller => 'repositories', :action => 'show', :id => 'redmine' }
67 )
68 end
69
70 def test_repositories
71 assert_routing(
72 { :method => 'get',
73 :path => "/projects/redmine/repository/statistics" },
74 { :controller => 'repositories', :action => 'stats', :id => 'redmine' }
75 )
76 assert_routing(
77 { :method => 'get',
78 :path => "/projects/redmine/repository/graph" },
79 { :controller => 'repositories', :action => 'graph', :id => 'redmine' }
80 )
81 end
82
83 def test_repositories_show_with_repository_id
84 assert_routing(
85 { :method => 'get',
86 :path => "/projects/redmine/repository/foo" },
87 { :controller => 'repositories', :action => 'show', :id => 'redmine', :repository_id => 'foo' }
88 )
89 end
90
91 def test_repositories_with_repository_id
92 assert_routing(
93 { :method => 'get',
94 :path => "/projects/redmine/repository/foo/statistics" },
95 { :controller => 'repositories', :action => 'stats', :id => 'redmine', :repository_id => 'foo' }
96 )
97 assert_routing(
98 { :method => 'get',
99 :path => "/projects/redmine/repository/foo/graph" },
100 { :controller => 'repositories', :action => 'graph', :id => 'redmine', :repository_id => 'foo' }
101 )
102 end
103
104 def test_repositories_revisions
105 empty_path_param = []
106 assert_routing(
107 { :method => 'get',
108 :path => "/projects/redmine/repository/revisions" },
109 { :controller => 'repositories', :action => 'revisions', :id => 'redmine' }
110 )
111 assert_routing(
112 { :method => 'get',
113 :path => "/projects/redmine/repository/revisions.atom" },
114 { :controller => 'repositories', :action => 'revisions', :id => 'redmine',
115 :format => 'atom' }
116 )
117 assert_routing(
118 { :method => 'get',
119 :path => "/projects/redmine/repository/revisions/2457" },
120 { :controller => 'repositories', :action => 'revision', :id => 'redmine',
121 :rev => '2457' }
122 )
123 assert_routing(
124 { :method => 'get',
125 :path => "/projects/redmine/repository/revisions/2457/show" },
126 { :controller => 'repositories', :action => 'show', :id => 'redmine',
127 :rev => '2457' }
128 )
129 assert_routing(
130 { :method => 'get',
131 :path => "/projects/redmine/repository/revisions/2457/show/#{@path_hash[:path]}" },
132 { :controller => 'repositories', :action => 'show', :id => 'redmine',
133 :path => @path_hash[:param] , :rev => '2457'}
134 )
135 assert_routing(
136 { :method => 'get',
137 :path => "/projects/redmine/repository/revisions/2457/diff" },
138 { :controller => 'repositories', :action => 'diff', :id => 'redmine',
139 :rev => '2457' }
140 )
141 assert_routing(
142 { :method => 'get',
143 :path => "/projects/redmine/repository/revisions/2457/diff" },
144 { :controller => 'repositories', :action => 'diff', :id => 'redmine',
145 :rev => '2457', :format => 'diff' },
146 {},
147 { :format => 'diff' }
148 )
149 assert_routing(
150 { :method => 'get',
151 :path => "/projects/redmine/repository/revisions/2/diff/#{@path_hash[:path]}" },
152 { :controller => 'repositories', :action => 'diff', :id => 'redmine',
153 :path => @path_hash[:param], :rev => '2' }
154 )
155 assert_routing(
156 { :method => 'get',
157 :path => "/projects/redmine/repository/revisions/2/diff/#{@path_hash[:path]}" },
158 { :controller => 'repositories', :action => 'diff', :id => 'redmine',
159 :path => @path_hash[:param], :rev => '2', :format => 'diff' },
160 {},
161 { :format => 'diff' }
162 )
163 assert_routing(
164 { :method => 'get',
165 :path => "/projects/redmine/repository/revisions/2/entry/#{@path_hash[:path]}" },
166 { :controller => 'repositories', :action => 'entry', :id => 'redmine',
167 :path => @path_hash[:param], :rev => '2' }
168 )
169 assert_routing(
170 { :method => 'get',
171 :path => "/projects/redmine/repository/revisions/2/raw/#{@path_hash[:path]}" },
172 { :controller => 'repositories', :action => 'raw', :id => 'redmine',
173 :path => @path_hash[:param], :rev => '2' }
174 )
175 assert_routing(
176 { :method => 'get',
177 :path => "/projects/redmine/repository/revisions/2/annotate/#{@path_hash[:path]}" },
178 { :controller => 'repositories', :action => 'annotate', :id => 'redmine',
179 :path => @path_hash[:param], :rev => '2' }
180 )
181 end
182
183 def test_repositories_revisions_with_repository_id
184 empty_path_param = []
185 assert_routing(
186 { :method => 'get',
187 :path => "/projects/redmine/repository/foo/revisions" },
188 { :controller => 'repositories', :action => 'revisions', :id => 'redmine', :repository_id => 'foo' }
189 )
190 assert_routing(
191 { :method => 'get',
192 :path => "/projects/redmine/repository/foo/revisions.atom" },
193 { :controller => 'repositories', :action => 'revisions', :id => 'redmine', :repository_id => 'foo',
194 :format => 'atom' }
195 )
196 assert_routing(
197 { :method => 'get',
198 :path => "/projects/redmine/repository/foo/revisions/2457" },
199 { :controller => 'repositories', :action => 'revision', :id => 'redmine', :repository_id => 'foo',
200 :rev => '2457' }
201 )
202 assert_routing(
203 { :method => 'get',
204 :path => "/projects/redmine/repository/foo/revisions/2457/show" },
205 { :controller => 'repositories', :action => 'show', :id => 'redmine', :repository_id => 'foo',
206 :rev => '2457' }
207 )
208 assert_routing(
209 { :method => 'get',
210 :path => "/projects/redmine/repository/foo/revisions/2457/show/#{@path_hash[:path]}" },
211 { :controller => 'repositories', :action => 'show', :id => 'redmine', :repository_id => 'foo',
212 :path => @path_hash[:param] , :rev => '2457'}
213 )
214 assert_routing(
215 { :method => 'get',
216 :path => "/projects/redmine/repository/foo/revisions/2457/diff" },
217 { :controller => 'repositories', :action => 'diff', :id => 'redmine', :repository_id => 'foo',
218 :rev => '2457' }
219 )
220 assert_routing(
221 { :method => 'get',
222 :path => "/projects/redmine/repository/foo/revisions/2457/diff" },
223 { :controller => 'repositories', :action => 'diff', :id => 'redmine', :repository_id => 'foo',
224 :rev => '2457', :format => 'diff' },
225 {},
226 { :format => 'diff' }
227 )
228 assert_routing(
229 { :method => 'get',
230 :path => "/projects/redmine/repository/foo/revisions/2/diff/#{@path_hash[:path]}" },
231 { :controller => 'repositories', :action => 'diff', :id => 'redmine', :repository_id => 'foo',
232 :path => @path_hash[:param], :rev => '2' }
233 )
234 assert_routing(
235 { :method => 'get',
236 :path => "/projects/redmine/repository/foo/revisions/2/diff/#{@path_hash[:path]}" },
237 { :controller => 'repositories', :action => 'diff', :id => 'redmine', :repository_id => 'foo',
238 :path => @path_hash[:param], :rev => '2', :format => 'diff' },
239 {},
240 { :format => 'diff' }
241 )
242 assert_routing(
243 { :method => 'get',
244 :path => "/projects/redmine/repository/foo/revisions/2/entry/#{@path_hash[:path]}" },
245 { :controller => 'repositories', :action => 'entry', :id => 'redmine', :repository_id => 'foo',
246 :path => @path_hash[:param], :rev => '2' }
247 )
248 assert_routing(
249 { :method => 'get',
250 :path => "/projects/redmine/repository/foo/revisions/2/raw/#{@path_hash[:path]}" },
251 { :controller => 'repositories', :action => 'raw', :id => 'redmine', :repository_id => 'foo',
252 :path => @path_hash[:param], :rev => '2' }
253 )
254 assert_routing(
255 { :method => 'get',
256 :path => "/projects/redmine/repository/foo/revisions/2/annotate/#{@path_hash[:path]}" },
257 { :controller => 'repositories', :action => 'annotate', :id => 'redmine', :repository_id => 'foo',
258 :path => @path_hash[:param], :rev => '2' }
259 )
260 end
261
262 def test_repositories_non_revisions_path
263 assert_routing(
264 { :method => 'get',
265 :path => "/projects/redmine/repository/changes" },
266 { :controller => 'repositories', :action => 'changes', :id => 'redmine' }
267 )
268 ['2457', 'master', 'slash/slash'].each do |rev|
269 assert_routing(
270 { :method => 'get',
271 :path => "/projects/redmine/repository/changes" },
272 { :controller => 'repositories', :action => 'changes', :id => 'redmine',
273 :rev => rev },
274 {},
275 { :rev => rev }
276 )
277 end
278 ['2457', 'master', 'slash/slash'].each do |rev|
279 assert_routing(
280 { :method => 'get',
281 :path => "/projects/redmine/repository/changes/#{@path_hash[:path]}" },
282 { :controller => 'repositories', :action => 'changes', :id => 'redmine',
283 :path => @path_hash[:param], :rev => rev },
284 {},
285 { :rev => rev }
286 )
287 end
288 assert_routing(
289 { :method => 'get',
290 :path => "/projects/redmine/repository/diff/#{@path_hash[:path]}" },
291 { :controller => 'repositories', :action => 'diff', :id => 'redmine',
292 :path => @path_hash[:param] }
293 )
294 assert_routing(
295 { :method => 'get',
296 :path => "/projects/redmine/repository/browse/#{@path_hash[:path]}" },
297 { :controller => 'repositories', :action => 'browse', :id => 'redmine',
298 :path => @path_hash[:param] }
299 )
300 assert_routing(
301 { :method => 'get',
302 :path => "/projects/redmine/repository/entry/#{@path_hash[:path]}" },
303 { :controller => 'repositories', :action => 'entry', :id => 'redmine',
304 :path => @path_hash[:param] }
305 )
306 assert_routing(
307 { :method => 'get',
308 :path => "/projects/redmine/repository/raw/#{@path_hash[:path]}" },
309 { :controller => 'repositories', :action => 'raw', :id => 'redmine',
310 :path => @path_hash[:param] }
311 )
312 assert_routing(
313 { :method => 'get',
314 :path => "/projects/redmine/repository/annotate/#{@path_hash[:path]}" },
315 { :controller => 'repositories', :action => 'annotate', :id => 'redmine',
316 :path => @path_hash[:param] }
317 )
318 assert_routing(
319 { :method => 'get',
320 :path => "/projects/redmine/repository/changes/#{@path_hash[:path]}" },
321 { :controller => 'repositories', :action => 'changes', :id => 'redmine',
322 :path => @path_hash[:param] }
323 )
324 assert_routing(
325 { :method => 'get',
326 :path => "/projects/redmine/repository/revision" },
327 { :controller => 'repositories', :action => 'revision', :id => 'redmine' }
328 )
329 end
330
331 def test_repositories_non_revisions_path_with_repository_id
332 assert_routing(
333 { :method => 'get',
334 :path => "/projects/redmine/repository/foo/changes" },
335 { :controller => 'repositories', :action => 'changes',
336 :id => 'redmine', :repository_id => 'foo' }
337 )
338 ['2457', 'master', 'slash/slash'].each do |rev|
339 assert_routing(
340 { :method => 'get',
341 :path => "/projects/redmine/repository/foo/changes" },
342 { :controller => 'repositories', :action => 'changes',
343 :id => 'redmine',
344 :repository_id => 'foo', :rev => rev },
345 {},
346 { :rev => rev }
347 )
348 end
349 ['2457', 'master', 'slash/slash'].each do |rev|
350 assert_routing(
351 { :method => 'get',
352 :path => "/projects/redmine/repository/foo/changes/#{@path_hash[:path]}" },
353 { :controller => 'repositories', :action => 'changes', :id => 'redmine',
354 :repository_id => 'foo', :path => @path_hash[:param], :rev => rev },
355 {},
356 { :rev => rev }
357 )
358 end
359 assert_routing(
360 { :method => 'get',
361 :path => "/projects/redmine/repository/foo/diff/#{@path_hash[:path]}" },
362 { :controller => 'repositories', :action => 'diff', :id => 'redmine', :repository_id => 'foo',
363 :path => @path_hash[:param] }
364 )
365 assert_routing(
366 { :method => 'get',
367 :path => "/projects/redmine/repository/foo/browse/#{@path_hash[:path]}" },
368 { :controller => 'repositories', :action => 'browse', :id => 'redmine', :repository_id => 'foo',
369 :path => @path_hash[:param] }
370 )
371 assert_routing(
372 { :method => 'get',
373 :path => "/projects/redmine/repository/foo/entry/#{@path_hash[:path]}" },
374 { :controller => 'repositories', :action => 'entry', :id => 'redmine', :repository_id => 'foo',
375 :path => @path_hash[:param] }
376 )
377 assert_routing(
378 { :method => 'get',
379 :path => "/projects/redmine/repository/foo/raw/#{@path_hash[:path]}" },
380 { :controller => 'repositories', :action => 'raw', :id => 'redmine', :repository_id => 'foo',
381 :path => @path_hash[:param] }
382 )
383 assert_routing(
384 { :method => 'get',
385 :path => "/projects/redmine/repository/foo/annotate/#{@path_hash[:path]}" },
386 { :controller => 'repositories', :action => 'annotate', :id => 'redmine', :repository_id => 'foo',
387 :path => @path_hash[:param] }
388 )
389 assert_routing(
390 { :method => 'get',
391 :path => "/projects/redmine/repository/foo/changes/#{@path_hash[:path]}" },
392 { :controller => 'repositories', :action => 'changes', :id => 'redmine', :repository_id => 'foo',
393 :path => @path_hash[:param] }
394 )
395 assert_routing(
396 { :method => 'get',
397 :path => "/projects/redmine/repository/foo/revision" },
398 { :controller => 'repositories', :action => 'revision', :id => 'redmine', :repository_id => 'foo'}
399 )
400 end
401
402 def test_repositories_related_issues
403 assert_routing(
404 { :method => 'post',
405 :path => "/projects/redmine/repository/revisions/123/issues" },
406 { :controller => 'repositories', :action => 'add_related_issue',
407 :id => 'redmine', :rev => '123' }
408 )
409 assert_routing(
410 { :method => 'delete',
411 :path => "/projects/redmine/repository/revisions/123/issues/25" },
412 { :controller => 'repositories', :action => 'remove_related_issue',
413 :id => 'redmine', :rev => '123', :issue_id => '25' }
414 )
415 end
416
417 def test_repositories_related_issues_with_repository_id
418 assert_routing(
419 { :method => 'post',
420 :path => "/projects/redmine/repository/foo/revisions/123/issues" },
421 { :controller => 'repositories', :action => 'add_related_issue',
422 :id => 'redmine', :repository_id => 'foo', :rev => '123' }
423 )
424 assert_routing(
425 { :method => 'delete',
426 :path => "/projects/redmine/repository/foo/revisions/123/issues/25" },
427 { :controller => 'repositories', :action => 'remove_related_issue',
428 :id => 'redmine', :repository_id => 'foo', :rev => '123', :issue_id => '25' }
429 )
430 end
431 end