comparison .svn/pristine/d9/d98764f99d236520bd5f6ca42381f61878a79847.svn-base @ 1298:4f746d8966dd redmine_2.3_integration

Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author Chris Cannam
date Fri, 14 Jun 2013 09:28:30 +0100
parents 622f24f53b42
children
comparison
equal deleted inserted replaced
1297:0a574315af3e 1298:4f746d8966dd
1 # Redmine - project management software
2 # Copyright (C) 2006-2013 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 RoutingWikiTest < ActionController::IntegrationTest
21 def test_wiki_matching
22 assert_routing(
23 { :method => 'get', :path => "/projects/567/wiki" },
24 { :controller => 'wiki', :action => 'show', :project_id => '567' }
25 )
26 assert_routing(
27 { :method => 'get', :path => "/projects/567/wiki/lalala" },
28 { :controller => 'wiki', :action => 'show', :project_id => '567',
29 :id => 'lalala' }
30 )
31 assert_routing(
32 { :method => 'get', :path => "/projects/567/wiki/lalala.pdf" },
33 { :controller => 'wiki', :action => 'show', :project_id => '567',
34 :id => 'lalala', :format => 'pdf' }
35 )
36 assert_routing(
37 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/diff" },
38 { :controller => 'wiki', :action => 'diff', :project_id => '1',
39 :id => 'CookBook_documentation' }
40 )
41 assert_routing(
42 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2" },
43 { :controller => 'wiki', :action => 'show', :project_id => '1',
44 :id => 'CookBook_documentation', :version => '2' }
45 )
46 assert_routing(
47 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2/diff" },
48 { :controller => 'wiki', :action => 'diff', :project_id => '1',
49 :id => 'CookBook_documentation', :version => '2' }
50 )
51 assert_routing(
52 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2/annotate" },
53 { :controller => 'wiki', :action => 'annotate', :project_id => '1',
54 :id => 'CookBook_documentation', :version => '2' }
55 )
56 # Make sure we don't route wiki page sub-uris to let plugins handle them
57 assert_raise(ActionController::RoutingError) do
58 assert_recognizes({}, {:method => 'get', :path => "/projects/1/wiki/CookBook_documentation/whatever"})
59 end
60 end
61
62 def test_wiki_misc
63 assert_routing(
64 { :method => 'get', :path => "/projects/567/wiki/date_index" },
65 { :controller => 'wiki', :action => 'date_index', :project_id => '567' }
66 )
67 assert_routing(
68 { :method => 'get', :path => "/projects/567/wiki/export" },
69 { :controller => 'wiki', :action => 'export', :project_id => '567' }
70 )
71 assert_routing(
72 { :method => 'get', :path => "/projects/567/wiki/export.pdf" },
73 { :controller => 'wiki', :action => 'export', :project_id => '567', :format => 'pdf' }
74 )
75 assert_routing(
76 { :method => 'get', :path => "/projects/567/wiki/index" },
77 { :controller => 'wiki', :action => 'index', :project_id => '567' }
78 )
79 end
80
81 def test_wiki_resources
82 assert_routing(
83 { :method => 'get', :path => "/projects/567/wiki/my_page/edit" },
84 { :controller => 'wiki', :action => 'edit', :project_id => '567',
85 :id => 'my_page' }
86 )
87 assert_routing(
88 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/history" },
89 { :controller => 'wiki', :action => 'history', :project_id => '1',
90 :id => 'CookBook_documentation' }
91 )
92 assert_routing(
93 { :method => 'get', :path => "/projects/22/wiki/ladida/rename" },
94 { :controller => 'wiki', :action => 'rename', :project_id => '22',
95 :id => 'ladida' }
96 )
97 ["post", "put"].each do |method|
98 assert_routing(
99 { :method => method, :path => "/projects/567/wiki/CookBook_documentation/preview" },
100 { :controller => 'wiki', :action => 'preview', :project_id => '567',
101 :id => 'CookBook_documentation' }
102 )
103 end
104 assert_routing(
105 { :method => 'post', :path => "/projects/22/wiki/ladida/rename" },
106 { :controller => 'wiki', :action => 'rename', :project_id => '22',
107 :id => 'ladida' }
108 )
109 assert_routing(
110 { :method => 'post', :path => "/projects/22/wiki/ladida/protect" },
111 { :controller => 'wiki', :action => 'protect', :project_id => '22',
112 :id => 'ladida' }
113 )
114 assert_routing(
115 { :method => 'post', :path => "/projects/22/wiki/ladida/add_attachment" },
116 { :controller => 'wiki', :action => 'add_attachment', :project_id => '22',
117 :id => 'ladida' }
118 )
119 assert_routing(
120 { :method => 'put', :path => "/projects/567/wiki/my_page" },
121 { :controller => 'wiki', :action => 'update', :project_id => '567',
122 :id => 'my_page' }
123 )
124 assert_routing(
125 { :method => 'delete', :path => "/projects/22/wiki/ladida" },
126 { :controller => 'wiki', :action => 'destroy', :project_id => '22',
127 :id => 'ladida' }
128 )
129 assert_routing(
130 { :method => 'delete', :path => "/projects/22/wiki/ladida/3" },
131 { :controller => 'wiki', :action => 'destroy_version', :project_id => '22',
132 :id => 'ladida', :version => '3' }
133 )
134 end
135
136 def test_api
137 assert_routing(
138 { :method => 'get', :path => "/projects/567/wiki/my_page.xml" },
139 { :controller => 'wiki', :action => 'show', :project_id => '567',
140 :id => 'my_page', :format => 'xml' }
141 )
142 assert_routing(
143 { :method => 'get', :path => "/projects/567/wiki/my_page.json" },
144 { :controller => 'wiki', :action => 'show', :project_id => '567',
145 :id => 'my_page', :format => 'json' }
146 )
147 assert_routing(
148 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2.xml" },
149 { :controller => 'wiki', :action => 'show', :project_id => '1',
150 :id => 'CookBook_documentation', :version => '2', :format => 'xml' }
151 )
152 assert_routing(
153 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2.json" },
154 { :controller => 'wiki', :action => 'show', :project_id => '1',
155 :id => 'CookBook_documentation', :version => '2', :format => 'json' }
156 )
157 assert_routing(
158 { :method => 'get', :path => "/projects/567/wiki/index.xml" },
159 { :controller => 'wiki', :action => 'index', :project_id => '567', :format => 'xml' }
160 )
161 assert_routing(
162 { :method => 'get', :path => "/projects/567/wiki/index.json" },
163 { :controller => 'wiki', :action => 'index', :project_id => '567', :format => 'json' }
164 )
165 assert_routing(
166 { :method => 'put', :path => "/projects/567/wiki/my_page.xml" },
167 { :controller => 'wiki', :action => 'update', :project_id => '567',
168 :id => 'my_page', :format => 'xml' }
169 )
170 assert_routing(
171 { :method => 'put', :path => "/projects/567/wiki/my_page.json" },
172 { :controller => 'wiki', :action => 'update', :project_id => '567',
173 :id => 'my_page', :format => 'json' }
174 )
175 assert_routing(
176 { :method => 'delete', :path => "/projects/567/wiki/my_page.xml" },
177 { :controller => 'wiki', :action => 'destroy', :project_id => '567',
178 :id => 'my_page', :format => 'xml' }
179 )
180 assert_routing(
181 { :method => 'delete', :path => "/projects/567/wiki/my_page.json" },
182 { :controller => 'wiki', :action => 'destroy', :project_id => '567',
183 :id => 'my_page', :format => 'json' }
184 )
185 end
186 end