Chris@1115
|
1 # Redmine - project management software
|
Chris@1115
|
2 # Copyright (C) 2006-2012 Jean-Philippe Lang
|
Chris@1115
|
3 #
|
Chris@1115
|
4 # This program is free software; you can redistribute it and/or
|
Chris@1115
|
5 # modify it under the terms of the GNU General Public License
|
Chris@1115
|
6 # as published by the Free Software Foundation; either version 2
|
Chris@1115
|
7 # of the License, or (at your option) any later version.
|
Chris@1115
|
8 #
|
Chris@1115
|
9 # This program is distributed in the hope that it will be useful,
|
Chris@1115
|
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Chris@1115
|
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Chris@1115
|
12 # GNU General Public License for more details.
|
Chris@1115
|
13 #
|
Chris@1115
|
14 # You should have received a copy of the GNU General Public License
|
Chris@1115
|
15 # along with this program; if not, write to the Free Software
|
Chris@1115
|
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Chris@1115
|
17
|
Chris@1115
|
18 require File.expand_path('../../../test_helper', __FILE__)
|
Chris@1115
|
19
|
Chris@1115
|
20 class RoutingWikiTest < ActionController::IntegrationTest
|
Chris@1115
|
21 def test_wiki_matching
|
Chris@1115
|
22 assert_routing(
|
Chris@1115
|
23 { :method => 'get', :path => "/projects/567/wiki" },
|
Chris@1115
|
24 { :controller => 'wiki', :action => 'show', :project_id => '567' }
|
Chris@1115
|
25 )
|
Chris@1115
|
26 assert_routing(
|
Chris@1115
|
27 { :method => 'get', :path => "/projects/567/wiki/lalala" },
|
Chris@1115
|
28 { :controller => 'wiki', :action => 'show', :project_id => '567',
|
Chris@1115
|
29 :id => 'lalala' }
|
Chris@1115
|
30 )
|
Chris@1115
|
31 assert_routing(
|
Chris@1115
|
32 { :method => 'get', :path => "/projects/567/wiki/lalala.pdf" },
|
Chris@1115
|
33 { :controller => 'wiki', :action => 'show', :project_id => '567',
|
Chris@1115
|
34 :id => 'lalala', :format => 'pdf' }
|
Chris@1115
|
35 )
|
Chris@1115
|
36 assert_routing(
|
Chris@1115
|
37 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/diff" },
|
Chris@1115
|
38 { :controller => 'wiki', :action => 'diff', :project_id => '1',
|
Chris@1115
|
39 :id => 'CookBook_documentation' }
|
Chris@1115
|
40 )
|
Chris@1115
|
41 assert_routing(
|
Chris@1115
|
42 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2" },
|
Chris@1115
|
43 { :controller => 'wiki', :action => 'show', :project_id => '1',
|
Chris@1115
|
44 :id => 'CookBook_documentation', :version => '2' }
|
Chris@1115
|
45 )
|
Chris@1115
|
46 assert_routing(
|
Chris@1115
|
47 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2/diff" },
|
Chris@1115
|
48 { :controller => 'wiki', :action => 'diff', :project_id => '1',
|
Chris@1115
|
49 :id => 'CookBook_documentation', :version => '2' }
|
Chris@1115
|
50 )
|
Chris@1115
|
51 assert_routing(
|
Chris@1115
|
52 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2/annotate" },
|
Chris@1115
|
53 { :controller => 'wiki', :action => 'annotate', :project_id => '1',
|
Chris@1115
|
54 :id => 'CookBook_documentation', :version => '2' }
|
Chris@1115
|
55 )
|
Chris@1115
|
56 end
|
Chris@1115
|
57
|
Chris@1115
|
58 def test_wiki_misc
|
Chris@1115
|
59 assert_routing(
|
Chris@1115
|
60 { :method => 'get', :path => "/projects/567/wiki/date_index" },
|
Chris@1115
|
61 { :controller => 'wiki', :action => 'date_index', :project_id => '567' }
|
Chris@1115
|
62 )
|
Chris@1115
|
63 assert_routing(
|
Chris@1115
|
64 { :method => 'get', :path => "/projects/567/wiki/export" },
|
Chris@1115
|
65 { :controller => 'wiki', :action => 'export', :project_id => '567' }
|
Chris@1115
|
66 )
|
Chris@1115
|
67 assert_routing(
|
Chris@1115
|
68 { :method => 'get', :path => "/projects/567/wiki/export.pdf" },
|
Chris@1115
|
69 { :controller => 'wiki', :action => 'export', :project_id => '567', :format => 'pdf' }
|
Chris@1115
|
70 )
|
Chris@1115
|
71 assert_routing(
|
Chris@1115
|
72 { :method => 'get', :path => "/projects/567/wiki/index" },
|
Chris@1115
|
73 { :controller => 'wiki', :action => 'index', :project_id => '567' }
|
Chris@1115
|
74 )
|
Chris@1115
|
75 end
|
Chris@1115
|
76
|
Chris@1115
|
77 def test_wiki_resources
|
Chris@1115
|
78 assert_routing(
|
Chris@1115
|
79 { :method => 'get', :path => "/projects/567/wiki/my_page/edit" },
|
Chris@1115
|
80 { :controller => 'wiki', :action => 'edit', :project_id => '567',
|
Chris@1115
|
81 :id => 'my_page' }
|
Chris@1115
|
82 )
|
Chris@1115
|
83 assert_routing(
|
Chris@1115
|
84 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/history" },
|
Chris@1115
|
85 { :controller => 'wiki', :action => 'history', :project_id => '1',
|
Chris@1115
|
86 :id => 'CookBook_documentation' }
|
Chris@1115
|
87 )
|
Chris@1115
|
88 assert_routing(
|
Chris@1115
|
89 { :method => 'get', :path => "/projects/22/wiki/ladida/rename" },
|
Chris@1115
|
90 { :controller => 'wiki', :action => 'rename', :project_id => '22',
|
Chris@1115
|
91 :id => 'ladida' }
|
Chris@1115
|
92 )
|
Chris@1115
|
93 ["post", "put"].each do |method|
|
Chris@1115
|
94 assert_routing(
|
Chris@1115
|
95 { :method => method, :path => "/projects/567/wiki/CookBook_documentation/preview" },
|
Chris@1115
|
96 { :controller => 'wiki', :action => 'preview', :project_id => '567',
|
Chris@1115
|
97 :id => 'CookBook_documentation' }
|
Chris@1115
|
98 )
|
Chris@1115
|
99 end
|
Chris@1115
|
100 assert_routing(
|
Chris@1115
|
101 { :method => 'post', :path => "/projects/22/wiki/ladida/rename" },
|
Chris@1115
|
102 { :controller => 'wiki', :action => 'rename', :project_id => '22',
|
Chris@1115
|
103 :id => 'ladida' }
|
Chris@1115
|
104 )
|
Chris@1115
|
105 assert_routing(
|
Chris@1115
|
106 { :method => 'post', :path => "/projects/22/wiki/ladida/protect" },
|
Chris@1115
|
107 { :controller => 'wiki', :action => 'protect', :project_id => '22',
|
Chris@1115
|
108 :id => 'ladida' }
|
Chris@1115
|
109 )
|
Chris@1115
|
110 assert_routing(
|
Chris@1115
|
111 { :method => 'post', :path => "/projects/22/wiki/ladida/add_attachment" },
|
Chris@1115
|
112 { :controller => 'wiki', :action => 'add_attachment', :project_id => '22',
|
Chris@1115
|
113 :id => 'ladida' }
|
Chris@1115
|
114 )
|
Chris@1115
|
115 assert_routing(
|
Chris@1115
|
116 { :method => 'put', :path => "/projects/567/wiki/my_page" },
|
Chris@1115
|
117 { :controller => 'wiki', :action => 'update', :project_id => '567',
|
Chris@1115
|
118 :id => 'my_page' }
|
Chris@1115
|
119 )
|
Chris@1115
|
120 assert_routing(
|
Chris@1115
|
121 { :method => 'delete', :path => "/projects/22/wiki/ladida" },
|
Chris@1115
|
122 { :controller => 'wiki', :action => 'destroy', :project_id => '22',
|
Chris@1115
|
123 :id => 'ladida' }
|
Chris@1115
|
124 )
|
Chris@1115
|
125 assert_routing(
|
Chris@1115
|
126 { :method => 'delete', :path => "/projects/22/wiki/ladida/3" },
|
Chris@1115
|
127 { :controller => 'wiki', :action => 'destroy_version', :project_id => '22',
|
Chris@1115
|
128 :id => 'ladida', :version => '3' }
|
Chris@1115
|
129 )
|
Chris@1115
|
130 end
|
Chris@1115
|
131
|
Chris@1115
|
132 def test_api
|
Chris@1115
|
133 assert_routing(
|
Chris@1115
|
134 { :method => 'get', :path => "/projects/567/wiki/my_page.xml" },
|
Chris@1115
|
135 { :controller => 'wiki', :action => 'show', :project_id => '567',
|
Chris@1115
|
136 :id => 'my_page', :format => 'xml' }
|
Chris@1115
|
137 )
|
Chris@1115
|
138 assert_routing(
|
Chris@1115
|
139 { :method => 'get', :path => "/projects/567/wiki/my_page.json" },
|
Chris@1115
|
140 { :controller => 'wiki', :action => 'show', :project_id => '567',
|
Chris@1115
|
141 :id => 'my_page', :format => 'json' }
|
Chris@1115
|
142 )
|
Chris@1115
|
143 assert_routing(
|
Chris@1115
|
144 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2.xml" },
|
Chris@1115
|
145 { :controller => 'wiki', :action => 'show', :project_id => '1',
|
Chris@1115
|
146 :id => 'CookBook_documentation', :version => '2', :format => 'xml' }
|
Chris@1115
|
147 )
|
Chris@1115
|
148 assert_routing(
|
Chris@1115
|
149 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2.json" },
|
Chris@1115
|
150 { :controller => 'wiki', :action => 'show', :project_id => '1',
|
Chris@1115
|
151 :id => 'CookBook_documentation', :version => '2', :format => 'json' }
|
Chris@1115
|
152 )
|
Chris@1115
|
153 assert_routing(
|
Chris@1115
|
154 { :method => 'get', :path => "/projects/567/wiki/index.xml" },
|
Chris@1115
|
155 { :controller => 'wiki', :action => 'index', :project_id => '567', :format => 'xml' }
|
Chris@1115
|
156 )
|
Chris@1115
|
157 assert_routing(
|
Chris@1115
|
158 { :method => 'get', :path => "/projects/567/wiki/index.json" },
|
Chris@1115
|
159 { :controller => 'wiki', :action => 'index', :project_id => '567', :format => 'json' }
|
Chris@1115
|
160 )
|
Chris@1115
|
161 assert_routing(
|
Chris@1115
|
162 { :method => 'put', :path => "/projects/567/wiki/my_page.xml" },
|
Chris@1115
|
163 { :controller => 'wiki', :action => 'update', :project_id => '567',
|
Chris@1115
|
164 :id => 'my_page', :format => 'xml' }
|
Chris@1115
|
165 )
|
Chris@1115
|
166 assert_routing(
|
Chris@1115
|
167 { :method => 'put', :path => "/projects/567/wiki/my_page.json" },
|
Chris@1115
|
168 { :controller => 'wiki', :action => 'update', :project_id => '567',
|
Chris@1115
|
169 :id => 'my_page', :format => 'json' }
|
Chris@1115
|
170 )
|
Chris@1115
|
171 assert_routing(
|
Chris@1115
|
172 { :method => 'delete', :path => "/projects/567/wiki/my_page.xml" },
|
Chris@1115
|
173 { :controller => 'wiki', :action => 'destroy', :project_id => '567',
|
Chris@1115
|
174 :id => 'my_page', :format => 'xml' }
|
Chris@1115
|
175 )
|
Chris@1115
|
176 assert_routing(
|
Chris@1115
|
177 { :method => 'delete', :path => "/projects/567/wiki/my_page.json" },
|
Chris@1115
|
178 { :controller => 'wiki', :action => 'destroy', :project_id => '567',
|
Chris@1115
|
179 :id => 'my_page', :format => 'json' }
|
Chris@1115
|
180 )
|
Chris@1115
|
181 end
|
Chris@1115
|
182 end
|