##// END OF EJS Templates
test: route: move projects test to new file...
Toshi MARUYAMA -
r8240:0bfdf7d5b759
parent child
Show More
@@ -0,0 +1,91
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 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 RoutingProjectsTest < ActionController::IntegrationTest
21 def test_projects
22 assert_routing(
23 { :method => 'get', :path => "/projects" },
24 { :controller => 'projects', :action => 'index' }
25 )
26 assert_routing(
27 { :method => 'get', :path => "/projects.atom" },
28 { :controller => 'projects', :action => 'index', :format => 'atom' }
29 )
30 assert_routing(
31 { :method => 'get', :path => "/projects.xml" },
32 { :controller => 'projects', :action => 'index', :format => 'xml' }
33 )
34 assert_routing(
35 { :method => 'get', :path => "/projects/new" },
36 { :controller => 'projects', :action => 'new' }
37 )
38 assert_routing(
39 { :method => 'get', :path => "/projects/test" },
40 { :controller => 'projects', :action => 'show', :id => 'test' }
41 )
42 assert_routing(
43 { :method => 'get', :path => "/projects/1.xml" },
44 { :controller => 'projects', :action => 'show', :id => '1',
45 :format => 'xml' }
46 )
47 assert_routing(
48 { :method => 'get', :path => "/projects/4223/settings" },
49 { :controller => 'projects', :action => 'settings', :id => '4223' }
50 )
51 assert_routing(
52 { :method => 'get', :path => "/projects/4223/settings/members" },
53 { :controller => 'projects', :action => 'settings', :id => '4223',
54 :tab => 'members' }
55 )
56 assert_routing(
57 { :method => 'post', :path => "/projects" },
58 { :controller => 'projects', :action => 'create' }
59 )
60 assert_routing(
61 { :method => 'post', :path => "/projects.xml" },
62 { :controller => 'projects', :action => 'create', :format => 'xml' }
63 )
64 assert_routing(
65 { :method => 'post', :path => "/projects/64/archive" },
66 { :controller => 'projects', :action => 'archive', :id => '64' }
67 )
68 assert_routing(
69 { :method => 'post', :path => "/projects/64/unarchive" },
70 { :controller => 'projects', :action => 'unarchive', :id => '64' }
71 )
72 assert_routing(
73 { :method => 'put', :path => "/projects/4223" },
74 { :controller => 'projects', :action => 'update', :id => '4223' }
75 )
76 assert_routing(
77 { :method => 'put', :path => "/projects/1.xml" },
78 { :controller => 'projects', :action => 'update', :id => '1',
79 :format => 'xml' }
80 )
81 assert_routing(
82 { :method => 'delete', :path => "/projects/64" },
83 { :controller => 'projects', :action => 'destroy', :id => '64' }
84 )
85 assert_routing(
86 { :method => 'delete', :path => "/projects/1.xml" },
87 { :controller => 'projects', :action => 'destroy', :id => '1',
88 :format => 'xml' }
89 )
90 end
91 end
@@ -1,234 +1,163
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 RoutingTest < ActionController::IntegrationTest
20 class RoutingTest < ActionController::IntegrationTest
21 def test_projects
22 assert_routing(
23 { :method => 'get', :path => "/projects" },
24 { :controller => 'projects', :action => 'index' }
25 )
26 assert_routing(
27 { :method => 'get', :path => "/projects.atom" },
28 { :controller => 'projects', :action => 'index', :format => 'atom' }
29 )
30 assert_routing(
31 { :method => 'get', :path => "/projects.xml" },
32 { :controller => 'projects', :action => 'index', :format => 'xml' }
33 )
34 assert_routing(
35 { :method => 'get', :path => "/projects/new" },
36 { :controller => 'projects', :action => 'new' }
37 )
38 assert_routing(
39 { :method => 'get', :path => "/projects/test" },
40 { :controller => 'projects', :action => 'show', :id => 'test' }
41 )
42 assert_routing(
43 { :method => 'get', :path => "/projects/1.xml" },
44 { :controller => 'projects', :action => 'show', :id => '1',
45 :format => 'xml' }
46 )
47 assert_routing(
48 { :method => 'get', :path => "/projects/4223/settings" },
49 { :controller => 'projects', :action => 'settings', :id => '4223' }
50 )
51 assert_routing(
52 { :method => 'get', :path => "/projects/4223/settings/members" },
53 { :controller => 'projects', :action => 'settings', :id => '4223',
54 :tab => 'members' }
55 )
56 assert_routing(
57 { :method => 'post', :path => "/projects" },
58 { :controller => 'projects', :action => 'create' }
59 )
60 assert_routing(
61 { :method => 'post', :path => "/projects.xml" },
62 { :controller => 'projects', :action => 'create', :format => 'xml' }
63 )
64 assert_routing(
65 { :method => 'post', :path => "/projects/64/archive" },
66 { :controller => 'projects', :action => 'archive', :id => '64' }
67 )
68 assert_routing(
69 { :method => 'post', :path => "/projects/64/unarchive" },
70 { :controller => 'projects', :action => 'unarchive', :id => '64' }
71 )
72 assert_routing(
73 { :method => 'put', :path => "/projects/4223" },
74 { :controller => 'projects', :action => 'update', :id => '4223' }
75 )
76 assert_routing(
77 { :method => 'put', :path => "/projects/1.xml" },
78 { :controller => 'projects', :action => 'update', :id => '1',
79 :format => 'xml' }
80 )
81 assert_routing(
82 { :method => 'delete', :path => "/projects/64" },
83 { :controller => 'projects', :action => 'destroy', :id => '64' }
84 )
85 assert_routing(
86 { :method => 'delete', :path => "/projects/1.xml" },
87 { :controller => 'projects', :action => 'destroy', :id => '1',
88 :format => 'xml' }
89 )
90 end
91
92 def test_queries
21 def test_queries
93 assert_routing(
22 assert_routing(
94 { :method => 'get', :path => "/queries.xml" },
23 { :method => 'get', :path => "/queries.xml" },
95 { :controller => 'queries', :action => 'index', :format => 'xml' }
24 { :controller => 'queries', :action => 'index', :format => 'xml' }
96 )
25 )
97 assert_routing(
26 assert_routing(
98 { :method => 'get', :path => "/queries.json" },
27 { :method => 'get', :path => "/queries.json" },
99 { :controller => 'queries', :action => 'index', :format => 'json' }
28 { :controller => 'queries', :action => 'index', :format => 'json' }
100 )
29 )
101 assert_routing(
30 assert_routing(
102 { :method => 'get', :path => "/queries/new" },
31 { :method => 'get', :path => "/queries/new" },
103 { :controller => 'queries', :action => 'new' }
32 { :controller => 'queries', :action => 'new' }
104 )
33 )
105 assert_routing(
34 assert_routing(
106 { :method => 'get', :path => "/projects/redmine/queries/new" },
35 { :method => 'get', :path => "/projects/redmine/queries/new" },
107 { :controller => 'queries', :action => 'new', :project_id => 'redmine' }
36 { :controller => 'queries', :action => 'new', :project_id => 'redmine' }
108 )
37 )
109 assert_routing(
38 assert_routing(
110 { :method => 'post', :path => "/queries" },
39 { :method => 'post', :path => "/queries" },
111 { :controller => 'queries', :action => 'create' }
40 { :controller => 'queries', :action => 'create' }
112 )
41 )
113 assert_routing(
42 assert_routing(
114 { :method => 'post', :path => "/projects/redmine/queries" },
43 { :method => 'post', :path => "/projects/redmine/queries" },
115 { :controller => 'queries', :action => 'create', :project_id => 'redmine' }
44 { :controller => 'queries', :action => 'create', :project_id => 'redmine' }
116 )
45 )
117 assert_routing(
46 assert_routing(
118 { :method => 'get', :path => "/queries/1/edit" },
47 { :method => 'get', :path => "/queries/1/edit" },
119 { :controller => 'queries', :action => 'edit', :id => '1' }
48 { :controller => 'queries', :action => 'edit', :id => '1' }
120 )
49 )
121 assert_routing(
50 assert_routing(
122 { :method => 'put', :path => "/queries/1" },
51 { :method => 'put', :path => "/queries/1" },
123 { :controller => 'queries', :action => 'update', :id => '1' }
52 { :controller => 'queries', :action => 'update', :id => '1' }
124 )
53 )
125 assert_routing(
54 assert_routing(
126 { :method => 'delete', :path => "/queries/1" },
55 { :method => 'delete', :path => "/queries/1" },
127 { :controller => 'queries', :action => 'destroy', :id => '1' }
56 { :controller => 'queries', :action => 'destroy', :id => '1' }
128 )
57 )
129 end
58 end
130
59
131 def test_wiki_singular_projects_pages
60 def test_wiki_singular_projects_pages
132 assert_routing(
61 assert_routing(
133 { :method => 'get', :path => "/projects/567/wiki" },
62 { :method => 'get', :path => "/projects/567/wiki" },
134 { :controller => 'wiki', :action => 'show', :project_id => '567' }
63 { :controller => 'wiki', :action => 'show', :project_id => '567' }
135 )
64 )
136 assert_routing(
65 assert_routing(
137 { :method => 'get', :path => "/projects/567/wiki/lalala" },
66 { :method => 'get', :path => "/projects/567/wiki/lalala" },
138 { :controller => 'wiki', :action => 'show', :project_id => '567',
67 { :controller => 'wiki', :action => 'show', :project_id => '567',
139 :id => 'lalala' }
68 :id => 'lalala' }
140 )
69 )
141 assert_routing(
70 assert_routing(
142 { :method => 'get', :path => "/projects/567/wiki/my_page/edit" },
71 { :method => 'get', :path => "/projects/567/wiki/my_page/edit" },
143 { :controller => 'wiki', :action => 'edit', :project_id => '567',
72 { :controller => 'wiki', :action => 'edit', :project_id => '567',
144 :id => 'my_page' }
73 :id => 'my_page' }
145 )
74 )
146 assert_routing(
75 assert_routing(
147 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/history" },
76 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/history" },
148 { :controller => 'wiki', :action => 'history', :project_id => '1',
77 { :controller => 'wiki', :action => 'history', :project_id => '1',
149 :id => 'CookBook_documentation' }
78 :id => 'CookBook_documentation' }
150 )
79 )
151 assert_routing(
80 assert_routing(
152 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/diff" },
81 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/diff" },
153 { :controller => 'wiki', :action => 'diff', :project_id => '1',
82 { :controller => 'wiki', :action => 'diff', :project_id => '1',
154 :id => 'CookBook_documentation' }
83 :id => 'CookBook_documentation' }
155 )
84 )
156 assert_routing(
85 assert_routing(
157 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/diff/2" },
86 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/diff/2" },
158 { :controller => 'wiki', :action => 'diff', :project_id => '1',
87 { :controller => 'wiki', :action => 'diff', :project_id => '1',
159 :id => 'CookBook_documentation', :version => '2' }
88 :id => 'CookBook_documentation', :version => '2' }
160 )
89 )
161 assert_routing(
90 assert_routing(
162 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/diff/2/vs/1" },
91 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/diff/2/vs/1" },
163 { :controller => 'wiki', :action => 'diff', :project_id => '1',
92 { :controller => 'wiki', :action => 'diff', :project_id => '1',
164 :id => 'CookBook_documentation', :version => '2', :version_from => '1' }
93 :id => 'CookBook_documentation', :version => '2', :version_from => '1' }
165 )
94 )
166 assert_routing(
95 assert_routing(
167 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/annotate/2" },
96 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/annotate/2" },
168 { :controller => 'wiki', :action => 'annotate', :project_id => '1',
97 { :controller => 'wiki', :action => 'annotate', :project_id => '1',
169 :id => 'CookBook_documentation', :version => '2' }
98 :id => 'CookBook_documentation', :version => '2' }
170 )
99 )
171 assert_routing(
100 assert_routing(
172 { :method => 'get', :path => "/projects/22/wiki/ladida/rename" },
101 { :method => 'get', :path => "/projects/22/wiki/ladida/rename" },
173 { :controller => 'wiki', :action => 'rename', :project_id => '22',
102 { :controller => 'wiki', :action => 'rename', :project_id => '22',
174 :id => 'ladida' }
103 :id => 'ladida' }
175 )
104 )
176 assert_routing(
105 assert_routing(
177 { :method => 'get', :path => "/projects/567/wiki/index" },
106 { :method => 'get', :path => "/projects/567/wiki/index" },
178 { :controller => 'wiki', :action => 'index', :project_id => '567' }
107 { :controller => 'wiki', :action => 'index', :project_id => '567' }
179 )
108 )
180 assert_routing(
109 assert_routing(
181 { :method => 'get', :path => "/projects/567/wiki/date_index" },
110 { :method => 'get', :path => "/projects/567/wiki/date_index" },
182 { :controller => 'wiki', :action => 'date_index', :project_id => '567' }
111 { :controller => 'wiki', :action => 'date_index', :project_id => '567' }
183 )
112 )
184 assert_routing(
113 assert_routing(
185 { :method => 'get', :path => "/projects/567/wiki/export" },
114 { :method => 'get', :path => "/projects/567/wiki/export" },
186 { :controller => 'wiki', :action => 'export', :project_id => '567' }
115 { :controller => 'wiki', :action => 'export', :project_id => '567' }
187 )
116 )
188 assert_routing(
117 assert_routing(
189 { :method => 'post', :path => "/projects/567/wiki/CookBook_documentation/preview" },
118 { :method => 'post', :path => "/projects/567/wiki/CookBook_documentation/preview" },
190 { :controller => 'wiki', :action => 'preview', :project_id => '567',
119 { :controller => 'wiki', :action => 'preview', :project_id => '567',
191 :id => 'CookBook_documentation' }
120 :id => 'CookBook_documentation' }
192 )
121 )
193 assert_routing(
122 assert_routing(
194 { :method => 'post', :path => "/projects/22/wiki/ladida/rename" },
123 { :method => 'post', :path => "/projects/22/wiki/ladida/rename" },
195 { :controller => 'wiki', :action => 'rename', :project_id => '22',
124 { :controller => 'wiki', :action => 'rename', :project_id => '22',
196 :id => 'ladida' }
125 :id => 'ladida' }
197 )
126 )
198 assert_routing(
127 assert_routing(
199 { :method => 'post', :path => "/projects/22/wiki/ladida/protect" },
128 { :method => 'post', :path => "/projects/22/wiki/ladida/protect" },
200 { :controller => 'wiki', :action => 'protect', :project_id => '22',
129 { :controller => 'wiki', :action => 'protect', :project_id => '22',
201 :id => 'ladida' }
130 :id => 'ladida' }
202 )
131 )
203 assert_routing(
132 assert_routing(
204 { :method => 'post', :path => "/projects/22/wiki/ladida/add_attachment" },
133 { :method => 'post', :path => "/projects/22/wiki/ladida/add_attachment" },
205 { :controller => 'wiki', :action => 'add_attachment', :project_id => '22',
134 { :controller => 'wiki', :action => 'add_attachment', :project_id => '22',
206 :id => 'ladida' }
135 :id => 'ladida' }
207 )
136 )
208 assert_routing(
137 assert_routing(
209 { :method => 'put', :path => "/projects/567/wiki/my_page" },
138 { :method => 'put', :path => "/projects/567/wiki/my_page" },
210 { :controller => 'wiki', :action => 'update', :project_id => '567',
139 { :controller => 'wiki', :action => 'update', :project_id => '567',
211 :id => 'my_page' }
140 :id => 'my_page' }
212 )
141 )
213 assert_routing(
142 assert_routing(
214 { :method => 'delete', :path => "/projects/22/wiki/ladida" },
143 { :method => 'delete', :path => "/projects/22/wiki/ladida" },
215 { :controller => 'wiki', :action => 'destroy', :project_id => '22',
144 { :controller => 'wiki', :action => 'destroy', :project_id => '22',
216 :id => 'ladida' }
145 :id => 'ladida' }
217 )
146 )
218 end
147 end
219
148
220 def test_wikis_plural_admin_setup
149 def test_wikis_plural_admin_setup
221 assert_routing(
150 assert_routing(
222 { :method => 'get', :path => "/projects/ladida/wiki/destroy" },
151 { :method => 'get', :path => "/projects/ladida/wiki/destroy" },
223 { :controller => 'wikis', :action => 'destroy', :id => 'ladida' }
152 { :controller => 'wikis', :action => 'destroy', :id => 'ladida' }
224 )
153 )
225 assert_routing(
154 assert_routing(
226 { :method => 'post', :path => "/projects/ladida/wiki" },
155 { :method => 'post', :path => "/projects/ladida/wiki" },
227 { :controller => 'wikis', :action => 'edit', :id => 'ladida' }
156 { :controller => 'wikis', :action => 'edit', :id => 'ladida' }
228 )
157 )
229 assert_routing(
158 assert_routing(
230 { :method => 'post', :path => "/projects/ladida/wiki/destroy" },
159 { :method => 'post', :path => "/projects/ladida/wiki/destroy" },
231 { :controller => 'wikis', :action => 'destroy', :id => 'ladida' }
160 { :controller => 'wikis', :action => 'destroy', :id => 'ladida' }
232 )
161 )
233 end
162 end
234 end
163 end
General Comments 0
You need to be logged in to leave comments. Login now