##// END OF EJS Templates
test: route: move queries test to new file...
Toshi MARUYAMA -
r8241:720e97c2f80b
parent child
Show More
@@ -0,0 +1,59
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 RoutingQueriesTest < ActionController::IntegrationTest
21 def test_queries
22 assert_routing(
23 { :method => 'get', :path => "/queries.xml" },
24 { :controller => 'queries', :action => 'index', :format => 'xml' }
25 )
26 assert_routing(
27 { :method => 'get', :path => "/queries.json" },
28 { :controller => 'queries', :action => 'index', :format => 'json' }
29 )
30 assert_routing(
31 { :method => 'get', :path => "/queries/new" },
32 { :controller => 'queries', :action => 'new' }
33 )
34 assert_routing(
35 { :method => 'get', :path => "/projects/redmine/queries/new" },
36 { :controller => 'queries', :action => 'new', :project_id => 'redmine' }
37 )
38 assert_routing(
39 { :method => 'post', :path => "/queries" },
40 { :controller => 'queries', :action => 'create' }
41 )
42 assert_routing(
43 { :method => 'post', :path => "/projects/redmine/queries" },
44 { :controller => 'queries', :action => 'create', :project_id => 'redmine' }
45 )
46 assert_routing(
47 { :method => 'get', :path => "/queries/1/edit" },
48 { :controller => 'queries', :action => 'edit', :id => '1' }
49 )
50 assert_routing(
51 { :method => 'put', :path => "/queries/1" },
52 { :controller => 'queries', :action => 'update', :id => '1' }
53 )
54 assert_routing(
55 { :method => 'delete', :path => "/queries/1" },
56 { :controller => 'queries', :action => 'destroy', :id => '1' }
57 )
58 end
59 end
@@ -1,163 +1,124
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_queries
22 assert_routing(
23 { :method => 'get', :path => "/queries.xml" },
24 { :controller => 'queries', :action => 'index', :format => 'xml' }
25 )
26 assert_routing(
27 { :method => 'get', :path => "/queries.json" },
28 { :controller => 'queries', :action => 'index', :format => 'json' }
29 )
30 assert_routing(
31 { :method => 'get', :path => "/queries/new" },
32 { :controller => 'queries', :action => 'new' }
33 )
34 assert_routing(
35 { :method => 'get', :path => "/projects/redmine/queries/new" },
36 { :controller => 'queries', :action => 'new', :project_id => 'redmine' }
37 )
38 assert_routing(
39 { :method => 'post', :path => "/queries" },
40 { :controller => 'queries', :action => 'create' }
41 )
42 assert_routing(
43 { :method => 'post', :path => "/projects/redmine/queries" },
44 { :controller => 'queries', :action => 'create', :project_id => 'redmine' }
45 )
46 assert_routing(
47 { :method => 'get', :path => "/queries/1/edit" },
48 { :controller => 'queries', :action => 'edit', :id => '1' }
49 )
50 assert_routing(
51 { :method => 'put', :path => "/queries/1" },
52 { :controller => 'queries', :action => 'update', :id => '1' }
53 )
54 assert_routing(
55 { :method => 'delete', :path => "/queries/1" },
56 { :controller => 'queries', :action => 'destroy', :id => '1' }
57 )
58 end
59
60 def test_wiki_singular_projects_pages
21 def test_wiki_singular_projects_pages
61 assert_routing(
22 assert_routing(
62 { :method => 'get', :path => "/projects/567/wiki" },
23 { :method => 'get', :path => "/projects/567/wiki" },
63 { :controller => 'wiki', :action => 'show', :project_id => '567' }
24 { :controller => 'wiki', :action => 'show', :project_id => '567' }
64 )
25 )
65 assert_routing(
26 assert_routing(
66 { :method => 'get', :path => "/projects/567/wiki/lalala" },
27 { :method => 'get', :path => "/projects/567/wiki/lalala" },
67 { :controller => 'wiki', :action => 'show', :project_id => '567',
28 { :controller => 'wiki', :action => 'show', :project_id => '567',
68 :id => 'lalala' }
29 :id => 'lalala' }
69 )
30 )
70 assert_routing(
31 assert_routing(
71 { :method => 'get', :path => "/projects/567/wiki/my_page/edit" },
32 { :method => 'get', :path => "/projects/567/wiki/my_page/edit" },
72 { :controller => 'wiki', :action => 'edit', :project_id => '567',
33 { :controller => 'wiki', :action => 'edit', :project_id => '567',
73 :id => 'my_page' }
34 :id => 'my_page' }
74 )
35 )
75 assert_routing(
36 assert_routing(
76 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/history" },
37 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/history" },
77 { :controller => 'wiki', :action => 'history', :project_id => '1',
38 { :controller => 'wiki', :action => 'history', :project_id => '1',
78 :id => 'CookBook_documentation' }
39 :id => 'CookBook_documentation' }
79 )
40 )
80 assert_routing(
41 assert_routing(
81 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/diff" },
42 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/diff" },
82 { :controller => 'wiki', :action => 'diff', :project_id => '1',
43 { :controller => 'wiki', :action => 'diff', :project_id => '1',
83 :id => 'CookBook_documentation' }
44 :id => 'CookBook_documentation' }
84 )
45 )
85 assert_routing(
46 assert_routing(
86 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/diff/2" },
47 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/diff/2" },
87 { :controller => 'wiki', :action => 'diff', :project_id => '1',
48 { :controller => 'wiki', :action => 'diff', :project_id => '1',
88 :id => 'CookBook_documentation', :version => '2' }
49 :id => 'CookBook_documentation', :version => '2' }
89 )
50 )
90 assert_routing(
51 assert_routing(
91 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/diff/2/vs/1" },
52 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/diff/2/vs/1" },
92 { :controller => 'wiki', :action => 'diff', :project_id => '1',
53 { :controller => 'wiki', :action => 'diff', :project_id => '1',
93 :id => 'CookBook_documentation', :version => '2', :version_from => '1' }
54 :id => 'CookBook_documentation', :version => '2', :version_from => '1' }
94 )
55 )
95 assert_routing(
56 assert_routing(
96 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/annotate/2" },
57 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/annotate/2" },
97 { :controller => 'wiki', :action => 'annotate', :project_id => '1',
58 { :controller => 'wiki', :action => 'annotate', :project_id => '1',
98 :id => 'CookBook_documentation', :version => '2' }
59 :id => 'CookBook_documentation', :version => '2' }
99 )
60 )
100 assert_routing(
61 assert_routing(
101 { :method => 'get', :path => "/projects/22/wiki/ladida/rename" },
62 { :method => 'get', :path => "/projects/22/wiki/ladida/rename" },
102 { :controller => 'wiki', :action => 'rename', :project_id => '22',
63 { :controller => 'wiki', :action => 'rename', :project_id => '22',
103 :id => 'ladida' }
64 :id => 'ladida' }
104 )
65 )
105 assert_routing(
66 assert_routing(
106 { :method => 'get', :path => "/projects/567/wiki/index" },
67 { :method => 'get', :path => "/projects/567/wiki/index" },
107 { :controller => 'wiki', :action => 'index', :project_id => '567' }
68 { :controller => 'wiki', :action => 'index', :project_id => '567' }
108 )
69 )
109 assert_routing(
70 assert_routing(
110 { :method => 'get', :path => "/projects/567/wiki/date_index" },
71 { :method => 'get', :path => "/projects/567/wiki/date_index" },
111 { :controller => 'wiki', :action => 'date_index', :project_id => '567' }
72 { :controller => 'wiki', :action => 'date_index', :project_id => '567' }
112 )
73 )
113 assert_routing(
74 assert_routing(
114 { :method => 'get', :path => "/projects/567/wiki/export" },
75 { :method => 'get', :path => "/projects/567/wiki/export" },
115 { :controller => 'wiki', :action => 'export', :project_id => '567' }
76 { :controller => 'wiki', :action => 'export', :project_id => '567' }
116 )
77 )
117 assert_routing(
78 assert_routing(
118 { :method => 'post', :path => "/projects/567/wiki/CookBook_documentation/preview" },
79 { :method => 'post', :path => "/projects/567/wiki/CookBook_documentation/preview" },
119 { :controller => 'wiki', :action => 'preview', :project_id => '567',
80 { :controller => 'wiki', :action => 'preview', :project_id => '567',
120 :id => 'CookBook_documentation' }
81 :id => 'CookBook_documentation' }
121 )
82 )
122 assert_routing(
83 assert_routing(
123 { :method => 'post', :path => "/projects/22/wiki/ladida/rename" },
84 { :method => 'post', :path => "/projects/22/wiki/ladida/rename" },
124 { :controller => 'wiki', :action => 'rename', :project_id => '22',
85 { :controller => 'wiki', :action => 'rename', :project_id => '22',
125 :id => 'ladida' }
86 :id => 'ladida' }
126 )
87 )
127 assert_routing(
88 assert_routing(
128 { :method => 'post', :path => "/projects/22/wiki/ladida/protect" },
89 { :method => 'post', :path => "/projects/22/wiki/ladida/protect" },
129 { :controller => 'wiki', :action => 'protect', :project_id => '22',
90 { :controller => 'wiki', :action => 'protect', :project_id => '22',
130 :id => 'ladida' }
91 :id => 'ladida' }
131 )
92 )
132 assert_routing(
93 assert_routing(
133 { :method => 'post', :path => "/projects/22/wiki/ladida/add_attachment" },
94 { :method => 'post', :path => "/projects/22/wiki/ladida/add_attachment" },
134 { :controller => 'wiki', :action => 'add_attachment', :project_id => '22',
95 { :controller => 'wiki', :action => 'add_attachment', :project_id => '22',
135 :id => 'ladida' }
96 :id => 'ladida' }
136 )
97 )
137 assert_routing(
98 assert_routing(
138 { :method => 'put', :path => "/projects/567/wiki/my_page" },
99 { :method => 'put', :path => "/projects/567/wiki/my_page" },
139 { :controller => 'wiki', :action => 'update', :project_id => '567',
100 { :controller => 'wiki', :action => 'update', :project_id => '567',
140 :id => 'my_page' }
101 :id => 'my_page' }
141 )
102 )
142 assert_routing(
103 assert_routing(
143 { :method => 'delete', :path => "/projects/22/wiki/ladida" },
104 { :method => 'delete', :path => "/projects/22/wiki/ladida" },
144 { :controller => 'wiki', :action => 'destroy', :project_id => '22',
105 { :controller => 'wiki', :action => 'destroy', :project_id => '22',
145 :id => 'ladida' }
106 :id => 'ladida' }
146 )
107 )
147 end
108 end
148
109
149 def test_wikis_plural_admin_setup
110 def test_wikis_plural_admin_setup
150 assert_routing(
111 assert_routing(
151 { :method => 'get', :path => "/projects/ladida/wiki/destroy" },
112 { :method => 'get', :path => "/projects/ladida/wiki/destroy" },
152 { :controller => 'wikis', :action => 'destroy', :id => 'ladida' }
113 { :controller => 'wikis', :action => 'destroy', :id => 'ladida' }
153 )
114 )
154 assert_routing(
115 assert_routing(
155 { :method => 'post', :path => "/projects/ladida/wiki" },
116 { :method => 'post', :path => "/projects/ladida/wiki" },
156 { :controller => 'wikis', :action => 'edit', :id => 'ladida' }
117 { :controller => 'wikis', :action => 'edit', :id => 'ladida' }
157 )
118 )
158 assert_routing(
119 assert_routing(
159 { :method => 'post', :path => "/projects/ladida/wiki/destroy" },
120 { :method => 'post', :path => "/projects/ladida/wiki/destroy" },
160 { :controller => 'wikis', :action => 'destroy', :id => 'ladida' }
121 { :controller => 'wikis', :action => 'destroy', :id => 'ladida' }
161 )
122 )
162 end
123 end
163 end
124 end
General Comments 0
You need to be logged in to leave comments. Login now