@@ -1,346 +1,352 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
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 |
|
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. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.expand_path('../../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../../test_helper', __FILE__) | |
19 |
|
19 | |||
20 | class RoutingRepositoriesTest < ActionController::IntegrationTest |
|
20 | class RoutingRepositoriesTest < ActionController::IntegrationTest | |
21 | def setup |
|
21 | def setup | |
22 | @path_hash = repository_path_hash(%w[path to file.c]) |
|
22 | @path_hash = repository_path_hash(%w[path to file.c]) | |
23 | assert_equal "path/to/file.c", @path_hash[:path] |
|
23 | assert_equal "path/to/file.c", @path_hash[:path] | |
24 | assert_equal %w[path to file.c], @path_hash[:param] |
|
24 | assert_equal %w[path to file.c], @path_hash[:param] | |
25 | end |
|
25 | end | |
26 |
|
26 | |||
27 | def test_repositories_resources |
|
27 | def test_repositories_resources | |
28 | assert_routing( |
|
28 | assert_routing( | |
29 | { :method => 'get', |
|
29 | { :method => 'get', | |
30 | :path => "/projects/redmine/repositories/new" }, |
|
30 | :path => "/projects/redmine/repositories/new" }, | |
31 | { :controller => 'repositories', :action => 'new', :project_id => 'redmine' } |
|
31 | { :controller => 'repositories', :action => 'new', :project_id => 'redmine' } | |
32 | ) |
|
32 | ) | |
33 | assert_routing( |
|
33 | assert_routing( | |
34 | { :method => 'post', |
|
34 | { :method => 'post', | |
35 | :path => "/projects/redmine/repositories" }, |
|
35 | :path => "/projects/redmine/repositories" }, | |
36 | { :controller => 'repositories', :action => 'create', :project_id => 'redmine' } |
|
36 | { :controller => 'repositories', :action => 'create', :project_id => 'redmine' } | |
37 | ) |
|
37 | ) | |
38 | assert_routing( |
|
38 | assert_routing( | |
39 | { :method => 'get', |
|
39 | { :method => 'get', | |
40 | :path => "/repositories/1/edit" }, |
|
40 | :path => "/repositories/1/edit" }, | |
41 | { :controller => 'repositories', :action => 'edit', :id => '1' } |
|
41 | { :controller => 'repositories', :action => 'edit', :id => '1' } | |
42 | ) |
|
42 | ) | |
43 | assert_routing( |
|
43 | assert_routing( | |
44 | { :method => 'put', |
|
44 | { :method => 'put', | |
45 | :path => "/repositories/1" }, |
|
45 | :path => "/repositories/1" }, | |
46 | { :controller => 'repositories', :action => 'update', :id => '1' } |
|
46 | { :controller => 'repositories', :action => 'update', :id => '1' } | |
47 | ) |
|
47 | ) | |
48 | assert_routing( |
|
48 | assert_routing( | |
49 | { :method => 'delete', |
|
49 | { :method => 'delete', | |
50 | :path => "/repositories/1" }, |
|
50 | :path => "/repositories/1" }, | |
51 | { :controller => 'repositories', :action => 'destroy', :id => '1' } |
|
51 | { :controller => 'repositories', :action => 'destroy', :id => '1' } | |
52 | ) |
|
52 | ) | |
53 | ["get", "post"].each do |method| |
|
53 | ["get", "post"].each do |method| | |
54 | assert_routing( |
|
54 | assert_routing( | |
55 | { :method => method, |
|
55 | { :method => method, | |
56 | :path => "/repositories/1/committers" }, |
|
56 | :path => "/repositories/1/committers" }, | |
57 | { :controller => 'repositories', :action => 'committers', :id => '1' } |
|
57 | { :controller => 'repositories', :action => 'committers', :id => '1' } | |
58 | ) |
|
58 | ) | |
59 | end |
|
59 | end | |
60 | end |
|
60 | end | |
61 |
|
61 | |||
62 | def test_repositories |
|
62 | def test_repositories_show | |
63 | assert_routing( |
|
63 | assert_routing( | |
64 | { :method => 'get', |
|
64 | { :method => 'get', | |
65 | :path => "/projects/redmine/repository" }, |
|
65 | :path => "/projects/redmine/repository" }, | |
66 | { :controller => 'repositories', :action => 'show', :id => 'redmine' } |
|
66 | { :controller => 'repositories', :action => 'show', :id => 'redmine' } | |
67 | ) |
|
67 | ) | |
|
68 | end | |||
|
69 | ||||
|
70 | def test_repositories | |||
68 | assert_routing( |
|
71 | assert_routing( | |
69 | { :method => 'get', |
|
72 | { :method => 'get', | |
70 | :path => "/projects/redmine/repository/statistics" }, |
|
73 | :path => "/projects/redmine/repository/statistics" }, | |
71 | { :controller => 'repositories', :action => 'stats', :id => 'redmine' } |
|
74 | { :controller => 'repositories', :action => 'stats', :id => 'redmine' } | |
72 | ) |
|
75 | ) | |
73 | assert_routing( |
|
76 | assert_routing( | |
74 | { :method => 'get', |
|
77 | { :method => 'get', | |
75 | :path => "/projects/redmine/repository/graph" }, |
|
78 | :path => "/projects/redmine/repository/graph" }, | |
76 | { :controller => 'repositories', :action => 'graph', :id => 'redmine' } |
|
79 | { :controller => 'repositories', :action => 'graph', :id => 'redmine' } | |
77 | ) |
|
80 | ) | |
78 | end |
|
81 | end | |
79 |
|
82 | |||
80 | def test_repositories_with_repository_id |
|
83 | def test_repositories_show_with_repository_id | |
81 | assert_routing( |
|
84 | assert_routing( | |
82 | { :method => 'get', |
|
85 | { :method => 'get', | |
83 | :path => "/projects/redmine/repository/foo" }, |
|
86 | :path => "/projects/redmine/repository/foo" }, | |
84 | { :controller => 'repositories', :action => 'show', :id => 'redmine', :repository_id => 'foo' } |
|
87 | { :controller => 'repositories', :action => 'show', :id => 'redmine', :repository_id => 'foo' } | |
85 | ) |
|
88 | ) | |
|
89 | end | |||
|
90 | ||||
|
91 | def test_repositories_with_repository_id | |||
86 | assert_routing( |
|
92 | assert_routing( | |
87 | { :method => 'get', |
|
93 | { :method => 'get', | |
88 | :path => "/projects/redmine/repository/foo/statistics" }, |
|
94 | :path => "/projects/redmine/repository/foo/statistics" }, | |
89 | { :controller => 'repositories', :action => 'stats', :id => 'redmine', :repository_id => 'foo' } |
|
95 | { :controller => 'repositories', :action => 'stats', :id => 'redmine', :repository_id => 'foo' } | |
90 | ) |
|
96 | ) | |
91 | assert_routing( |
|
97 | assert_routing( | |
92 | { :method => 'get', |
|
98 | { :method => 'get', | |
93 | :path => "/projects/redmine/repository/foo/graph" }, |
|
99 | :path => "/projects/redmine/repository/foo/graph" }, | |
94 | { :controller => 'repositories', :action => 'graph', :id => 'redmine', :repository_id => 'foo' } |
|
100 | { :controller => 'repositories', :action => 'graph', :id => 'redmine', :repository_id => 'foo' } | |
95 | ) |
|
101 | ) | |
96 | end |
|
102 | end | |
97 |
|
103 | |||
98 | def test_repositories_revisions |
|
104 | def test_repositories_revisions | |
99 | empty_path_param = [] |
|
105 | empty_path_param = [] | |
100 | assert_routing( |
|
106 | assert_routing( | |
101 | { :method => 'get', |
|
107 | { :method => 'get', | |
102 | :path => "/projects/redmine/repository/revisions" }, |
|
108 | :path => "/projects/redmine/repository/revisions" }, | |
103 | { :controller => 'repositories', :action => 'revisions', :id => 'redmine' } |
|
109 | { :controller => 'repositories', :action => 'revisions', :id => 'redmine' } | |
104 | ) |
|
110 | ) | |
105 | assert_routing( |
|
111 | assert_routing( | |
106 | { :method => 'get', |
|
112 | { :method => 'get', | |
107 | :path => "/projects/redmine/repository/revisions.atom" }, |
|
113 | :path => "/projects/redmine/repository/revisions.atom" }, | |
108 | { :controller => 'repositories', :action => 'revisions', :id => 'redmine', |
|
114 | { :controller => 'repositories', :action => 'revisions', :id => 'redmine', | |
109 | :format => 'atom' } |
|
115 | :format => 'atom' } | |
110 | ) |
|
116 | ) | |
111 | assert_routing( |
|
117 | assert_routing( | |
112 | { :method => 'get', |
|
118 | { :method => 'get', | |
113 | :path => "/projects/redmine/repository/revisions/2457" }, |
|
119 | :path => "/projects/redmine/repository/revisions/2457" }, | |
114 | { :controller => 'repositories', :action => 'revision', :id => 'redmine', |
|
120 | { :controller => 'repositories', :action => 'revision', :id => 'redmine', | |
115 | :rev => '2457' } |
|
121 | :rev => '2457' } | |
116 | ) |
|
122 | ) | |
117 | assert_routing( |
|
123 | assert_routing( | |
118 | { :method => 'get', |
|
124 | { :method => 'get', | |
119 | :path => "/projects/redmine/repository/revisions/2457/show" }, |
|
125 | :path => "/projects/redmine/repository/revisions/2457/show" }, | |
120 | { :controller => 'repositories', :action => 'show', :id => 'redmine', |
|
126 | { :controller => 'repositories', :action => 'show', :id => 'redmine', | |
121 | :path => empty_path_param, :rev => '2457' } |
|
127 | :path => empty_path_param, :rev => '2457' } | |
122 | ) |
|
128 | ) | |
123 | assert_routing( |
|
129 | assert_routing( | |
124 | { :method => 'get', |
|
130 | { :method => 'get', | |
125 | :path => "/projects/redmine/repository/revisions/2457/show/#{@path_hash[:path]}" }, |
|
131 | :path => "/projects/redmine/repository/revisions/2457/show/#{@path_hash[:path]}" }, | |
126 | { :controller => 'repositories', :action => 'show', :id => 'redmine', |
|
132 | { :controller => 'repositories', :action => 'show', :id => 'redmine', | |
127 | :path => @path_hash[:param] , :rev => '2457'} |
|
133 | :path => @path_hash[:param] , :rev => '2457'} | |
128 | ) |
|
134 | ) | |
129 | assert_routing( |
|
135 | assert_routing( | |
130 | { :method => 'get', |
|
136 | { :method => 'get', | |
131 | :path => "/projects/redmine/repository/revisions/2457/changes" }, |
|
137 | :path => "/projects/redmine/repository/revisions/2457/changes" }, | |
132 | { :controller => 'repositories', :action => 'changes', :id => 'redmine', |
|
138 | { :controller => 'repositories', :action => 'changes', :id => 'redmine', | |
133 | :path => empty_path_param, :rev => '2457' } |
|
139 | :path => empty_path_param, :rev => '2457' } | |
134 | ) |
|
140 | ) | |
135 | assert_routing( |
|
141 | assert_routing( | |
136 | { :method => 'get', |
|
142 | { :method => 'get', | |
137 | :path => "/projects/redmine/repository/revisions/2457/changes/#{@path_hash[:path]}" }, |
|
143 | :path => "/projects/redmine/repository/revisions/2457/changes/#{@path_hash[:path]}" }, | |
138 | { :controller => 'repositories', :action => 'changes', :id => 'redmine', |
|
144 | { :controller => 'repositories', :action => 'changes', :id => 'redmine', | |
139 | :path => @path_hash[:param] , :rev => '2457'} |
|
145 | :path => @path_hash[:param] , :rev => '2457'} | |
140 | ) |
|
146 | ) | |
141 | assert_routing( |
|
147 | assert_routing( | |
142 | { :method => 'get', |
|
148 | { :method => 'get', | |
143 | :path => "/projects/redmine/repository/revisions/2457/diff" }, |
|
149 | :path => "/projects/redmine/repository/revisions/2457/diff" }, | |
144 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', |
|
150 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', | |
145 | :rev => '2457' } |
|
151 | :rev => '2457' } | |
146 | ) |
|
152 | ) | |
147 | assert_routing( |
|
153 | assert_routing( | |
148 | { :method => 'get', |
|
154 | { :method => 'get', | |
149 | :path => "/projects/redmine/repository/revisions/2457/diff.diff" }, |
|
155 | :path => "/projects/redmine/repository/revisions/2457/diff.diff" }, | |
150 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', |
|
156 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', | |
151 | :rev => '2457', :format => 'diff' } |
|
157 | :rev => '2457', :format => 'diff' } | |
152 | ) |
|
158 | ) | |
153 | assert_routing( |
|
159 | assert_routing( | |
154 | { :method => 'get', |
|
160 | { :method => 'get', | |
155 | :path => "/projects/redmine/repository/revisions/2/diff/#{@path_hash[:path]}" }, |
|
161 | :path => "/projects/redmine/repository/revisions/2/diff/#{@path_hash[:path]}" }, | |
156 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', |
|
162 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', | |
157 | :path => @path_hash[:param], :rev => '2' } |
|
163 | :path => @path_hash[:param], :rev => '2' } | |
158 | ) |
|
164 | ) | |
159 | assert_routing( |
|
165 | assert_routing( | |
160 | { :method => 'get', |
|
166 | { :method => 'get', | |
161 | :path => "/projects/redmine/repository/revisions/2/entry/#{@path_hash[:path]}" }, |
|
167 | :path => "/projects/redmine/repository/revisions/2/entry/#{@path_hash[:path]}" }, | |
162 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', |
|
168 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', | |
163 | :path => @path_hash[:param], :rev => '2' } |
|
169 | :path => @path_hash[:param], :rev => '2' } | |
164 | ) |
|
170 | ) | |
165 | assert_routing( |
|
171 | assert_routing( | |
166 | { :method => 'get', |
|
172 | { :method => 'get', | |
167 | :path => "/projects/redmine/repository/revisions/2/raw/#{@path_hash[:path]}" }, |
|
173 | :path => "/projects/redmine/repository/revisions/2/raw/#{@path_hash[:path]}" }, | |
168 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', |
|
174 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', | |
169 | :path => @path_hash[:param], :rev => '2', :format => 'raw' } |
|
175 | :path => @path_hash[:param], :rev => '2', :format => 'raw' } | |
170 | ) |
|
176 | ) | |
171 | assert_routing( |
|
177 | assert_routing( | |
172 | { :method => 'get', |
|
178 | { :method => 'get', | |
173 | :path => "/projects/redmine/repository/revisions/2/annotate/#{@path_hash[:path]}" }, |
|
179 | :path => "/projects/redmine/repository/revisions/2/annotate/#{@path_hash[:path]}" }, | |
174 | { :controller => 'repositories', :action => 'annotate', :id => 'redmine', |
|
180 | { :controller => 'repositories', :action => 'annotate', :id => 'redmine', | |
175 | :path => @path_hash[:param], :rev => '2' } |
|
181 | :path => @path_hash[:param], :rev => '2' } | |
176 | ) |
|
182 | ) | |
177 | end |
|
183 | end | |
178 |
|
184 | |||
179 | def test_repositories_revisions_with_repository_id |
|
185 | def test_repositories_revisions_with_repository_id | |
180 | empty_path_param = [] |
|
186 | empty_path_param = [] | |
181 | assert_routing( |
|
187 | assert_routing( | |
182 | { :method => 'get', |
|
188 | { :method => 'get', | |
183 | :path => "/projects/redmine/repository/foo/revisions" }, |
|
189 | :path => "/projects/redmine/repository/foo/revisions" }, | |
184 | { :controller => 'repositories', :action => 'revisions', :id => 'redmine', :repository_id => 'foo' } |
|
190 | { :controller => 'repositories', :action => 'revisions', :id => 'redmine', :repository_id => 'foo' } | |
185 | ) |
|
191 | ) | |
186 | assert_routing( |
|
192 | assert_routing( | |
187 | { :method => 'get', |
|
193 | { :method => 'get', | |
188 | :path => "/projects/redmine/repository/foo/revisions.atom" }, |
|
194 | :path => "/projects/redmine/repository/foo/revisions.atom" }, | |
189 | { :controller => 'repositories', :action => 'revisions', :id => 'redmine', :repository_id => 'foo', |
|
195 | { :controller => 'repositories', :action => 'revisions', :id => 'redmine', :repository_id => 'foo', | |
190 | :format => 'atom' } |
|
196 | :format => 'atom' } | |
191 | ) |
|
197 | ) | |
192 | assert_routing( |
|
198 | assert_routing( | |
193 | { :method => 'get', |
|
199 | { :method => 'get', | |
194 | :path => "/projects/redmine/repository/foo/revisions/2457" }, |
|
200 | :path => "/projects/redmine/repository/foo/revisions/2457" }, | |
195 | { :controller => 'repositories', :action => 'revision', :id => 'redmine', :repository_id => 'foo', |
|
201 | { :controller => 'repositories', :action => 'revision', :id => 'redmine', :repository_id => 'foo', | |
196 | :rev => '2457' } |
|
202 | :rev => '2457' } | |
197 | ) |
|
203 | ) | |
198 | assert_routing( |
|
204 | assert_routing( | |
199 | { :method => 'get', |
|
205 | { :method => 'get', | |
200 | :path => "/projects/redmine/repository/foo/revisions/2457/show" }, |
|
206 | :path => "/projects/redmine/repository/foo/revisions/2457/show" }, | |
201 | { :controller => 'repositories', :action => 'show', :id => 'redmine', :repository_id => 'foo', |
|
207 | { :controller => 'repositories', :action => 'show', :id => 'redmine', :repository_id => 'foo', | |
202 | :path => empty_path_param, :rev => '2457' } |
|
208 | :path => empty_path_param, :rev => '2457' } | |
203 | ) |
|
209 | ) | |
204 | assert_routing( |
|
210 | assert_routing( | |
205 | { :method => 'get', |
|
211 | { :method => 'get', | |
206 | :path => "/projects/redmine/repository/foo/revisions/2457/show/#{@path_hash[:path]}" }, |
|
212 | :path => "/projects/redmine/repository/foo/revisions/2457/show/#{@path_hash[:path]}" }, | |
207 | { :controller => 'repositories', :action => 'show', :id => 'redmine', :repository_id => 'foo', |
|
213 | { :controller => 'repositories', :action => 'show', :id => 'redmine', :repository_id => 'foo', | |
208 | :path => @path_hash[:param] , :rev => '2457'} |
|
214 | :path => @path_hash[:param] , :rev => '2457'} | |
209 | ) |
|
215 | ) | |
210 | assert_routing( |
|
216 | assert_routing( | |
211 | { :method => 'get', |
|
217 | { :method => 'get', | |
212 | :path => "/projects/redmine/repository/foo/revisions/2457/changes" }, |
|
218 | :path => "/projects/redmine/repository/foo/revisions/2457/changes" }, | |
213 | { :controller => 'repositories', :action => 'changes', :id => 'redmine', :repository_id => 'foo', |
|
219 | { :controller => 'repositories', :action => 'changes', :id => 'redmine', :repository_id => 'foo', | |
214 | :path => empty_path_param, :rev => '2457' } |
|
220 | :path => empty_path_param, :rev => '2457' } | |
215 | ) |
|
221 | ) | |
216 | assert_routing( |
|
222 | assert_routing( | |
217 | { :method => 'get', |
|
223 | { :method => 'get', | |
218 | :path => "/projects/redmine/repository/foo/revisions/2457/changes/#{@path_hash[:path]}" }, |
|
224 | :path => "/projects/redmine/repository/foo/revisions/2457/changes/#{@path_hash[:path]}" }, | |
219 | { :controller => 'repositories', :action => 'changes', :id => 'redmine', :repository_id => 'foo', |
|
225 | { :controller => 'repositories', :action => 'changes', :id => 'redmine', :repository_id => 'foo', | |
220 | :path => @path_hash[:param] , :rev => '2457'} |
|
226 | :path => @path_hash[:param] , :rev => '2457'} | |
221 | ) |
|
227 | ) | |
222 | assert_routing( |
|
228 | assert_routing( | |
223 | { :method => 'get', |
|
229 | { :method => 'get', | |
224 | :path => "/projects/redmine/repository/foo/revisions/2457/diff" }, |
|
230 | :path => "/projects/redmine/repository/foo/revisions/2457/diff" }, | |
225 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', :repository_id => 'foo', |
|
231 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', :repository_id => 'foo', | |
226 | :rev => '2457' } |
|
232 | :rev => '2457' } | |
227 | ) |
|
233 | ) | |
228 | assert_routing( |
|
234 | assert_routing( | |
229 | { :method => 'get', |
|
235 | { :method => 'get', | |
230 | :path => "/projects/redmine/repository/foo/revisions/2457/diff.diff" }, |
|
236 | :path => "/projects/redmine/repository/foo/revisions/2457/diff.diff" }, | |
231 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', :repository_id => 'foo', |
|
237 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', :repository_id => 'foo', | |
232 | :rev => '2457', :format => 'diff' } |
|
238 | :rev => '2457', :format => 'diff' } | |
233 | ) |
|
239 | ) | |
234 | assert_routing( |
|
240 | assert_routing( | |
235 | { :method => 'get', |
|
241 | { :method => 'get', | |
236 | :path => "/projects/redmine/repository/foo/revisions/2/diff/#{@path_hash[:path]}" }, |
|
242 | :path => "/projects/redmine/repository/foo/revisions/2/diff/#{@path_hash[:path]}" }, | |
237 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', :repository_id => 'foo', |
|
243 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', :repository_id => 'foo', | |
238 | :path => @path_hash[:param], :rev => '2' } |
|
244 | :path => @path_hash[:param], :rev => '2' } | |
239 | ) |
|
245 | ) | |
240 | assert_routing( |
|
246 | assert_routing( | |
241 | { :method => 'get', |
|
247 | { :method => 'get', | |
242 | :path => "/projects/redmine/repository/foo/revisions/2/entry/#{@path_hash[:path]}" }, |
|
248 | :path => "/projects/redmine/repository/foo/revisions/2/entry/#{@path_hash[:path]}" }, | |
243 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', :repository_id => 'foo', |
|
249 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', :repository_id => 'foo', | |
244 | :path => @path_hash[:param], :rev => '2' } |
|
250 | :path => @path_hash[:param], :rev => '2' } | |
245 | ) |
|
251 | ) | |
246 | assert_routing( |
|
252 | assert_routing( | |
247 | { :method => 'get', |
|
253 | { :method => 'get', | |
248 | :path => "/projects/redmine/repository/foo/revisions/2/raw/#{@path_hash[:path]}" }, |
|
254 | :path => "/projects/redmine/repository/foo/revisions/2/raw/#{@path_hash[:path]}" }, | |
249 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', :repository_id => 'foo', |
|
255 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', :repository_id => 'foo', | |
250 | :path => @path_hash[:param], :rev => '2', :format => 'raw' } |
|
256 | :path => @path_hash[:param], :rev => '2', :format => 'raw' } | |
251 | ) |
|
257 | ) | |
252 | assert_routing( |
|
258 | assert_routing( | |
253 | { :method => 'get', |
|
259 | { :method => 'get', | |
254 | :path => "/projects/redmine/repository/foo/revisions/2/annotate/#{@path_hash[:path]}" }, |
|
260 | :path => "/projects/redmine/repository/foo/revisions/2/annotate/#{@path_hash[:path]}" }, | |
255 | { :controller => 'repositories', :action => 'annotate', :id => 'redmine', :repository_id => 'foo', |
|
261 | { :controller => 'repositories', :action => 'annotate', :id => 'redmine', :repository_id => 'foo', | |
256 | :path => @path_hash[:param], :rev => '2' } |
|
262 | :path => @path_hash[:param], :rev => '2' } | |
257 | ) |
|
263 | ) | |
258 | end |
|
264 | end | |
259 |
|
265 | |||
260 | def test_repositories_non_revisions_path |
|
266 | def test_repositories_non_revisions_path | |
261 | assert_routing( |
|
267 | assert_routing( | |
262 | { :method => 'get', |
|
268 | { :method => 'get', | |
263 | :path => "/projects/redmine/repository/diff/#{@path_hash[:path]}" }, |
|
269 | :path => "/projects/redmine/repository/diff/#{@path_hash[:path]}" }, | |
264 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', |
|
270 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', | |
265 | :path => @path_hash[:param] } |
|
271 | :path => @path_hash[:param] } | |
266 | ) |
|
272 | ) | |
267 | assert_routing( |
|
273 | assert_routing( | |
268 | { :method => 'get', |
|
274 | { :method => 'get', | |
269 | :path => "/projects/redmine/repository/browse/#{@path_hash[:path]}" }, |
|
275 | :path => "/projects/redmine/repository/browse/#{@path_hash[:path]}" }, | |
270 | { :controller => 'repositories', :action => 'browse', :id => 'redmine', |
|
276 | { :controller => 'repositories', :action => 'browse', :id => 'redmine', | |
271 | :path => @path_hash[:param] } |
|
277 | :path => @path_hash[:param] } | |
272 | ) |
|
278 | ) | |
273 | assert_routing( |
|
279 | assert_routing( | |
274 | { :method => 'get', |
|
280 | { :method => 'get', | |
275 | :path => "/projects/redmine/repository/entry/#{@path_hash[:path]}" }, |
|
281 | :path => "/projects/redmine/repository/entry/#{@path_hash[:path]}" }, | |
276 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', |
|
282 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', | |
277 | :path => @path_hash[:param] } |
|
283 | :path => @path_hash[:param] } | |
278 | ) |
|
284 | ) | |
279 | assert_routing( |
|
285 | assert_routing( | |
280 | { :method => 'get', |
|
286 | { :method => 'get', | |
281 | :path => "/projects/redmine/repository/raw/#{@path_hash[:path]}" }, |
|
287 | :path => "/projects/redmine/repository/raw/#{@path_hash[:path]}" }, | |
282 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', |
|
288 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', | |
283 | :path => @path_hash[:param], :format => 'raw' } |
|
289 | :path => @path_hash[:param], :format => 'raw' } | |
284 | ) |
|
290 | ) | |
285 | assert_routing( |
|
291 | assert_routing( | |
286 | { :method => 'get', |
|
292 | { :method => 'get', | |
287 | :path => "/projects/redmine/repository/annotate/#{@path_hash[:path]}" }, |
|
293 | :path => "/projects/redmine/repository/annotate/#{@path_hash[:path]}" }, | |
288 | { :controller => 'repositories', :action => 'annotate', :id => 'redmine', |
|
294 | { :controller => 'repositories', :action => 'annotate', :id => 'redmine', | |
289 | :path => @path_hash[:param] } |
|
295 | :path => @path_hash[:param] } | |
290 | ) |
|
296 | ) | |
291 | assert_routing( |
|
297 | assert_routing( | |
292 | { :method => 'get', |
|
298 | { :method => 'get', | |
293 | :path => "/projects/redmine/repository/changes/#{@path_hash[:path]}" }, |
|
299 | :path => "/projects/redmine/repository/changes/#{@path_hash[:path]}" }, | |
294 | { :controller => 'repositories', :action => 'changes', :id => 'redmine', |
|
300 | { :controller => 'repositories', :action => 'changes', :id => 'redmine', | |
295 | :path => @path_hash[:param] } |
|
301 | :path => @path_hash[:param] } | |
296 | ) |
|
302 | ) | |
297 | end |
|
303 | end | |
298 |
|
304 | |||
299 | def test_repositories_non_revisions_path_with_repository_id |
|
305 | def test_repositories_non_revisions_path_with_repository_id | |
300 | assert_routing( |
|
306 | assert_routing( | |
301 | { :method => 'get', |
|
307 | { :method => 'get', | |
302 | :path => "/projects/redmine/repository/foo/diff/#{@path_hash[:path]}" }, |
|
308 | :path => "/projects/redmine/repository/foo/diff/#{@path_hash[:path]}" }, | |
303 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', :repository_id => 'foo', |
|
309 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', :repository_id => 'foo', | |
304 | :path => @path_hash[:param] } |
|
310 | :path => @path_hash[:param] } | |
305 | ) |
|
311 | ) | |
306 | assert_routing( |
|
312 | assert_routing( | |
307 | { :method => 'get', |
|
313 | { :method => 'get', | |
308 | :path => "/projects/redmine/repository/foo/browse/#{@path_hash[:path]}" }, |
|
314 | :path => "/projects/redmine/repository/foo/browse/#{@path_hash[:path]}" }, | |
309 | { :controller => 'repositories', :action => 'browse', :id => 'redmine', :repository_id => 'foo', |
|
315 | { :controller => 'repositories', :action => 'browse', :id => 'redmine', :repository_id => 'foo', | |
310 | :path => @path_hash[:param] } |
|
316 | :path => @path_hash[:param] } | |
311 | ) |
|
317 | ) | |
312 | assert_routing( |
|
318 | assert_routing( | |
313 | { :method => 'get', |
|
319 | { :method => 'get', | |
314 | :path => "/projects/redmine/repository/foo/entry/#{@path_hash[:path]}" }, |
|
320 | :path => "/projects/redmine/repository/foo/entry/#{@path_hash[:path]}" }, | |
315 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', :repository_id => 'foo', |
|
321 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', :repository_id => 'foo', | |
316 | :path => @path_hash[:param] } |
|
322 | :path => @path_hash[:param] } | |
317 | ) |
|
323 | ) | |
318 | assert_routing( |
|
324 | assert_routing( | |
319 | { :method => 'get', |
|
325 | { :method => 'get', | |
320 | :path => "/projects/redmine/repository/foo/raw/#{@path_hash[:path]}" }, |
|
326 | :path => "/projects/redmine/repository/foo/raw/#{@path_hash[:path]}" }, | |
321 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', :repository_id => 'foo', |
|
327 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', :repository_id => 'foo', | |
322 | :path => @path_hash[:param], :format => 'raw' } |
|
328 | :path => @path_hash[:param], :format => 'raw' } | |
323 | ) |
|
329 | ) | |
324 | assert_routing( |
|
330 | assert_routing( | |
325 | { :method => 'get', |
|
331 | { :method => 'get', | |
326 | :path => "/projects/redmine/repository/foo/annotate/#{@path_hash[:path]}" }, |
|
332 | :path => "/projects/redmine/repository/foo/annotate/#{@path_hash[:path]}" }, | |
327 | { :controller => 'repositories', :action => 'annotate', :id => 'redmine', :repository_id => 'foo', |
|
333 | { :controller => 'repositories', :action => 'annotate', :id => 'redmine', :repository_id => 'foo', | |
328 | :path => @path_hash[:param] } |
|
334 | :path => @path_hash[:param] } | |
329 | ) |
|
335 | ) | |
330 | assert_routing( |
|
336 | assert_routing( | |
331 | { :method => 'get', |
|
337 | { :method => 'get', | |
332 | :path => "/projects/redmine/repository/foo/changes/#{@path_hash[:path]}" }, |
|
338 | :path => "/projects/redmine/repository/foo/changes/#{@path_hash[:path]}" }, | |
333 | { :controller => 'repositories', :action => 'changes', :id => 'redmine', :repository_id => 'foo', |
|
339 | { :controller => 'repositories', :action => 'changes', :id => 'redmine', :repository_id => 'foo', | |
334 | :path => @path_hash[:param] } |
|
340 | :path => @path_hash[:param] } | |
335 | ) |
|
341 | ) | |
336 | end |
|
342 | end | |
337 |
|
343 | |||
338 | private |
|
344 | private | |
339 |
|
345 | |||
340 | def repository_path_hash(arr) |
|
346 | def repository_path_hash(arr) | |
341 | hs = {} |
|
347 | hs = {} | |
342 | hs[:path] = arr.join("/") |
|
348 | hs[:path] = arr.join("/") | |
343 | hs[:param] = arr |
|
349 | hs[:param] = arr | |
344 | hs |
|
350 | hs | |
345 | end |
|
351 | end | |
346 | end |
|
352 | end |
General Comments 0
You need to be logged in to leave comments.
Login now