##// END OF EJS Templates
Refactor: convert timelogs to a REST resource (:time_entries)...
Eric Davis -
r4136:718816c5d4b0
parent child
Show More
@@ -1,221 +1,220
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
2 # Copyright (C) 2006-2007 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 class TimelogController < ApplicationController
18 class TimelogController < ApplicationController
19 menu_item :issues
19 menu_item :issues
20 before_filter :find_project, :authorize, :only => [:new, :create, :edit, :update, :destroy]
20 before_filter :find_project, :authorize, :only => [:new, :create, :edit, :update, :destroy]
21 before_filter :find_optional_project, :only => [:index]
21 before_filter :find_optional_project, :only => [:index]
22
22
23 verify :method => :post, :only => :destroy, :redirect_to => { :action => :index }
24
25 helper :sort
23 helper :sort
26 include SortHelper
24 include SortHelper
27 helper :issues
25 helper :issues
28 include TimelogHelper
26 include TimelogHelper
29 helper :custom_fields
27 helper :custom_fields
30 include CustomFieldsHelper
28 include CustomFieldsHelper
31
29
32 def index
30 def index
33 sort_init 'spent_on', 'desc'
31 sort_init 'spent_on', 'desc'
34 sort_update 'spent_on' => 'spent_on',
32 sort_update 'spent_on' => 'spent_on',
35 'user' => 'user_id',
33 'user' => 'user_id',
36 'activity' => 'activity_id',
34 'activity' => 'activity_id',
37 'project' => "#{Project.table_name}.name",
35 'project' => "#{Project.table_name}.name",
38 'issue' => 'issue_id',
36 'issue' => 'issue_id',
39 'hours' => 'hours'
37 'hours' => 'hours'
40
38
41 cond = ARCondition.new
39 cond = ARCondition.new
42 if @project.nil?
40 if @project.nil?
43 cond << Project.allowed_to_condition(User.current, :view_time_entries)
41 cond << Project.allowed_to_condition(User.current, :view_time_entries)
44 elsif @issue.nil?
42 elsif @issue.nil?
45 cond << @project.project_condition(Setting.display_subprojects_issues?)
43 cond << @project.project_condition(Setting.display_subprojects_issues?)
46 else
44 else
47 cond << "#{Issue.table_name}.root_id = #{@issue.root_id} AND #{Issue.table_name}.lft >= #{@issue.lft} AND #{Issue.table_name}.rgt <= #{@issue.rgt}"
45 cond << "#{Issue.table_name}.root_id = #{@issue.root_id} AND #{Issue.table_name}.lft >= #{@issue.lft} AND #{Issue.table_name}.rgt <= #{@issue.rgt}"
48 end
46 end
49
47
50 retrieve_date_range
48 retrieve_date_range
51 cond << ['spent_on BETWEEN ? AND ?', @from, @to]
49 cond << ['spent_on BETWEEN ? AND ?', @from, @to]
52
50
53 TimeEntry.visible_by(User.current) do
51 TimeEntry.visible_by(User.current) do
54 respond_to do |format|
52 respond_to do |format|
55 format.html {
53 format.html {
56 # Paginate results
54 # Paginate results
57 @entry_count = TimeEntry.count(:include => [:project, :issue], :conditions => cond.conditions)
55 @entry_count = TimeEntry.count(:include => [:project, :issue], :conditions => cond.conditions)
58 @entry_pages = Paginator.new self, @entry_count, per_page_option, params['page']
56 @entry_pages = Paginator.new self, @entry_count, per_page_option, params['page']
59 @entries = TimeEntry.find(:all,
57 @entries = TimeEntry.find(:all,
60 :include => [:project, :activity, :user, {:issue => :tracker}],
58 :include => [:project, :activity, :user, {:issue => :tracker}],
61 :conditions => cond.conditions,
59 :conditions => cond.conditions,
62 :order => sort_clause,
60 :order => sort_clause,
63 :limit => @entry_pages.items_per_page,
61 :limit => @entry_pages.items_per_page,
64 :offset => @entry_pages.current.offset)
62 :offset => @entry_pages.current.offset)
65 @total_hours = TimeEntry.sum(:hours, :include => [:project, :issue], :conditions => cond.conditions).to_f
63 @total_hours = TimeEntry.sum(:hours, :include => [:project, :issue], :conditions => cond.conditions).to_f
66
64
67 render :layout => !request.xhr?
65 render :layout => !request.xhr?
68 }
66 }
69 format.atom {
67 format.atom {
70 entries = TimeEntry.find(:all,
68 entries = TimeEntry.find(:all,
71 :include => [:project, :activity, :user, {:issue => :tracker}],
69 :include => [:project, :activity, :user, {:issue => :tracker}],
72 :conditions => cond.conditions,
70 :conditions => cond.conditions,
73 :order => "#{TimeEntry.table_name}.created_on DESC",
71 :order => "#{TimeEntry.table_name}.created_on DESC",
74 :limit => Setting.feeds_limit.to_i)
72 :limit => Setting.feeds_limit.to_i)
75 render_feed(entries, :title => l(:label_spent_time))
73 render_feed(entries, :title => l(:label_spent_time))
76 }
74 }
77 format.csv {
75 format.csv {
78 # Export all entries
76 # Export all entries
79 @entries = TimeEntry.find(:all,
77 @entries = TimeEntry.find(:all,
80 :include => [:project, :activity, :user, {:issue => [:tracker, :assigned_to, :priority]}],
78 :include => [:project, :activity, :user, {:issue => [:tracker, :assigned_to, :priority]}],
81 :conditions => cond.conditions,
79 :conditions => cond.conditions,
82 :order => sort_clause)
80 :order => sort_clause)
83 send_data(entries_to_csv(@entries), :type => 'text/csv; header=present', :filename => 'timelog.csv')
81 send_data(entries_to_csv(@entries), :type => 'text/csv; header=present', :filename => 'timelog.csv')
84 }
82 }
85 end
83 end
86 end
84 end
87 end
85 end
88
86
89 def new
87 def new
90 @time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => User.current.today)
88 @time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => User.current.today)
91 @time_entry.attributes = params[:time_entry]
89 @time_entry.attributes = params[:time_entry]
92
90
93 call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
91 call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
94 render :action => 'edit'
92 render :action => 'edit'
95 end
93 end
96
94
97 verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
95 verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
98 def create
96 def create
99 @time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => User.current.today)
97 @time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => User.current.today)
100 @time_entry.attributes = params[:time_entry]
98 @time_entry.attributes = params[:time_entry]
101
99
102 call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
100 call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
103
101
104 if @time_entry.save
102 if @time_entry.save
105 flash[:notice] = l(:notice_successful_update)
103 flash[:notice] = l(:notice_successful_update)
106 redirect_back_or_default :action => 'index', :project_id => @time_entry.project
104 redirect_back_or_default :action => 'index', :project_id => @time_entry.project
107 else
105 else
108 render :action => 'edit'
106 render :action => 'edit'
109 end
107 end
110 end
108 end
111
109
112 def edit
110 def edit
113 (render_403; return) if @time_entry && !@time_entry.editable_by?(User.current)
111 (render_403; return) if @time_entry && !@time_entry.editable_by?(User.current)
114 @time_entry.attributes = params[:time_entry]
112 @time_entry.attributes = params[:time_entry]
115
113
116 call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
114 call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
117 end
115 end
118
116
119 verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
117 verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
120 def update
118 def update
121 (render_403; return) if @time_entry && !@time_entry.editable_by?(User.current)
119 (render_403; return) if @time_entry && !@time_entry.editable_by?(User.current)
122 @time_entry.attributes = params[:time_entry]
120 @time_entry.attributes = params[:time_entry]
123
121
124 call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
122 call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
125
123
126 if @time_entry.save
124 if @time_entry.save
127 flash[:notice] = l(:notice_successful_update)
125 flash[:notice] = l(:notice_successful_update)
128 redirect_back_or_default :action => 'index', :project_id => @time_entry.project
126 redirect_back_or_default :action => 'index', :project_id => @time_entry.project
129 else
127 else
130 render :action => 'edit'
128 render :action => 'edit'
131 end
129 end
132 end
130 end
133
131
132 verify :method => :delete, :only => :destroy, :render => {:nothing => true, :status => :method_not_allowed }
134 def destroy
133 def destroy
135 (render_404; return) unless @time_entry
134 (render_404; return) unless @time_entry
136 (render_403; return) unless @time_entry.editable_by?(User.current)
135 (render_403; return) unless @time_entry.editable_by?(User.current)
137 if @time_entry.destroy && @time_entry.destroyed?
136 if @time_entry.destroy && @time_entry.destroyed?
138 flash[:notice] = l(:notice_successful_delete)
137 flash[:notice] = l(:notice_successful_delete)
139 else
138 else
140 flash[:error] = l(:notice_unable_delete_time_entry)
139 flash[:error] = l(:notice_unable_delete_time_entry)
141 end
140 end
142 redirect_to :back
141 redirect_to :back
143 rescue ::ActionController::RedirectBackError
142 rescue ::ActionController::RedirectBackError
144 redirect_to :action => 'index', :project_id => @time_entry.project
143 redirect_to :action => 'index', :project_id => @time_entry.project
145 end
144 end
146
145
147 private
146 private
148 def find_project
147 def find_project
149 if params[:id]
148 if params[:id]
150 @time_entry = TimeEntry.find(params[:id])
149 @time_entry = TimeEntry.find(params[:id])
151 @project = @time_entry.project
150 @project = @time_entry.project
152 elsif params[:issue_id]
151 elsif params[:issue_id]
153 @issue = Issue.find(params[:issue_id])
152 @issue = Issue.find(params[:issue_id])
154 @project = @issue.project
153 @project = @issue.project
155 elsif params[:project_id]
154 elsif params[:project_id]
156 @project = Project.find(params[:project_id])
155 @project = Project.find(params[:project_id])
157 else
156 else
158 render_404
157 render_404
159 return false
158 return false
160 end
159 end
161 rescue ActiveRecord::RecordNotFound
160 rescue ActiveRecord::RecordNotFound
162 render_404
161 render_404
163 end
162 end
164
163
165 def find_optional_project
164 def find_optional_project
166 if !params[:issue_id].blank?
165 if !params[:issue_id].blank?
167 @issue = Issue.find(params[:issue_id])
166 @issue = Issue.find(params[:issue_id])
168 @project = @issue.project
167 @project = @issue.project
169 elsif !params[:project_id].blank?
168 elsif !params[:project_id].blank?
170 @project = Project.find(params[:project_id])
169 @project = Project.find(params[:project_id])
171 end
170 end
172 deny_access unless User.current.allowed_to?(:view_time_entries, @project, :global => true)
171 deny_access unless User.current.allowed_to?(:view_time_entries, @project, :global => true)
173 end
172 end
174
173
175 # Retrieves the date range based on predefined ranges or specific from/to param dates
174 # Retrieves the date range based on predefined ranges or specific from/to param dates
176 def retrieve_date_range
175 def retrieve_date_range
177 @free_period = false
176 @free_period = false
178 @from, @to = nil, nil
177 @from, @to = nil, nil
179
178
180 if params[:period_type] == '1' || (params[:period_type].nil? && !params[:period].nil?)
179 if params[:period_type] == '1' || (params[:period_type].nil? && !params[:period].nil?)
181 case params[:period].to_s
180 case params[:period].to_s
182 when 'today'
181 when 'today'
183 @from = @to = Date.today
182 @from = @to = Date.today
184 when 'yesterday'
183 when 'yesterday'
185 @from = @to = Date.today - 1
184 @from = @to = Date.today - 1
186 when 'current_week'
185 when 'current_week'
187 @from = Date.today - (Date.today.cwday - 1)%7
186 @from = Date.today - (Date.today.cwday - 1)%7
188 @to = @from + 6
187 @to = @from + 6
189 when 'last_week'
188 when 'last_week'
190 @from = Date.today - 7 - (Date.today.cwday - 1)%7
189 @from = Date.today - 7 - (Date.today.cwday - 1)%7
191 @to = @from + 6
190 @to = @from + 6
192 when '7_days'
191 when '7_days'
193 @from = Date.today - 7
192 @from = Date.today - 7
194 @to = Date.today
193 @to = Date.today
195 when 'current_month'
194 when 'current_month'
196 @from = Date.civil(Date.today.year, Date.today.month, 1)
195 @from = Date.civil(Date.today.year, Date.today.month, 1)
197 @to = (@from >> 1) - 1
196 @to = (@from >> 1) - 1
198 when 'last_month'
197 when 'last_month'
199 @from = Date.civil(Date.today.year, Date.today.month, 1) << 1
198 @from = Date.civil(Date.today.year, Date.today.month, 1) << 1
200 @to = (@from >> 1) - 1
199 @to = (@from >> 1) - 1
201 when '30_days'
200 when '30_days'
202 @from = Date.today - 30
201 @from = Date.today - 30
203 @to = Date.today
202 @to = Date.today
204 when 'current_year'
203 when 'current_year'
205 @from = Date.civil(Date.today.year, 1, 1)
204 @from = Date.civil(Date.today.year, 1, 1)
206 @to = Date.civil(Date.today.year, 12, 31)
205 @to = Date.civil(Date.today.year, 12, 31)
207 end
206 end
208 elsif params[:period_type] == '2' || (params[:period_type].nil? && (!params[:from].nil? || !params[:to].nil?))
207 elsif params[:period_type] == '2' || (params[:period_type].nil? && (!params[:from].nil? || !params[:to].nil?))
209 begin; @from = params[:from].to_s.to_date unless params[:from].blank?; rescue; end
208 begin; @from = params[:from].to_s.to_date unless params[:from].blank?; rescue; end
210 begin; @to = params[:to].to_s.to_date unless params[:to].blank?; rescue; end
209 begin; @to = params[:to].to_s.to_date unless params[:to].blank?; rescue; end
211 @free_period = true
210 @free_period = true
212 else
211 else
213 # default
212 # default
214 end
213 end
215
214
216 @from, @to = @to, @from if @from && @to && @from > @to
215 @from, @to = @to, @from if @from && @to && @from > @to
217 @from ||= (TimeEntry.earilest_date_for_project(@project) || Date.today)
216 @from ||= (TimeEntry.earilest_date_for_project(@project) || Date.today)
218 @to ||= (TimeEntry.latest_date_for_project(@project) || Date.today)
217 @to ||= (TimeEntry.latest_date_for_project(@project) || Date.today)
219 end
218 end
220
219
221 end
220 end
@@ -1,41 +1,41
1 <table class="list time-entries">
1 <table class="list time-entries">
2 <thead>
2 <thead>
3 <tr>
3 <tr>
4 <%= sort_header_tag('spent_on', :caption => l(:label_date), :default_order => 'desc') %>
4 <%= sort_header_tag('spent_on', :caption => l(:label_date), :default_order => 'desc') %>
5 <%= sort_header_tag('user', :caption => l(:label_member)) %>
5 <%= sort_header_tag('user', :caption => l(:label_member)) %>
6 <%= sort_header_tag('activity', :caption => l(:label_activity)) %>
6 <%= sort_header_tag('activity', :caption => l(:label_activity)) %>
7 <%= sort_header_tag('project', :caption => l(:label_project)) %>
7 <%= sort_header_tag('project', :caption => l(:label_project)) %>
8 <%= sort_header_tag('issue', :caption => l(:label_issue), :default_order => 'desc') %>
8 <%= sort_header_tag('issue', :caption => l(:label_issue), :default_order => 'desc') %>
9 <th><%= l(:field_comments) %></th>
9 <th><%= l(:field_comments) %></th>
10 <%= sort_header_tag('hours', :caption => l(:field_hours)) %>
10 <%= sort_header_tag('hours', :caption => l(:field_hours)) %>
11 <th></th>
11 <th></th>
12 </tr>
12 </tr>
13 </thead>
13 </thead>
14 <tbody>
14 <tbody>
15 <% entries.each do |entry| -%>
15 <% entries.each do |entry| -%>
16 <tr class="time-entry <%= cycle("odd", "even") %>">
16 <tr class="time-entry <%= cycle("odd", "even") %>">
17 <td class="spent_on"><%= format_date(entry.spent_on) %></td>
17 <td class="spent_on"><%= format_date(entry.spent_on) %></td>
18 <td class="user"><%=h entry.user %></td>
18 <td class="user"><%=h entry.user %></td>
19 <td class="activity"><%=h entry.activity %></td>
19 <td class="activity"><%=h entry.activity %></td>
20 <td class="project"><%=h entry.project %></td>
20 <td class="project"><%=h entry.project %></td>
21 <td class="subject">
21 <td class="subject">
22 <% if entry.issue -%>
22 <% if entry.issue -%>
23 <%= entry.issue.visible? ? link_to_issue(entry.issue, :truncate => 50) : "##{entry.issue.id}" -%>
23 <%= entry.issue.visible? ? link_to_issue(entry.issue, :truncate => 50) : "##{entry.issue.id}" -%>
24 <% end -%>
24 <% end -%>
25 </td>
25 </td>
26 <td class="comments"><%=h entry.comments %></td>
26 <td class="comments"><%=h entry.comments %></td>
27 <td class="hours"><%= html_hours("%.2f" % entry.hours) %></td>
27 <td class="hours"><%= html_hours("%.2f" % entry.hours) %></td>
28 <td align="center">
28 <td align="center">
29 <% if entry.editable_by?(User.current) -%>
29 <% if entry.editable_by?(User.current) -%>
30 <%= link_to image_tag('edit.png'), {:controller => 'timelog', :action => 'edit', :id => entry, :project_id => nil},
30 <%= link_to image_tag('edit.png'), {:controller => 'timelog', :action => 'edit', :id => entry, :project_id => nil},
31 :title => l(:button_edit) %>
31 :title => l(:button_edit) %>
32 <%= link_to image_tag('delete.png'), {:controller => 'timelog', :action => 'destroy', :id => entry, :project_id => nil},
32 <%= link_to image_tag('delete.png'), {:controller => 'timelog', :action => 'destroy', :id => entry, :project_id => nil},
33 :confirm => l(:text_are_you_sure),
33 :confirm => l(:text_are_you_sure),
34 :method => :post,
34 :method => :delete,
35 :title => l(:button_delete) %>
35 :title => l(:button_delete) %>
36 <% end -%>
36 <% end -%>
37 </td>
37 </td>
38 </tr>
38 </tr>
39 <% end -%>
39 <% end -%>
40 </tbody>
40 </tbody>
41 </table>
41 </table>
@@ -1,260 +1,246
1 ActionController::Routing::Routes.draw do |map|
1 ActionController::Routing::Routes.draw do |map|
2 # Add your own custom routes here.
2 # Add your own custom routes here.
3 # The priority is based upon order of creation: first created -> highest priority.
3 # The priority is based upon order of creation: first created -> highest priority.
4
4
5 # Here's a sample route:
5 # Here's a sample route:
6 # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
6 # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
7 # Keep in mind you can assign values other than :controller and :action
7 # Keep in mind you can assign values other than :controller and :action
8
8
9 map.home '', :controller => 'welcome'
9 map.home '', :controller => 'welcome'
10
10
11 map.signin 'login', :controller => 'account', :action => 'login'
11 map.signin 'login', :controller => 'account', :action => 'login'
12 map.signout 'logout', :controller => 'account', :action => 'logout'
12 map.signout 'logout', :controller => 'account', :action => 'logout'
13
13
14 map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow'
14 map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow'
15 map.connect 'help/:ctrl/:page', :controller => 'help'
15 map.connect 'help/:ctrl/:page', :controller => 'help'
16
17 map.connect 'time_entries/:id/edit', :action => 'edit', :controller => 'timelog'
18 map.connect 'time_entries/:id', :action => 'update', :controller => 'timelog', :conditions => {:method => :put}
19 map.connect 'projects/:project_id/time_entries/new', :action => 'new', :controller => 'timelog'
20 map.connect 'projects/:project_id/issues/:issue_id/time_entries/new', :action => 'new', :controller => 'timelog'
21
22 map.with_options :controller => 'timelog' do |timelog|
23 timelog.connect 'projects/:project_id/time_entries', :action => 'index'
24
25 timelog.with_options :action => 'index', :conditions => {:method => :get} do |time_details|
26 time_details.connect 'time_entries'
27 time_details.connect 'time_entries.:format'
28 time_details.connect 'issues/:issue_id/time_entries'
29 time_details.connect 'issues/:issue_id/time_entries.:format'
30 time_details.connect 'projects/:project_id/time_entries.:format'
31 time_details.connect 'projects/:project_id/issues/:issue_id/time_entries'
32 time_details.connect 'projects/:project_id/issues/:issue_id/time_entries.:format'
33 end
34 timelog.connect 'projects/:project_id/time_entries/report', :controller => 'time_entry_reports', :action => 'report'
35 timelog.with_options :controller => 'time_entry_reports', :action => 'report',:conditions => {:method => :get} do |time_report|
36 time_report.connect 'time_entries/report'
37 time_report.connect 'time_entries/report.:format'
38 time_report.connect 'projects/:project_id/time_entries/report.:format'
39 end
40
41 timelog.with_options :action => 'new', :conditions => {:method => :get} do |time_edit|
42 time_edit.connect 'issues/:issue_id/time_entries/new'
43 end
44
16
45 timelog.connect 'projects/:project_id/timelog/edit', :action => 'create', :conditions => {:method => :post}
17 map.connect 'projects/:project_id/time_entries/report', :controller => 'time_entry_reports', :action => 'report'
46 timelog.connect 'time_entries/:id/destroy', :action => 'destroy', :conditions => {:method => :post}
18 map.with_options :controller => 'time_entry_reports', :action => 'report',:conditions => {:method => :get} do |time_report|
19 time_report.connect 'time_entries/report'
20 time_report.connect 'time_entries/report.:format'
21 time_report.connect 'projects/:project_id/time_entries/report.:format'
47 end
22 end
23
24 # TODO: wasteful since this is also nested under issues, projects, and projects/issues
25 map.resources :time_entries, :controller => 'timelog'
48
26
49 map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post}
27 map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post}
50 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get}
28 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get}
51 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post}
29 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post}
52 map.with_options :controller => 'wiki' do |wiki_routes|
30 map.with_options :controller => 'wiki' do |wiki_routes|
53 wiki_routes.with_options :conditions => {:method => :get} do |wiki_views|
31 wiki_routes.with_options :conditions => {:method => :get} do |wiki_views|
54 wiki_views.connect 'projects/:id/wiki/:page', :action => 'special', :page => /page_index|date_index|export/i
32 wiki_views.connect 'projects/:id/wiki/:page', :action => 'special', :page => /page_index|date_index|export/i
55 wiki_views.connect 'projects/:id/wiki/:page', :action => 'index', :page => nil
33 wiki_views.connect 'projects/:id/wiki/:page', :action => 'index', :page => nil
56 wiki_views.connect 'projects/:id/wiki/:page/edit', :action => 'edit'
34 wiki_views.connect 'projects/:id/wiki/:page/edit', :action => 'edit'
57 wiki_views.connect 'projects/:id/wiki/:page/rename', :action => 'rename'
35 wiki_views.connect 'projects/:id/wiki/:page/rename', :action => 'rename'
58 wiki_views.connect 'projects/:id/wiki/:page/history', :action => 'history'
36 wiki_views.connect 'projects/:id/wiki/:page/history', :action => 'history'
59 wiki_views.connect 'projects/:id/wiki/:page/diff/:version/vs/:version_from', :action => 'diff'
37 wiki_views.connect 'projects/:id/wiki/:page/diff/:version/vs/:version_from', :action => 'diff'
60 wiki_views.connect 'projects/:id/wiki/:page/annotate/:version', :action => 'annotate'
38 wiki_views.connect 'projects/:id/wiki/:page/annotate/:version', :action => 'annotate'
61 end
39 end
62
40
63 wiki_routes.connect 'projects/:id/wiki/:page/:action',
41 wiki_routes.connect 'projects/:id/wiki/:page/:action',
64 :action => /edit|rename|destroy|preview|protect/,
42 :action => /edit|rename|destroy|preview|protect/,
65 :conditions => {:method => :post}
43 :conditions => {:method => :post}
66 end
44 end
67
45
68 map.with_options :controller => 'messages' do |messages_routes|
46 map.with_options :controller => 'messages' do |messages_routes|
69 messages_routes.with_options :conditions => {:method => :get} do |messages_views|
47 messages_routes.with_options :conditions => {:method => :get} do |messages_views|
70 messages_views.connect 'boards/:board_id/topics/new', :action => 'new'
48 messages_views.connect 'boards/:board_id/topics/new', :action => 'new'
71 messages_views.connect 'boards/:board_id/topics/:id', :action => 'show'
49 messages_views.connect 'boards/:board_id/topics/:id', :action => 'show'
72 messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit'
50 messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit'
73 end
51 end
74 messages_routes.with_options :conditions => {:method => :post} do |messages_actions|
52 messages_routes.with_options :conditions => {:method => :post} do |messages_actions|
75 messages_actions.connect 'boards/:board_id/topics/new', :action => 'new'
53 messages_actions.connect 'boards/:board_id/topics/new', :action => 'new'
76 messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply'
54 messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply'
77 messages_actions.connect 'boards/:board_id/topics/:id/:action', :action => /edit|destroy/
55 messages_actions.connect 'boards/:board_id/topics/:id/:action', :action => /edit|destroy/
78 end
56 end
79 end
57 end
80
58
81 map.with_options :controller => 'boards' do |board_routes|
59 map.with_options :controller => 'boards' do |board_routes|
82 board_routes.with_options :conditions => {:method => :get} do |board_views|
60 board_routes.with_options :conditions => {:method => :get} do |board_views|
83 board_views.connect 'projects/:project_id/boards', :action => 'index'
61 board_views.connect 'projects/:project_id/boards', :action => 'index'
84 board_views.connect 'projects/:project_id/boards/new', :action => 'new'
62 board_views.connect 'projects/:project_id/boards/new', :action => 'new'
85 board_views.connect 'projects/:project_id/boards/:id', :action => 'show'
63 board_views.connect 'projects/:project_id/boards/:id', :action => 'show'
86 board_views.connect 'projects/:project_id/boards/:id.:format', :action => 'show'
64 board_views.connect 'projects/:project_id/boards/:id.:format', :action => 'show'
87 board_views.connect 'projects/:project_id/boards/:id/edit', :action => 'edit'
65 board_views.connect 'projects/:project_id/boards/:id/edit', :action => 'edit'
88 end
66 end
89 board_routes.with_options :conditions => {:method => :post} do |board_actions|
67 board_routes.with_options :conditions => {:method => :post} do |board_actions|
90 board_actions.connect 'projects/:project_id/boards', :action => 'new'
68 board_actions.connect 'projects/:project_id/boards', :action => 'new'
91 board_actions.connect 'projects/:project_id/boards/:id/:action', :action => /edit|destroy/
69 board_actions.connect 'projects/:project_id/boards/:id/:action', :action => /edit|destroy/
92 end
70 end
93 end
71 end
94
72
95 map.with_options :controller => 'documents' do |document_routes|
73 map.with_options :controller => 'documents' do |document_routes|
96 document_routes.with_options :conditions => {:method => :get} do |document_views|
74 document_routes.with_options :conditions => {:method => :get} do |document_views|
97 document_views.connect 'projects/:project_id/documents', :action => 'index'
75 document_views.connect 'projects/:project_id/documents', :action => 'index'
98 document_views.connect 'projects/:project_id/documents/new', :action => 'new'
76 document_views.connect 'projects/:project_id/documents/new', :action => 'new'
99 document_views.connect 'documents/:id', :action => 'show'
77 document_views.connect 'documents/:id', :action => 'show'
100 document_views.connect 'documents/:id/edit', :action => 'edit'
78 document_views.connect 'documents/:id/edit', :action => 'edit'
101 end
79 end
102 document_routes.with_options :conditions => {:method => :post} do |document_actions|
80 document_routes.with_options :conditions => {:method => :post} do |document_actions|
103 document_actions.connect 'projects/:project_id/documents', :action => 'new'
81 document_actions.connect 'projects/:project_id/documents', :action => 'new'
104 document_actions.connect 'documents/:id/:action', :action => /destroy|edit/
82 document_actions.connect 'documents/:id/:action', :action => /destroy|edit/
105 end
83 end
106 end
84 end
107
85
108 map.resources :issue_moves, :only => [:new, :create], :path_prefix => '/issues', :as => 'move'
86 map.resources :issue_moves, :only => [:new, :create], :path_prefix => '/issues', :as => 'move'
109
87
110 # Misc issue routes. TODO: move into resources
88 # Misc issue routes. TODO: move into resources
111 map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', :action => 'issues'
89 map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', :action => 'issues'
112 map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue' # TODO: would look nicer as /issues/:id/preview
90 map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue' # TODO: would look nicer as /issues/:id/preview
113 map.issues_context_menu '/issues/context_menu', :controller => 'context_menus', :action => 'issues'
91 map.issues_context_menu '/issues/context_menu', :controller => 'context_menus', :action => 'issues'
114 map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index'
92 map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index'
115 map.bulk_edit_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_edit', :conditions => { :method => :get }
93 map.bulk_edit_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_edit', :conditions => { :method => :get }
116 map.bulk_update_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_update', :conditions => { :method => :post }
94 map.bulk_update_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_update', :conditions => { :method => :post }
117 map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/, :conditions => { :method => :post }
95 map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/, :conditions => { :method => :post }
118 map.connect '/issues/:id/destroy', :controller => 'issues', :action => 'destroy', :conditions => { :method => :post } # legacy
96 map.connect '/issues/:id/destroy', :controller => 'issues', :action => 'destroy', :conditions => { :method => :post } # legacy
119
97
120 map.resource :gantt, :path_prefix => '/issues', :controller => 'gantts', :only => [:show, :update]
98 map.resource :gantt, :path_prefix => '/issues', :controller => 'gantts', :only => [:show, :update]
121 map.resource :gantt, :path_prefix => '/projects/:project_id/issues', :controller => 'gantts', :only => [:show, :update]
99 map.resource :gantt, :path_prefix => '/projects/:project_id/issues', :controller => 'gantts', :only => [:show, :update]
122 map.resource :calendar, :path_prefix => '/issues', :controller => 'calendars', :only => [:show, :update]
100 map.resource :calendar, :path_prefix => '/issues', :controller => 'calendars', :only => [:show, :update]
123 map.resource :calendar, :path_prefix => '/projects/:project_id/issues', :controller => 'calendars', :only => [:show, :update]
101 map.resource :calendar, :path_prefix => '/projects/:project_id/issues', :controller => 'calendars', :only => [:show, :update]
124
102
125 map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports|
103 map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports|
126 reports.connect 'projects/:id/issues/report', :action => 'issue_report'
104 reports.connect 'projects/:id/issues/report', :action => 'issue_report'
127 reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details'
105 reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details'
128 end
106 end
129
107
130 # Following two routes conflict with the resources because #index allows POST
108 # Following two routes conflict with the resources because #index allows POST
131 map.connect '/issues', :controller => 'issues', :action => 'index', :conditions => { :method => :post }
109 map.connect '/issues', :controller => 'issues', :action => 'index', :conditions => { :method => :post }
132 map.connect '/issues/create', :controller => 'issues', :action => 'index', :conditions => { :method => :post }
110 map.connect '/issues/create', :controller => 'issues', :action => 'index', :conditions => { :method => :post }
133
111
134 map.resources :issues, :member => { :edit => :post }, :collection => {}
112 map.resources :issues, :member => { :edit => :post }, :collection => {} do |issues|
135 map.resources :issues, :path_prefix => '/projects/:project_id', :collection => { :create => :post }
113 issues.resources :time_entries, :controller => 'timelog'
114 end
115
116 map.resources :issues, :path_prefix => '/projects/:project_id', :collection => { :create => :post } do |issues|
117 issues.resources :time_entries, :controller => 'timelog'
118 end
136
119
137 map.with_options :controller => 'issue_relations', :conditions => {:method => :post} do |relations|
120 map.with_options :controller => 'issue_relations', :conditions => {:method => :post} do |relations|
138 relations.connect 'issues/:issue_id/relations/:id', :action => 'new'
121 relations.connect 'issues/:issue_id/relations/:id', :action => 'new'
139 relations.connect 'issues/:issue_id/relations/:id/destroy', :action => 'destroy'
122 relations.connect 'issues/:issue_id/relations/:id/destroy', :action => 'destroy'
140 end
123 end
141
124
142 map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new'
125 map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new'
143
126
144 map.with_options :controller => 'users' do |users|
127 map.with_options :controller => 'users' do |users|
145 users.connect 'users/:id/edit/:tab', :action => 'edit', :tab => nil, :conditions => {:method => :get}
128 users.connect 'users/:id/edit/:tab', :action => 'edit', :tab => nil, :conditions => {:method => :get}
146
129
147 users.with_options :conditions => {:method => :post} do |user_actions|
130 users.with_options :conditions => {:method => :post} do |user_actions|
148 user_actions.connect 'users/:id/memberships', :action => 'edit_membership'
131 user_actions.connect 'users/:id/memberships', :action => 'edit_membership'
149 user_actions.connect 'users/:id/memberships/:membership_id', :action => 'edit_membership'
132 user_actions.connect 'users/:id/memberships/:membership_id', :action => 'edit_membership'
150 user_actions.connect 'users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership'
133 user_actions.connect 'users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership'
151 end
134 end
152 end
135 end
153
136
154 map.resources :users, :member => {
137 map.resources :users, :member => {
155 :edit_membership => :post,
138 :edit_membership => :post,
156 :destroy_membership => :post
139 :destroy_membership => :post
157 },
140 },
158 :except => [:destroy]
141 :except => [:destroy]
159
142
160 # For nice "roadmap" in the url for the index action
143 # For nice "roadmap" in the url for the index action
161 map.connect 'projects/:project_id/roadmap', :controller => 'versions', :action => 'index'
144 map.connect 'projects/:project_id/roadmap', :controller => 'versions', :action => 'index'
162
145
163 map.all_news 'news', :controller => 'news', :action => 'index'
146 map.all_news 'news', :controller => 'news', :action => 'index'
164 map.formatted_all_news 'news.:format', :controller => 'news', :action => 'index'
147 map.formatted_all_news 'news.:format', :controller => 'news', :action => 'index'
165 map.preview_news '/news/preview', :controller => 'previews', :action => 'news'
148 map.preview_news '/news/preview', :controller => 'previews', :action => 'news'
166 map.connect 'news/:id/comments', :controller => 'comments', :action => 'create', :conditions => {:method => :post}
149 map.connect 'news/:id/comments', :controller => 'comments', :action => 'create', :conditions => {:method => :post}
167 map.connect 'news/:id/comments/:comment_id', :controller => 'comments', :action => 'destroy', :conditions => {:method => :delete}
150 map.connect 'news/:id/comments/:comment_id', :controller => 'comments', :action => 'destroy', :conditions => {:method => :delete}
168
151
169 map.resources :projects, :member => {
152 map.resources :projects, :member => {
170 :copy => [:get, :post],
153 :copy => [:get, :post],
171 :settings => :get,
154 :settings => :get,
172 :modules => :post,
155 :modules => :post,
173 :archive => :post,
156 :archive => :post,
174 :unarchive => :post
157 :unarchive => :post
175 } do |project|
158 } do |project|
176 project.resource :project_enumerations, :as => 'enumerations', :only => [:update, :destroy]
159 project.resource :project_enumerations, :as => 'enumerations', :only => [:update, :destroy]
177 project.resources :files, :only => [:index, :new, :create]
160 project.resources :files, :only => [:index, :new, :create]
178 project.resources :versions, :collection => {:close_completed => :put}, :member => {:status_by => :post}
161 project.resources :versions, :collection => {:close_completed => :put}, :member => {:status_by => :post}
179 project.resources :news, :shallow => true
162 project.resources :news, :shallow => true
163 project.resources :time_entries, :controller => 'timelog', :path_prefix => 'projects/:project_id'
164
165
180 end
166 end
181
167
182 # Destroy uses a get request to prompt the user before the actual DELETE request
168 # Destroy uses a get request to prompt the user before the actual DELETE request
183 map.project_destroy_confirm 'projects/:id/destroy', :controller => 'projects', :action => 'destroy', :conditions => {:method => :get}
169 map.project_destroy_confirm 'projects/:id/destroy', :controller => 'projects', :action => 'destroy', :conditions => {:method => :get}
184
170
185 # TODO: port to be part of the resources route(s)
171 # TODO: port to be part of the resources route(s)
186 map.with_options :controller => 'projects' do |project_mapper|
172 map.with_options :controller => 'projects' do |project_mapper|
187 project_mapper.with_options :conditions => {:method => :get} do |project_views|
173 project_mapper.with_options :conditions => {:method => :get} do |project_views|
188 project_views.connect 'projects/:id/settings/:tab', :controller => 'projects', :action => 'settings'
174 project_views.connect 'projects/:id/settings/:tab', :controller => 'projects', :action => 'settings'
189 project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new'
175 project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new'
190 end
176 end
191 end
177 end
192
178
193 map.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity|
179 map.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity|
194 activity.connect 'projects/:id/activity'
180 activity.connect 'projects/:id/activity'
195 activity.connect 'projects/:id/activity.:format'
181 activity.connect 'projects/:id/activity.:format'
196 activity.connect 'activity', :id => nil
182 activity.connect 'activity', :id => nil
197 activity.connect 'activity.:format', :id => nil
183 activity.connect 'activity.:format', :id => nil
198 end
184 end
199
185
200
186
201 map.with_options :controller => 'issue_categories' do |categories|
187 map.with_options :controller => 'issue_categories' do |categories|
202 categories.connect 'projects/:project_id/issue_categories/new', :action => 'new'
188 categories.connect 'projects/:project_id/issue_categories/new', :action => 'new'
203 end
189 end
204
190
205 map.with_options :controller => 'repositories' do |repositories|
191 map.with_options :controller => 'repositories' do |repositories|
206 repositories.with_options :conditions => {:method => :get} do |repository_views|
192 repositories.with_options :conditions => {:method => :get} do |repository_views|
207 repository_views.connect 'projects/:id/repository', :action => 'show'
193 repository_views.connect 'projects/:id/repository', :action => 'show'
208 repository_views.connect 'projects/:id/repository/edit', :action => 'edit'
194 repository_views.connect 'projects/:id/repository/edit', :action => 'edit'
209 repository_views.connect 'projects/:id/repository/statistics', :action => 'stats'
195 repository_views.connect 'projects/:id/repository/statistics', :action => 'stats'
210 repository_views.connect 'projects/:id/repository/revisions', :action => 'revisions'
196 repository_views.connect 'projects/:id/repository/revisions', :action => 'revisions'
211 repository_views.connect 'projects/:id/repository/revisions.:format', :action => 'revisions'
197 repository_views.connect 'projects/:id/repository/revisions.:format', :action => 'revisions'
212 repository_views.connect 'projects/:id/repository/revisions/:rev', :action => 'revision'
198 repository_views.connect 'projects/:id/repository/revisions/:rev', :action => 'revision'
213 repository_views.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff'
199 repository_views.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff'
214 repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff'
200 repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff'
215 repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path', :action => 'entry', :format => 'raw', :requirements => { :rev => /[a-z0-9\.\-_]+/ }
201 repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path', :action => 'entry', :format => 'raw', :requirements => { :rev => /[a-z0-9\.\-_]+/ }
216 repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path', :requirements => { :rev => /[a-z0-9\.\-_]+/ }
202 repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path', :requirements => { :rev => /[a-z0-9\.\-_]+/ }
217 repository_views.connect 'projects/:id/repository/raw/*path', :action => 'entry', :format => 'raw'
203 repository_views.connect 'projects/:id/repository/raw/*path', :action => 'entry', :format => 'raw'
218 # TODO: why the following route is required?
204 # TODO: why the following route is required?
219 repository_views.connect 'projects/:id/repository/entry/*path', :action => 'entry'
205 repository_views.connect 'projects/:id/repository/entry/*path', :action => 'entry'
220 repository_views.connect 'projects/:id/repository/:action/*path'
206 repository_views.connect 'projects/:id/repository/:action/*path'
221 end
207 end
222
208
223 repositories.connect 'projects/:id/repository/:action', :conditions => {:method => :post}
209 repositories.connect 'projects/:id/repository/:action', :conditions => {:method => :post}
224 end
210 end
225
211
226 map.connect 'attachments/:id', :controller => 'attachments', :action => 'show', :id => /\d+/
212 map.connect 'attachments/:id', :controller => 'attachments', :action => 'show', :id => /\d+/
227 map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/
213 map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/
228 map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/
214 map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/
229
215
230 map.resources :groups
216 map.resources :groups
231
217
232 #left old routes at the bottom for backwards compat
218 #left old routes at the bottom for backwards compat
233 map.connect 'projects/:project_id/issues/:action', :controller => 'issues'
219 map.connect 'projects/:project_id/issues/:action', :controller => 'issues'
234 map.connect 'projects/:project_id/documents/:action', :controller => 'documents'
220 map.connect 'projects/:project_id/documents/:action', :controller => 'documents'
235 map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards'
221 map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards'
236 map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages'
222 map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages'
237 map.connect 'wiki/:id/:page/:action', :page => nil, :controller => 'wiki'
223 map.connect 'wiki/:id/:page/:action', :page => nil, :controller => 'wiki'
238 map.connect 'issues/:issue_id/relations/:action/:id', :controller => 'issue_relations'
224 map.connect 'issues/:issue_id/relations/:action/:id', :controller => 'issue_relations'
239 map.connect 'projects/:project_id/news/:action', :controller => 'news'
225 map.connect 'projects/:project_id/news/:action', :controller => 'news'
240 map.connect 'projects/:project_id/timelog/:action/:id', :controller => 'timelog', :project_id => /.+/
226 map.connect 'projects/:project_id/timelog/:action/:id', :controller => 'timelog', :project_id => /.+/
241 map.with_options :controller => 'repositories' do |omap|
227 map.with_options :controller => 'repositories' do |omap|
242 omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse'
228 omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse'
243 omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes'
229 omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes'
244 omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff'
230 omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff'
245 omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry'
231 omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry'
246 omap.repositories_entry 'repositories/annotate/:id/*path', :action => 'annotate'
232 omap.repositories_entry 'repositories/annotate/:id/*path', :action => 'annotate'
247 omap.connect 'repositories/revision/:id/:rev', :action => 'revision'
233 omap.connect 'repositories/revision/:id/:rev', :action => 'revision'
248 end
234 end
249
235
250 map.with_options :controller => 'sys' do |sys|
236 map.with_options :controller => 'sys' do |sys|
251 sys.connect 'sys/projects.:format', :action => 'projects', :conditions => {:method => :get}
237 sys.connect 'sys/projects.:format', :action => 'projects', :conditions => {:method => :get}
252 sys.connect 'sys/projects/:id/repository.:format', :action => 'create_project_repository', :conditions => {:method => :post}
238 sys.connect 'sys/projects/:id/repository.:format', :action => 'create_project_repository', :conditions => {:method => :post}
253 end
239 end
254
240
255 # Install the default route as the lowest priority.
241 # Install the default route as the lowest priority.
256 map.connect ':controller/:action/:id'
242 map.connect ':controller/:action/:id'
257 map.connect 'robots.txt', :controller => 'welcome', :action => 'robots'
243 map.connect 'robots.txt', :controller => 'welcome', :action => 'robots'
258 # Used for OpenID
244 # Used for OpenID
259 map.root :controller => 'account', :action => 'login'
245 map.root :controller => 'account', :action => 'login'
260 end
246 end
@@ -1,231 +1,231
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 # redMine - project management software
2 # redMine - project management software
3 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 # Copyright (C) 2006-2007 Jean-Philippe Lang
4 #
4 #
5 # This program is free software; you can redistribute it and/or
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
8 # of the License, or (at your option) any later version.
9 #
9 #
10 # This program is distributed in the hope that it will be useful,
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
13 # GNU General Public License for more details.
14 #
14 #
15 # You should have received a copy of the GNU General Public License
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
18
19 require File.dirname(__FILE__) + '/../test_helper'
19 require File.dirname(__FILE__) + '/../test_helper'
20 require 'timelog_controller'
20 require 'timelog_controller'
21
21
22 # Re-raise errors caught by the controller.
22 # Re-raise errors caught by the controller.
23 class TimelogController; def rescue_action(e) raise e end; end
23 class TimelogController; def rescue_action(e) raise e end; end
24
24
25 class TimelogControllerTest < ActionController::TestCase
25 class TimelogControllerTest < ActionController::TestCase
26 fixtures :projects, :enabled_modules, :roles, :members, :member_roles, :issues, :time_entries, :users, :trackers, :enumerations, :issue_statuses, :custom_fields, :custom_values
26 fixtures :projects, :enabled_modules, :roles, :members, :member_roles, :issues, :time_entries, :users, :trackers, :enumerations, :issue_statuses, :custom_fields, :custom_values
27
27
28 def setup
28 def setup
29 @controller = TimelogController.new
29 @controller = TimelogController.new
30 @request = ActionController::TestRequest.new
30 @request = ActionController::TestRequest.new
31 @response = ActionController::TestResponse.new
31 @response = ActionController::TestResponse.new
32 end
32 end
33
33
34 def test_get_new
34 def test_get_new
35 @request.session[:user_id] = 3
35 @request.session[:user_id] = 3
36 get :new, :project_id => 1
36 get :new, :project_id => 1
37 assert_response :success
37 assert_response :success
38 assert_template 'edit'
38 assert_template 'edit'
39 # Default activity selected
39 # Default activity selected
40 assert_tag :tag => 'option', :attributes => { :selected => 'selected' },
40 assert_tag :tag => 'option', :attributes => { :selected => 'selected' },
41 :content => 'Development'
41 :content => 'Development'
42 end
42 end
43
43
44 def test_get_new_should_only_show_active_time_entry_activities
44 def test_get_new_should_only_show_active_time_entry_activities
45 @request.session[:user_id] = 3
45 @request.session[:user_id] = 3
46 get :new, :project_id => 1
46 get :new, :project_id => 1
47 assert_response :success
47 assert_response :success
48 assert_template 'edit'
48 assert_template 'edit'
49 assert_no_tag :tag => 'option', :content => 'Inactive Activity'
49 assert_no_tag :tag => 'option', :content => 'Inactive Activity'
50
50
51 end
51 end
52
52
53 def test_get_edit_existing_time
53 def test_get_edit_existing_time
54 @request.session[:user_id] = 2
54 @request.session[:user_id] = 2
55 get :edit, :id => 2, :project_id => nil
55 get :edit, :id => 2, :project_id => nil
56 assert_response :success
56 assert_response :success
57 assert_template 'edit'
57 assert_template 'edit'
58 # Default activity selected
58 # Default activity selected
59 assert_tag :tag => 'form', :attributes => { :action => '/projects/ecookbook/timelog/update/2' }
59 assert_tag :tag => 'form', :attributes => { :action => '/projects/ecookbook/time_entries/2' }
60 end
60 end
61
61
62 def test_get_edit_with_an_existing_time_entry_with_inactive_activity
62 def test_get_edit_with_an_existing_time_entry_with_inactive_activity
63 te = TimeEntry.find(1)
63 te = TimeEntry.find(1)
64 te.activity = TimeEntryActivity.find_by_name("Inactive Activity")
64 te.activity = TimeEntryActivity.find_by_name("Inactive Activity")
65 te.save!
65 te.save!
66
66
67 @request.session[:user_id] = 1
67 @request.session[:user_id] = 1
68 get :edit, :project_id => 1, :id => 1
68 get :edit, :project_id => 1, :id => 1
69 assert_response :success
69 assert_response :success
70 assert_template 'edit'
70 assert_template 'edit'
71 # Blank option since nothing is pre-selected
71 # Blank option since nothing is pre-selected
72 assert_tag :tag => 'option', :content => '--- Please select ---'
72 assert_tag :tag => 'option', :content => '--- Please select ---'
73 end
73 end
74
74
75 def test_post_create
75 def test_post_create
76 # TODO: should POST to issues’ time log instead of project. change form
76 # TODO: should POST to issues’ time log instead of project. change form
77 # and routing
77 # and routing
78 @request.session[:user_id] = 3
78 @request.session[:user_id] = 3
79 post :create, :project_id => 1,
79 post :create, :project_id => 1,
80 :time_entry => {:comments => 'Some work on TimelogControllerTest',
80 :time_entry => {:comments => 'Some work on TimelogControllerTest',
81 # Not the default activity
81 # Not the default activity
82 :activity_id => '11',
82 :activity_id => '11',
83 :spent_on => '2008-03-14',
83 :spent_on => '2008-03-14',
84 :issue_id => '1',
84 :issue_id => '1',
85 :hours => '7.3'}
85 :hours => '7.3'}
86 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
86 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
87
87
88 i = Issue.find(1)
88 i = Issue.find(1)
89 t = TimeEntry.find_by_comments('Some work on TimelogControllerTest')
89 t = TimeEntry.find_by_comments('Some work on TimelogControllerTest')
90 assert_not_nil t
90 assert_not_nil t
91 assert_equal 11, t.activity_id
91 assert_equal 11, t.activity_id
92 assert_equal 7.3, t.hours
92 assert_equal 7.3, t.hours
93 assert_equal 3, t.user_id
93 assert_equal 3, t.user_id
94 assert_equal i, t.issue
94 assert_equal i, t.issue
95 assert_equal i.project, t.project
95 assert_equal i.project, t.project
96 end
96 end
97
97
98 def test_update
98 def test_update
99 entry = TimeEntry.find(1)
99 entry = TimeEntry.find(1)
100 assert_equal 1, entry.issue_id
100 assert_equal 1, entry.issue_id
101 assert_equal 2, entry.user_id
101 assert_equal 2, entry.user_id
102
102
103 @request.session[:user_id] = 1
103 @request.session[:user_id] = 1
104 put :update, :id => 1,
104 put :update, :id => 1,
105 :time_entry => {:issue_id => '2',
105 :time_entry => {:issue_id => '2',
106 :hours => '8'}
106 :hours => '8'}
107 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
107 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
108 entry.reload
108 entry.reload
109
109
110 assert_equal 8, entry.hours
110 assert_equal 8, entry.hours
111 assert_equal 2, entry.issue_id
111 assert_equal 2, entry.issue_id
112 assert_equal 2, entry.user_id
112 assert_equal 2, entry.user_id
113 end
113 end
114
114
115 def test_destroy
115 def test_destroy
116 @request.session[:user_id] = 2
116 @request.session[:user_id] = 2
117 post :destroy, :id => 1
117 delete :destroy, :id => 1
118 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
118 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
119 assert_equal I18n.t(:notice_successful_delete), flash[:notice]
119 assert_equal I18n.t(:notice_successful_delete), flash[:notice]
120 assert_nil TimeEntry.find_by_id(1)
120 assert_nil TimeEntry.find_by_id(1)
121 end
121 end
122
122
123 def test_destroy_should_fail
123 def test_destroy_should_fail
124 # simulate that this fails (e.g. due to a plugin), see #5700
124 # simulate that this fails (e.g. due to a plugin), see #5700
125 TimeEntry.class_eval do
125 TimeEntry.class_eval do
126 before_destroy :stop_callback_chain
126 before_destroy :stop_callback_chain
127 def stop_callback_chain ; return false ; end
127 def stop_callback_chain ; return false ; end
128 end
128 end
129
129
130 @request.session[:user_id] = 2
130 @request.session[:user_id] = 2
131 post :destroy, :id => 1
131 delete :destroy, :id => 1
132 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
132 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
133 assert_equal I18n.t(:notice_unable_delete_time_entry), flash[:error]
133 assert_equal I18n.t(:notice_unable_delete_time_entry), flash[:error]
134 assert_not_nil TimeEntry.find_by_id(1)
134 assert_not_nil TimeEntry.find_by_id(1)
135
135
136 # remove the simulation
136 # remove the simulation
137 TimeEntry.before_destroy.reject! {|callback| callback.method == :stop_callback_chain }
137 TimeEntry.before_destroy.reject! {|callback| callback.method == :stop_callback_chain }
138 end
138 end
139
139
140 def test_index_all_projects
140 def test_index_all_projects
141 get :index
141 get :index
142 assert_response :success
142 assert_response :success
143 assert_template 'index'
143 assert_template 'index'
144 assert_not_nil assigns(:total_hours)
144 assert_not_nil assigns(:total_hours)
145 assert_equal "162.90", "%.2f" % assigns(:total_hours)
145 assert_equal "162.90", "%.2f" % assigns(:total_hours)
146 end
146 end
147
147
148 def test_index_at_project_level
148 def test_index_at_project_level
149 get :index, :project_id => 1
149 get :index, :project_id => 1
150 assert_response :success
150 assert_response :success
151 assert_template 'index'
151 assert_template 'index'
152 assert_not_nil assigns(:entries)
152 assert_not_nil assigns(:entries)
153 assert_equal 4, assigns(:entries).size
153 assert_equal 4, assigns(:entries).size
154 # project and subproject
154 # project and subproject
155 assert_equal [1, 3], assigns(:entries).collect(&:project_id).uniq.sort
155 assert_equal [1, 3], assigns(:entries).collect(&:project_id).uniq.sort
156 assert_not_nil assigns(:total_hours)
156 assert_not_nil assigns(:total_hours)
157 assert_equal "162.90", "%.2f" % assigns(:total_hours)
157 assert_equal "162.90", "%.2f" % assigns(:total_hours)
158 # display all time by default
158 # display all time by default
159 assert_equal '2007-03-12'.to_date, assigns(:from)
159 assert_equal '2007-03-12'.to_date, assigns(:from)
160 assert_equal '2007-04-22'.to_date, assigns(:to)
160 assert_equal '2007-04-22'.to_date, assigns(:to)
161 end
161 end
162
162
163 def test_index_at_project_level_with_date_range
163 def test_index_at_project_level_with_date_range
164 get :index, :project_id => 1, :from => '2007-03-20', :to => '2007-04-30'
164 get :index, :project_id => 1, :from => '2007-03-20', :to => '2007-04-30'
165 assert_response :success
165 assert_response :success
166 assert_template 'index'
166 assert_template 'index'
167 assert_not_nil assigns(:entries)
167 assert_not_nil assigns(:entries)
168 assert_equal 3, assigns(:entries).size
168 assert_equal 3, assigns(:entries).size
169 assert_not_nil assigns(:total_hours)
169 assert_not_nil assigns(:total_hours)
170 assert_equal "12.90", "%.2f" % assigns(:total_hours)
170 assert_equal "12.90", "%.2f" % assigns(:total_hours)
171 assert_equal '2007-03-20'.to_date, assigns(:from)
171 assert_equal '2007-03-20'.to_date, assigns(:from)
172 assert_equal '2007-04-30'.to_date, assigns(:to)
172 assert_equal '2007-04-30'.to_date, assigns(:to)
173 end
173 end
174
174
175 def test_index_at_project_level_with_period
175 def test_index_at_project_level_with_period
176 get :index, :project_id => 1, :period => '7_days'
176 get :index, :project_id => 1, :period => '7_days'
177 assert_response :success
177 assert_response :success
178 assert_template 'index'
178 assert_template 'index'
179 assert_not_nil assigns(:entries)
179 assert_not_nil assigns(:entries)
180 assert_not_nil assigns(:total_hours)
180 assert_not_nil assigns(:total_hours)
181 assert_equal Date.today - 7, assigns(:from)
181 assert_equal Date.today - 7, assigns(:from)
182 assert_equal Date.today, assigns(:to)
182 assert_equal Date.today, assigns(:to)
183 end
183 end
184
184
185 def test_index_one_day
185 def test_index_one_day
186 get :index, :project_id => 1, :from => "2007-03-23", :to => "2007-03-23"
186 get :index, :project_id => 1, :from => "2007-03-23", :to => "2007-03-23"
187 assert_response :success
187 assert_response :success
188 assert_template 'index'
188 assert_template 'index'
189 assert_not_nil assigns(:total_hours)
189 assert_not_nil assigns(:total_hours)
190 assert_equal "4.25", "%.2f" % assigns(:total_hours)
190 assert_equal "4.25", "%.2f" % assigns(:total_hours)
191 end
191 end
192
192
193 def test_index_at_issue_level
193 def test_index_at_issue_level
194 get :index, :issue_id => 1
194 get :index, :issue_id => 1
195 assert_response :success
195 assert_response :success
196 assert_template 'index'
196 assert_template 'index'
197 assert_not_nil assigns(:entries)
197 assert_not_nil assigns(:entries)
198 assert_equal 2, assigns(:entries).size
198 assert_equal 2, assigns(:entries).size
199 assert_not_nil assigns(:total_hours)
199 assert_not_nil assigns(:total_hours)
200 assert_equal 154.25, assigns(:total_hours)
200 assert_equal 154.25, assigns(:total_hours)
201 # display all time based on what's been logged
201 # display all time based on what's been logged
202 assert_equal '2007-03-12'.to_date, assigns(:from)
202 assert_equal '2007-03-12'.to_date, assigns(:from)
203 assert_equal '2007-04-22'.to_date, assigns(:to)
203 assert_equal '2007-04-22'.to_date, assigns(:to)
204 end
204 end
205
205
206 def test_index_atom_feed
206 def test_index_atom_feed
207 get :index, :project_id => 1, :format => 'atom'
207 get :index, :project_id => 1, :format => 'atom'
208 assert_response :success
208 assert_response :success
209 assert_equal 'application/atom+xml', @response.content_type
209 assert_equal 'application/atom+xml', @response.content_type
210 assert_not_nil assigns(:items)
210 assert_not_nil assigns(:items)
211 assert assigns(:items).first.is_a?(TimeEntry)
211 assert assigns(:items).first.is_a?(TimeEntry)
212 end
212 end
213
213
214 def test_index_all_projects_csv_export
214 def test_index_all_projects_csv_export
215 Setting.date_format = '%m/%d/%Y'
215 Setting.date_format = '%m/%d/%Y'
216 get :index, :format => 'csv'
216 get :index, :format => 'csv'
217 assert_response :success
217 assert_response :success
218 assert_equal 'text/csv', @response.content_type
218 assert_equal 'text/csv', @response.content_type
219 assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment\n")
219 assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment\n")
220 assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\"\n")
220 assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\"\n")
221 end
221 end
222
222
223 def test_index_csv_export
223 def test_index_csv_export
224 Setting.date_format = '%m/%d/%Y'
224 Setting.date_format = '%m/%d/%Y'
225 get :index, :project_id => 1, :format => 'csv'
225 get :index, :project_id => 1, :format => 'csv'
226 assert_response :success
226 assert_response :success
227 assert_equal 'text/csv', @response.content_type
227 assert_equal 'text/csv', @response.content_type
228 assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment\n")
228 assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment\n")
229 assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\"\n")
229 assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\"\n")
230 end
230 end
231 end
231 end
@@ -1,310 +1,343
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2010 Jean-Philippe Lang
2 # Copyright (C) 2006-2010 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.dirname(__FILE__)}/../test_helper"
18 require "#{File.dirname(__FILE__)}/../test_helper"
19
19
20 class RoutingTest < ActionController::IntegrationTest
20 class RoutingTest < ActionController::IntegrationTest
21 context "activities" do
21 context "activities" do
22 should_route :get, "/activity", :controller => 'activities', :action => 'index', :id => nil
22 should_route :get, "/activity", :controller => 'activities', :action => 'index', :id => nil
23 should_route :get, "/activity.atom", :controller => 'activities', :action => 'index', :id => nil, :format => 'atom'
23 should_route :get, "/activity.atom", :controller => 'activities', :action => 'index', :id => nil, :format => 'atom'
24 end
24 end
25
25
26 context "attachments" do
26 context "attachments" do
27 should_route :get, "/attachments/1", :controller => 'attachments', :action => 'show', :id => '1'
27 should_route :get, "/attachments/1", :controller => 'attachments', :action => 'show', :id => '1'
28 should_route :get, "/attachments/1/filename.ext", :controller => 'attachments', :action => 'show', :id => '1', :filename => 'filename.ext'
28 should_route :get, "/attachments/1/filename.ext", :controller => 'attachments', :action => 'show', :id => '1', :filename => 'filename.ext'
29 should_route :get, "/attachments/download/1", :controller => 'attachments', :action => 'download', :id => '1'
29 should_route :get, "/attachments/download/1", :controller => 'attachments', :action => 'download', :id => '1'
30 should_route :get, "/attachments/download/1/filename.ext", :controller => 'attachments', :action => 'download', :id => '1', :filename => 'filename.ext'
30 should_route :get, "/attachments/download/1/filename.ext", :controller => 'attachments', :action => 'download', :id => '1', :filename => 'filename.ext'
31 end
31 end
32
32
33 context "boards" do
33 context "boards" do
34 should_route :get, "/projects/world_domination/boards", :controller => 'boards', :action => 'index', :project_id => 'world_domination'
34 should_route :get, "/projects/world_domination/boards", :controller => 'boards', :action => 'index', :project_id => 'world_domination'
35 should_route :get, "/projects/world_domination/boards/new", :controller => 'boards', :action => 'new', :project_id => 'world_domination'
35 should_route :get, "/projects/world_domination/boards/new", :controller => 'boards', :action => 'new', :project_id => 'world_domination'
36 should_route :get, "/projects/world_domination/boards/44", :controller => 'boards', :action => 'show', :project_id => 'world_domination', :id => '44'
36 should_route :get, "/projects/world_domination/boards/44", :controller => 'boards', :action => 'show', :project_id => 'world_domination', :id => '44'
37 should_route :get, "/projects/world_domination/boards/44.atom", :controller => 'boards', :action => 'show', :project_id => 'world_domination', :id => '44', :format => 'atom'
37 should_route :get, "/projects/world_domination/boards/44.atom", :controller => 'boards', :action => 'show', :project_id => 'world_domination', :id => '44', :format => 'atom'
38 should_route :get, "/projects/world_domination/boards/44/edit", :controller => 'boards', :action => 'edit', :project_id => 'world_domination', :id => '44'
38 should_route :get, "/projects/world_domination/boards/44/edit", :controller => 'boards', :action => 'edit', :project_id => 'world_domination', :id => '44'
39
39
40 should_route :post, "/projects/world_domination/boards/new", :controller => 'boards', :action => 'new', :project_id => 'world_domination'
40 should_route :post, "/projects/world_domination/boards/new", :controller => 'boards', :action => 'new', :project_id => 'world_domination'
41 should_route :post, "/projects/world_domination/boards/44/edit", :controller => 'boards', :action => 'edit', :project_id => 'world_domination', :id => '44'
41 should_route :post, "/projects/world_domination/boards/44/edit", :controller => 'boards', :action => 'edit', :project_id => 'world_domination', :id => '44'
42 should_route :post, "/projects/world_domination/boards/44/destroy", :controller => 'boards', :action => 'destroy', :project_id => 'world_domination', :id => '44'
42 should_route :post, "/projects/world_domination/boards/44/destroy", :controller => 'boards', :action => 'destroy', :project_id => 'world_domination', :id => '44'
43
43
44 end
44 end
45
45
46 context "documents" do
46 context "documents" do
47 should_route :get, "/projects/567/documents", :controller => 'documents', :action => 'index', :project_id => '567'
47 should_route :get, "/projects/567/documents", :controller => 'documents', :action => 'index', :project_id => '567'
48 should_route :get, "/projects/567/documents/new", :controller => 'documents', :action => 'new', :project_id => '567'
48 should_route :get, "/projects/567/documents/new", :controller => 'documents', :action => 'new', :project_id => '567'
49 should_route :get, "/documents/22", :controller => 'documents', :action => 'show', :id => '22'
49 should_route :get, "/documents/22", :controller => 'documents', :action => 'show', :id => '22'
50 should_route :get, "/documents/22/edit", :controller => 'documents', :action => 'edit', :id => '22'
50 should_route :get, "/documents/22/edit", :controller => 'documents', :action => 'edit', :id => '22'
51
51
52 should_route :post, "/projects/567/documents/new", :controller => 'documents', :action => 'new', :project_id => '567'
52 should_route :post, "/projects/567/documents/new", :controller => 'documents', :action => 'new', :project_id => '567'
53 should_route :post, "/documents/567/edit", :controller => 'documents', :action => 'edit', :id => '567'
53 should_route :post, "/documents/567/edit", :controller => 'documents', :action => 'edit', :id => '567'
54 should_route :post, "/documents/567/destroy", :controller => 'documents', :action => 'destroy', :id => '567'
54 should_route :post, "/documents/567/destroy", :controller => 'documents', :action => 'destroy', :id => '567'
55 end
55 end
56
56
57 context "issues" do
57 context "issues" do
58 # REST actions
58 # REST actions
59 should_route :get, "/issues", :controller => 'issues', :action => 'index'
59 should_route :get, "/issues", :controller => 'issues', :action => 'index'
60 should_route :get, "/issues.pdf", :controller => 'issues', :action => 'index', :format => 'pdf'
60 should_route :get, "/issues.pdf", :controller => 'issues', :action => 'index', :format => 'pdf'
61 should_route :get, "/issues.atom", :controller => 'issues', :action => 'index', :format => 'atom'
61 should_route :get, "/issues.atom", :controller => 'issues', :action => 'index', :format => 'atom'
62 should_route :get, "/issues.xml", :controller => 'issues', :action => 'index', :format => 'xml'
62 should_route :get, "/issues.xml", :controller => 'issues', :action => 'index', :format => 'xml'
63 should_route :get, "/projects/23/issues", :controller => 'issues', :action => 'index', :project_id => '23'
63 should_route :get, "/projects/23/issues", :controller => 'issues', :action => 'index', :project_id => '23'
64 should_route :get, "/projects/23/issues.pdf", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'pdf'
64 should_route :get, "/projects/23/issues.pdf", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'pdf'
65 should_route :get, "/projects/23/issues.atom", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'atom'
65 should_route :get, "/projects/23/issues.atom", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'atom'
66 should_route :get, "/projects/23/issues.xml", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'xml'
66 should_route :get, "/projects/23/issues.xml", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'xml'
67 should_route :get, "/issues/64", :controller => 'issues', :action => 'show', :id => '64'
67 should_route :get, "/issues/64", :controller => 'issues', :action => 'show', :id => '64'
68 should_route :get, "/issues/64.pdf", :controller => 'issues', :action => 'show', :id => '64', :format => 'pdf'
68 should_route :get, "/issues/64.pdf", :controller => 'issues', :action => 'show', :id => '64', :format => 'pdf'
69 should_route :get, "/issues/64.atom", :controller => 'issues', :action => 'show', :id => '64', :format => 'atom'
69 should_route :get, "/issues/64.atom", :controller => 'issues', :action => 'show', :id => '64', :format => 'atom'
70 should_route :get, "/issues/64.xml", :controller => 'issues', :action => 'show', :id => '64', :format => 'xml'
70 should_route :get, "/issues/64.xml", :controller => 'issues', :action => 'show', :id => '64', :format => 'xml'
71
71
72 should_route :get, "/projects/23/issues/new", :controller => 'issues', :action => 'new', :project_id => '23'
72 should_route :get, "/projects/23/issues/new", :controller => 'issues', :action => 'new', :project_id => '23'
73 should_route :post, "/projects/23/issues", :controller => 'issues', :action => 'create', :project_id => '23'
73 should_route :post, "/projects/23/issues", :controller => 'issues', :action => 'create', :project_id => '23'
74 should_route :post, "/issues.xml", :controller => 'issues', :action => 'create', :format => 'xml'
74 should_route :post, "/issues.xml", :controller => 'issues', :action => 'create', :format => 'xml'
75
75
76 should_route :get, "/issues/64/edit", :controller => 'issues', :action => 'edit', :id => '64'
76 should_route :get, "/issues/64/edit", :controller => 'issues', :action => 'edit', :id => '64'
77 # TODO: Should use PUT
77 # TODO: Should use PUT
78 should_route :post, "/issues/64/edit", :controller => 'issues', :action => 'edit', :id => '64'
78 should_route :post, "/issues/64/edit", :controller => 'issues', :action => 'edit', :id => '64'
79 should_route :put, "/issues/1.xml", :controller => 'issues', :action => 'update', :id => '1', :format => 'xml'
79 should_route :put, "/issues/1.xml", :controller => 'issues', :action => 'update', :id => '1', :format => 'xml'
80
80
81 # TODO: Should use DELETE
81 # TODO: Should use DELETE
82 should_route :post, "/issues/64/destroy", :controller => 'issues', :action => 'destroy', :id => '64'
82 should_route :post, "/issues/64/destroy", :controller => 'issues', :action => 'destroy', :id => '64'
83 should_route :delete, "/issues/1.xml", :controller => 'issues', :action => 'destroy', :id => '1', :format => 'xml'
83 should_route :delete, "/issues/1.xml", :controller => 'issues', :action => 'destroy', :id => '1', :format => 'xml'
84
84
85 # Extra actions
85 # Extra actions
86 should_route :get, "/projects/23/issues/64/copy", :controller => 'issues', :action => 'new', :project_id => '23', :copy_from => '64'
86 should_route :get, "/projects/23/issues/64/copy", :controller => 'issues', :action => 'new', :project_id => '23', :copy_from => '64'
87
87
88 should_route :get, "/issues/move/new", :controller => 'issue_moves', :action => 'new'
88 should_route :get, "/issues/move/new", :controller => 'issue_moves', :action => 'new'
89 should_route :post, "/issues/move", :controller => 'issue_moves', :action => 'create'
89 should_route :post, "/issues/move", :controller => 'issue_moves', :action => 'create'
90
90
91 should_route :post, "/issues/1/quoted", :controller => 'journals', :action => 'new', :id => '1'
91 should_route :post, "/issues/1/quoted", :controller => 'journals', :action => 'new', :id => '1'
92
92
93 should_route :get, "/issues/calendar", :controller => 'calendars', :action => 'show'
93 should_route :get, "/issues/calendar", :controller => 'calendars', :action => 'show'
94 should_route :put, "/issues/calendar", :controller => 'calendars', :action => 'update'
94 should_route :put, "/issues/calendar", :controller => 'calendars', :action => 'update'
95 should_route :get, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'show', :project_id => 'project-name'
95 should_route :get, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'show', :project_id => 'project-name'
96 should_route :put, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'update', :project_id => 'project-name'
96 should_route :put, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'update', :project_id => 'project-name'
97
97
98 should_route :get, "/issues/gantt", :controller => 'gantts', :action => 'show'
98 should_route :get, "/issues/gantt", :controller => 'gantts', :action => 'show'
99 should_route :put, "/issues/gantt", :controller => 'gantts', :action => 'update'
99 should_route :put, "/issues/gantt", :controller => 'gantts', :action => 'update'
100 should_route :get, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'show', :project_id => 'project-name'
100 should_route :get, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'show', :project_id => 'project-name'
101 should_route :put, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'update', :project_id => 'project-name'
101 should_route :put, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'update', :project_id => 'project-name'
102
102
103 should_route :get, "/issues/auto_complete", :controller => 'auto_completes', :action => 'issues'
103 should_route :get, "/issues/auto_complete", :controller => 'auto_completes', :action => 'issues'
104
104
105 should_route :get, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123'
105 should_route :get, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123'
106 should_route :post, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123'
106 should_route :post, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123'
107 should_route :get, "/issues/context_menu", :controller => 'context_menus', :action => 'issues'
107 should_route :get, "/issues/context_menu", :controller => 'context_menus', :action => 'issues'
108 should_route :post, "/issues/context_menu", :controller => 'context_menus', :action => 'issues'
108 should_route :post, "/issues/context_menu", :controller => 'context_menus', :action => 'issues'
109
109
110 should_route :get, "/issues/changes", :controller => 'journals', :action => 'index'
110 should_route :get, "/issues/changes", :controller => 'journals', :action => 'index'
111
111
112 should_route :get, "/issues/bulk_edit", :controller => 'issues', :action => 'bulk_edit'
112 should_route :get, "/issues/bulk_edit", :controller => 'issues', :action => 'bulk_edit'
113 should_route :post, "/issues/bulk_edit", :controller => 'issues', :action => 'bulk_update'
113 should_route :post, "/issues/bulk_edit", :controller => 'issues', :action => 'bulk_update'
114 end
114 end
115
115
116 context "issue categories" do
116 context "issue categories" do
117 should_route :get, "/projects/test/issue_categories/new", :controller => 'issue_categories', :action => 'new', :project_id => 'test'
117 should_route :get, "/projects/test/issue_categories/new", :controller => 'issue_categories', :action => 'new', :project_id => 'test'
118
118
119 should_route :post, "/projects/test/issue_categories/new", :controller => 'issue_categories', :action => 'new', :project_id => 'test'
119 should_route :post, "/projects/test/issue_categories/new", :controller => 'issue_categories', :action => 'new', :project_id => 'test'
120 end
120 end
121
121
122 context "issue relations" do
122 context "issue relations" do
123 should_route :post, "/issues/1/relations", :controller => 'issue_relations', :action => 'new', :issue_id => '1'
123 should_route :post, "/issues/1/relations", :controller => 'issue_relations', :action => 'new', :issue_id => '1'
124 should_route :post, "/issues/1/relations/23/destroy", :controller => 'issue_relations', :action => 'destroy', :issue_id => '1', :id => '23'
124 should_route :post, "/issues/1/relations/23/destroy", :controller => 'issue_relations', :action => 'destroy', :issue_id => '1', :id => '23'
125 end
125 end
126
126
127 context "issue reports" do
127 context "issue reports" do
128 should_route :get, "/projects/567/issues/report", :controller => 'reports', :action => 'issue_report', :id => '567'
128 should_route :get, "/projects/567/issues/report", :controller => 'reports', :action => 'issue_report', :id => '567'
129 should_route :get, "/projects/567/issues/report/assigned_to", :controller => 'reports', :action => 'issue_report_details', :id => '567', :detail => 'assigned_to'
129 should_route :get, "/projects/567/issues/report/assigned_to", :controller => 'reports', :action => 'issue_report_details', :id => '567', :detail => 'assigned_to'
130 end
130 end
131
131
132 context "members" do
132 context "members" do
133 should_route :post, "/projects/5234/members/new", :controller => 'members', :action => 'new', :id => '5234'
133 should_route :post, "/projects/5234/members/new", :controller => 'members', :action => 'new', :id => '5234'
134 end
134 end
135
135
136 context "messages" do
136 context "messages" do
137 should_route :get, "/boards/22/topics/2", :controller => 'messages', :action => 'show', :id => '2', :board_id => '22'
137 should_route :get, "/boards/22/topics/2", :controller => 'messages', :action => 'show', :id => '2', :board_id => '22'
138 should_route :get, "/boards/lala/topics/new", :controller => 'messages', :action => 'new', :board_id => 'lala'
138 should_route :get, "/boards/lala/topics/new", :controller => 'messages', :action => 'new', :board_id => 'lala'
139 should_route :get, "/boards/lala/topics/22/edit", :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala'
139 should_route :get, "/boards/lala/topics/22/edit", :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala'
140
140
141 should_route :post, "/boards/lala/topics/new", :controller => 'messages', :action => 'new', :board_id => 'lala'
141 should_route :post, "/boards/lala/topics/new", :controller => 'messages', :action => 'new', :board_id => 'lala'
142 should_route :post, "/boards/lala/topics/22/edit", :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala'
142 should_route :post, "/boards/lala/topics/22/edit", :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala'
143 should_route :post, "/boards/22/topics/555/replies", :controller => 'messages', :action => 'reply', :id => '555', :board_id => '22'
143 should_route :post, "/boards/22/topics/555/replies", :controller => 'messages', :action => 'reply', :id => '555', :board_id => '22'
144 should_route :post, "/boards/22/topics/555/destroy", :controller => 'messages', :action => 'destroy', :id => '555', :board_id => '22'
144 should_route :post, "/boards/22/topics/555/destroy", :controller => 'messages', :action => 'destroy', :id => '555', :board_id => '22'
145 end
145 end
146
146
147 context "news" do
147 context "news" do
148 should_route :get, "/news", :controller => 'news', :action => 'index'
148 should_route :get, "/news", :controller => 'news', :action => 'index'
149 should_route :get, "/news.atom", :controller => 'news', :action => 'index', :format => 'atom'
149 should_route :get, "/news.atom", :controller => 'news', :action => 'index', :format => 'atom'
150 should_route :get, "/news.xml", :controller => 'news', :action => 'index', :format => 'xml'
150 should_route :get, "/news.xml", :controller => 'news', :action => 'index', :format => 'xml'
151 should_route :get, "/news.json", :controller => 'news', :action => 'index', :format => 'json'
151 should_route :get, "/news.json", :controller => 'news', :action => 'index', :format => 'json'
152 should_route :get, "/projects/567/news", :controller => 'news', :action => 'index', :project_id => '567'
152 should_route :get, "/projects/567/news", :controller => 'news', :action => 'index', :project_id => '567'
153 should_route :get, "/projects/567/news.atom", :controller => 'news', :action => 'index', :format => 'atom', :project_id => '567'
153 should_route :get, "/projects/567/news.atom", :controller => 'news', :action => 'index', :format => 'atom', :project_id => '567'
154 should_route :get, "/projects/567/news.xml", :controller => 'news', :action => 'index', :format => 'xml', :project_id => '567'
154 should_route :get, "/projects/567/news.xml", :controller => 'news', :action => 'index', :format => 'xml', :project_id => '567'
155 should_route :get, "/projects/567/news.json", :controller => 'news', :action => 'index', :format => 'json', :project_id => '567'
155 should_route :get, "/projects/567/news.json", :controller => 'news', :action => 'index', :format => 'json', :project_id => '567'
156 should_route :get, "/news/2", :controller => 'news', :action => 'show', :id => '2'
156 should_route :get, "/news/2", :controller => 'news', :action => 'show', :id => '2'
157 should_route :get, "/projects/567/news/new", :controller => 'news', :action => 'new', :project_id => '567'
157 should_route :get, "/projects/567/news/new", :controller => 'news', :action => 'new', :project_id => '567'
158 should_route :get, "/news/234", :controller => 'news', :action => 'show', :id => '234'
158 should_route :get, "/news/234", :controller => 'news', :action => 'show', :id => '234'
159 should_route :get, "/news/567/edit", :controller => 'news', :action => 'edit', :id => '567'
159 should_route :get, "/news/567/edit", :controller => 'news', :action => 'edit', :id => '567'
160 should_route :get, "/news/preview", :controller => 'previews', :action => 'news'
160 should_route :get, "/news/preview", :controller => 'previews', :action => 'news'
161
161
162 should_route :post, "/projects/567/news", :controller => 'news', :action => 'create', :project_id => '567'
162 should_route :post, "/projects/567/news", :controller => 'news', :action => 'create', :project_id => '567'
163 should_route :post, "/news/567/comments", :controller => 'comments', :action => 'create', :id => '567'
163 should_route :post, "/news/567/comments", :controller => 'comments', :action => 'create', :id => '567'
164
164
165 should_route :put, "/news/567", :controller => 'news', :action => 'update', :id => '567'
165 should_route :put, "/news/567", :controller => 'news', :action => 'update', :id => '567'
166
166
167 should_route :delete, "/news/567", :controller => 'news', :action => 'destroy', :id => '567'
167 should_route :delete, "/news/567", :controller => 'news', :action => 'destroy', :id => '567'
168 should_route :delete, "/news/567/comments/15", :controller => 'comments', :action => 'destroy', :id => '567', :comment_id => '15'
168 should_route :delete, "/news/567/comments/15", :controller => 'comments', :action => 'destroy', :id => '567', :comment_id => '15'
169 end
169 end
170
170
171 context "projects" do
171 context "projects" do
172 should_route :get, "/projects", :controller => 'projects', :action => 'index'
172 should_route :get, "/projects", :controller => 'projects', :action => 'index'
173 should_route :get, "/projects.atom", :controller => 'projects', :action => 'index', :format => 'atom'
173 should_route :get, "/projects.atom", :controller => 'projects', :action => 'index', :format => 'atom'
174 should_route :get, "/projects.xml", :controller => 'projects', :action => 'index', :format => 'xml'
174 should_route :get, "/projects.xml", :controller => 'projects', :action => 'index', :format => 'xml'
175 should_route :get, "/projects/new", :controller => 'projects', :action => 'new'
175 should_route :get, "/projects/new", :controller => 'projects', :action => 'new'
176 should_route :get, "/projects/test", :controller => 'projects', :action => 'show', :id => 'test'
176 should_route :get, "/projects/test", :controller => 'projects', :action => 'show', :id => 'test'
177 should_route :get, "/projects/1.xml", :controller => 'projects', :action => 'show', :id => '1', :format => 'xml'
177 should_route :get, "/projects/1.xml", :controller => 'projects', :action => 'show', :id => '1', :format => 'xml'
178 should_route :get, "/projects/4223/settings", :controller => 'projects', :action => 'settings', :id => '4223'
178 should_route :get, "/projects/4223/settings", :controller => 'projects', :action => 'settings', :id => '4223'
179 should_route :get, "/projects/4223/settings/members", :controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members'
179 should_route :get, "/projects/4223/settings/members", :controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members'
180 should_route :get, "/projects/33/files", :controller => 'files', :action => 'index', :project_id => '33'
180 should_route :get, "/projects/33/files", :controller => 'files', :action => 'index', :project_id => '33'
181 should_route :get, "/projects/33/files/new", :controller => 'files', :action => 'new', :project_id => '33'
181 should_route :get, "/projects/33/files/new", :controller => 'files', :action => 'new', :project_id => '33'
182 should_route :get, "/projects/33/roadmap", :controller => 'versions', :action => 'index', :project_id => '33'
182 should_route :get, "/projects/33/roadmap", :controller => 'versions', :action => 'index', :project_id => '33'
183 should_route :get, "/projects/33/activity", :controller => 'activities', :action => 'index', :id => '33'
183 should_route :get, "/projects/33/activity", :controller => 'activities', :action => 'index', :id => '33'
184 should_route :get, "/projects/33/activity.atom", :controller => 'activities', :action => 'index', :id => '33', :format => 'atom'
184 should_route :get, "/projects/33/activity.atom", :controller => 'activities', :action => 'index', :id => '33', :format => 'atom'
185
185
186 should_route :post, "/projects", :controller => 'projects', :action => 'create'
186 should_route :post, "/projects", :controller => 'projects', :action => 'create'
187 should_route :post, "/projects.xml", :controller => 'projects', :action => 'create', :format => 'xml'
187 should_route :post, "/projects.xml", :controller => 'projects', :action => 'create', :format => 'xml'
188 should_route :post, "/projects/33/files", :controller => 'files', :action => 'create', :project_id => '33'
188 should_route :post, "/projects/33/files", :controller => 'files', :action => 'create', :project_id => '33'
189 should_route :post, "/projects/64/archive", :controller => 'projects', :action => 'archive', :id => '64'
189 should_route :post, "/projects/64/archive", :controller => 'projects', :action => 'archive', :id => '64'
190 should_route :post, "/projects/64/unarchive", :controller => 'projects', :action => 'unarchive', :id => '64'
190 should_route :post, "/projects/64/unarchive", :controller => 'projects', :action => 'unarchive', :id => '64'
191
191
192 should_route :put, "/projects/64/enumerations", :controller => 'project_enumerations', :action => 'update', :project_id => '64'
192 should_route :put, "/projects/64/enumerations", :controller => 'project_enumerations', :action => 'update', :project_id => '64'
193 should_route :put, "/projects/4223", :controller => 'projects', :action => 'update', :id => '4223'
193 should_route :put, "/projects/4223", :controller => 'projects', :action => 'update', :id => '4223'
194 should_route :put, "/projects/1.xml", :controller => 'projects', :action => 'update', :id => '1', :format => 'xml'
194 should_route :put, "/projects/1.xml", :controller => 'projects', :action => 'update', :id => '1', :format => 'xml'
195
195
196 should_route :delete, "/projects/64", :controller => 'projects', :action => 'destroy', :id => '64'
196 should_route :delete, "/projects/64", :controller => 'projects', :action => 'destroy', :id => '64'
197 should_route :delete, "/projects/1.xml", :controller => 'projects', :action => 'destroy', :id => '1', :format => 'xml'
197 should_route :delete, "/projects/1.xml", :controller => 'projects', :action => 'destroy', :id => '1', :format => 'xml'
198 should_route :delete, "/projects/64/enumerations", :controller => 'project_enumerations', :action => 'destroy', :project_id => '64'
198 should_route :delete, "/projects/64/enumerations", :controller => 'project_enumerations', :action => 'destroy', :project_id => '64'
199 end
199 end
200
200
201 context "repositories" do
201 context "repositories" do
202 should_route :get, "/projects/redmine/repository", :controller => 'repositories', :action => 'show', :id => 'redmine'
202 should_route :get, "/projects/redmine/repository", :controller => 'repositories', :action => 'show', :id => 'redmine'
203 should_route :get, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine'
203 should_route :get, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine'
204 should_route :get, "/projects/redmine/repository/revisions", :controller => 'repositories', :action => 'revisions', :id => 'redmine'
204 should_route :get, "/projects/redmine/repository/revisions", :controller => 'repositories', :action => 'revisions', :id => 'redmine'
205 should_route :get, "/projects/redmine/repository/revisions.atom", :controller => 'repositories', :action => 'revisions', :id => 'redmine', :format => 'atom'
205 should_route :get, "/projects/redmine/repository/revisions.atom", :controller => 'repositories', :action => 'revisions', :id => 'redmine', :format => 'atom'
206 should_route :get, "/projects/redmine/repository/revisions/2457", :controller => 'repositories', :action => 'revision', :id => 'redmine', :rev => '2457'
206 should_route :get, "/projects/redmine/repository/revisions/2457", :controller => 'repositories', :action => 'revision', :id => 'redmine', :rev => '2457'
207 should_route :get, "/projects/redmine/repository/revisions/2457/diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457'
207 should_route :get, "/projects/redmine/repository/revisions/2457/diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457'
208 should_route :get, "/projects/redmine/repository/revisions/2457/diff.diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457', :format => 'diff'
208 should_route :get, "/projects/redmine/repository/revisions/2457/diff.diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457', :format => 'diff'
209 should_route :get, "/projects/redmine/repository/diff/path/to/file.c", :controller => 'repositories', :action => 'diff', :id => 'redmine', :path => %w[path to file.c]
209 should_route :get, "/projects/redmine/repository/diff/path/to/file.c", :controller => 'repositories', :action => 'diff', :id => 'redmine', :path => %w[path to file.c]
210 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'
210 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'
211 should_route :get, "/projects/redmine/repository/browse/path/to/file.c", :controller => 'repositories', :action => 'browse', :id => 'redmine', :path => %w[path to file.c]
211 should_route :get, "/projects/redmine/repository/browse/path/to/file.c", :controller => 'repositories', :action => 'browse', :id => 'redmine', :path => %w[path to file.c]
212 should_route :get, "/projects/redmine/repository/entry/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c]
212 should_route :get, "/projects/redmine/repository/entry/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c]
213 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'
213 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'
214 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'
214 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'
215 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'
215 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'
216 should_route :get, "/projects/redmine/repository/annotate/path/to/file.c", :controller => 'repositories', :action => 'annotate', :id => 'redmine', :path => %w[path to file.c]
216 should_route :get, "/projects/redmine/repository/annotate/path/to/file.c", :controller => 'repositories', :action => 'annotate', :id => 'redmine', :path => %w[path to file.c]
217 should_route :get, "/projects/redmine/repository/changes/path/to/file.c", :controller => 'repositories', :action => 'changes', :id => 'redmine', :path => %w[path to file.c]
217 should_route :get, "/projects/redmine/repository/changes/path/to/file.c", :controller => 'repositories', :action => 'changes', :id => 'redmine', :path => %w[path to file.c]
218 should_route :get, "/projects/redmine/repository/statistics", :controller => 'repositories', :action => 'stats', :id => 'redmine'
218 should_route :get, "/projects/redmine/repository/statistics", :controller => 'repositories', :action => 'stats', :id => 'redmine'
219
219
220
220
221 should_route :post, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine'
221 should_route :post, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine'
222 end
222 end
223
223
224 context "timelogs" do
224 context "timelogs (global)" do
225 should_route :get, "/time_entries", :controller => 'timelog', :action => 'index'
225 should_route :get, "/time_entries", :controller => 'timelog', :action => 'index'
226 should_route :get, "/time_entries.csv", :controller => 'timelog', :action => 'index', :format => 'csv'
226 should_route :get, "/time_entries.csv", :controller => 'timelog', :action => 'index', :format => 'csv'
227 should_route :get, "/time_entries.atom", :controller => 'timelog', :action => 'index', :format => 'atom'
227 should_route :get, "/time_entries.atom", :controller => 'timelog', :action => 'index', :format => 'atom'
228 should_route :get, "/time_entries/new", :controller => 'timelog', :action => 'new'
229 should_route :get, "/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22'
230
231 should_route :post, "/time_entries", :controller => 'timelog', :action => 'create'
232
233 should_route :put, "/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22'
234
235 should_route :delete, "/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55'
236 end
237
238 context "timelogs (scoped under project)" do
228 should_route :get, "/projects/567/time_entries", :controller => 'timelog', :action => 'index', :project_id => '567'
239 should_route :get, "/projects/567/time_entries", :controller => 'timelog', :action => 'index', :project_id => '567'
229 should_route :get, "/projects/567/time_entries.csv", :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'csv'
240 should_route :get, "/projects/567/time_entries.csv", :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'csv'
230 should_route :get, "/projects/567/time_entries.atom", :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'atom'
241 should_route :get, "/projects/567/time_entries.atom", :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'atom'
242 should_route :get, "/projects/567/time_entries/new", :controller => 'timelog', :action => 'new', :project_id => '567'
243 should_route :get, "/projects/567/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22', :project_id => '567'
244
245 should_route :post, "/projects/567/time_entries", :controller => 'timelog', :action => 'create', :project_id => '567'
246
247 should_route :put, "/projects/567/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :project_id => '567'
248
249 should_route :delete, "/projects/567/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :project_id => '567'
250 end
251
252 context "timelogs (scoped under issues)" do
231 should_route :get, "/issues/234/time_entries", :controller => 'timelog', :action => 'index', :issue_id => '234'
253 should_route :get, "/issues/234/time_entries", :controller => 'timelog', :action => 'index', :issue_id => '234'
232 should_route :get, "/issues/234/time_entries.csv", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'csv'
254 should_route :get, "/issues/234/time_entries.csv", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'csv'
233 should_route :get, "/issues/234/time_entries.atom", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'atom'
255 should_route :get, "/issues/234/time_entries.atom", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'atom'
234 should_route :get, "/projects/ecookbook/issues/123/time_entries", :controller => 'timelog', :action => 'index', :project_id => 'ecookbook', :issue_id => '123'
256 should_route :get, "/issues/234/time_entries/new", :controller => 'timelog', :action => 'new', :issue_id => '234'
257 should_route :get, "/issues/234/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22', :issue_id => '234'
235
258
236 should_route :get, "/issues/567/time_entries/new", :controller => 'timelog', :action => 'new', :issue_id => '567'
259 should_route :post, "/issues/234/time_entries", :controller => 'timelog', :action => 'create', :issue_id => '234'
237 should_route :get, "/projects/ecookbook/time_entries/new", :controller => 'timelog', :action => 'new', :project_id => 'ecookbook'
238 should_route :get, "/projects/ecookbook/issues/567/time_entries/new", :controller => 'timelog', :action => 'new', :project_id => 'ecookbook', :issue_id => '567'
239 should_route :get, "/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22'
240
260
241 should_route :post, "/projects/ecookbook/timelog/edit", :controller => 'timelog', :action => 'create', :project_id => 'ecookbook'
261 should_route :put, "/issues/234/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :issue_id => '234'
242 should_route :post, "/time_entries/55/destroy", :controller => 'timelog', :action => 'destroy', :id => '55'
243
262
244 should_route :put, "/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22'
263 should_route :delete, "/issues/234/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :issue_id => '234'
264 end
265
266 context "timelogs (scoped under project and issues)" do
267 should_route :get, "/projects/ecookbook/issues/234/time_entries", :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook'
268 should_route :get, "/projects/ecookbook/issues/234/time_entries.csv", :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook', :format => 'csv'
269 should_route :get, "/projects/ecookbook/issues/234/time_entries.atom", :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook', :format => 'atom'
270 should_route :get, "/projects/ecookbook/issues/234/time_entries/new", :controller => 'timelog', :action => 'new', :issue_id => '234', :project_id => 'ecookbook'
271 should_route :get, "/projects/ecookbook/issues/234/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22', :issue_id => '234', :project_id => 'ecookbook'
272
273 should_route :post, "/projects/ecookbook/issues/234/time_entries", :controller => 'timelog', :action => 'create', :issue_id => '234', :project_id => 'ecookbook'
274
275 should_route :put, "/projects/ecookbook/issues/234/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :issue_id => '234', :project_id => 'ecookbook'
276
277 should_route :delete, "/projects/ecookbook/issues/234/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :issue_id => '234', :project_id => 'ecookbook'
245 end
278 end
246
279
247 context "time_entry_reports" do
280 context "time_entry_reports" do
248 should_route :get, "/time_entries/report", :controller => 'time_entry_reports', :action => 'report'
281 should_route :get, "/time_entries/report", :controller => 'time_entry_reports', :action => 'report'
249 should_route :get, "/projects/567/time_entries/report", :controller => 'time_entry_reports', :action => 'report', :project_id => '567'
282 should_route :get, "/projects/567/time_entries/report", :controller => 'time_entry_reports', :action => 'report', :project_id => '567'
250 should_route :get, "/projects/567/time_entries/report.csv", :controller => 'time_entry_reports', :action => 'report', :project_id => '567', :format => 'csv'
283 should_route :get, "/projects/567/time_entries/report.csv", :controller => 'time_entry_reports', :action => 'report', :project_id => '567', :format => 'csv'
251 end
284 end
252
285
253 context "users" do
286 context "users" do
254 should_route :get, "/users", :controller => 'users', :action => 'index'
287 should_route :get, "/users", :controller => 'users', :action => 'index'
255 should_route :get, "/users/44", :controller => 'users', :action => 'show', :id => '44'
288 should_route :get, "/users/44", :controller => 'users', :action => 'show', :id => '44'
256 should_route :get, "/users/new", :controller => 'users', :action => 'new'
289 should_route :get, "/users/new", :controller => 'users', :action => 'new'
257 should_route :get, "/users/444/edit", :controller => 'users', :action => 'edit', :id => '444'
290 should_route :get, "/users/444/edit", :controller => 'users', :action => 'edit', :id => '444'
258 should_route :get, "/users/222/edit/membership", :controller => 'users', :action => 'edit', :id => '222', :tab => 'membership'
291 should_route :get, "/users/222/edit/membership", :controller => 'users', :action => 'edit', :id => '222', :tab => 'membership'
259
292
260 should_route :post, "/users", :controller => 'users', :action => 'create'
293 should_route :post, "/users", :controller => 'users', :action => 'create'
261 should_route :post, "/users/123/memberships", :controller => 'users', :action => 'edit_membership', :id => '123'
294 should_route :post, "/users/123/memberships", :controller => 'users', :action => 'edit_membership', :id => '123'
262 should_route :post, "/users/123/memberships/55", :controller => 'users', :action => 'edit_membership', :id => '123', :membership_id => '55'
295 should_route :post, "/users/123/memberships/55", :controller => 'users', :action => 'edit_membership', :id => '123', :membership_id => '55'
263 should_route :post, "/users/567/memberships/12/destroy", :controller => 'users', :action => 'destroy_membership', :id => '567', :membership_id => '12'
296 should_route :post, "/users/567/memberships/12/destroy", :controller => 'users', :action => 'destroy_membership', :id => '567', :membership_id => '12'
264
297
265 should_route :put, "/users/444", :controller => 'users', :action => 'update', :id => '444'
298 should_route :put, "/users/444", :controller => 'users', :action => 'update', :id => '444'
266 end
299 end
267
300
268 # TODO: should they all be scoped under /projects/:project_id ?
301 # TODO: should they all be scoped under /projects/:project_id ?
269 context "versions" do
302 context "versions" do
270 should_route :get, "/projects/foo/versions/new", :controller => 'versions', :action => 'new', :project_id => 'foo'
303 should_route :get, "/projects/foo/versions/new", :controller => 'versions', :action => 'new', :project_id => 'foo'
271 should_route :get, "/versions/show/1", :controller => 'versions', :action => 'show', :id => '1'
304 should_route :get, "/versions/show/1", :controller => 'versions', :action => 'show', :id => '1'
272 should_route :get, "/versions/edit/1", :controller => 'versions', :action => 'edit', :id => '1'
305 should_route :get, "/versions/edit/1", :controller => 'versions', :action => 'edit', :id => '1'
273
306
274 should_route :post, "/projects/foo/versions", :controller => 'versions', :action => 'create', :project_id => 'foo'
307 should_route :post, "/projects/foo/versions", :controller => 'versions', :action => 'create', :project_id => 'foo'
275 should_route :post, "/versions/update/1", :controller => 'versions', :action => 'update', :id => '1'
308 should_route :post, "/versions/update/1", :controller => 'versions', :action => 'update', :id => '1'
276
309
277 should_route :delete, "/versions/destroy/1", :controller => 'versions', :action => 'destroy', :id => '1'
310 should_route :delete, "/versions/destroy/1", :controller => 'versions', :action => 'destroy', :id => '1'
278 end
311 end
279
312
280 context "wiki (singular, project's pages)" do
313 context "wiki (singular, project's pages)" do
281 should_route :get, "/projects/567/wiki", :controller => 'wiki', :action => 'index', :id => '567'
314 should_route :get, "/projects/567/wiki", :controller => 'wiki', :action => 'index', :id => '567'
282 should_route :get, "/projects/567/wiki/lalala", :controller => 'wiki', :action => 'index', :id => '567', :page => 'lalala'
315 should_route :get, "/projects/567/wiki/lalala", :controller => 'wiki', :action => 'index', :id => '567', :page => 'lalala'
283 should_route :get, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page'
316 should_route :get, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page'
284 should_route :get, "/projects/1/wiki/CookBook_documentation/history", :controller => 'wiki', :action => 'history', :id => '1', :page => 'CookBook_documentation'
317 should_route :get, "/projects/1/wiki/CookBook_documentation/history", :controller => 'wiki', :action => 'history', :id => '1', :page => 'CookBook_documentation'
285 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'
318 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'
286 should_route :get, "/projects/1/wiki/CookBook_documentation/annotate/2", :controller => 'wiki', :action => 'annotate', :id => '1', :page => 'CookBook_documentation', :version => '2'
319 should_route :get, "/projects/1/wiki/CookBook_documentation/annotate/2", :controller => 'wiki', :action => 'annotate', :id => '1', :page => 'CookBook_documentation', :version => '2'
287 should_route :get, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida'
320 should_route :get, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida'
288 should_route :get, "/projects/567/wiki/page_index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'page_index'
321 should_route :get, "/projects/567/wiki/page_index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'page_index'
289 should_route :get, "/projects/567/wiki/Page_Index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'Page_Index'
322 should_route :get, "/projects/567/wiki/Page_Index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'Page_Index'
290 should_route :get, "/projects/567/wiki/date_index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'date_index'
323 should_route :get, "/projects/567/wiki/date_index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'date_index'
291 should_route :get, "/projects/567/wiki/export", :controller => 'wiki', :action => 'special', :id => '567', :page => 'export'
324 should_route :get, "/projects/567/wiki/export", :controller => 'wiki', :action => 'special', :id => '567', :page => 'export'
292
325
293 should_route :post, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page'
326 should_route :post, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page'
294 should_route :post, "/projects/567/wiki/CookBook_documentation/preview", :controller => 'wiki', :action => 'preview', :id => '567', :page => 'CookBook_documentation'
327 should_route :post, "/projects/567/wiki/CookBook_documentation/preview", :controller => 'wiki', :action => 'preview', :id => '567', :page => 'CookBook_documentation'
295 should_route :post, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida'
328 should_route :post, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida'
296 should_route :post, "/projects/22/wiki/ladida/destroy", :controller => 'wiki', :action => 'destroy', :id => '22', :page => 'ladida'
329 should_route :post, "/projects/22/wiki/ladida/destroy", :controller => 'wiki', :action => 'destroy', :id => '22', :page => 'ladida'
297 should_route :post, "/projects/22/wiki/ladida/protect", :controller => 'wiki', :action => 'protect', :id => '22', :page => 'ladida'
330 should_route :post, "/projects/22/wiki/ladida/protect", :controller => 'wiki', :action => 'protect', :id => '22', :page => 'ladida'
298 end
331 end
299
332
300 context "wikis (plural, admin setup)" do
333 context "wikis (plural, admin setup)" do
301 should_route :get, "/projects/ladida/wiki/destroy", :controller => 'wikis', :action => 'destroy', :id => 'ladida'
334 should_route :get, "/projects/ladida/wiki/destroy", :controller => 'wikis', :action => 'destroy', :id => 'ladida'
302
335
303 should_route :post, "/projects/ladida/wiki", :controller => 'wikis', :action => 'edit', :id => 'ladida'
336 should_route :post, "/projects/ladida/wiki", :controller => 'wikis', :action => 'edit', :id => 'ladida'
304 should_route :post, "/projects/ladida/wiki/destroy", :controller => 'wikis', :action => 'destroy', :id => 'ladida'
337 should_route :post, "/projects/ladida/wiki/destroy", :controller => 'wikis', :action => 'destroy', :id => 'ladida'
305 end
338 end
306
339
307 context "administration panel" do
340 context "administration panel" do
308 should_route :get, "/admin/projects", :controller => 'admin', :action => 'projects'
341 should_route :get, "/admin/projects", :controller => 'admin', :action => 'projects'
309 end
342 end
310 end
343 end
General Comments 0
You need to be logged in to leave comments. Login now