##// END OF EJS Templates
Refactor: convert the Projects routes to resources....
Eric Davis -
r3957:8d52608dbad6
parent child
Show More
@@ -1,46 +1,46
1 1 <div class="contextual">
2 2 <%= link_to l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add' %>
3 3 </div>
4 4
5 5 <h2><%=l(:label_project_plural)%></h2>
6 6
7 7 <% form_tag({}, :method => :get) do %>
8 8 <fieldset><legend><%= l(:label_filter_plural) %></legend>
9 9 <label><%= l(:field_status) %> :</label>
10 10 <%= select_tag 'status', project_status_options_for_select(@status), :class => "small", :onchange => "this.form.submit(); return false;" %>
11 11 <label><%= l(:label_project) %>:</label>
12 12 <%= text_field_tag 'name', params[:name], :size => 30 %>
13 13 <%= submit_tag l(:button_apply), :class => "small", :name => nil %>
14 14 </fieldset>
15 15 <% end %>
16 16 &nbsp;
17 17
18 18 <div class="autoscroll">
19 19 <table class="list">
20 20 <thead><tr>
21 21 <th><%=l(:label_project)%></th>
22 22 <th><%=l(:field_description)%></th>
23 23 <th><%=l(:field_is_public)%></th>
24 24 <th><%=l(:field_created_on)%></th>
25 25 <th></th>
26 26 </tr></thead>
27 27 <tbody>
28 28 <% project_tree(@projects) do |project, level| %>
29 29 <tr class="<%= cycle("odd", "even") %> <%= css_project_classes(project) %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
30 30 <td class="name"><%= link_to_project(project, :action => 'settings') %></td>
31 31 <td><%= textilizable project.short_description, :project => project %></td>
32 32 <td align="center"><%= checked_image project.is_public? %></td>
33 33 <td align="center"><%= format_date(project.created_on) %></td>
34 34 <td class="buttons">
35 35 <%= link_to(l(:button_archive), { :controller => 'projects', :action => 'archive', :id => project, :status => params[:status] }, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-lock') if project.active? %>
36 36 <%= link_to(l(:button_unarchive), { :controller => 'projects', :action => 'unarchive', :id => project, :status => params[:status] }, :method => :post, :class => 'icon icon-unlock') if !project.active? && (project.parent.nil? || project.parent.active?) %>
37 37 <%= link_to(l(:button_copy), { :controller => 'projects', :action => 'copy', :id => project }, :class => 'icon icon-copy') %>
38 <%= link_to(l(:button_delete), { :controller => 'projects', :action => 'destroy', :id => project }, :class => 'icon icon-del') %>
38 <%= link_to(l(:button_delete), project_destroy_confirm_path(project), :class => 'icon icon-del') %>
39 39 </td>
40 40 </tr>
41 41 <% end %>
42 42 </tbody>
43 43 </table>
44 44 </div>
45 45
46 46 <% html_title(l(:label_project_plural)) -%>
@@ -1,4 +1,4
1 <% labelled_tabular_form_for :project, @project, :url => { :action => "update", :id => @project } do |f| %>
1 <% labelled_tabular_form_for :project, @project, :url => project_path(@project), :html => {:method => (@project.new_record? ? :post : :put) } do |f| %>
2 2 <%= render :partial => 'form', :locals => { :f => f } %>
3 3 <%= submit_tag l(:button_save) %>
4 4 <% end %>
@@ -1,16 +1,16
1 1 <h2><%=l(:label_confirmation)%></h2>
2 2 <div class="warning">
3 3 <p><strong><%=h @project_to_destroy %></strong><br />
4 4 <%=l(:text_project_destroy_confirmation)%>
5 5
6 6 <% if @project_to_destroy.descendants.any? %>
7 7 <br /><%= l(:text_subprojects_destroy_warning, content_tag('strong', h(@project_to_destroy.descendants.collect{|p| p.to_s}.join(', ')))) %>
8 8 <% end %>
9 9 </p>
10 10 <p>
11 <% form_tag({:controller => 'projects', :action => 'destroy', :id => @project_to_destroy}) do %>
11 <% form_tag(project_path(@project_to_destroy), :method => :delete) do %>
12 12 <label><%= check_box_tag 'confirm', 1 %> <%= l(:general_text_Yes) %></label>
13 13 <%= submit_tag l(:button_delete) %>
14 14 <% end %>
15 15 </p>
16 16 </div>
@@ -1,284 +1,281
1 1 ActionController::Routing::Routes.draw do |map|
2 2 # Add your own custom routes here.
3 3 # The priority is based upon order of creation: first created -> highest priority.
4 4
5 5 # Here's a sample route:
6 6 # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
7 7 # Keep in mind you can assign values other than :controller and :action
8 8
9 9 map.home '', :controller => 'welcome'
10 10
11 11 map.signin 'login', :controller => 'account', :action => 'login'
12 12 map.signout 'logout', :controller => 'account', :action => 'logout'
13 13
14 14 map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow'
15 15 map.connect 'help/:ctrl/:page', :controller => 'help'
16 16
17 17 map.connect 'time_entries/:id/edit', :action => 'edit', :controller => 'timelog'
18 18 map.connect 'projects/:project_id/time_entries/new', :action => 'edit', :controller => 'timelog'
19 19 map.connect 'projects/:project_id/issues/:issue_id/time_entries/new', :action => 'edit', :controller => 'timelog'
20 20
21 21 map.with_options :controller => 'timelog' do |timelog|
22 22 timelog.connect 'projects/:project_id/time_entries', :action => 'details'
23 23
24 24 timelog.with_options :action => 'details', :conditions => {:method => :get} do |time_details|
25 25 time_details.connect 'time_entries'
26 26 time_details.connect 'time_entries.:format'
27 27 time_details.connect 'issues/:issue_id/time_entries'
28 28 time_details.connect 'issues/:issue_id/time_entries.:format'
29 29 time_details.connect 'projects/:project_id/time_entries.:format'
30 30 time_details.connect 'projects/:project_id/issues/:issue_id/time_entries'
31 31 time_details.connect 'projects/:project_id/issues/:issue_id/time_entries.:format'
32 32 end
33 33 timelog.connect 'projects/:project_id/time_entries/report', :action => 'report'
34 34 timelog.with_options :action => 'report',:conditions => {:method => :get} do |time_report|
35 35 time_report.connect 'time_entries/report'
36 36 time_report.connect 'time_entries/report.:format'
37 37 time_report.connect 'projects/:project_id/time_entries/report.:format'
38 38 end
39 39
40 40 timelog.with_options :action => 'edit', :conditions => {:method => :get} do |time_edit|
41 41 time_edit.connect 'issues/:issue_id/time_entries/new'
42 42 end
43 43
44 44 timelog.connect 'time_entries/:id/destroy', :action => 'destroy', :conditions => {:method => :post}
45 45 end
46 46
47 47 map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post}
48 48 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get}
49 49 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post}
50 50 map.with_options :controller => 'wiki' do |wiki_routes|
51 51 wiki_routes.with_options :conditions => {:method => :get} do |wiki_views|
52 52 wiki_views.connect 'projects/:id/wiki/:page', :action => 'special', :page => /page_index|date_index|export/i
53 53 wiki_views.connect 'projects/:id/wiki/:page', :action => 'index', :page => nil
54 54 wiki_views.connect 'projects/:id/wiki/:page/edit', :action => 'edit'
55 55 wiki_views.connect 'projects/:id/wiki/:page/rename', :action => 'rename'
56 56 wiki_views.connect 'projects/:id/wiki/:page/history', :action => 'history'
57 57 wiki_views.connect 'projects/:id/wiki/:page/diff/:version/vs/:version_from', :action => 'diff'
58 58 wiki_views.connect 'projects/:id/wiki/:page/annotate/:version', :action => 'annotate'
59 59 end
60 60
61 61 wiki_routes.connect 'projects/:id/wiki/:page/:action',
62 62 :action => /edit|rename|destroy|preview|protect/,
63 63 :conditions => {:method => :post}
64 64 end
65 65
66 66 map.with_options :controller => 'messages' do |messages_routes|
67 67 messages_routes.with_options :conditions => {:method => :get} do |messages_views|
68 68 messages_views.connect 'boards/:board_id/topics/new', :action => 'new'
69 69 messages_views.connect 'boards/:board_id/topics/:id', :action => 'show'
70 70 messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit'
71 71 end
72 72 messages_routes.with_options :conditions => {:method => :post} do |messages_actions|
73 73 messages_actions.connect 'boards/:board_id/topics/new', :action => 'new'
74 74 messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply'
75 75 messages_actions.connect 'boards/:board_id/topics/:id/:action', :action => /edit|destroy/
76 76 end
77 77 end
78 78
79 79 map.with_options :controller => 'boards' do |board_routes|
80 80 board_routes.with_options :conditions => {:method => :get} do |board_views|
81 81 board_views.connect 'projects/:project_id/boards', :action => 'index'
82 82 board_views.connect 'projects/:project_id/boards/new', :action => 'new'
83 83 board_views.connect 'projects/:project_id/boards/:id', :action => 'show'
84 84 board_views.connect 'projects/:project_id/boards/:id.:format', :action => 'show'
85 85 board_views.connect 'projects/:project_id/boards/:id/edit', :action => 'edit'
86 86 end
87 87 board_routes.with_options :conditions => {:method => :post} do |board_actions|
88 88 board_actions.connect 'projects/:project_id/boards', :action => 'new'
89 89 board_actions.connect 'projects/:project_id/boards/:id/:action', :action => /edit|destroy/
90 90 end
91 91 end
92 92
93 93 map.with_options :controller => 'documents' do |document_routes|
94 94 document_routes.with_options :conditions => {:method => :get} do |document_views|
95 95 document_views.connect 'projects/:project_id/documents', :action => 'index'
96 96 document_views.connect 'projects/:project_id/documents/new', :action => 'new'
97 97 document_views.connect 'documents/:id', :action => 'show'
98 98 document_views.connect 'documents/:id/edit', :action => 'edit'
99 99 end
100 100 document_routes.with_options :conditions => {:method => :post} do |document_actions|
101 101 document_actions.connect 'projects/:project_id/documents', :action => 'new'
102 102 document_actions.connect 'documents/:id/:action', :action => /destroy|edit/
103 103 end
104 104 end
105 105
106 106 map.resources :issue_moves, :only => [:new, :create], :path_prefix => '/issues', :as => 'move'
107 107
108 108 # Misc issue routes. TODO: move into resources
109 109 map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', :action => 'issues'
110 110 map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue' # TODO: would look nicer as /issues/:id/preview
111 111 map.issues_context_menu '/issues/context_menu', :controller => 'context_menus', :action => 'issues'
112 112 map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index'
113 113 map.bulk_edit_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_edit', :conditions => { :method => :get }
114 114 map.bulk_update_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_update', :conditions => { :method => :post }
115 115 map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/, :conditions => { :method => :post }
116 116 map.connect '/issues/:id/destroy', :controller => 'issues', :action => 'destroy', :conditions => { :method => :post } # legacy
117 117
118 118 map.resource :gantt, :path_prefix => '/issues', :controller => 'gantts', :only => [:show, :update]
119 119 map.resource :gantt, :path_prefix => '/projects/:project_id/issues', :controller => 'gantts', :only => [:show, :update]
120 120 map.resource :calendar, :path_prefix => '/issues', :controller => 'calendars', :only => [:show, :update]
121 121 map.resource :calendar, :path_prefix => '/projects/:project_id/issues', :controller => 'calendars', :only => [:show, :update]
122 122
123 123 map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports|
124 124 reports.connect 'projects/:id/issues/report', :action => 'issue_report'
125 125 reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details'
126 126 end
127 127
128 128 # Following two routes conflict with the resources because #index allows POST
129 129 map.connect '/issues', :controller => 'issues', :action => 'index', :conditions => { :method => :post }
130 130 map.connect '/issues/create', :controller => 'issues', :action => 'index', :conditions => { :method => :post }
131 131
132 132 map.resources :issues, :member => { :edit => :post }, :collection => {}
133 133 map.resources :issues, :path_prefix => '/projects/:project_id', :collection => { :create => :post }
134 134
135 135 map.with_options :controller => 'issue_relations', :conditions => {:method => :post} do |relations|
136 136 relations.connect 'issues/:issue_id/relations/:id', :action => 'new'
137 137 relations.connect 'issues/:issue_id/relations/:id/destroy', :action => 'destroy'
138 138 end
139 139
140 140 map.with_options :controller => 'news' do |news_routes|
141 141 news_routes.with_options :conditions => {:method => :get} do |news_views|
142 142 news_views.connect 'news', :action => 'index'
143 143 news_views.connect 'projects/:project_id/news', :action => 'index'
144 144 news_views.connect 'projects/:project_id/news.:format', :action => 'index'
145 145 news_views.connect 'news.:format', :action => 'index'
146 146 news_views.connect 'projects/:project_id/news/new', :action => 'new'
147 147 news_views.connect 'news/:id', :action => 'show'
148 148 news_views.connect 'news/:id/edit', :action => 'edit'
149 149 end
150 150 news_routes.with_options do |news_actions|
151 151 news_actions.connect 'projects/:project_id/news', :action => 'new'
152 152 news_actions.connect 'news/:id/edit', :action => 'edit'
153 153 news_actions.connect 'news/:id/destroy', :action => 'destroy'
154 154 end
155 155 end
156 156
157 157 map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new'
158 158
159 159 map.with_options :controller => 'users' do |users|
160 160 users.with_options :conditions => {:method => :get} do |user_views|
161 161 user_views.connect 'users', :action => 'index'
162 162 user_views.connect 'users/:id', :action => 'show', :id => /\d+/
163 163 user_views.connect 'users/new', :action => 'add'
164 164 user_views.connect 'users/:id/edit/:tab', :action => 'edit', :tab => nil
165 165 end
166 166 users.with_options :conditions => {:method => :post} do |user_actions|
167 167 user_actions.connect 'users', :action => 'add'
168 168 user_actions.connect 'users/new', :action => 'add'
169 169 user_actions.connect 'users/:id/edit', :action => 'edit'
170 170 user_actions.connect 'users/:id/memberships', :action => 'edit_membership'
171 171 user_actions.connect 'users/:id/memberships/:membership_id', :action => 'edit_membership'
172 172 user_actions.connect 'users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership'
173 173 end
174 174 end
175
176 map.with_options :controller => 'projects' do |projects|
177 projects.with_options :conditions => {:method => :get} do |project_views|
178 project_views.connect 'projects', :action => 'index'
179 project_views.connect 'projects.:format', :action => 'index'
180 project_views.connect 'projects/new', :action => 'new'
181 project_views.connect 'projects/:id', :action => 'show'
182 project_views.connect 'projects/:id.:format', :action => 'show'
183 project_views.connect 'projects/:id/:action', :action => /destroy|settings/
175
176 map.resources :projects, :member => {
177 :copy => [:get, :post],
178 :settings => :get,
179 :modules => :post,
180 :archive => :post,
181 :unarchive => :post
182 }
183
184 # Destroy uses a get request to prompt the user before the actual DELETE request
185 map.project_destroy_confirm 'projects/:id/destroy', :controller => 'projects', :action => 'destroy', :conditions => {:method => :get}
186
187 # TODO: port to be part of the resources route(s)
188 map.with_options :controller => 'projects' do |project_mapper|
189 project_mapper.with_options :conditions => {:method => :get} do |project_views|
184 190 project_views.connect 'projects/:id/files', :controller => 'files', :action => 'index'
185 191 project_views.connect 'projects/:id/files/new', :controller => 'files', :action => 'new'
186 project_views.connect 'projects/:id/settings/:tab', :action => 'settings'
192 project_views.connect 'projects/:id/settings/:tab', :controller => 'projects', :action => 'settings'
187 193 project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new'
188 194 end
189 195
190 projects.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity|
191 activity.connect 'projects/:id/activity'
192 activity.connect 'projects/:id/activity.:format'
193 activity.connect 'activity', :id => nil
194 activity.connect 'activity.:format', :id => nil
195 end
196
197 projects.with_options :conditions => {:method => :post} do |project_actions|
198 project_actions.connect 'projects/new', :action => 'create'
199 project_actions.connect 'projects', :action => 'create'
200 project_actions.connect 'projects.:format', :action => 'create', :format => /xml/
201 project_actions.connect 'projects/:id/edit', :action => 'update'
202 project_actions.connect 'projects/:id/:action', :action => /destroy|archive|unarchive/
196 project_mapper.with_options :conditions => {:method => :post} do |project_actions|
203 197 project_actions.connect 'projects/:id/files/new', :controller => 'files', :action => 'new'
204 198 project_actions.connect 'projects/:id/activities/save', :controller => 'project_enumerations', :action => 'save'
205 199 end
206 200
207 projects.with_options :conditions => {:method => :put} do |project_actions|
208 project_actions.conditions 'projects/:id.:format', :action => 'update', :format => /xml/
209 end
210
211 projects.with_options :conditions => {:method => :delete} do |project_actions|
212 project_actions.conditions 'projects/:id.:format', :action => 'destroy', :format => /xml/
201 project_mapper.with_options :conditions => {:method => :delete} do |project_actions|
213 202 project_actions.conditions 'projects/:id/reset_activities', :controller => 'project_enumerations', :action => 'destroy'
214 203 end
204
215 205 end
216 206
207 map.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity|
208 activity.connect 'projects/:id/activity'
209 activity.connect 'projects/:id/activity.:format'
210 activity.connect 'activity', :id => nil
211 activity.connect 'activity.:format', :id => nil
212 end
213
217 214 map.with_options :controller => 'versions' do |versions|
218 215 versions.connect 'projects/:project_id/versions/new', :action => 'new'
219 216 versions.connect 'projects/:project_id/roadmap', :action => 'index'
220 217 versions.with_options :conditions => {:method => :post} do |version_actions|
221 218 version_actions.connect 'projects/:project_id/versions/close_completed', :action => 'close_completed'
222 219 end
223 220 end
224 221
225 222 map.with_options :controller => 'issue_categories' do |categories|
226 223 categories.connect 'projects/:project_id/issue_categories/new', :action => 'new'
227 224 end
228 225
229 226 map.with_options :controller => 'repositories' do |repositories|
230 227 repositories.with_options :conditions => {:method => :get} do |repository_views|
231 228 repository_views.connect 'projects/:id/repository', :action => 'show'
232 229 repository_views.connect 'projects/:id/repository/edit', :action => 'edit'
233 230 repository_views.connect 'projects/:id/repository/statistics', :action => 'stats'
234 231 repository_views.connect 'projects/:id/repository/revisions', :action => 'revisions'
235 232 repository_views.connect 'projects/:id/repository/revisions.:format', :action => 'revisions'
236 233 repository_views.connect 'projects/:id/repository/revisions/:rev', :action => 'revision'
237 234 repository_views.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff'
238 235 repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff'
239 236 repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path', :action => 'entry', :format => 'raw', :requirements => { :rev => /[a-z0-9\.\-_]+/ }
240 237 repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path', :requirements => { :rev => /[a-z0-9\.\-_]+/ }
241 238 repository_views.connect 'projects/:id/repository/raw/*path', :action => 'entry', :format => 'raw'
242 239 # TODO: why the following route is required?
243 240 repository_views.connect 'projects/:id/repository/entry/*path', :action => 'entry'
244 241 repository_views.connect 'projects/:id/repository/:action/*path'
245 242 end
246 243
247 244 repositories.connect 'projects/:id/repository/:action', :conditions => {:method => :post}
248 245 end
249 246
250 247 map.connect 'attachments/:id', :controller => 'attachments', :action => 'show', :id => /\d+/
251 248 map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/
252 249 map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/
253 250
254 251 map.resources :groups
255 252
256 253 #left old routes at the bottom for backwards compat
257 254 map.connect 'projects/:project_id/issues/:action', :controller => 'issues'
258 255 map.connect 'projects/:project_id/documents/:action', :controller => 'documents'
259 256 map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards'
260 257 map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages'
261 258 map.connect 'wiki/:id/:page/:action', :page => nil, :controller => 'wiki'
262 259 map.connect 'issues/:issue_id/relations/:action/:id', :controller => 'issue_relations'
263 260 map.connect 'projects/:project_id/news/:action', :controller => 'news'
264 261 map.connect 'projects/:project_id/timelog/:action/:id', :controller => 'timelog', :project_id => /.+/
265 262 map.with_options :controller => 'repositories' do |omap|
266 263 omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse'
267 264 omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes'
268 265 omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff'
269 266 omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry'
270 267 omap.repositories_entry 'repositories/annotate/:id/*path', :action => 'annotate'
271 268 omap.connect 'repositories/revision/:id/:rev', :action => 'revision'
272 269 end
273 270
274 271 map.with_options :controller => 'sys' do |sys|
275 272 sys.connect 'sys/projects.:format', :action => 'projects', :conditions => {:method => :get}
276 273 sys.connect 'sys/projects/:id/repository.:format', :action => 'create_project_repository', :conditions => {:method => :post}
277 274 end
278 275
279 276 # Install the default route as the lowest priority.
280 277 map.connect ':controller/:action/:id'
281 278 map.connect 'robots.txt', :controller => 'welcome', :action => 'robots'
282 279 # Used for OpenID
283 280 map.root :controller => 'account', :action => 'login'
284 281 end
@@ -1,291 +1,290
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2010 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require "#{File.dirname(__FILE__)}/../test_helper"
19 19
20 20 class RoutingTest < ActionController::IntegrationTest
21 21 context "activities" do
22 22 should_route :get, "/activity", :controller => 'activities', :action => 'index', :id => nil
23 23 should_route :get, "/activity.atom", :controller => 'activities', :action => 'index', :id => nil, :format => 'atom'
24 24 end
25 25
26 26 context "attachments" do
27 27 should_route :get, "/attachments/1", :controller => 'attachments', :action => 'show', :id => '1'
28 28 should_route :get, "/attachments/1/filename.ext", :controller => 'attachments', :action => 'show', :id => '1', :filename => 'filename.ext'
29 29 should_route :get, "/attachments/download/1", :controller => 'attachments', :action => 'download', :id => '1'
30 30 should_route :get, "/attachments/download/1/filename.ext", :controller => 'attachments', :action => 'download', :id => '1', :filename => 'filename.ext'
31 31 end
32 32
33 33 context "boards" do
34 34 should_route :get, "/projects/world_domination/boards", :controller => 'boards', :action => 'index', :project_id => 'world_domination'
35 35 should_route :get, "/projects/world_domination/boards/new", :controller => 'boards', :action => 'new', :project_id => 'world_domination'
36 36 should_route :get, "/projects/world_domination/boards/44", :controller => 'boards', :action => 'show', :project_id => 'world_domination', :id => '44'
37 37 should_route :get, "/projects/world_domination/boards/44.atom", :controller => 'boards', :action => 'show', :project_id => 'world_domination', :id => '44', :format => 'atom'
38 38 should_route :get, "/projects/world_domination/boards/44/edit", :controller => 'boards', :action => 'edit', :project_id => 'world_domination', :id => '44'
39 39
40 40 should_route :post, "/projects/world_domination/boards/new", :controller => 'boards', :action => 'new', :project_id => 'world_domination'
41 41 should_route :post, "/projects/world_domination/boards/44/edit", :controller => 'boards', :action => 'edit', :project_id => 'world_domination', :id => '44'
42 42 should_route :post, "/projects/world_domination/boards/44/destroy", :controller => 'boards', :action => 'destroy', :project_id => 'world_domination', :id => '44'
43 43
44 44 end
45 45
46 46 context "documents" do
47 47 should_route :get, "/projects/567/documents", :controller => 'documents', :action => 'index', :project_id => '567'
48 48 should_route :get, "/projects/567/documents/new", :controller => 'documents', :action => 'new', :project_id => '567'
49 49 should_route :get, "/documents/22", :controller => 'documents', :action => 'show', :id => '22'
50 50 should_route :get, "/documents/22/edit", :controller => 'documents', :action => 'edit', :id => '22'
51 51
52 52 should_route :post, "/projects/567/documents/new", :controller => 'documents', :action => 'new', :project_id => '567'
53 53 should_route :post, "/documents/567/edit", :controller => 'documents', :action => 'edit', :id => '567'
54 54 should_route :post, "/documents/567/destroy", :controller => 'documents', :action => 'destroy', :id => '567'
55 55 end
56 56
57 57 context "issues" do
58 58 # REST actions
59 59 should_route :get, "/issues", :controller => 'issues', :action => 'index'
60 60 should_route :get, "/issues.pdf", :controller => 'issues', :action => 'index', :format => 'pdf'
61 61 should_route :get, "/issues.atom", :controller => 'issues', :action => 'index', :format => 'atom'
62 62 should_route :get, "/issues.xml", :controller => 'issues', :action => 'index', :format => 'xml'
63 63 should_route :get, "/projects/23/issues", :controller => 'issues', :action => 'index', :project_id => '23'
64 64 should_route :get, "/projects/23/issues.pdf", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'pdf'
65 65 should_route :get, "/projects/23/issues.atom", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'atom'
66 66 should_route :get, "/projects/23/issues.xml", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'xml'
67 67 should_route :get, "/issues/64", :controller => 'issues', :action => 'show', :id => '64'
68 68 should_route :get, "/issues/64.pdf", :controller => 'issues', :action => 'show', :id => '64', :format => 'pdf'
69 69 should_route :get, "/issues/64.atom", :controller => 'issues', :action => 'show', :id => '64', :format => 'atom'
70 70 should_route :get, "/issues/64.xml", :controller => 'issues', :action => 'show', :id => '64', :format => 'xml'
71 71
72 72 should_route :get, "/projects/23/issues/new", :controller => 'issues', :action => 'new', :project_id => '23'
73 73 should_route :post, "/projects/23/issues", :controller => 'issues', :action => 'create', :project_id => '23'
74 74 should_route :post, "/issues.xml", :controller => 'issues', :action => 'create', :format => 'xml'
75 75
76 76 should_route :get, "/issues/64/edit", :controller => 'issues', :action => 'edit', :id => '64'
77 77 # TODO: Should use PUT
78 78 should_route :post, "/issues/64/edit", :controller => 'issues', :action => 'edit', :id => '64'
79 79 should_route :put, "/issues/1.xml", :controller => 'issues', :action => 'update', :id => '1', :format => 'xml'
80 80
81 81 # TODO: Should use DELETE
82 82 should_route :post, "/issues/64/destroy", :controller => 'issues', :action => 'destroy', :id => '64'
83 83 should_route :delete, "/issues/1.xml", :controller => 'issues', :action => 'destroy', :id => '1', :format => 'xml'
84 84
85 85 # Extra actions
86 86 should_route :get, "/projects/23/issues/64/copy", :controller => 'issues', :action => 'new', :project_id => '23', :copy_from => '64'
87 87
88 88 should_route :get, "/issues/move/new", :controller => 'issue_moves', :action => 'new'
89 89 should_route :post, "/issues/move", :controller => 'issue_moves', :action => 'create'
90 90
91 91 should_route :post, "/issues/1/quoted", :controller => 'journals', :action => 'new', :id => '1'
92 92
93 93 should_route :get, "/issues/calendar", :controller => 'calendars', :action => 'show'
94 94 should_route :put, "/issues/calendar", :controller => 'calendars', :action => 'update'
95 95 should_route :get, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'show', :project_id => 'project-name'
96 96 should_route :put, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'update', :project_id => 'project-name'
97 97
98 98 should_route :get, "/issues/gantt", :controller => 'gantts', :action => 'show'
99 99 should_route :put, "/issues/gantt", :controller => 'gantts', :action => 'update'
100 100 should_route :get, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'show', :project_id => 'project-name'
101 101 should_route :put, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'update', :project_id => 'project-name'
102 102
103 103 should_route :get, "/issues/auto_complete", :controller => 'auto_completes', :action => 'issues'
104 104
105 105 should_route :get, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123'
106 106 should_route :post, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123'
107 107 should_route :get, "/issues/context_menu", :controller => 'context_menus', :action => 'issues'
108 108 should_route :post, "/issues/context_menu", :controller => 'context_menus', :action => 'issues'
109 109
110 110 should_route :get, "/issues/changes", :controller => 'journals', :action => 'index'
111 111
112 112 should_route :get, "/issues/bulk_edit", :controller => 'issues', :action => 'bulk_edit'
113 113 should_route :post, "/issues/bulk_edit", :controller => 'issues', :action => 'bulk_update'
114 114 end
115 115
116 116 context "issue categories" do
117 117 should_route :get, "/projects/test/issue_categories/new", :controller => 'issue_categories', :action => 'new', :project_id => 'test'
118 118
119 119 should_route :post, "/projects/test/issue_categories/new", :controller => 'issue_categories', :action => 'new', :project_id => 'test'
120 120 end
121 121
122 122 context "issue relations" do
123 123 should_route :post, "/issues/1/relations", :controller => 'issue_relations', :action => 'new', :issue_id => '1'
124 124 should_route :post, "/issues/1/relations/23/destroy", :controller => 'issue_relations', :action => 'destroy', :issue_id => '1', :id => '23'
125 125 end
126 126
127 127 context "issue reports" do
128 128 should_route :get, "/projects/567/issues/report", :controller => 'reports', :action => 'issue_report', :id => '567'
129 129 should_route :get, "/projects/567/issues/report/assigned_to", :controller => 'reports', :action => 'issue_report_details', :id => '567', :detail => 'assigned_to'
130 130 end
131 131
132 132 context "members" do
133 133 should_route :post, "/projects/5234/members/new", :controller => 'members', :action => 'new', :id => '5234'
134 134 end
135 135
136 136 context "messages" do
137 137 should_route :get, "/boards/22/topics/2", :controller => 'messages', :action => 'show', :id => '2', :board_id => '22'
138 138 should_route :get, "/boards/lala/topics/new", :controller => 'messages', :action => 'new', :board_id => 'lala'
139 139 should_route :get, "/boards/lala/topics/22/edit", :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala'
140 140
141 141 should_route :post, "/boards/lala/topics/new", :controller => 'messages', :action => 'new', :board_id => 'lala'
142 142 should_route :post, "/boards/lala/topics/22/edit", :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala'
143 143 should_route :post, "/boards/22/topics/555/replies", :controller => 'messages', :action => 'reply', :id => '555', :board_id => '22'
144 144 should_route :post, "/boards/22/topics/555/destroy", :controller => 'messages', :action => 'destroy', :id => '555', :board_id => '22'
145 145 end
146 146
147 147 context "news" do
148 148 should_route :get, "/news", :controller => 'news', :action => 'index'
149 149 should_route :get, "/news.atom", :controller => 'news', :action => 'index', :format => 'atom'
150 150 should_route :get, "/news.xml", :controller => 'news', :action => 'index', :format => 'xml'
151 151 should_route :get, "/news.json", :controller => 'news', :action => 'index', :format => 'json'
152 152 should_route :get, "/projects/567/news", :controller => 'news', :action => 'index', :project_id => '567'
153 153 should_route :get, "/projects/567/news.atom", :controller => 'news', :action => 'index', :format => 'atom', :project_id => '567'
154 154 should_route :get, "/projects/567/news.xml", :controller => 'news', :action => 'index', :format => 'xml', :project_id => '567'
155 155 should_route :get, "/projects/567/news.json", :controller => 'news', :action => 'index', :format => 'json', :project_id => '567'
156 156 should_route :get, "/news/2", :controller => 'news', :action => 'show', :id => '2'
157 157 should_route :get, "/projects/567/news/new", :controller => 'news', :action => 'new', :project_id => '567'
158 158 should_route :get, "/news/234", :controller => 'news', :action => 'show', :id => '234'
159 159
160 160 should_route :post, "/projects/567/news/new", :controller => 'news', :action => 'new', :project_id => '567'
161 161 should_route :post, "/news/567/edit", :controller => 'news', :action => 'edit', :id => '567'
162 162 should_route :post, "/news/567/destroy", :controller => 'news', :action => 'destroy', :id => '567'
163 163 end
164 164
165 165 context "projects" do
166 166 should_route :get, "/projects", :controller => 'projects', :action => 'index'
167 167 should_route :get, "/projects.atom", :controller => 'projects', :action => 'index', :format => 'atom'
168 168 should_route :get, "/projects.xml", :controller => 'projects', :action => 'index', :format => 'xml'
169 169 should_route :get, "/projects/new", :controller => 'projects', :action => 'new'
170 170 should_route :get, "/projects/test", :controller => 'projects', :action => 'show', :id => 'test'
171 171 should_route :get, "/projects/1.xml", :controller => 'projects', :action => 'show', :id => '1', :format => 'xml'
172 172 should_route :get, "/projects/4223/settings", :controller => 'projects', :action => 'settings', :id => '4223'
173 173 should_route :get, "/projects/4223/settings/members", :controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members'
174 should_route :get, "/projects/567/destroy", :controller => 'projects', :action => 'destroy', :id => '567'
175 174 should_route :get, "/projects/33/files", :controller => 'files', :action => 'index', :id => '33'
176 175 should_route :get, "/projects/33/files/new", :controller => 'files', :action => 'new', :id => '33'
177 176 should_route :get, "/projects/33/roadmap", :controller => 'versions', :action => 'index', :project_id => '33'
178 177 should_route :get, "/projects/33/activity", :controller => 'activities', :action => 'index', :id => '33'
179 178 should_route :get, "/projects/33/activity.atom", :controller => 'activities', :action => 'index', :id => '33', :format => 'atom'
180 179
181 should_route :post, "/projects/new", :controller => 'projects', :action => 'create'
180 should_route :post, "/projects", :controller => 'projects', :action => 'create'
182 181 should_route :post, "/projects.xml", :controller => 'projects', :action => 'create', :format => 'xml'
183 should_route :post, "/projects/4223/edit", :controller => 'projects', :action => 'update', :id => '4223'
184 should_route :post, "/projects/64/destroy", :controller => 'projects', :action => 'destroy', :id => '64'
185 182 should_route :post, "/projects/33/files/new", :controller => 'files', :action => 'new', :id => '33'
186 183 should_route :post, "/projects/64/archive", :controller => 'projects', :action => 'archive', :id => '64'
187 184 should_route :post, "/projects/64/unarchive", :controller => 'projects', :action => 'unarchive', :id => '64'
188 185 should_route :post, "/projects/64/activities/save", :controller => 'project_enumerations', :action => 'save', :id => '64'
189 186
187 should_route :put, "/projects/4223", :controller => 'projects', :action => 'update', :id => '4223'
190 188 should_route :put, "/projects/1.xml", :controller => 'projects', :action => 'update', :id => '1', :format => 'xml'
191 189
190 should_route :delete, "/projects/64", :controller => 'projects', :action => 'destroy', :id => '64'
192 191 should_route :delete, "/projects/1.xml", :controller => 'projects', :action => 'destroy', :id => '1', :format => 'xml'
193 192 should_route :delete, "/projects/64/reset_activities", :controller => 'project_enumerations', :action => 'destroy', :id => '64'
194 193 end
195 194
196 195 context "repositories" do
197 196 should_route :get, "/projects/redmine/repository", :controller => 'repositories', :action => 'show', :id => 'redmine'
198 197 should_route :get, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine'
199 198 should_route :get, "/projects/redmine/repository/revisions", :controller => 'repositories', :action => 'revisions', :id => 'redmine'
200 199 should_route :get, "/projects/redmine/repository/revisions.atom", :controller => 'repositories', :action => 'revisions', :id => 'redmine', :format => 'atom'
201 200 should_route :get, "/projects/redmine/repository/revisions/2457", :controller => 'repositories', :action => 'revision', :id => 'redmine', :rev => '2457'
202 201 should_route :get, "/projects/redmine/repository/revisions/2457/diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457'
203 202 should_route :get, "/projects/redmine/repository/revisions/2457/diff.diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457', :format => 'diff'
204 203 should_route :get, "/projects/redmine/repository/diff/path/to/file.c", :controller => 'repositories', :action => 'diff', :id => 'redmine', :path => %w[path to file.c]
205 204 should_route :get, "/projects/redmine/repository/revisions/2/diff/path/to/file.c", :controller => 'repositories', :action => 'diff', :id => 'redmine', :path => %w[path to file.c], :rev => '2'
206 205 should_route :get, "/projects/redmine/repository/browse/path/to/file.c", :controller => 'repositories', :action => 'browse', :id => 'redmine', :path => %w[path to file.c]
207 206 should_route :get, "/projects/redmine/repository/entry/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c]
208 207 should_route :get, "/projects/redmine/repository/revisions/2/entry/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :rev => '2'
209 208 should_route :get, "/projects/redmine/repository/raw/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :format => 'raw'
210 209 should_route :get, "/projects/redmine/repository/revisions/2/raw/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :rev => '2', :format => 'raw'
211 210 should_route :get, "/projects/redmine/repository/annotate/path/to/file.c", :controller => 'repositories', :action => 'annotate', :id => 'redmine', :path => %w[path to file.c]
212 211 should_route :get, "/projects/redmine/repository/changes/path/to/file.c", :controller => 'repositories', :action => 'changes', :id => 'redmine', :path => %w[path to file.c]
213 212 should_route :get, "/projects/redmine/repository/statistics", :controller => 'repositories', :action => 'stats', :id => 'redmine'
214 213
215 214
216 215 should_route :post, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine'
217 216 end
218 217
219 218 context "timelogs" do
220 219 should_route :get, "/issues/567/time_entries/new", :controller => 'timelog', :action => 'edit', :issue_id => '567'
221 220 should_route :get, "/projects/ecookbook/time_entries/new", :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook'
222 221 should_route :get, "/projects/ecookbook/issues/567/time_entries/new", :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook', :issue_id => '567'
223 222 should_route :get, "/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22'
224 223 should_route :get, "/time_entries/report", :controller => 'timelog', :action => 'report'
225 224 should_route :get, "/projects/567/time_entries/report", :controller => 'timelog', :action => 'report', :project_id => '567'
226 225 should_route :get, "/projects/567/time_entries/report.csv", :controller => 'timelog', :action => 'report', :project_id => '567', :format => 'csv'
227 226 should_route :get, "/time_entries", :controller => 'timelog', :action => 'details'
228 227 should_route :get, "/time_entries.csv", :controller => 'timelog', :action => 'details', :format => 'csv'
229 228 should_route :get, "/time_entries.atom", :controller => 'timelog', :action => 'details', :format => 'atom'
230 229 should_route :get, "/projects/567/time_entries", :controller => 'timelog', :action => 'details', :project_id => '567'
231 230 should_route :get, "/projects/567/time_entries.csv", :controller => 'timelog', :action => 'details', :project_id => '567', :format => 'csv'
232 231 should_route :get, "/projects/567/time_entries.atom", :controller => 'timelog', :action => 'details', :project_id => '567', :format => 'atom'
233 232 should_route :get, "/issues/234/time_entries", :controller => 'timelog', :action => 'details', :issue_id => '234'
234 233 should_route :get, "/issues/234/time_entries.csv", :controller => 'timelog', :action => 'details', :issue_id => '234', :format => 'csv'
235 234 should_route :get, "/issues/234/time_entries.atom", :controller => 'timelog', :action => 'details', :issue_id => '234', :format => 'atom'
236 235 should_route :get, "/projects/ecookbook/issues/123/time_entries", :controller => 'timelog', :action => 'details', :project_id => 'ecookbook', :issue_id => '123'
237 236
238 237 should_route :post, "/time_entries/55/destroy", :controller => 'timelog', :action => 'destroy', :id => '55'
239 238 end
240 239
241 240 context "users" do
242 241 should_route :get, "/users", :controller => 'users', :action => 'index'
243 242 should_route :get, "/users/44", :controller => 'users', :action => 'show', :id => '44'
244 243 should_route :get, "/users/new", :controller => 'users', :action => 'add'
245 244 should_route :get, "/users/444/edit", :controller => 'users', :action => 'edit', :id => '444'
246 245 should_route :get, "/users/222/edit/membership", :controller => 'users', :action => 'edit', :id => '222', :tab => 'membership'
247 246
248 247 should_route :post, "/users/new", :controller => 'users', :action => 'add'
249 248 should_route :post, "/users/444/edit", :controller => 'users', :action => 'edit', :id => '444'
250 249 should_route :post, "/users/123/memberships", :controller => 'users', :action => 'edit_membership', :id => '123'
251 250 should_route :post, "/users/123/memberships/55", :controller => 'users', :action => 'edit_membership', :id => '123', :membership_id => '55'
252 251 should_route :post, "/users/567/memberships/12/destroy", :controller => 'users', :action => 'destroy_membership', :id => '567', :membership_id => '12'
253 252 end
254 253
255 254 context "versions" do
256 255 should_route :get, "/projects/foo/versions/new", :controller => 'versions', :action => 'new', :project_id => 'foo'
257 256
258 257 should_route :post, "/projects/foo/versions/new", :controller => 'versions', :action => 'new', :project_id => 'foo'
259 258 end
260 259
261 260 context "wiki (singular, project's pages)" do
262 261 should_route :get, "/projects/567/wiki", :controller => 'wiki', :action => 'index', :id => '567'
263 262 should_route :get, "/projects/567/wiki/lalala", :controller => 'wiki', :action => 'index', :id => '567', :page => 'lalala'
264 263 should_route :get, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page'
265 264 should_route :get, "/projects/1/wiki/CookBook_documentation/history", :controller => 'wiki', :action => 'history', :id => '1', :page => 'CookBook_documentation'
266 265 should_route :get, "/projects/1/wiki/CookBook_documentation/diff/2/vs/1", :controller => 'wiki', :action => 'diff', :id => '1', :page => 'CookBook_documentation', :version => '2', :version_from => '1'
267 266 should_route :get, "/projects/1/wiki/CookBook_documentation/annotate/2", :controller => 'wiki', :action => 'annotate', :id => '1', :page => 'CookBook_documentation', :version => '2'
268 267 should_route :get, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida'
269 268 should_route :get, "/projects/567/wiki/page_index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'page_index'
270 269 should_route :get, "/projects/567/wiki/Page_Index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'Page_Index'
271 270 should_route :get, "/projects/567/wiki/date_index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'date_index'
272 271 should_route :get, "/projects/567/wiki/export", :controller => 'wiki', :action => 'special', :id => '567', :page => 'export'
273 272
274 273 should_route :post, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page'
275 274 should_route :post, "/projects/567/wiki/CookBook_documentation/preview", :controller => 'wiki', :action => 'preview', :id => '567', :page => 'CookBook_documentation'
276 275 should_route :post, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida'
277 276 should_route :post, "/projects/22/wiki/ladida/destroy", :controller => 'wiki', :action => 'destroy', :id => '22', :page => 'ladida'
278 277 should_route :post, "/projects/22/wiki/ladida/protect", :controller => 'wiki', :action => 'protect', :id => '22', :page => 'ladida'
279 278 end
280 279
281 280 context "wikis (plural, admin setup)" do
282 281 should_route :get, "/projects/ladida/wiki/destroy", :controller => 'wikis', :action => 'destroy', :id => 'ladida'
283 282
284 283 should_route :post, "/projects/ladida/wiki", :controller => 'wikis', :action => 'edit', :id => 'ladida'
285 284 should_route :post, "/projects/ladida/wiki/destroy", :controller => 'wikis', :action => 'destroy', :id => 'ladida'
286 285 end
287 286
288 287 context "administration panel" do
289 288 should_route :get, "/admin/projects", :controller => 'admin', :action => 'projects'
290 289 end
291 290 end
General Comments 0
You need to be logged in to leave comments. Login now