@@ -1,345 +1,313 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2009 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2009 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 ProjectsController < ApplicationController |
|
18 | class ProjectsController < ApplicationController | |
19 | menu_item :overview |
|
19 | menu_item :overview | |
20 | menu_item :roadmap, :only => :roadmap |
|
20 | menu_item :roadmap, :only => :roadmap | |
21 | menu_item :files, :only => [:list_files, :add_file] |
|
21 | menu_item :files, :only => [:list_files, :add_file] | |
22 | menu_item :settings, :only => :settings |
|
22 | menu_item :settings, :only => :settings | |
23 |
|
23 | |||
24 | before_filter :find_project, :except => [ :index, :list, :add, :copy ] |
|
24 | before_filter :find_project, :except => [ :index, :list, :add, :copy ] | |
25 | before_filter :authorize, :except => [ :index, :list, :add, :copy, :archive, :unarchive, :destroy] |
|
25 | before_filter :authorize, :except => [ :index, :list, :add, :copy, :archive, :unarchive, :destroy] | |
26 | before_filter :authorize_global, :only => :add |
|
26 | before_filter :authorize_global, :only => :add | |
27 | before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ] |
|
27 | before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ] | |
28 | accept_key_auth :index |
|
28 | accept_key_auth :index | |
29 |
|
29 | |||
30 | after_filter :only => [:add, :edit, :archive, :unarchive, :destroy] do |controller| |
|
30 | after_filter :only => [:add, :edit, :archive, :unarchive, :destroy] do |controller| | |
31 | if controller.request.post? |
|
31 | if controller.request.post? | |
32 | controller.send :expire_action, :controller => 'welcome', :action => 'robots.txt' |
|
32 | controller.send :expire_action, :controller => 'welcome', :action => 'robots.txt' | |
33 | end |
|
33 | end | |
34 | end |
|
34 | end | |
35 |
|
35 | |||
36 | helper :sort |
|
36 | helper :sort | |
37 | include SortHelper |
|
37 | include SortHelper | |
38 | helper :custom_fields |
|
38 | helper :custom_fields | |
39 | include CustomFieldsHelper |
|
39 | include CustomFieldsHelper | |
40 | helper :issues |
|
40 | helper :issues | |
41 | helper :queries |
|
41 | helper :queries | |
42 | include QueriesHelper |
|
42 | include QueriesHelper | |
43 | helper :repositories |
|
43 | helper :repositories | |
44 | include RepositoriesHelper |
|
44 | include RepositoriesHelper | |
45 | include ProjectsHelper |
|
45 | include ProjectsHelper | |
46 |
|
46 | |||
47 | # Lists visible projects |
|
47 | # Lists visible projects | |
48 | def index |
|
48 | def index | |
49 | respond_to do |format| |
|
49 | respond_to do |format| | |
50 | format.html { |
|
50 | format.html { | |
51 | @projects = Project.visible.find(:all, :order => 'lft') |
|
51 | @projects = Project.visible.find(:all, :order => 'lft') | |
52 | } |
|
52 | } | |
53 | format.xml { |
|
53 | format.xml { | |
54 | @projects = Project.visible.find(:all, :order => 'lft') |
|
54 | @projects = Project.visible.find(:all, :order => 'lft') | |
55 | } |
|
55 | } | |
56 | format.atom { |
|
56 | format.atom { | |
57 | projects = Project.visible.find(:all, :order => 'created_on DESC', |
|
57 | projects = Project.visible.find(:all, :order => 'created_on DESC', | |
58 | :limit => Setting.feeds_limit.to_i) |
|
58 | :limit => Setting.feeds_limit.to_i) | |
59 | render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}") |
|
59 | render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}") | |
60 | } |
|
60 | } | |
61 | end |
|
61 | end | |
62 | end |
|
62 | end | |
63 |
|
63 | |||
64 | # Add a new project |
|
64 | # Add a new project | |
65 | def add |
|
65 | def add | |
66 | @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") |
|
66 | @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") | |
67 | @trackers = Tracker.all |
|
67 | @trackers = Tracker.all | |
68 | @project = Project.new(params[:project]) |
|
68 | @project = Project.new(params[:project]) | |
69 | if request.get? |
|
69 | if request.get? | |
70 | @project.identifier = Project.next_identifier if Setting.sequential_project_identifiers? |
|
70 | @project.identifier = Project.next_identifier if Setting.sequential_project_identifiers? | |
71 | @project.trackers = Tracker.all |
|
71 | @project.trackers = Tracker.all | |
72 | @project.is_public = Setting.default_projects_public? |
|
72 | @project.is_public = Setting.default_projects_public? | |
73 | @project.enabled_module_names = Setting.default_projects_modules |
|
73 | @project.enabled_module_names = Setting.default_projects_modules | |
74 | else |
|
74 | else | |
75 | @project.enabled_module_names = params[:enabled_modules] |
|
75 | @project.enabled_module_names = params[:enabled_modules] | |
76 | if validate_parent_id && @project.save |
|
76 | if validate_parent_id && @project.save | |
77 | @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') |
|
77 | @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') | |
78 | # Add current user as a project member if he is not admin |
|
78 | # Add current user as a project member if he is not admin | |
79 | unless User.current.admin? |
|
79 | unless User.current.admin? | |
80 | r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first |
|
80 | r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first | |
81 | m = Member.new(:user => User.current, :roles => [r]) |
|
81 | m = Member.new(:user => User.current, :roles => [r]) | |
82 | @project.members << m |
|
82 | @project.members << m | |
83 | end |
|
83 | end | |
84 | respond_to do |format| |
|
84 | respond_to do |format| | |
85 | format.html { |
|
85 | format.html { | |
86 | flash[:notice] = l(:notice_successful_create) |
|
86 | flash[:notice] = l(:notice_successful_create) | |
87 | redirect_to :controller => 'projects', :action => 'settings', :id => @project |
|
87 | redirect_to :controller => 'projects', :action => 'settings', :id => @project | |
88 | } |
|
88 | } | |
89 | format.xml { head :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) } |
|
89 | format.xml { head :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) } | |
90 | end |
|
90 | end | |
91 | else |
|
91 | else | |
92 | respond_to do |format| |
|
92 | respond_to do |format| | |
93 | format.html |
|
93 | format.html | |
94 | format.xml { render :xml => @project.errors, :status => :unprocessable_entity } |
|
94 | format.xml { render :xml => @project.errors, :status => :unprocessable_entity } | |
95 | end |
|
95 | end | |
96 | end |
|
96 | end | |
97 | end |
|
97 | end | |
98 | end |
|
98 | end | |
99 |
|
99 | |||
100 | def copy |
|
100 | def copy | |
101 | @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") |
|
101 | @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") | |
102 | @trackers = Tracker.all |
|
102 | @trackers = Tracker.all | |
103 | @root_projects = Project.find(:all, |
|
103 | @root_projects = Project.find(:all, | |
104 | :conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}", |
|
104 | :conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}", | |
105 | :order => 'name') |
|
105 | :order => 'name') | |
106 | @source_project = Project.find(params[:id]) |
|
106 | @source_project = Project.find(params[:id]) | |
107 | if request.get? |
|
107 | if request.get? | |
108 | @project = Project.copy_from(@source_project) |
|
108 | @project = Project.copy_from(@source_project) | |
109 | if @project |
|
109 | if @project | |
110 | @project.identifier = Project.next_identifier if Setting.sequential_project_identifiers? |
|
110 | @project.identifier = Project.next_identifier if Setting.sequential_project_identifiers? | |
111 | else |
|
111 | else | |
112 | redirect_to :controller => 'admin', :action => 'projects' |
|
112 | redirect_to :controller => 'admin', :action => 'projects' | |
113 | end |
|
113 | end | |
114 | else |
|
114 | else | |
115 | Mailer.with_deliveries(params[:notifications] == '1') do |
|
115 | Mailer.with_deliveries(params[:notifications] == '1') do | |
116 | @project = Project.new(params[:project]) |
|
116 | @project = Project.new(params[:project]) | |
117 | @project.enabled_module_names = params[:enabled_modules] |
|
117 | @project.enabled_module_names = params[:enabled_modules] | |
118 | if validate_parent_id && @project.copy(@source_project, :only => params[:only]) |
|
118 | if validate_parent_id && @project.copy(@source_project, :only => params[:only]) | |
119 | @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') |
|
119 | @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') | |
120 | flash[:notice] = l(:notice_successful_create) |
|
120 | flash[:notice] = l(:notice_successful_create) | |
121 | redirect_to :controller => 'admin', :action => 'projects' |
|
121 | redirect_to :controller => 'admin', :action => 'projects' | |
122 | elsif !@project.new_record? |
|
122 | elsif !@project.new_record? | |
123 | # Project was created |
|
123 | # Project was created | |
124 | # But some objects were not copied due to validation failures |
|
124 | # But some objects were not copied due to validation failures | |
125 | # (eg. issues from disabled trackers) |
|
125 | # (eg. issues from disabled trackers) | |
126 | # TODO: inform about that |
|
126 | # TODO: inform about that | |
127 | redirect_to :controller => 'admin', :action => 'projects' |
|
127 | redirect_to :controller => 'admin', :action => 'projects' | |
128 | end |
|
128 | end | |
129 | end |
|
129 | end | |
130 | end |
|
130 | end | |
131 | rescue ActiveRecord::RecordNotFound |
|
131 | rescue ActiveRecord::RecordNotFound | |
132 | redirect_to :controller => 'admin', :action => 'projects' |
|
132 | redirect_to :controller => 'admin', :action => 'projects' | |
133 | end |
|
133 | end | |
134 |
|
134 | |||
135 | # Show @project |
|
135 | # Show @project | |
136 | def show |
|
136 | def show | |
137 | if params[:jump] |
|
137 | if params[:jump] | |
138 | # try to redirect to the requested menu item |
|
138 | # try to redirect to the requested menu item | |
139 | redirect_to_project_menu_item(@project, params[:jump]) && return |
|
139 | redirect_to_project_menu_item(@project, params[:jump]) && return | |
140 | end |
|
140 | end | |
141 |
|
141 | |||
142 | @users_by_role = @project.users_by_role |
|
142 | @users_by_role = @project.users_by_role | |
143 | @subprojects = @project.children.visible |
|
143 | @subprojects = @project.children.visible | |
144 | @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC") |
|
144 | @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC") | |
145 | @trackers = @project.rolled_up_trackers |
|
145 | @trackers = @project.rolled_up_trackers | |
146 |
|
146 | |||
147 | cond = @project.project_condition(Setting.display_subprojects_issues?) |
|
147 | cond = @project.project_condition(Setting.display_subprojects_issues?) | |
148 |
|
148 | |||
149 | @open_issues_by_tracker = Issue.visible.count(:group => :tracker, |
|
149 | @open_issues_by_tracker = Issue.visible.count(:group => :tracker, | |
150 | :include => [:project, :status, :tracker], |
|
150 | :include => [:project, :status, :tracker], | |
151 | :conditions => ["(#{cond}) AND #{IssueStatus.table_name}.is_closed=?", false]) |
|
151 | :conditions => ["(#{cond}) AND #{IssueStatus.table_name}.is_closed=?", false]) | |
152 | @total_issues_by_tracker = Issue.visible.count(:group => :tracker, |
|
152 | @total_issues_by_tracker = Issue.visible.count(:group => :tracker, | |
153 | :include => [:project, :status, :tracker], |
|
153 | :include => [:project, :status, :tracker], | |
154 | :conditions => cond) |
|
154 | :conditions => cond) | |
155 |
|
155 | |||
156 | TimeEntry.visible_by(User.current) do |
|
156 | TimeEntry.visible_by(User.current) do | |
157 | @total_hours = TimeEntry.sum(:hours, |
|
157 | @total_hours = TimeEntry.sum(:hours, | |
158 | :include => :project, |
|
158 | :include => :project, | |
159 | :conditions => cond).to_f |
|
159 | :conditions => cond).to_f | |
160 | end |
|
160 | end | |
161 | @key = User.current.rss_key |
|
161 | @key = User.current.rss_key | |
162 |
|
162 | |||
163 | respond_to do |format| |
|
163 | respond_to do |format| | |
164 | format.html |
|
164 | format.html | |
165 | format.xml |
|
165 | format.xml | |
166 | end |
|
166 | end | |
167 | end |
|
167 | end | |
168 |
|
168 | |||
169 | def settings |
|
169 | def settings | |
170 | @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") |
|
170 | @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") | |
171 | @issue_category ||= IssueCategory.new |
|
171 | @issue_category ||= IssueCategory.new | |
172 | @member ||= @project.members.new |
|
172 | @member ||= @project.members.new | |
173 | @trackers = Tracker.all |
|
173 | @trackers = Tracker.all | |
174 | @repository ||= @project.repository |
|
174 | @repository ||= @project.repository | |
175 | @wiki ||= @project.wiki |
|
175 | @wiki ||= @project.wiki | |
176 | end |
|
176 | end | |
177 |
|
177 | |||
178 | # Edit @project |
|
178 | # Edit @project | |
179 | def edit |
|
179 | def edit | |
180 | if request.get? |
|
180 | if request.get? | |
181 | else |
|
181 | else | |
182 | @project.attributes = params[:project] |
|
182 | @project.attributes = params[:project] | |
183 | if validate_parent_id && @project.save |
|
183 | if validate_parent_id && @project.save | |
184 | @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') |
|
184 | @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') | |
185 | respond_to do |format| |
|
185 | respond_to do |format| | |
186 | format.html { |
|
186 | format.html { | |
187 | flash[:notice] = l(:notice_successful_update) |
|
187 | flash[:notice] = l(:notice_successful_update) | |
188 | redirect_to :action => 'settings', :id => @project |
|
188 | redirect_to :action => 'settings', :id => @project | |
189 | } |
|
189 | } | |
190 | format.xml { head :ok } |
|
190 | format.xml { head :ok } | |
191 | end |
|
191 | end | |
192 | else |
|
192 | else | |
193 | respond_to do |format| |
|
193 | respond_to do |format| | |
194 | format.html { |
|
194 | format.html { | |
195 | settings |
|
195 | settings | |
196 | render :action => 'settings' |
|
196 | render :action => 'settings' | |
197 | } |
|
197 | } | |
198 | format.xml { render :xml => @project.errors, :status => :unprocessable_entity } |
|
198 | format.xml { render :xml => @project.errors, :status => :unprocessable_entity } | |
199 | end |
|
199 | end | |
200 | end |
|
200 | end | |
201 | end |
|
201 | end | |
202 | end |
|
202 | end | |
203 |
|
203 | |||
204 | def modules |
|
204 | def modules | |
205 | @project.enabled_module_names = params[:enabled_modules] |
|
205 | @project.enabled_module_names = params[:enabled_modules] | |
206 | flash[:notice] = l(:notice_successful_update) |
|
206 | flash[:notice] = l(:notice_successful_update) | |
207 | redirect_to :action => 'settings', :id => @project, :tab => 'modules' |
|
207 | redirect_to :action => 'settings', :id => @project, :tab => 'modules' | |
208 | end |
|
208 | end | |
209 |
|
209 | |||
210 | def archive |
|
210 | def archive | |
211 | if request.post? |
|
211 | if request.post? | |
212 | unless @project.archive |
|
212 | unless @project.archive | |
213 | flash[:error] = l(:error_can_not_archive_project) |
|
213 | flash[:error] = l(:error_can_not_archive_project) | |
214 | end |
|
214 | end | |
215 | end |
|
215 | end | |
216 | redirect_to(url_for(:controller => 'admin', :action => 'projects', :status => params[:status])) |
|
216 | redirect_to(url_for(:controller => 'admin', :action => 'projects', :status => params[:status])) | |
217 | end |
|
217 | end | |
218 |
|
218 | |||
219 | def unarchive |
|
219 | def unarchive | |
220 | @project.unarchive if request.post? && !@project.active? |
|
220 | @project.unarchive if request.post? && !@project.active? | |
221 | redirect_to(url_for(:controller => 'admin', :action => 'projects', :status => params[:status])) |
|
221 | redirect_to(url_for(:controller => 'admin', :action => 'projects', :status => params[:status])) | |
222 | end |
|
222 | end | |
223 |
|
223 | |||
224 | # Delete @project |
|
224 | # Delete @project | |
225 | def destroy |
|
225 | def destroy | |
226 | @project_to_destroy = @project |
|
226 | @project_to_destroy = @project | |
227 | if request.get? |
|
227 | if request.get? | |
228 | # display confirmation view |
|
228 | # display confirmation view | |
229 | else |
|
229 | else | |
230 | if params[:format] == 'xml' || params[:confirm] |
|
230 | if params[:format] == 'xml' || params[:confirm] | |
231 | @project_to_destroy.destroy |
|
231 | @project_to_destroy.destroy | |
232 | respond_to do |format| |
|
232 | respond_to do |format| | |
233 | format.html { redirect_to :controller => 'admin', :action => 'projects' } |
|
233 | format.html { redirect_to :controller => 'admin', :action => 'projects' } | |
234 | format.xml { head :ok } |
|
234 | format.xml { head :ok } | |
235 | end |
|
235 | end | |
236 | end |
|
236 | end | |
237 | end |
|
237 | end | |
238 | # hide project in layout |
|
238 | # hide project in layout | |
239 | @project = nil |
|
239 | @project = nil | |
240 | end |
|
240 | end | |
241 |
|
241 | |||
242 | def add_file |
|
242 | def add_file | |
243 | if request.post? |
|
243 | if request.post? | |
244 | container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id])) |
|
244 | container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id])) | |
245 | attachments = Attachment.attach_files(container, params[:attachments]) |
|
245 | attachments = Attachment.attach_files(container, params[:attachments]) | |
246 | render_attachment_warning_if_needed(container) |
|
246 | render_attachment_warning_if_needed(container) | |
247 |
|
247 | |||
248 | if !attachments.empty? && Setting.notified_events.include?('file_added') |
|
248 | if !attachments.empty? && Setting.notified_events.include?('file_added') | |
249 | Mailer.deliver_attachments_added(attachments[:files]) |
|
249 | Mailer.deliver_attachments_added(attachments[:files]) | |
250 | end |
|
250 | end | |
251 | redirect_to :controller => 'projects', :action => 'list_files', :id => @project |
|
251 | redirect_to :controller => 'projects', :action => 'list_files', :id => @project | |
252 | return |
|
252 | return | |
253 | end |
|
253 | end | |
254 | @versions = @project.versions.sort |
|
254 | @versions = @project.versions.sort | |
255 | end |
|
255 | end | |
256 |
|
256 | |||
257 | def save_activities |
|
257 | def save_activities | |
258 | if request.post? && params[:enumerations] |
|
258 | if request.post? && params[:enumerations] | |
259 | Project.transaction do |
|
259 | Project.transaction do | |
260 | params[:enumerations].each do |id, activity| |
|
260 | params[:enumerations].each do |id, activity| | |
261 | @project.update_or_create_time_entry_activity(id, activity) |
|
261 | @project.update_or_create_time_entry_activity(id, activity) | |
262 | end |
|
262 | end | |
263 | end |
|
263 | end | |
264 | flash[:notice] = l(:notice_successful_update) |
|
264 | flash[:notice] = l(:notice_successful_update) | |
265 | end |
|
265 | end | |
266 |
|
266 | |||
267 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'activities', :id => @project |
|
267 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'activities', :id => @project | |
268 | end |
|
268 | end | |
269 |
|
269 | |||
270 | def reset_activities |
|
270 | def reset_activities | |
271 | @project.time_entry_activities.each do |time_entry_activity| |
|
271 | @project.time_entry_activities.each do |time_entry_activity| | |
272 | time_entry_activity.destroy(time_entry_activity.parent) |
|
272 | time_entry_activity.destroy(time_entry_activity.parent) | |
273 | end |
|
273 | end | |
274 | flash[:notice] = l(:notice_successful_update) |
|
274 | flash[:notice] = l(:notice_successful_update) | |
275 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'activities', :id => @project |
|
275 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'activities', :id => @project | |
276 | end |
|
276 | end | |
277 |
|
277 | |||
278 | def list_files |
|
278 | def list_files | |
279 | sort_init 'filename', 'asc' |
|
279 | sort_init 'filename', 'asc' | |
280 | sort_update 'filename' => "#{Attachment.table_name}.filename", |
|
280 | sort_update 'filename' => "#{Attachment.table_name}.filename", | |
281 | 'created_on' => "#{Attachment.table_name}.created_on", |
|
281 | 'created_on' => "#{Attachment.table_name}.created_on", | |
282 | 'size' => "#{Attachment.table_name}.filesize", |
|
282 | 'size' => "#{Attachment.table_name}.filesize", | |
283 | 'downloads' => "#{Attachment.table_name}.downloads" |
|
283 | 'downloads' => "#{Attachment.table_name}.downloads" | |
284 |
|
284 | |||
285 | @containers = [ Project.find(@project.id, :include => :attachments, :order => sort_clause)] |
|
285 | @containers = [ Project.find(@project.id, :include => :attachments, :order => sort_clause)] | |
286 | @containers += @project.versions.find(:all, :include => :attachments, :order => sort_clause).sort.reverse |
|
286 | @containers += @project.versions.find(:all, :include => :attachments, :order => sort_clause).sort.reverse | |
287 | render :layout => !request.xhr? |
|
287 | render :layout => !request.xhr? | |
288 | end |
|
288 | end | |
289 |
|
289 | |||
290 | def roadmap |
|
|||
291 | @trackers = @project.trackers.find(:all, :order => 'position') |
|
|||
292 | retrieve_selected_tracker_ids(@trackers, @trackers.select {|t| t.is_in_roadmap?}) |
|
|||
293 | @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') |
|
|||
294 | project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id] |
|
|||
295 |
|
||||
296 | @versions = @project.shared_versions || [] |
|
|||
297 | @versions += @project.rolled_up_versions.visible if @with_subprojects |
|
|||
298 | @versions = @versions.uniq.sort |
|
|||
299 | @versions.reject! {|version| version.closed? || version.completed? } unless params[:completed] |
|
|||
300 |
|
||||
301 | @issues_by_version = {} |
|
|||
302 | unless @selected_tracker_ids.empty? |
|
|||
303 | @versions.each do |version| |
|
|||
304 | issues = version.fixed_issues.visible.find(:all, |
|
|||
305 | :include => [:project, :status, :tracker, :priority], |
|
|||
306 | :conditions => {:tracker_id => @selected_tracker_ids, :project_id => project_ids}, |
|
|||
307 | :order => "#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id") |
|
|||
308 | @issues_by_version[version] = issues |
|
|||
309 | end |
|
|||
310 | end |
|
|||
311 | @versions.reject! {|version| !project_ids.include?(version.project_id) && @issues_by_version[version].blank?} |
|
|||
312 | end |
|
|||
313 |
|
||||
314 | private |
|
290 | private | |
315 | def find_optional_project |
|
291 | def find_optional_project | |
316 | return true unless params[:id] |
|
292 | return true unless params[:id] | |
317 | @project = Project.find(params[:id]) |
|
293 | @project = Project.find(params[:id]) | |
318 | authorize |
|
294 | authorize | |
319 | rescue ActiveRecord::RecordNotFound |
|
295 | rescue ActiveRecord::RecordNotFound | |
320 | render_404 |
|
296 | render_404 | |
321 | end |
|
297 | end | |
322 |
|
298 | |||
323 | def retrieve_selected_tracker_ids(selectable_trackers, default_trackers=nil) |
|
|||
324 | if ids = params[:tracker_ids] |
|
|||
325 | @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s } |
|
|||
326 | else |
|
|||
327 | @selected_tracker_ids = (default_trackers || selectable_trackers).collect {|t| t.id.to_s } |
|
|||
328 | end |
|
|||
329 | end |
|
|||
330 |
|
||||
331 | # Validates parent_id param according to user's permissions |
|
299 | # Validates parent_id param according to user's permissions | |
332 | # TODO: move it to Project model in a validation that depends on User.current |
|
300 | # TODO: move it to Project model in a validation that depends on User.current | |
333 | def validate_parent_id |
|
301 | def validate_parent_id | |
334 | return true if User.current.admin? |
|
302 | return true if User.current.admin? | |
335 | parent_id = params[:project] && params[:project][:parent_id] |
|
303 | parent_id = params[:project] && params[:project][:parent_id] | |
336 | if parent_id || @project.new_record? |
|
304 | if parent_id || @project.new_record? | |
337 | parent = parent_id.blank? ? nil : Project.find_by_id(parent_id.to_i) |
|
305 | parent = parent_id.blank? ? nil : Project.find_by_id(parent_id.to_i) | |
338 | unless @project.allowed_parents.include?(parent) |
|
306 | unless @project.allowed_parents.include?(parent) | |
339 | @project.errors.add :parent_id, :invalid |
|
307 | @project.errors.add :parent_id, :invalid | |
340 | return false |
|
308 | return false | |
341 | end |
|
309 | end | |
342 | end |
|
310 | end | |
343 | true |
|
311 | true | |
344 | end |
|
312 | end | |
345 | end |
|
313 | end |
@@ -1,108 +1,141 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006 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 VersionsController < ApplicationController |
|
18 | class VersionsController < ApplicationController | |
19 | menu_item :roadmap |
|
19 | menu_item :roadmap | |
20 | model_object Version |
|
20 | model_object Version | |
21 | before_filter :find_model_object, :except => [:new, :close_completed] |
|
21 | before_filter :find_model_object, :except => [:index, :new, :close_completed] | |
22 | before_filter :find_project_from_association, :except => [:new, :close_completed] |
|
22 | before_filter :find_project_from_association, :except => [:index, :new, :close_completed] | |
23 | before_filter :find_project, :only => [:new, :close_completed] |
|
23 | before_filter :find_project, :only => [:index, :new, :close_completed] | |
24 | before_filter :authorize |
|
24 | before_filter :authorize | |
25 |
|
25 | |||
26 | helper :custom_fields |
|
26 | helper :custom_fields | |
27 | helper :projects |
|
27 | helper :projects | |
28 |
|
28 | |||
|
29 | def index | |||
|
30 | @trackers = @project.trackers.find(:all, :order => 'position') | |||
|
31 | retrieve_selected_tracker_ids(@trackers, @trackers.select {|t| t.is_in_roadmap?}) | |||
|
32 | @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') | |||
|
33 | project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id] | |||
|
34 | ||||
|
35 | @versions = @project.shared_versions || [] | |||
|
36 | @versions += @project.rolled_up_versions.visible if @with_subprojects | |||
|
37 | @versions = @versions.uniq.sort | |||
|
38 | @versions.reject! {|version| version.closed? || version.completed? } unless params[:completed] | |||
|
39 | ||||
|
40 | @issues_by_version = {} | |||
|
41 | unless @selected_tracker_ids.empty? | |||
|
42 | @versions.each do |version| | |||
|
43 | issues = version.fixed_issues.visible.find(:all, | |||
|
44 | :include => [:project, :status, :tracker, :priority], | |||
|
45 | :conditions => {:tracker_id => @selected_tracker_ids, :project_id => project_ids}, | |||
|
46 | :order => "#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id") | |||
|
47 | @issues_by_version[version] = issues | |||
|
48 | end | |||
|
49 | end | |||
|
50 | @versions.reject! {|version| !project_ids.include?(version.project_id) && @issues_by_version[version].blank?} | |||
|
51 | end | |||
|
52 | ||||
29 | def show |
|
53 | def show | |
30 | @issues = @version.fixed_issues.visible.find(:all, |
|
54 | @issues = @version.fixed_issues.visible.find(:all, | |
31 | :include => [:status, :tracker, :priority], |
|
55 | :include => [:status, :tracker, :priority], | |
32 | :order => "#{Tracker.table_name}.position, #{Issue.table_name}.id") |
|
56 | :order => "#{Tracker.table_name}.position, #{Issue.table_name}.id") | |
33 | end |
|
57 | end | |
34 |
|
58 | |||
35 | def new |
|
59 | def new | |
36 | @version = @project.versions.build |
|
60 | @version = @project.versions.build | |
37 | if params[:version] |
|
61 | if params[:version] | |
38 | attributes = params[:version].dup |
|
62 | attributes = params[:version].dup | |
39 | attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing']) |
|
63 | attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing']) | |
40 | @version.attributes = attributes |
|
64 | @version.attributes = attributes | |
41 | end |
|
65 | end | |
42 | if request.post? |
|
66 | if request.post? | |
43 | if @version.save |
|
67 | if @version.save | |
44 | respond_to do |format| |
|
68 | respond_to do |format| | |
45 | format.html do |
|
69 | format.html do | |
46 | flash[:notice] = l(:notice_successful_create) |
|
70 | flash[:notice] = l(:notice_successful_create) | |
47 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
71 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project | |
48 | end |
|
72 | end | |
49 | format.js do |
|
73 | format.js do | |
50 | # IE doesn't support the replace_html rjs method for select box options |
|
74 | # IE doesn't support the replace_html rjs method for select box options | |
51 | render(:update) {|page| page.replace "issue_fixed_version_id", |
|
75 | render(:update) {|page| page.replace "issue_fixed_version_id", | |
52 | content_tag('select', '<option></option>' + version_options_for_select(@project.shared_versions.open, @version), :id => 'issue_fixed_version_id', :name => 'issue[fixed_version_id]') |
|
76 | content_tag('select', '<option></option>' + version_options_for_select(@project.shared_versions.open, @version), :id => 'issue_fixed_version_id', :name => 'issue[fixed_version_id]') | |
53 | } |
|
77 | } | |
54 | end |
|
78 | end | |
55 | end |
|
79 | end | |
56 | else |
|
80 | else | |
57 | respond_to do |format| |
|
81 | respond_to do |format| | |
58 | format.html |
|
82 | format.html | |
59 | format.js do |
|
83 | format.js do | |
60 | render(:update) {|page| page.alert(@version.errors.full_messages.join('\n')) } |
|
84 | render(:update) {|page| page.alert(@version.errors.full_messages.join('\n')) } | |
61 | end |
|
85 | end | |
62 | end |
|
86 | end | |
63 | end |
|
87 | end | |
64 | end |
|
88 | end | |
65 | end |
|
89 | end | |
66 |
|
90 | |||
67 | def edit |
|
91 | def edit | |
68 | if request.post? && params[:version] |
|
92 | if request.post? && params[:version] | |
69 | attributes = params[:version].dup |
|
93 | attributes = params[:version].dup | |
70 | attributes.delete('sharing') unless @version.allowed_sharings.include?(attributes['sharing']) |
|
94 | attributes.delete('sharing') unless @version.allowed_sharings.include?(attributes['sharing']) | |
71 | if @version.update_attributes(attributes) |
|
95 | if @version.update_attributes(attributes) | |
72 | flash[:notice] = l(:notice_successful_update) |
|
96 | flash[:notice] = l(:notice_successful_update) | |
73 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
97 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project | |
74 | end |
|
98 | end | |
75 | end |
|
99 | end | |
76 | end |
|
100 | end | |
77 |
|
101 | |||
78 | def close_completed |
|
102 | def close_completed | |
79 | if request.post? |
|
103 | if request.post? | |
80 | @project.close_completed_versions |
|
104 | @project.close_completed_versions | |
81 | end |
|
105 | end | |
82 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
106 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project | |
83 | end |
|
107 | end | |
84 |
|
108 | |||
85 | def destroy |
|
109 | def destroy | |
86 | if @version.fixed_issues.empty? |
|
110 | if @version.fixed_issues.empty? | |
87 | @version.destroy |
|
111 | @version.destroy | |
88 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
112 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project | |
89 | else |
|
113 | else | |
90 | flash[:error] = l(:notice_unable_delete_version) |
|
114 | flash[:error] = l(:notice_unable_delete_version) | |
91 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
115 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project | |
92 | end |
|
116 | end | |
93 | end |
|
117 | end | |
94 |
|
118 | |||
95 | def status_by |
|
119 | def status_by | |
96 | respond_to do |format| |
|
120 | respond_to do |format| | |
97 | format.html { render :action => 'show' } |
|
121 | format.html { render :action => 'show' } | |
98 | format.js { render(:update) {|page| page.replace_html 'status_by', render_issue_status_by(@version, params[:status_by])} } |
|
122 | format.js { render(:update) {|page| page.replace_html 'status_by', render_issue_status_by(@version, params[:status_by])} } | |
99 | end |
|
123 | end | |
100 | end |
|
124 | end | |
101 |
|
125 | |||
102 | private |
|
126 | private | |
103 | def find_project |
|
127 | def find_project | |
104 | @project = Project.find(params[:project_id]) |
|
128 | @project = Project.find(params[:project_id]) | |
105 | rescue ActiveRecord::RecordNotFound |
|
129 | rescue ActiveRecord::RecordNotFound | |
106 | render_404 |
|
130 | render_404 | |
107 | end |
|
131 | end | |
|
132 | ||||
|
133 | def retrieve_selected_tracker_ids(selectable_trackers, default_trackers=nil) | |||
|
134 | if ids = params[:tracker_ids] | |||
|
135 | @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s } | |||
|
136 | else | |||
|
137 | @selected_tracker_ids = (default_trackers || selectable_trackers).collect {|t| t.id.to_s } | |||
|
138 | end | |||
|
139 | end | |||
|
140 | ||||
108 | end |
|
141 | end |
1 | NO CONTENT: file renamed from app/views/projects/roadmap.rhtml to app/views/versions/index.html.erb |
|
NO CONTENT: file renamed from app/views/projects/roadmap.rhtml to app/views/versions/index.html.erb |
@@ -1,282 +1,283 | |||||
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 |
|
16 | |||
17 | map.connect 'time_entries/:id/edit', :action => 'edit', :controller => 'timelog' |
|
17 | map.connect 'time_entries/:id/edit', :action => 'edit', :controller => 'timelog' | |
18 | map.connect 'projects/:project_id/time_entries/new', :action => 'edit', :controller => 'timelog' |
|
18 | map.connect 'projects/:project_id/time_entries/new', :action => 'edit', :controller => 'timelog' | |
19 | map.connect 'projects/:project_id/issues/:issue_id/time_entries/new', :action => 'edit', :controller => 'timelog' |
|
19 | map.connect 'projects/:project_id/issues/:issue_id/time_entries/new', :action => 'edit', :controller => 'timelog' | |
20 |
|
20 | |||
21 | map.with_options :controller => 'timelog' do |timelog| |
|
21 | map.with_options :controller => 'timelog' do |timelog| | |
22 | timelog.connect 'projects/:project_id/time_entries', :action => 'details' |
|
22 | timelog.connect 'projects/:project_id/time_entries', :action => 'details' | |
23 |
|
23 | |||
24 | timelog.with_options :action => 'details', :conditions => {:method => :get} do |time_details| |
|
24 | timelog.with_options :action => 'details', :conditions => {:method => :get} do |time_details| | |
25 | time_details.connect 'time_entries' |
|
25 | time_details.connect 'time_entries' | |
26 | time_details.connect 'time_entries.:format' |
|
26 | time_details.connect 'time_entries.:format' | |
27 | time_details.connect 'issues/:issue_id/time_entries' |
|
27 | time_details.connect 'issues/:issue_id/time_entries' | |
28 | time_details.connect 'issues/:issue_id/time_entries.:format' |
|
28 | time_details.connect 'issues/:issue_id/time_entries.:format' | |
29 | time_details.connect 'projects/:project_id/time_entries.:format' |
|
29 | time_details.connect 'projects/:project_id/time_entries.:format' | |
30 | time_details.connect 'projects/:project_id/issues/:issue_id/time_entries' |
|
30 | time_details.connect 'projects/:project_id/issues/:issue_id/time_entries' | |
31 | time_details.connect 'projects/:project_id/issues/:issue_id/time_entries.:format' |
|
31 | time_details.connect 'projects/:project_id/issues/:issue_id/time_entries.:format' | |
32 | end |
|
32 | end | |
33 | timelog.connect 'projects/:project_id/time_entries/report', :action => 'report' |
|
33 | timelog.connect 'projects/:project_id/time_entries/report', :action => 'report' | |
34 | timelog.with_options :action => 'report',:conditions => {:method => :get} do |time_report| |
|
34 | timelog.with_options :action => 'report',:conditions => {:method => :get} do |time_report| | |
35 | time_report.connect 'time_entries/report' |
|
35 | time_report.connect 'time_entries/report' | |
36 | time_report.connect 'time_entries/report.:format' |
|
36 | time_report.connect 'time_entries/report.:format' | |
37 | time_report.connect 'projects/:project_id/time_entries/report.:format' |
|
37 | time_report.connect 'projects/:project_id/time_entries/report.:format' | |
38 | end |
|
38 | end | |
39 |
|
39 | |||
40 | timelog.with_options :action => 'edit', :conditions => {:method => :get} do |time_edit| |
|
40 | timelog.with_options :action => 'edit', :conditions => {:method => :get} do |time_edit| | |
41 | time_edit.connect 'issues/:issue_id/time_entries/new' |
|
41 | time_edit.connect 'issues/:issue_id/time_entries/new' | |
42 | end |
|
42 | end | |
43 |
|
43 | |||
44 | timelog.connect 'time_entries/:id/destroy', :action => 'destroy', :conditions => {:method => :post} |
|
44 | timelog.connect 'time_entries/:id/destroy', :action => 'destroy', :conditions => {:method => :post} | |
45 | end |
|
45 | end | |
46 |
|
46 | |||
47 | map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post} |
|
47 | map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post} | |
48 | map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get} |
|
48 | map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get} | |
49 | map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post} |
|
49 | map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post} | |
50 | map.with_options :controller => 'wiki' do |wiki_routes| |
|
50 | map.with_options :controller => 'wiki' do |wiki_routes| | |
51 | wiki_routes.with_options :conditions => {:method => :get} do |wiki_views| |
|
51 | wiki_routes.with_options :conditions => {:method => :get} do |wiki_views| | |
52 | wiki_views.connect 'projects/:id/wiki/:page', :action => 'special', :page => /page_index|date_index|export/i |
|
52 | wiki_views.connect 'projects/:id/wiki/:page', :action => 'special', :page => /page_index|date_index|export/i | |
53 | wiki_views.connect 'projects/:id/wiki/:page', :action => 'index', :page => nil |
|
53 | wiki_views.connect 'projects/:id/wiki/:page', :action => 'index', :page => nil | |
54 | wiki_views.connect 'projects/:id/wiki/:page/edit', :action => 'edit' |
|
54 | wiki_views.connect 'projects/:id/wiki/:page/edit', :action => 'edit' | |
55 | wiki_views.connect 'projects/:id/wiki/:page/rename', :action => 'rename' |
|
55 | wiki_views.connect 'projects/:id/wiki/:page/rename', :action => 'rename' | |
56 | wiki_views.connect 'projects/:id/wiki/:page/history', :action => 'history' |
|
56 | wiki_views.connect 'projects/:id/wiki/:page/history', :action => 'history' | |
57 | wiki_views.connect 'projects/:id/wiki/:page/diff/:version/vs/:version_from', :action => 'diff' |
|
57 | wiki_views.connect 'projects/:id/wiki/:page/diff/:version/vs/:version_from', :action => 'diff' | |
58 | wiki_views.connect 'projects/:id/wiki/:page/annotate/:version', :action => 'annotate' |
|
58 | wiki_views.connect 'projects/:id/wiki/:page/annotate/:version', :action => 'annotate' | |
59 | end |
|
59 | end | |
60 |
|
60 | |||
61 | wiki_routes.connect 'projects/:id/wiki/:page/:action', |
|
61 | wiki_routes.connect 'projects/:id/wiki/:page/:action', | |
62 | :action => /edit|rename|destroy|preview|protect/, |
|
62 | :action => /edit|rename|destroy|preview|protect/, | |
63 | :conditions => {:method => :post} |
|
63 | :conditions => {:method => :post} | |
64 | end |
|
64 | end | |
65 |
|
65 | |||
66 | map.with_options :controller => 'messages' do |messages_routes| |
|
66 | map.with_options :controller => 'messages' do |messages_routes| | |
67 | messages_routes.with_options :conditions => {:method => :get} do |messages_views| |
|
67 | messages_routes.with_options :conditions => {:method => :get} do |messages_views| | |
68 | messages_views.connect 'boards/:board_id/topics/new', :action => 'new' |
|
68 | messages_views.connect 'boards/:board_id/topics/new', :action => 'new' | |
69 | messages_views.connect 'boards/:board_id/topics/:id', :action => 'show' |
|
69 | messages_views.connect 'boards/:board_id/topics/:id', :action => 'show' | |
70 | messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit' |
|
70 | messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit' | |
71 | end |
|
71 | end | |
72 | messages_routes.with_options :conditions => {:method => :post} do |messages_actions| |
|
72 | messages_routes.with_options :conditions => {:method => :post} do |messages_actions| | |
73 | messages_actions.connect 'boards/:board_id/topics/new', :action => 'new' |
|
73 | messages_actions.connect 'boards/:board_id/topics/new', :action => 'new' | |
74 | messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply' |
|
74 | messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply' | |
75 | messages_actions.connect 'boards/:board_id/topics/:id/:action', :action => /edit|destroy/ |
|
75 | messages_actions.connect 'boards/:board_id/topics/:id/:action', :action => /edit|destroy/ | |
76 | end |
|
76 | end | |
77 | end |
|
77 | end | |
78 |
|
78 | |||
79 | map.with_options :controller => 'boards' do |board_routes| |
|
79 | map.with_options :controller => 'boards' do |board_routes| | |
80 | board_routes.with_options :conditions => {:method => :get} do |board_views| |
|
80 | board_routes.with_options :conditions => {:method => :get} do |board_views| | |
81 | board_views.connect 'projects/:project_id/boards', :action => 'index' |
|
81 | board_views.connect 'projects/:project_id/boards', :action => 'index' | |
82 | board_views.connect 'projects/:project_id/boards/new', :action => 'new' |
|
82 | board_views.connect 'projects/:project_id/boards/new', :action => 'new' | |
83 | board_views.connect 'projects/:project_id/boards/:id', :action => 'show' |
|
83 | board_views.connect 'projects/:project_id/boards/:id', :action => 'show' | |
84 | board_views.connect 'projects/:project_id/boards/:id.:format', :action => 'show' |
|
84 | board_views.connect 'projects/:project_id/boards/:id.:format', :action => 'show' | |
85 | board_views.connect 'projects/:project_id/boards/:id/edit', :action => 'edit' |
|
85 | board_views.connect 'projects/:project_id/boards/:id/edit', :action => 'edit' | |
86 | end |
|
86 | end | |
87 | board_routes.with_options :conditions => {:method => :post} do |board_actions| |
|
87 | board_routes.with_options :conditions => {:method => :post} do |board_actions| | |
88 | board_actions.connect 'projects/:project_id/boards', :action => 'new' |
|
88 | board_actions.connect 'projects/:project_id/boards', :action => 'new' | |
89 | board_actions.connect 'projects/:project_id/boards/:id/:action', :action => /edit|destroy/ |
|
89 | board_actions.connect 'projects/:project_id/boards/:id/:action', :action => /edit|destroy/ | |
90 | end |
|
90 | end | |
91 | end |
|
91 | end | |
92 |
|
92 | |||
93 | map.with_options :controller => 'documents' do |document_routes| |
|
93 | map.with_options :controller => 'documents' do |document_routes| | |
94 | document_routes.with_options :conditions => {:method => :get} do |document_views| |
|
94 | document_routes.with_options :conditions => {:method => :get} do |document_views| | |
95 | document_views.connect 'projects/:project_id/documents', :action => 'index' |
|
95 | document_views.connect 'projects/:project_id/documents', :action => 'index' | |
96 | document_views.connect 'projects/:project_id/documents/new', :action => 'new' |
|
96 | document_views.connect 'projects/:project_id/documents/new', :action => 'new' | |
97 | document_views.connect 'documents/:id', :action => 'show' |
|
97 | document_views.connect 'documents/:id', :action => 'show' | |
98 | document_views.connect 'documents/:id/edit', :action => 'edit' |
|
98 | document_views.connect 'documents/:id/edit', :action => 'edit' | |
99 | end |
|
99 | end | |
100 | document_routes.with_options :conditions => {:method => :post} do |document_actions| |
|
100 | document_routes.with_options :conditions => {:method => :post} do |document_actions| | |
101 | document_actions.connect 'projects/:project_id/documents', :action => 'new' |
|
101 | document_actions.connect 'projects/:project_id/documents', :action => 'new' | |
102 | document_actions.connect 'documents/:id/:action', :action => /destroy|edit/ |
|
102 | document_actions.connect 'documents/:id/:action', :action => /destroy|edit/ | |
103 | end |
|
103 | end | |
104 | end |
|
104 | end | |
105 |
|
105 | |||
106 | map.resources :issue_moves, :only => [:new, :create], :path_prefix => '/issues', :as => 'move' |
|
106 | map.resources :issue_moves, :only => [:new, :create], :path_prefix => '/issues', :as => 'move' | |
107 |
|
107 | |||
108 | # Misc issue routes. TODO: move into resources |
|
108 | # Misc issue routes. TODO: move into resources | |
109 | map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', :action => 'issues' |
|
109 | map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', :action => 'issues' | |
110 | map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue' # TODO: would look nicer as /issues/:id/preview |
|
110 | map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue' # TODO: would look nicer as /issues/:id/preview | |
111 | map.issues_context_menu '/issues/context_menu', :controller => 'context_menus', :action => 'issues' |
|
111 | map.issues_context_menu '/issues/context_menu', :controller => 'context_menus', :action => 'issues' | |
112 | map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index' |
|
112 | map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index' | |
113 | map.bulk_edit_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_edit', :conditions => { :method => :get } |
|
113 | map.bulk_edit_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_edit', :conditions => { :method => :get } | |
114 | map.bulk_update_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_update', :conditions => { :method => :post } |
|
114 | map.bulk_update_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_update', :conditions => { :method => :post } | |
115 | map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/, :conditions => { :method => :post } |
|
115 | map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/, :conditions => { :method => :post } | |
116 | map.connect '/issues/:id/destroy', :controller => 'issues', :action => 'destroy', :conditions => { :method => :post } # legacy |
|
116 | map.connect '/issues/:id/destroy', :controller => 'issues', :action => 'destroy', :conditions => { :method => :post } # legacy | |
117 |
|
117 | |||
118 | map.resource :gantt, :path_prefix => '/issues', :controller => 'gantts', :only => [:show, :update] |
|
118 | map.resource :gantt, :path_prefix => '/issues', :controller => 'gantts', :only => [:show, :update] | |
119 | map.resource :gantt, :path_prefix => '/projects/:project_id/issues', :controller => 'gantts', :only => [:show, :update] |
|
119 | map.resource :gantt, :path_prefix => '/projects/:project_id/issues', :controller => 'gantts', :only => [:show, :update] | |
120 | map.resource :calendar, :path_prefix => '/issues', :controller => 'calendars', :only => [:show, :update] |
|
120 | map.resource :calendar, :path_prefix => '/issues', :controller => 'calendars', :only => [:show, :update] | |
121 | map.resource :calendar, :path_prefix => '/projects/:project_id/issues', :controller => 'calendars', :only => [:show, :update] |
|
121 | map.resource :calendar, :path_prefix => '/projects/:project_id/issues', :controller => 'calendars', :only => [:show, :update] | |
122 |
|
122 | |||
123 | map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports| |
|
123 | map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports| | |
124 | reports.connect 'projects/:id/issues/report', :action => 'issue_report' |
|
124 | reports.connect 'projects/:id/issues/report', :action => 'issue_report' | |
125 | reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details' |
|
125 | reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details' | |
126 | end |
|
126 | end | |
127 |
|
127 | |||
128 | # Following two routes conflict with the resources because #index allows POST |
|
128 | # Following two routes conflict with the resources because #index allows POST | |
129 | map.connect '/issues', :controller => 'issues', :action => 'index', :conditions => { :method => :post } |
|
129 | map.connect '/issues', :controller => 'issues', :action => 'index', :conditions => { :method => :post } | |
130 | map.connect '/issues/create', :controller => 'issues', :action => 'index', :conditions => { :method => :post } |
|
130 | map.connect '/issues/create', :controller => 'issues', :action => 'index', :conditions => { :method => :post } | |
131 |
|
131 | |||
132 | map.resources :issues, :member => { :edit => :post }, :collection => {} |
|
132 | map.resources :issues, :member => { :edit => :post }, :collection => {} | |
133 | map.resources :issues, :path_prefix => '/projects/:project_id', :collection => { :create => :post } |
|
133 | map.resources :issues, :path_prefix => '/projects/:project_id', :collection => { :create => :post } | |
134 |
|
134 | |||
135 | map.with_options :controller => 'issue_relations', :conditions => {:method => :post} do |relations| |
|
135 | map.with_options :controller => 'issue_relations', :conditions => {:method => :post} do |relations| | |
136 | relations.connect 'issues/:issue_id/relations/:id', :action => 'new' |
|
136 | relations.connect 'issues/:issue_id/relations/:id', :action => 'new' | |
137 | relations.connect 'issues/:issue_id/relations/:id/destroy', :action => 'destroy' |
|
137 | relations.connect 'issues/:issue_id/relations/:id/destroy', :action => 'destroy' | |
138 | end |
|
138 | end | |
139 |
|
139 | |||
140 | map.with_options :controller => 'news' do |news_routes| |
|
140 | map.with_options :controller => 'news' do |news_routes| | |
141 | news_routes.with_options :conditions => {:method => :get} do |news_views| |
|
141 | news_routes.with_options :conditions => {:method => :get} do |news_views| | |
142 | news_views.connect 'news', :action => 'index' |
|
142 | news_views.connect 'news', :action => 'index' | |
143 | news_views.connect 'projects/:project_id/news', :action => 'index' |
|
143 | news_views.connect 'projects/:project_id/news', :action => 'index' | |
144 | news_views.connect 'projects/:project_id/news.:format', :action => 'index' |
|
144 | news_views.connect 'projects/:project_id/news.:format', :action => 'index' | |
145 | news_views.connect 'news.:format', :action => 'index' |
|
145 | news_views.connect 'news.:format', :action => 'index' | |
146 | news_views.connect 'projects/:project_id/news/new', :action => 'new' |
|
146 | news_views.connect 'projects/:project_id/news/new', :action => 'new' | |
147 | news_views.connect 'news/:id', :action => 'show' |
|
147 | news_views.connect 'news/:id', :action => 'show' | |
148 | news_views.connect 'news/:id/edit', :action => 'edit' |
|
148 | news_views.connect 'news/:id/edit', :action => 'edit' | |
149 | end |
|
149 | end | |
150 | news_routes.with_options do |news_actions| |
|
150 | news_routes.with_options do |news_actions| | |
151 | news_actions.connect 'projects/:project_id/news', :action => 'new' |
|
151 | news_actions.connect 'projects/:project_id/news', :action => 'new' | |
152 | news_actions.connect 'news/:id/edit', :action => 'edit' |
|
152 | news_actions.connect 'news/:id/edit', :action => 'edit' | |
153 | news_actions.connect 'news/:id/destroy', :action => 'destroy' |
|
153 | news_actions.connect 'news/:id/destroy', :action => 'destroy' | |
154 | end |
|
154 | end | |
155 | end |
|
155 | end | |
156 |
|
156 | |||
157 | map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new' |
|
157 | map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new' | |
158 |
|
158 | |||
159 | map.with_options :controller => 'users' do |users| |
|
159 | map.with_options :controller => 'users' do |users| | |
160 | users.with_options :conditions => {:method => :get} do |user_views| |
|
160 | users.with_options :conditions => {:method => :get} do |user_views| | |
161 | user_views.connect 'users', :action => 'index' |
|
161 | user_views.connect 'users', :action => 'index' | |
162 | user_views.connect 'users/:id', :action => 'show', :id => /\d+/ |
|
162 | user_views.connect 'users/:id', :action => 'show', :id => /\d+/ | |
163 | user_views.connect 'users/new', :action => 'add' |
|
163 | user_views.connect 'users/new', :action => 'add' | |
164 | user_views.connect 'users/:id/edit/:tab', :action => 'edit', :tab => nil |
|
164 | user_views.connect 'users/:id/edit/:tab', :action => 'edit', :tab => nil | |
165 | end |
|
165 | end | |
166 | users.with_options :conditions => {:method => :post} do |user_actions| |
|
166 | users.with_options :conditions => {:method => :post} do |user_actions| | |
167 | user_actions.connect 'users', :action => 'add' |
|
167 | user_actions.connect 'users', :action => 'add' | |
168 | user_actions.connect 'users/new', :action => 'add' |
|
168 | user_actions.connect 'users/new', :action => 'add' | |
169 | user_actions.connect 'users/:id/edit', :action => 'edit' |
|
169 | user_actions.connect 'users/:id/edit', :action => 'edit' | |
170 | user_actions.connect 'users/:id/memberships', :action => 'edit_membership' |
|
170 | user_actions.connect 'users/:id/memberships', :action => 'edit_membership' | |
171 | user_actions.connect 'users/:id/memberships/:membership_id', :action => 'edit_membership' |
|
171 | user_actions.connect 'users/:id/memberships/:membership_id', :action => 'edit_membership' | |
172 | user_actions.connect 'users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership' |
|
172 | user_actions.connect 'users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership' | |
173 | end |
|
173 | end | |
174 | end |
|
174 | end | |
175 |
|
175 | |||
176 | map.with_options :controller => 'projects' do |projects| |
|
176 | map.with_options :controller => 'projects' do |projects| | |
177 | projects.with_options :conditions => {:method => :get} do |project_views| |
|
177 | projects.with_options :conditions => {:method => :get} do |project_views| | |
178 | project_views.connect 'projects', :action => 'index' |
|
178 | project_views.connect 'projects', :action => 'index' | |
179 | project_views.connect 'projects.:format', :action => 'index' |
|
179 | project_views.connect 'projects.:format', :action => 'index' | |
180 | project_views.connect 'projects/new', :action => 'add' |
|
180 | project_views.connect 'projects/new', :action => 'add' | |
181 | project_views.connect 'projects/:id', :action => 'show' |
|
181 | project_views.connect 'projects/:id', :action => 'show' | |
182 | project_views.connect 'projects/:id.:format', :action => 'show' |
|
182 | project_views.connect 'projects/:id.:format', :action => 'show' | |
183 |
project_views.connect 'projects/:id/:action', :action => / |
|
183 | project_views.connect 'projects/:id/:action', :action => /destroy|settings/ | |
184 | project_views.connect 'projects/:id/files', :action => 'list_files' |
|
184 | project_views.connect 'projects/:id/files', :action => 'list_files' | |
185 | project_views.connect 'projects/:id/files/new', :action => 'add_file' |
|
185 | project_views.connect 'projects/:id/files/new', :action => 'add_file' | |
186 | project_views.connect 'projects/:id/settings/:tab', :action => 'settings' |
|
186 | project_views.connect 'projects/:id/settings/:tab', :action => 'settings' | |
187 | project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new' |
|
187 | project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new' | |
188 | end |
|
188 | end | |
189 |
|
189 | |||
190 | projects.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity| |
|
190 | projects.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity| | |
191 | activity.connect 'projects/:id/activity' |
|
191 | activity.connect 'projects/:id/activity' | |
192 | activity.connect 'projects/:id/activity.:format' |
|
192 | activity.connect 'projects/:id/activity.:format' | |
193 | activity.connect 'activity', :id => nil |
|
193 | activity.connect 'activity', :id => nil | |
194 | activity.connect 'activity.:format', :id => nil |
|
194 | activity.connect 'activity.:format', :id => nil | |
195 | end |
|
195 | end | |
196 |
|
196 | |||
197 | projects.with_options :conditions => {:method => :post} do |project_actions| |
|
197 | projects.with_options :conditions => {:method => :post} do |project_actions| | |
198 | project_actions.connect 'projects/new', :action => 'add' |
|
198 | project_actions.connect 'projects/new', :action => 'add' | |
199 | project_actions.connect 'projects', :action => 'add' |
|
199 | project_actions.connect 'projects', :action => 'add' | |
200 | project_actions.connect 'projects.:format', :action => 'add', :format => /xml/ |
|
200 | project_actions.connect 'projects.:format', :action => 'add', :format => /xml/ | |
201 | project_actions.connect 'projects/:id/:action', :action => /edit|destroy|archive|unarchive/ |
|
201 | project_actions.connect 'projects/:id/:action', :action => /edit|destroy|archive|unarchive/ | |
202 | project_actions.connect 'projects/:id/files/new', :action => 'add_file' |
|
202 | project_actions.connect 'projects/:id/files/new', :action => 'add_file' | |
203 | project_actions.connect 'projects/:id/activities/save', :action => 'save_activities' |
|
203 | project_actions.connect 'projects/:id/activities/save', :action => 'save_activities' | |
204 | end |
|
204 | end | |
205 |
|
205 | |||
206 | projects.with_options :conditions => {:method => :put} do |project_actions| |
|
206 | projects.with_options :conditions => {:method => :put} do |project_actions| | |
207 | project_actions.conditions 'projects/:id.:format', :action => 'edit', :format => /xml/ |
|
207 | project_actions.conditions 'projects/:id.:format', :action => 'edit', :format => /xml/ | |
208 | end |
|
208 | end | |
209 |
|
209 | |||
210 | projects.with_options :conditions => {:method => :delete} do |project_actions| |
|
210 | projects.with_options :conditions => {:method => :delete} do |project_actions| | |
211 | project_actions.conditions 'projects/:id.:format', :action => 'destroy', :format => /xml/ |
|
211 | project_actions.conditions 'projects/:id.:format', :action => 'destroy', :format => /xml/ | |
212 | project_actions.conditions 'projects/:id/reset_activities', :action => 'reset_activities' |
|
212 | project_actions.conditions 'projects/:id/reset_activities', :action => 'reset_activities' | |
213 | end |
|
213 | end | |
214 | end |
|
214 | end | |
215 |
|
215 | |||
216 | map.with_options :controller => 'versions' do |versions| |
|
216 | map.with_options :controller => 'versions' do |versions| | |
217 | versions.connect 'projects/:project_id/versions/new', :action => 'new' |
|
217 | versions.connect 'projects/:project_id/versions/new', :action => 'new' | |
|
218 | versions.connect 'projects/:project_id/roadmap', :action => 'index' | |||
218 | versions.with_options :conditions => {:method => :post} do |version_actions| |
|
219 | versions.with_options :conditions => {:method => :post} do |version_actions| | |
219 | version_actions.connect 'projects/:project_id/versions/close_completed', :action => 'close_completed' |
|
220 | version_actions.connect 'projects/:project_id/versions/close_completed', :action => 'close_completed' | |
220 | end |
|
221 | end | |
221 | end |
|
222 | end | |
222 |
|
223 | |||
223 | map.with_options :controller => 'issue_categories' do |categories| |
|
224 | map.with_options :controller => 'issue_categories' do |categories| | |
224 | categories.connect 'projects/:project_id/issue_categories/new', :action => 'new' |
|
225 | categories.connect 'projects/:project_id/issue_categories/new', :action => 'new' | |
225 | end |
|
226 | end | |
226 |
|
227 | |||
227 | map.with_options :controller => 'repositories' do |repositories| |
|
228 | map.with_options :controller => 'repositories' do |repositories| | |
228 | repositories.with_options :conditions => {:method => :get} do |repository_views| |
|
229 | repositories.with_options :conditions => {:method => :get} do |repository_views| | |
229 | repository_views.connect 'projects/:id/repository', :action => 'show' |
|
230 | repository_views.connect 'projects/:id/repository', :action => 'show' | |
230 | repository_views.connect 'projects/:id/repository/edit', :action => 'edit' |
|
231 | repository_views.connect 'projects/:id/repository/edit', :action => 'edit' | |
231 | repository_views.connect 'projects/:id/repository/statistics', :action => 'stats' |
|
232 | repository_views.connect 'projects/:id/repository/statistics', :action => 'stats' | |
232 | repository_views.connect 'projects/:id/repository/revisions', :action => 'revisions' |
|
233 | repository_views.connect 'projects/:id/repository/revisions', :action => 'revisions' | |
233 | repository_views.connect 'projects/:id/repository/revisions.:format', :action => 'revisions' |
|
234 | repository_views.connect 'projects/:id/repository/revisions.:format', :action => 'revisions' | |
234 | repository_views.connect 'projects/:id/repository/revisions/:rev', :action => 'revision' |
|
235 | repository_views.connect 'projects/:id/repository/revisions/:rev', :action => 'revision' | |
235 | repository_views.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff' |
|
236 | repository_views.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff' | |
236 | repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff' |
|
237 | repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff' | |
237 | repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path', :action => 'entry', :format => 'raw', :requirements => { :rev => /[a-z0-9\.\-_]+/ } |
|
238 | repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path', :action => 'entry', :format => 'raw', :requirements => { :rev => /[a-z0-9\.\-_]+/ } | |
238 | repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path', :requirements => { :rev => /[a-z0-9\.\-_]+/ } |
|
239 | repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path', :requirements => { :rev => /[a-z0-9\.\-_]+/ } | |
239 | repository_views.connect 'projects/:id/repository/raw/*path', :action => 'entry', :format => 'raw' |
|
240 | repository_views.connect 'projects/:id/repository/raw/*path', :action => 'entry', :format => 'raw' | |
240 | # TODO: why the following route is required? |
|
241 | # TODO: why the following route is required? | |
241 | repository_views.connect 'projects/:id/repository/entry/*path', :action => 'entry' |
|
242 | repository_views.connect 'projects/:id/repository/entry/*path', :action => 'entry' | |
242 | repository_views.connect 'projects/:id/repository/:action/*path' |
|
243 | repository_views.connect 'projects/:id/repository/:action/*path' | |
243 | end |
|
244 | end | |
244 |
|
245 | |||
245 | repositories.connect 'projects/:id/repository/:action', :conditions => {:method => :post} |
|
246 | repositories.connect 'projects/:id/repository/:action', :conditions => {:method => :post} | |
246 | end |
|
247 | end | |
247 |
|
248 | |||
248 | map.connect 'attachments/:id', :controller => 'attachments', :action => 'show', :id => /\d+/ |
|
249 | map.connect 'attachments/:id', :controller => 'attachments', :action => 'show', :id => /\d+/ | |
249 | map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/ |
|
250 | map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/ | |
250 | map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/ |
|
251 | map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/ | |
251 |
|
252 | |||
252 | map.resources :groups |
|
253 | map.resources :groups | |
253 |
|
254 | |||
254 | #left old routes at the bottom for backwards compat |
|
255 | #left old routes at the bottom for backwards compat | |
255 | map.connect 'projects/:project_id/issues/:action', :controller => 'issues' |
|
256 | map.connect 'projects/:project_id/issues/:action', :controller => 'issues' | |
256 | map.connect 'projects/:project_id/documents/:action', :controller => 'documents' |
|
257 | map.connect 'projects/:project_id/documents/:action', :controller => 'documents' | |
257 | map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards' |
|
258 | map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards' | |
258 | map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages' |
|
259 | map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages' | |
259 | map.connect 'wiki/:id/:page/:action', :page => nil, :controller => 'wiki' |
|
260 | map.connect 'wiki/:id/:page/:action', :page => nil, :controller => 'wiki' | |
260 | map.connect 'issues/:issue_id/relations/:action/:id', :controller => 'issue_relations' |
|
261 | map.connect 'issues/:issue_id/relations/:action/:id', :controller => 'issue_relations' | |
261 | map.connect 'projects/:project_id/news/:action', :controller => 'news' |
|
262 | map.connect 'projects/:project_id/news/:action', :controller => 'news' | |
262 | map.connect 'projects/:project_id/timelog/:action/:id', :controller => 'timelog', :project_id => /.+/ |
|
263 | map.connect 'projects/:project_id/timelog/:action/:id', :controller => 'timelog', :project_id => /.+/ | |
263 | map.with_options :controller => 'repositories' do |omap| |
|
264 | map.with_options :controller => 'repositories' do |omap| | |
264 | omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse' |
|
265 | omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse' | |
265 | omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes' |
|
266 | omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes' | |
266 | omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff' |
|
267 | omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff' | |
267 | omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry' |
|
268 | omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry' | |
268 | omap.repositories_entry 'repositories/annotate/:id/*path', :action => 'annotate' |
|
269 | omap.repositories_entry 'repositories/annotate/:id/*path', :action => 'annotate' | |
269 | omap.connect 'repositories/revision/:id/:rev', :action => 'revision' |
|
270 | omap.connect 'repositories/revision/:id/:rev', :action => 'revision' | |
270 | end |
|
271 | end | |
271 |
|
272 | |||
272 | map.with_options :controller => 'sys' do |sys| |
|
273 | map.with_options :controller => 'sys' do |sys| | |
273 | sys.connect 'sys/projects.:format', :action => 'projects', :conditions => {:method => :get} |
|
274 | sys.connect 'sys/projects.:format', :action => 'projects', :conditions => {:method => :get} | |
274 | sys.connect 'sys/projects/:id/repository.:format', :action => 'create_project_repository', :conditions => {:method => :post} |
|
275 | sys.connect 'sys/projects/:id/repository.:format', :action => 'create_project_repository', :conditions => {:method => :post} | |
275 | end |
|
276 | end | |
276 |
|
277 | |||
277 | # Install the default route as the lowest priority. |
|
278 | # Install the default route as the lowest priority. | |
278 | map.connect ':controller/:action/:id' |
|
279 | map.connect ':controller/:action/:id' | |
279 | map.connect 'robots.txt', :controller => 'welcome', :action => 'robots' |
|
280 | map.connect 'robots.txt', :controller => 'welcome', :action => 'robots' | |
280 | # Used for OpenID |
|
281 | # Used for OpenID | |
281 | map.root :controller => 'account', :action => 'login' |
|
282 | map.root :controller => 'account', :action => 'login' | |
282 | end |
|
283 | end |
@@ -1,231 +1,230 | |||||
1 | require 'redmine/access_control' |
|
1 | require 'redmine/access_control' | |
2 | require 'redmine/menu_manager' |
|
2 | require 'redmine/menu_manager' | |
3 | require 'redmine/activity' |
|
3 | require 'redmine/activity' | |
4 | require 'redmine/search' |
|
4 | require 'redmine/search' | |
5 | require 'redmine/custom_field_format' |
|
5 | require 'redmine/custom_field_format' | |
6 | require 'redmine/mime_type' |
|
6 | require 'redmine/mime_type' | |
7 | require 'redmine/core_ext' |
|
7 | require 'redmine/core_ext' | |
8 | require 'redmine/themes' |
|
8 | require 'redmine/themes' | |
9 | require 'redmine/hook' |
|
9 | require 'redmine/hook' | |
10 | require 'redmine/plugin' |
|
10 | require 'redmine/plugin' | |
11 | require 'redmine/wiki_formatting' |
|
11 | require 'redmine/wiki_formatting' | |
12 | require 'redmine/scm/base' |
|
12 | require 'redmine/scm/base' | |
13 |
|
13 | |||
14 | begin |
|
14 | begin | |
15 | require_library_or_gem 'RMagick' unless Object.const_defined?(:Magick) |
|
15 | require_library_or_gem 'RMagick' unless Object.const_defined?(:Magick) | |
16 | rescue LoadError |
|
16 | rescue LoadError | |
17 | # RMagick is not available |
|
17 | # RMagick is not available | |
18 | end |
|
18 | end | |
19 |
|
19 | |||
20 | if RUBY_VERSION < '1.9' |
|
20 | if RUBY_VERSION < '1.9' | |
21 | require 'faster_csv' |
|
21 | require 'faster_csv' | |
22 | else |
|
22 | else | |
23 | require 'csv' |
|
23 | require 'csv' | |
24 | FCSV = CSV |
|
24 | FCSV = CSV | |
25 | end |
|
25 | end | |
26 |
|
26 | |||
27 | Redmine::Scm::Base.add "Subversion" |
|
27 | Redmine::Scm::Base.add "Subversion" | |
28 | Redmine::Scm::Base.add "Darcs" |
|
28 | Redmine::Scm::Base.add "Darcs" | |
29 | Redmine::Scm::Base.add "Mercurial" |
|
29 | Redmine::Scm::Base.add "Mercurial" | |
30 | Redmine::Scm::Base.add "Cvs" |
|
30 | Redmine::Scm::Base.add "Cvs" | |
31 | Redmine::Scm::Base.add "Bazaar" |
|
31 | Redmine::Scm::Base.add "Bazaar" | |
32 | Redmine::Scm::Base.add "Git" |
|
32 | Redmine::Scm::Base.add "Git" | |
33 | Redmine::Scm::Base.add "Filesystem" |
|
33 | Redmine::Scm::Base.add "Filesystem" | |
34 |
|
34 | |||
35 | Redmine::CustomFieldFormat.map do |fields| |
|
35 | Redmine::CustomFieldFormat.map do |fields| | |
36 | fields.register Redmine::CustomFieldFormat.new('string', :label => :label_string, :order => 1) |
|
36 | fields.register Redmine::CustomFieldFormat.new('string', :label => :label_string, :order => 1) | |
37 | fields.register Redmine::CustomFieldFormat.new('text', :label => :label_text, :order => 2) |
|
37 | fields.register Redmine::CustomFieldFormat.new('text', :label => :label_text, :order => 2) | |
38 | fields.register Redmine::CustomFieldFormat.new('int', :label => :label_integer, :order => 3) |
|
38 | fields.register Redmine::CustomFieldFormat.new('int', :label => :label_integer, :order => 3) | |
39 | fields.register Redmine::CustomFieldFormat.new('float', :label => :label_float, :order => 4) |
|
39 | fields.register Redmine::CustomFieldFormat.new('float', :label => :label_float, :order => 4) | |
40 | fields.register Redmine::CustomFieldFormat.new('list', :label => :label_list, :order => 5) |
|
40 | fields.register Redmine::CustomFieldFormat.new('list', :label => :label_list, :order => 5) | |
41 | fields.register Redmine::CustomFieldFormat.new('date', :label => :label_date, :order => 6) |
|
41 | fields.register Redmine::CustomFieldFormat.new('date', :label => :label_date, :order => 6) | |
42 | fields.register Redmine::CustomFieldFormat.new('bool', :label => :label_boolean, :order => 7) |
|
42 | fields.register Redmine::CustomFieldFormat.new('bool', :label => :label_boolean, :order => 7) | |
43 | end |
|
43 | end | |
44 |
|
44 | |||
45 | # Permissions |
|
45 | # Permissions | |
46 | Redmine::AccessControl.map do |map| |
|
46 | Redmine::AccessControl.map do |map| | |
47 | map.permission :view_project, {:projects => [:show], :activities => [:index]}, :public => true |
|
47 | map.permission :view_project, {:projects => [:show], :activities => [:index]}, :public => true | |
48 | map.permission :search_project, {:search => :index}, :public => true |
|
48 | map.permission :search_project, {:search => :index}, :public => true | |
49 | map.permission :add_project, {:projects => :add}, :require => :loggedin |
|
49 | map.permission :add_project, {:projects => :add}, :require => :loggedin | |
50 | map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member |
|
50 | map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member | |
51 | map.permission :select_project_modules, {:projects => :modules}, :require => :member |
|
51 | map.permission :select_project_modules, {:projects => :modules}, :require => :member | |
52 | map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy, :autocomplete_for_member]}, :require => :member |
|
52 | map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy, :autocomplete_for_member]}, :require => :member | |
53 | map.permission :manage_versions, {:projects => :settings, :versions => [:new, :edit, :close_completed, :destroy]}, :require => :member |
|
53 | map.permission :manage_versions, {:projects => :settings, :versions => [:new, :edit, :close_completed, :destroy]}, :require => :member | |
54 | map.permission :add_subprojects, {:projects => :add}, :require => :member |
|
54 | map.permission :add_subprojects, {:projects => :add}, :require => :member | |
55 |
|
55 | |||
56 | map.project_module :issue_tracking do |map| |
|
56 | map.project_module :issue_tracking do |map| | |
57 | # Issue categories |
|
57 | # Issue categories | |
58 | map.permission :manage_categories, {:projects => :settings, :issue_categories => [:new, :edit, :destroy]}, :require => :member |
|
58 | map.permission :manage_categories, {:projects => :settings, :issue_categories => [:new, :edit, :destroy]}, :require => :member | |
59 | # Issues |
|
59 | # Issues | |
60 |
map.permission :view_issues, {: |
|
60 | map.permission :view_issues, {:issues => [:index, :show], | |
61 | :issues => [:index, :show], |
|
|||
62 | :auto_complete => [:issues], |
|
61 | :auto_complete => [:issues], | |
63 | :context_menus => [:issues], |
|
62 | :context_menus => [:issues], | |
64 | :versions => [:show, :status_by], |
|
63 | :versions => [:index, :show, :status_by], | |
65 | :journals => :index, |
|
64 | :journals => :index, | |
66 | :queries => :index, |
|
65 | :queries => :index, | |
67 | :reports => [:issue_report, :issue_report_details]} |
|
66 | :reports => [:issue_report, :issue_report_details]} | |
68 | map.permission :add_issues, {:issues => [:new, :create, :update_form]} |
|
67 | map.permission :add_issues, {:issues => [:new, :create, :update_form]} | |
69 | map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :bulk_update, :update_form], :journals => [:new]} |
|
68 | map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :bulk_update, :update_form], :journals => [:new]} | |
70 | map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]} |
|
69 | map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]} | |
71 | map.permission :manage_subtasks, {} |
|
70 | map.permission :manage_subtasks, {} | |
72 | map.permission :add_issue_notes, {:issues => [:edit, :update], :journals => [:new]} |
|
71 | map.permission :add_issue_notes, {:issues => [:edit, :update], :journals => [:new]} | |
73 | map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin |
|
72 | map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin | |
74 | map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin |
|
73 | map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin | |
75 | map.permission :move_issues, {:issue_moves => [:new, :create]}, :require => :loggedin |
|
74 | map.permission :move_issues, {:issue_moves => [:new, :create]}, :require => :loggedin | |
76 | map.permission :delete_issues, {:issues => :destroy}, :require => :member |
|
75 | map.permission :delete_issues, {:issues => :destroy}, :require => :member | |
77 | # Queries |
|
76 | # Queries | |
78 | map.permission :manage_public_queries, {:queries => [:new, :edit, :destroy]}, :require => :member |
|
77 | map.permission :manage_public_queries, {:queries => [:new, :edit, :destroy]}, :require => :member | |
79 | map.permission :save_queries, {:queries => [:new, :edit, :destroy]}, :require => :loggedin |
|
78 | map.permission :save_queries, {:queries => [:new, :edit, :destroy]}, :require => :loggedin | |
80 | # Watchers |
|
79 | # Watchers | |
81 | map.permission :view_issue_watchers, {} |
|
80 | map.permission :view_issue_watchers, {} | |
82 | map.permission :add_issue_watchers, {:watchers => :new} |
|
81 | map.permission :add_issue_watchers, {:watchers => :new} | |
83 | map.permission :delete_issue_watchers, {:watchers => :destroy} |
|
82 | map.permission :delete_issue_watchers, {:watchers => :destroy} | |
84 | end |
|
83 | end | |
85 |
|
84 | |||
86 | map.project_module :time_tracking do |map| |
|
85 | map.project_module :time_tracking do |map| | |
87 | map.permission :log_time, {:timelog => :edit}, :require => :loggedin |
|
86 | map.permission :log_time, {:timelog => :edit}, :require => :loggedin | |
88 | map.permission :view_time_entries, :timelog => [:details, :report] |
|
87 | map.permission :view_time_entries, :timelog => [:details, :report] | |
89 | map.permission :edit_time_entries, {:timelog => [:edit, :destroy]}, :require => :member |
|
88 | map.permission :edit_time_entries, {:timelog => [:edit, :destroy]}, :require => :member | |
90 | map.permission :edit_own_time_entries, {:timelog => [:edit, :destroy]}, :require => :loggedin |
|
89 | map.permission :edit_own_time_entries, {:timelog => [:edit, :destroy]}, :require => :loggedin | |
91 | map.permission :manage_project_activities, {:projects => [:save_activities, :reset_activities]}, :require => :member |
|
90 | map.permission :manage_project_activities, {:projects => [:save_activities, :reset_activities]}, :require => :member | |
92 | end |
|
91 | end | |
93 |
|
92 | |||
94 | map.project_module :news do |map| |
|
93 | map.project_module :news do |map| | |
95 | map.permission :manage_news, {:news => [:new, :edit, :destroy, :destroy_comment]}, :require => :member |
|
94 | map.permission :manage_news, {:news => [:new, :edit, :destroy, :destroy_comment]}, :require => :member | |
96 | map.permission :view_news, {:news => [:index, :show]}, :public => true |
|
95 | map.permission :view_news, {:news => [:index, :show]}, :public => true | |
97 | map.permission :comment_news, {:news => :add_comment} |
|
96 | map.permission :comment_news, {:news => :add_comment} | |
98 | end |
|
97 | end | |
99 |
|
98 | |||
100 | map.project_module :documents do |map| |
|
99 | map.project_module :documents do |map| | |
101 | map.permission :manage_documents, {:documents => [:new, :edit, :destroy, :add_attachment]}, :require => :loggedin |
|
100 | map.permission :manage_documents, {:documents => [:new, :edit, :destroy, :add_attachment]}, :require => :loggedin | |
102 | map.permission :view_documents, :documents => [:index, :show, :download] |
|
101 | map.permission :view_documents, :documents => [:index, :show, :download] | |
103 | end |
|
102 | end | |
104 |
|
103 | |||
105 | map.project_module :files do |map| |
|
104 | map.project_module :files do |map| | |
106 | map.permission :manage_files, {:projects => :add_file}, :require => :loggedin |
|
105 | map.permission :manage_files, {:projects => :add_file}, :require => :loggedin | |
107 | map.permission :view_files, :projects => :list_files, :versions => :download |
|
106 | map.permission :view_files, :projects => :list_files, :versions => :download | |
108 | end |
|
107 | end | |
109 |
|
108 | |||
110 | map.project_module :wiki do |map| |
|
109 | map.project_module :wiki do |map| | |
111 | map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member |
|
110 | map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member | |
112 | map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member |
|
111 | map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member | |
113 | map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member |
|
112 | map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member | |
114 | map.permission :view_wiki_pages, :wiki => [:index, :special] |
|
113 | map.permission :view_wiki_pages, :wiki => [:index, :special] | |
115 | map.permission :export_wiki_pages, {} |
|
114 | map.permission :export_wiki_pages, {} | |
116 | map.permission :view_wiki_edits, :wiki => [:history, :diff, :annotate] |
|
115 | map.permission :view_wiki_edits, :wiki => [:history, :diff, :annotate] | |
117 | map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment] |
|
116 | map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment] | |
118 | map.permission :delete_wiki_pages_attachments, {} |
|
117 | map.permission :delete_wiki_pages_attachments, {} | |
119 | map.permission :protect_wiki_pages, {:wiki => :protect}, :require => :member |
|
118 | map.permission :protect_wiki_pages, {:wiki => :protect}, :require => :member | |
120 | end |
|
119 | end | |
121 |
|
120 | |||
122 | map.project_module :repository do |map| |
|
121 | map.project_module :repository do |map| | |
123 | map.permission :manage_repository, {:repositories => [:edit, :committers, :destroy]}, :require => :member |
|
122 | map.permission :manage_repository, {:repositories => [:edit, :committers, :destroy]}, :require => :member | |
124 | map.permission :browse_repository, :repositories => [:show, :browse, :entry, :annotate, :changes, :diff, :stats, :graph] |
|
123 | map.permission :browse_repository, :repositories => [:show, :browse, :entry, :annotate, :changes, :diff, :stats, :graph] | |
125 | map.permission :view_changesets, :repositories => [:show, :revisions, :revision] |
|
124 | map.permission :view_changesets, :repositories => [:show, :revisions, :revision] | |
126 | map.permission :commit_access, {} |
|
125 | map.permission :commit_access, {} | |
127 | end |
|
126 | end | |
128 |
|
127 | |||
129 | map.project_module :boards do |map| |
|
128 | map.project_module :boards do |map| | |
130 | map.permission :manage_boards, {:boards => [:new, :edit, :destroy]}, :require => :member |
|
129 | map.permission :manage_boards, {:boards => [:new, :edit, :destroy]}, :require => :member | |
131 | map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true |
|
130 | map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true | |
132 | map.permission :add_messages, {:messages => [:new, :reply, :quote]} |
|
131 | map.permission :add_messages, {:messages => [:new, :reply, :quote]} | |
133 | map.permission :edit_messages, {:messages => :edit}, :require => :member |
|
132 | map.permission :edit_messages, {:messages => :edit}, :require => :member | |
134 | map.permission :edit_own_messages, {:messages => :edit}, :require => :loggedin |
|
133 | map.permission :edit_own_messages, {:messages => :edit}, :require => :loggedin | |
135 | map.permission :delete_messages, {:messages => :destroy}, :require => :member |
|
134 | map.permission :delete_messages, {:messages => :destroy}, :require => :member | |
136 | map.permission :delete_own_messages, {:messages => :destroy}, :require => :loggedin |
|
135 | map.permission :delete_own_messages, {:messages => :destroy}, :require => :loggedin | |
137 | end |
|
136 | end | |
138 |
|
137 | |||
139 | map.project_module :calendar do |map| |
|
138 | map.project_module :calendar do |map| | |
140 | map.permission :view_calendar, :calendars => [:show, :update] |
|
139 | map.permission :view_calendar, :calendars => [:show, :update] | |
141 | end |
|
140 | end | |
142 |
|
141 | |||
143 | map.project_module :gantt do |map| |
|
142 | map.project_module :gantt do |map| | |
144 | map.permission :view_gantt, :gantts => [:show, :update] |
|
143 | map.permission :view_gantt, :gantts => [:show, :update] | |
145 | end |
|
144 | end | |
146 | end |
|
145 | end | |
147 |
|
146 | |||
148 | Redmine::MenuManager.map :top_menu do |menu| |
|
147 | Redmine::MenuManager.map :top_menu do |menu| | |
149 | menu.push :home, :home_path |
|
148 | menu.push :home, :home_path | |
150 | menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? } |
|
149 | menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? } | |
151 | menu.push :projects, { :controller => 'projects', :action => 'index' }, :caption => :label_project_plural |
|
150 | menu.push :projects, { :controller => 'projects', :action => 'index' }, :caption => :label_project_plural | |
152 | menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true |
|
151 | menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true | |
153 | menu.push :help, Redmine::Info.help_url, :last => true |
|
152 | menu.push :help, Redmine::Info.help_url, :last => true | |
154 | end |
|
153 | end | |
155 |
|
154 | |||
156 | Redmine::MenuManager.map :account_menu do |menu| |
|
155 | Redmine::MenuManager.map :account_menu do |menu| | |
157 | menu.push :login, :signin_path, :if => Proc.new { !User.current.logged? } |
|
156 | menu.push :login, :signin_path, :if => Proc.new { !User.current.logged? } | |
158 | menu.push :register, { :controller => 'account', :action => 'register' }, :if => Proc.new { !User.current.logged? && Setting.self_registration? } |
|
157 | menu.push :register, { :controller => 'account', :action => 'register' }, :if => Proc.new { !User.current.logged? && Setting.self_registration? } | |
159 | menu.push :my_account, { :controller => 'my', :action => 'account' }, :if => Proc.new { User.current.logged? } |
|
158 | menu.push :my_account, { :controller => 'my', :action => 'account' }, :if => Proc.new { User.current.logged? } | |
160 | menu.push :logout, :signout_path, :if => Proc.new { User.current.logged? } |
|
159 | menu.push :logout, :signout_path, :if => Proc.new { User.current.logged? } | |
161 | end |
|
160 | end | |
162 |
|
161 | |||
163 | Redmine::MenuManager.map :application_menu do |menu| |
|
162 | Redmine::MenuManager.map :application_menu do |menu| | |
164 | # Empty |
|
163 | # Empty | |
165 | end |
|
164 | end | |
166 |
|
165 | |||
167 | Redmine::MenuManager.map :admin_menu do |menu| |
|
166 | Redmine::MenuManager.map :admin_menu do |menu| | |
168 | menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural |
|
167 | menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural | |
169 | menu.push :users, {:controller => 'users'}, :caption => :label_user_plural |
|
168 | menu.push :users, {:controller => 'users'}, :caption => :label_user_plural | |
170 | menu.push :groups, {:controller => 'groups'}, :caption => :label_group_plural |
|
169 | menu.push :groups, {:controller => 'groups'}, :caption => :label_group_plural | |
171 | menu.push :roles, {:controller => 'roles'}, :caption => :label_role_and_permissions |
|
170 | menu.push :roles, {:controller => 'roles'}, :caption => :label_role_and_permissions | |
172 | menu.push :trackers, {:controller => 'trackers'}, :caption => :label_tracker_plural |
|
171 | menu.push :trackers, {:controller => 'trackers'}, :caption => :label_tracker_plural | |
173 | menu.push :issue_statuses, {:controller => 'issue_statuses'}, :caption => :label_issue_status_plural, |
|
172 | menu.push :issue_statuses, {:controller => 'issue_statuses'}, :caption => :label_issue_status_plural, | |
174 | :html => {:class => 'issue_statuses'} |
|
173 | :html => {:class => 'issue_statuses'} | |
175 | menu.push :workflows, {:controller => 'workflows', :action => 'edit'}, :caption => :label_workflow |
|
174 | menu.push :workflows, {:controller => 'workflows', :action => 'edit'}, :caption => :label_workflow | |
176 | menu.push :custom_fields, {:controller => 'custom_fields'}, :caption => :label_custom_field_plural, |
|
175 | menu.push :custom_fields, {:controller => 'custom_fields'}, :caption => :label_custom_field_plural, | |
177 | :html => {:class => 'custom_fields'} |
|
176 | :html => {:class => 'custom_fields'} | |
178 | menu.push :enumerations, {:controller => 'enumerations'} |
|
177 | menu.push :enumerations, {:controller => 'enumerations'} | |
179 | menu.push :settings, {:controller => 'settings'} |
|
178 | menu.push :settings, {:controller => 'settings'} | |
180 | menu.push :ldap_authentication, {:controller => 'ldap_auth_sources', :action => 'index'}, |
|
179 | menu.push :ldap_authentication, {:controller => 'ldap_auth_sources', :action => 'index'}, | |
181 | :html => {:class => 'server_authentication'} |
|
180 | :html => {:class => 'server_authentication'} | |
182 | menu.push :plugins, {:controller => 'admin', :action => 'plugins'}, :last => true |
|
181 | menu.push :plugins, {:controller => 'admin', :action => 'plugins'}, :last => true | |
183 | menu.push :info, {:controller => 'admin', :action => 'info'}, :caption => :label_information_plural, :last => true |
|
182 | menu.push :info, {:controller => 'admin', :action => 'info'}, :caption => :label_information_plural, :last => true | |
184 | end |
|
183 | end | |
185 |
|
184 | |||
186 | Redmine::MenuManager.map :project_menu do |menu| |
|
185 | Redmine::MenuManager.map :project_menu do |menu| | |
187 | menu.push :overview, { :controller => 'projects', :action => 'show' } |
|
186 | menu.push :overview, { :controller => 'projects', :action => 'show' } | |
188 | menu.push :activity, { :controller => 'activities', :action => 'index' } |
|
187 | menu.push :activity, { :controller => 'activities', :action => 'index' } | |
189 |
menu.push :roadmap, { :controller => ' |
|
188 | menu.push :roadmap, { :controller => 'versions', :action => 'index' }, :param => :project_id, | |
190 | :if => Proc.new { |p| p.shared_versions.any? } |
|
189 | :if => Proc.new { |p| p.shared_versions.any? } | |
191 | menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural |
|
190 | menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural | |
192 | menu.push :new_issue, { :controller => 'issues', :action => 'new' }, :param => :project_id, :caption => :label_issue_new, |
|
191 | menu.push :new_issue, { :controller => 'issues', :action => 'new' }, :param => :project_id, :caption => :label_issue_new, | |
193 | :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) } |
|
192 | :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) } | |
194 | menu.push :gantt, { :controller => 'gantts', :action => 'show' }, :param => :project_id, :caption => :label_gantt |
|
193 | menu.push :gantt, { :controller => 'gantts', :action => 'show' }, :param => :project_id, :caption => :label_gantt | |
195 | menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :param => :project_id, :caption => :label_calendar |
|
194 | menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :param => :project_id, :caption => :label_calendar | |
196 | menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural |
|
195 | menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural | |
197 | menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural |
|
196 | menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural | |
198 | menu.push :wiki, { :controller => 'wiki', :action => 'index', :page => nil }, |
|
197 | menu.push :wiki, { :controller => 'wiki', :action => 'index', :page => nil }, | |
199 | :if => Proc.new { |p| p.wiki && !p.wiki.new_record? } |
|
198 | :if => Proc.new { |p| p.wiki && !p.wiki.new_record? } | |
200 | menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id, |
|
199 | menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id, | |
201 | :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural |
|
200 | :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural | |
202 | menu.push :files, { :controller => 'projects', :action => 'list_files' }, :caption => :label_file_plural |
|
201 | menu.push :files, { :controller => 'projects', :action => 'list_files' }, :caption => :label_file_plural | |
203 | menu.push :repository, { :controller => 'repositories', :action => 'show' }, |
|
202 | menu.push :repository, { :controller => 'repositories', :action => 'show' }, | |
204 | :if => Proc.new { |p| p.repository && !p.repository.new_record? } |
|
203 | :if => Proc.new { |p| p.repository && !p.repository.new_record? } | |
205 | menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true |
|
204 | menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true | |
206 | end |
|
205 | end | |
207 |
|
206 | |||
208 | Redmine::Activity.map do |activity| |
|
207 | Redmine::Activity.map do |activity| | |
209 | activity.register :issues, :class_name => %w(Issue Journal) |
|
208 | activity.register :issues, :class_name => %w(Issue Journal) | |
210 | activity.register :changesets |
|
209 | activity.register :changesets | |
211 | activity.register :news |
|
210 | activity.register :news | |
212 | activity.register :documents, :class_name => %w(Document Attachment) |
|
211 | activity.register :documents, :class_name => %w(Document Attachment) | |
213 | activity.register :files, :class_name => 'Attachment' |
|
212 | activity.register :files, :class_name => 'Attachment' | |
214 | activity.register :wiki_edits, :class_name => 'WikiContent::Version', :default => false |
|
213 | activity.register :wiki_edits, :class_name => 'WikiContent::Version', :default => false | |
215 | activity.register :messages, :default => false |
|
214 | activity.register :messages, :default => false | |
216 | activity.register :time_entries, :default => false |
|
215 | activity.register :time_entries, :default => false | |
217 | end |
|
216 | end | |
218 |
|
217 | |||
219 | Redmine::Search.map do |search| |
|
218 | Redmine::Search.map do |search| | |
220 | search.register :issues |
|
219 | search.register :issues | |
221 | search.register :news |
|
220 | search.register :news | |
222 | search.register :documents |
|
221 | search.register :documents | |
223 | search.register :changesets |
|
222 | search.register :changesets | |
224 | search.register :wiki_pages |
|
223 | search.register :wiki_pages | |
225 | search.register :messages |
|
224 | search.register :messages | |
226 | search.register :projects |
|
225 | search.register :projects | |
227 | end |
|
226 | end | |
228 |
|
227 | |||
229 | Redmine::WikiFormatting.map do |format| |
|
228 | Redmine::WikiFormatting.map do |format| | |
230 | format.register :textile, Redmine::WikiFormatting::Textile::Formatter, Redmine::WikiFormatting::Textile::Helper |
|
229 | format.register :textile, Redmine::WikiFormatting::Textile::Formatter, Redmine::WikiFormatting::Textile::Helper | |
231 | end |
|
230 | end |
@@ -1,663 +1,631 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2008 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2008 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 | require 'projects_controller' |
|
19 | require 'projects_controller' | |
20 |
|
20 | |||
21 | # Re-raise errors caught by the controller. |
|
21 | # Re-raise errors caught by the controller. | |
22 | class ProjectsController; def rescue_action(e) raise e end; end |
|
22 | class ProjectsController; def rescue_action(e) raise e end; end | |
23 |
|
23 | |||
24 | class ProjectsControllerTest < ActionController::TestCase |
|
24 | class ProjectsControllerTest < ActionController::TestCase | |
25 | fixtures :projects, :versions, :users, :roles, :members, :member_roles, :issues, :journals, :journal_details, |
|
25 | fixtures :projects, :versions, :users, :roles, :members, :member_roles, :issues, :journals, :journal_details, | |
26 | :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages, |
|
26 | :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages, | |
27 | :attachments, :custom_fields, :custom_values, :time_entries |
|
27 | :attachments, :custom_fields, :custom_values, :time_entries | |
28 |
|
28 | |||
29 | def setup |
|
29 | def setup | |
30 | @controller = ProjectsController.new |
|
30 | @controller = ProjectsController.new | |
31 | @request = ActionController::TestRequest.new |
|
31 | @request = ActionController::TestRequest.new | |
32 | @response = ActionController::TestResponse.new |
|
32 | @response = ActionController::TestResponse.new | |
33 | @request.session[:user_id] = nil |
|
33 | @request.session[:user_id] = nil | |
34 | Setting.default_language = 'en' |
|
34 | Setting.default_language = 'en' | |
35 | end |
|
35 | end | |
36 |
|
36 | |||
37 | def test_index |
|
37 | def test_index | |
38 | get :index |
|
38 | get :index | |
39 | assert_response :success |
|
39 | assert_response :success | |
40 | assert_template 'index' |
|
40 | assert_template 'index' | |
41 | assert_not_nil assigns(:projects) |
|
41 | assert_not_nil assigns(:projects) | |
42 |
|
42 | |||
43 | assert_tag :ul, :child => {:tag => 'li', |
|
43 | assert_tag :ul, :child => {:tag => 'li', | |
44 | :descendant => {:tag => 'a', :content => 'eCookbook'}, |
|
44 | :descendant => {:tag => 'a', :content => 'eCookbook'}, | |
45 | :child => { :tag => 'ul', |
|
45 | :child => { :tag => 'ul', | |
46 | :descendant => { :tag => 'a', |
|
46 | :descendant => { :tag => 'a', | |
47 | :content => 'Child of private child' |
|
47 | :content => 'Child of private child' | |
48 | } |
|
48 | } | |
49 | } |
|
49 | } | |
50 | } |
|
50 | } | |
51 |
|
51 | |||
52 | assert_no_tag :a, :content => /Private child of eCookbook/ |
|
52 | assert_no_tag :a, :content => /Private child of eCookbook/ | |
53 | end |
|
53 | end | |
54 |
|
54 | |||
55 | def test_index_atom |
|
55 | def test_index_atom | |
56 | get :index, :format => 'atom' |
|
56 | get :index, :format => 'atom' | |
57 | assert_response :success |
|
57 | assert_response :success | |
58 | assert_template 'common/feed.atom.rxml' |
|
58 | assert_template 'common/feed.atom.rxml' | |
59 | assert_select 'feed>title', :text => 'Redmine: Latest projects' |
|
59 | assert_select 'feed>title', :text => 'Redmine: Latest projects' | |
60 | assert_select 'feed>entry', :count => Project.count(:conditions => Project.visible_by(User.current)) |
|
60 | assert_select 'feed>entry', :count => Project.count(:conditions => Project.visible_by(User.current)) | |
61 | end |
|
61 | end | |
62 |
|
62 | |||
63 | context "#index" do |
|
63 | context "#index" do | |
64 | context "by non-admin user with view_time_entries permission" do |
|
64 | context "by non-admin user with view_time_entries permission" do | |
65 | setup do |
|
65 | setup do | |
66 | @request.session[:user_id] = 3 |
|
66 | @request.session[:user_id] = 3 | |
67 | end |
|
67 | end | |
68 | should "show overall spent time link" do |
|
68 | should "show overall spent time link" do | |
69 | get :index |
|
69 | get :index | |
70 | assert_template 'index' |
|
70 | assert_template 'index' | |
71 | assert_tag :a, :attributes => {:href => '/time_entries'} |
|
71 | assert_tag :a, :attributes => {:href => '/time_entries'} | |
72 | end |
|
72 | end | |
73 | end |
|
73 | end | |
74 |
|
74 | |||
75 | context "by non-admin user without view_time_entries permission" do |
|
75 | context "by non-admin user without view_time_entries permission" do | |
76 | setup do |
|
76 | setup do | |
77 | Role.find(2).remove_permission! :view_time_entries |
|
77 | Role.find(2).remove_permission! :view_time_entries | |
78 | Role.non_member.remove_permission! :view_time_entries |
|
78 | Role.non_member.remove_permission! :view_time_entries | |
79 | Role.anonymous.remove_permission! :view_time_entries |
|
79 | Role.anonymous.remove_permission! :view_time_entries | |
80 | @request.session[:user_id] = 3 |
|
80 | @request.session[:user_id] = 3 | |
81 | end |
|
81 | end | |
82 | should "not show overall spent time link" do |
|
82 | should "not show overall spent time link" do | |
83 | get :index |
|
83 | get :index | |
84 | assert_template 'index' |
|
84 | assert_template 'index' | |
85 | assert_no_tag :a, :attributes => {:href => '/time_entries'} |
|
85 | assert_no_tag :a, :attributes => {:href => '/time_entries'} | |
86 | end |
|
86 | end | |
87 | end |
|
87 | end | |
88 | end |
|
88 | end | |
89 |
|
89 | |||
90 | context "#add" do |
|
90 | context "#add" do | |
91 | context "by admin user" do |
|
91 | context "by admin user" do | |
92 | setup do |
|
92 | setup do | |
93 | @request.session[:user_id] = 1 |
|
93 | @request.session[:user_id] = 1 | |
94 | end |
|
94 | end | |
95 |
|
95 | |||
96 | should "accept get" do |
|
96 | should "accept get" do | |
97 | get :add |
|
97 | get :add | |
98 | assert_response :success |
|
98 | assert_response :success | |
99 | assert_template 'add' |
|
99 | assert_template 'add' | |
100 | end |
|
100 | end | |
101 |
|
101 | |||
102 | should "accept post" do |
|
102 | should "accept post" do | |
103 | post :add, :project => { :name => "blog", |
|
103 | post :add, :project => { :name => "blog", | |
104 | :description => "weblog", |
|
104 | :description => "weblog", | |
105 | :identifier => "blog", |
|
105 | :identifier => "blog", | |
106 | :is_public => 1, |
|
106 | :is_public => 1, | |
107 | :custom_field_values => { '3' => 'Beta' } |
|
107 | :custom_field_values => { '3' => 'Beta' } | |
108 | } |
|
108 | } | |
109 | assert_redirected_to '/projects/blog/settings' |
|
109 | assert_redirected_to '/projects/blog/settings' | |
110 |
|
110 | |||
111 | project = Project.find_by_name('blog') |
|
111 | project = Project.find_by_name('blog') | |
112 | assert_kind_of Project, project |
|
112 | assert_kind_of Project, project | |
113 | assert_equal 'weblog', project.description |
|
113 | assert_equal 'weblog', project.description | |
114 | assert_equal true, project.is_public? |
|
114 | assert_equal true, project.is_public? | |
115 | assert_nil project.parent |
|
115 | assert_nil project.parent | |
116 | end |
|
116 | end | |
117 |
|
117 | |||
118 | should "accept post with parent" do |
|
118 | should "accept post with parent" do | |
119 | post :add, :project => { :name => "blog", |
|
119 | post :add, :project => { :name => "blog", | |
120 | :description => "weblog", |
|
120 | :description => "weblog", | |
121 | :identifier => "blog", |
|
121 | :identifier => "blog", | |
122 | :is_public => 1, |
|
122 | :is_public => 1, | |
123 | :custom_field_values => { '3' => 'Beta' }, |
|
123 | :custom_field_values => { '3' => 'Beta' }, | |
124 | :parent_id => 1 |
|
124 | :parent_id => 1 | |
125 | } |
|
125 | } | |
126 | assert_redirected_to '/projects/blog/settings' |
|
126 | assert_redirected_to '/projects/blog/settings' | |
127 |
|
127 | |||
128 | project = Project.find_by_name('blog') |
|
128 | project = Project.find_by_name('blog') | |
129 | assert_kind_of Project, project |
|
129 | assert_kind_of Project, project | |
130 | assert_equal Project.find(1), project.parent |
|
130 | assert_equal Project.find(1), project.parent | |
131 | end |
|
131 | end | |
132 | end |
|
132 | end | |
133 |
|
133 | |||
134 | context "by non-admin user with add_project permission" do |
|
134 | context "by non-admin user with add_project permission" do | |
135 | setup do |
|
135 | setup do | |
136 | Role.non_member.add_permission! :add_project |
|
136 | Role.non_member.add_permission! :add_project | |
137 | @request.session[:user_id] = 9 |
|
137 | @request.session[:user_id] = 9 | |
138 | end |
|
138 | end | |
139 |
|
139 | |||
140 | should "accept get" do |
|
140 | should "accept get" do | |
141 | get :add |
|
141 | get :add | |
142 | assert_response :success |
|
142 | assert_response :success | |
143 | assert_template 'add' |
|
143 | assert_template 'add' | |
144 | assert_no_tag :select, :attributes => {:name => 'project[parent_id]'} |
|
144 | assert_no_tag :select, :attributes => {:name => 'project[parent_id]'} | |
145 | end |
|
145 | end | |
146 |
|
146 | |||
147 | should "accept post" do |
|
147 | should "accept post" do | |
148 | post :add, :project => { :name => "blog", |
|
148 | post :add, :project => { :name => "blog", | |
149 | :description => "weblog", |
|
149 | :description => "weblog", | |
150 | :identifier => "blog", |
|
150 | :identifier => "blog", | |
151 | :is_public => 1, |
|
151 | :is_public => 1, | |
152 | :custom_field_values => { '3' => 'Beta' } |
|
152 | :custom_field_values => { '3' => 'Beta' } | |
153 | } |
|
153 | } | |
154 |
|
154 | |||
155 | assert_redirected_to '/projects/blog/settings' |
|
155 | assert_redirected_to '/projects/blog/settings' | |
156 |
|
156 | |||
157 | project = Project.find_by_name('blog') |
|
157 | project = Project.find_by_name('blog') | |
158 | assert_kind_of Project, project |
|
158 | assert_kind_of Project, project | |
159 | assert_equal 'weblog', project.description |
|
159 | assert_equal 'weblog', project.description | |
160 | assert_equal true, project.is_public? |
|
160 | assert_equal true, project.is_public? | |
161 |
|
161 | |||
162 | # User should be added as a project member |
|
162 | # User should be added as a project member | |
163 | assert User.find(9).member_of?(project) |
|
163 | assert User.find(9).member_of?(project) | |
164 | assert_equal 1, project.members.size |
|
164 | assert_equal 1, project.members.size | |
165 | end |
|
165 | end | |
166 |
|
166 | |||
167 | should "fail with parent_id" do |
|
167 | should "fail with parent_id" do | |
168 | assert_no_difference 'Project.count' do |
|
168 | assert_no_difference 'Project.count' do | |
169 | post :add, :project => { :name => "blog", |
|
169 | post :add, :project => { :name => "blog", | |
170 | :description => "weblog", |
|
170 | :description => "weblog", | |
171 | :identifier => "blog", |
|
171 | :identifier => "blog", | |
172 | :is_public => 1, |
|
172 | :is_public => 1, | |
173 | :custom_field_values => { '3' => 'Beta' }, |
|
173 | :custom_field_values => { '3' => 'Beta' }, | |
174 | :parent_id => 1 |
|
174 | :parent_id => 1 | |
175 | } |
|
175 | } | |
176 | end |
|
176 | end | |
177 | assert_response :success |
|
177 | assert_response :success | |
178 | project = assigns(:project) |
|
178 | project = assigns(:project) | |
179 | assert_kind_of Project, project |
|
179 | assert_kind_of Project, project | |
180 | assert_not_nil project.errors.on(:parent_id) |
|
180 | assert_not_nil project.errors.on(:parent_id) | |
181 | end |
|
181 | end | |
182 | end |
|
182 | end | |
183 |
|
183 | |||
184 | context "by non-admin user with add_subprojects permission" do |
|
184 | context "by non-admin user with add_subprojects permission" do | |
185 | setup do |
|
185 | setup do | |
186 | Role.find(1).remove_permission! :add_project |
|
186 | Role.find(1).remove_permission! :add_project | |
187 | Role.find(1).add_permission! :add_subprojects |
|
187 | Role.find(1).add_permission! :add_subprojects | |
188 | @request.session[:user_id] = 2 |
|
188 | @request.session[:user_id] = 2 | |
189 | end |
|
189 | end | |
190 |
|
190 | |||
191 | should "accept get" do |
|
191 | should "accept get" do | |
192 | get :add, :parent_id => 'ecookbook' |
|
192 | get :add, :parent_id => 'ecookbook' | |
193 | assert_response :success |
|
193 | assert_response :success | |
194 | assert_template 'add' |
|
194 | assert_template 'add' | |
195 | # parent project selected |
|
195 | # parent project selected | |
196 | assert_tag :select, :attributes => {:name => 'project[parent_id]'}, |
|
196 | assert_tag :select, :attributes => {:name => 'project[parent_id]'}, | |
197 | :child => {:tag => 'option', :attributes => {:value => '1', :selected => 'selected'}} |
|
197 | :child => {:tag => 'option', :attributes => {:value => '1', :selected => 'selected'}} | |
198 | # no empty value |
|
198 | # no empty value | |
199 | assert_no_tag :select, :attributes => {:name => 'project[parent_id]'}, |
|
199 | assert_no_tag :select, :attributes => {:name => 'project[parent_id]'}, | |
200 | :child => {:tag => 'option', :attributes => {:value => ''}} |
|
200 | :child => {:tag => 'option', :attributes => {:value => ''}} | |
201 | end |
|
201 | end | |
202 |
|
202 | |||
203 | should "accept post with parent_id" do |
|
203 | should "accept post with parent_id" do | |
204 | post :add, :project => { :name => "blog", |
|
204 | post :add, :project => { :name => "blog", | |
205 | :description => "weblog", |
|
205 | :description => "weblog", | |
206 | :identifier => "blog", |
|
206 | :identifier => "blog", | |
207 | :is_public => 1, |
|
207 | :is_public => 1, | |
208 | :custom_field_values => { '3' => 'Beta' }, |
|
208 | :custom_field_values => { '3' => 'Beta' }, | |
209 | :parent_id => 1 |
|
209 | :parent_id => 1 | |
210 | } |
|
210 | } | |
211 | assert_redirected_to '/projects/blog/settings' |
|
211 | assert_redirected_to '/projects/blog/settings' | |
212 | project = Project.find_by_name('blog') |
|
212 | project = Project.find_by_name('blog') | |
213 | end |
|
213 | end | |
214 |
|
214 | |||
215 | should "fail without parent_id" do |
|
215 | should "fail without parent_id" do | |
216 | assert_no_difference 'Project.count' do |
|
216 | assert_no_difference 'Project.count' do | |
217 | post :add, :project => { :name => "blog", |
|
217 | post :add, :project => { :name => "blog", | |
218 | :description => "weblog", |
|
218 | :description => "weblog", | |
219 | :identifier => "blog", |
|
219 | :identifier => "blog", | |
220 | :is_public => 1, |
|
220 | :is_public => 1, | |
221 | :custom_field_values => { '3' => 'Beta' } |
|
221 | :custom_field_values => { '3' => 'Beta' } | |
222 | } |
|
222 | } | |
223 | end |
|
223 | end | |
224 | assert_response :success |
|
224 | assert_response :success | |
225 | project = assigns(:project) |
|
225 | project = assigns(:project) | |
226 | assert_kind_of Project, project |
|
226 | assert_kind_of Project, project | |
227 | assert_not_nil project.errors.on(:parent_id) |
|
227 | assert_not_nil project.errors.on(:parent_id) | |
228 | end |
|
228 | end | |
229 |
|
229 | |||
230 | should "fail with unauthorized parent_id" do |
|
230 | should "fail with unauthorized parent_id" do | |
231 | assert !User.find(2).member_of?(Project.find(6)) |
|
231 | assert !User.find(2).member_of?(Project.find(6)) | |
232 | assert_no_difference 'Project.count' do |
|
232 | assert_no_difference 'Project.count' do | |
233 | post :add, :project => { :name => "blog", |
|
233 | post :add, :project => { :name => "blog", | |
234 | :description => "weblog", |
|
234 | :description => "weblog", | |
235 | :identifier => "blog", |
|
235 | :identifier => "blog", | |
236 | :is_public => 1, |
|
236 | :is_public => 1, | |
237 | :custom_field_values => { '3' => 'Beta' }, |
|
237 | :custom_field_values => { '3' => 'Beta' }, | |
238 | :parent_id => 6 |
|
238 | :parent_id => 6 | |
239 | } |
|
239 | } | |
240 | end |
|
240 | end | |
241 | assert_response :success |
|
241 | assert_response :success | |
242 | project = assigns(:project) |
|
242 | project = assigns(:project) | |
243 | assert_kind_of Project, project |
|
243 | assert_kind_of Project, project | |
244 | assert_not_nil project.errors.on(:parent_id) |
|
244 | assert_not_nil project.errors.on(:parent_id) | |
245 | end |
|
245 | end | |
246 | end |
|
246 | end | |
247 | end |
|
247 | end | |
248 |
|
248 | |||
249 | def test_show_by_id |
|
249 | def test_show_by_id | |
250 | get :show, :id => 1 |
|
250 | get :show, :id => 1 | |
251 | assert_response :success |
|
251 | assert_response :success | |
252 | assert_template 'show' |
|
252 | assert_template 'show' | |
253 | assert_not_nil assigns(:project) |
|
253 | assert_not_nil assigns(:project) | |
254 | end |
|
254 | end | |
255 |
|
255 | |||
256 | def test_show_by_identifier |
|
256 | def test_show_by_identifier | |
257 | get :show, :id => 'ecookbook' |
|
257 | get :show, :id => 'ecookbook' | |
258 | assert_response :success |
|
258 | assert_response :success | |
259 | assert_template 'show' |
|
259 | assert_template 'show' | |
260 | assert_not_nil assigns(:project) |
|
260 | assert_not_nil assigns(:project) | |
261 | assert_equal Project.find_by_identifier('ecookbook'), assigns(:project) |
|
261 | assert_equal Project.find_by_identifier('ecookbook'), assigns(:project) | |
262 | end |
|
262 | end | |
263 |
|
263 | |||
264 | def test_show_should_not_fail_when_custom_values_are_nil |
|
264 | def test_show_should_not_fail_when_custom_values_are_nil | |
265 | project = Project.find_by_identifier('ecookbook') |
|
265 | project = Project.find_by_identifier('ecookbook') | |
266 | project.custom_values.first.update_attribute(:value, nil) |
|
266 | project.custom_values.first.update_attribute(:value, nil) | |
267 | get :show, :id => 'ecookbook' |
|
267 | get :show, :id => 'ecookbook' | |
268 | assert_response :success |
|
268 | assert_response :success | |
269 | assert_template 'show' |
|
269 | assert_template 'show' | |
270 | assert_not_nil assigns(:project) |
|
270 | assert_not_nil assigns(:project) | |
271 | assert_equal Project.find_by_identifier('ecookbook'), assigns(:project) |
|
271 | assert_equal Project.find_by_identifier('ecookbook'), assigns(:project) | |
272 | end |
|
272 | end | |
273 |
|
273 | |||
274 | def test_private_subprojects_hidden |
|
274 | def test_private_subprojects_hidden | |
275 | get :show, :id => 'ecookbook' |
|
275 | get :show, :id => 'ecookbook' | |
276 | assert_response :success |
|
276 | assert_response :success | |
277 | assert_template 'show' |
|
277 | assert_template 'show' | |
278 | assert_no_tag :tag => 'a', :content => /Private child/ |
|
278 | assert_no_tag :tag => 'a', :content => /Private child/ | |
279 | end |
|
279 | end | |
280 |
|
280 | |||
281 | def test_private_subprojects_visible |
|
281 | def test_private_subprojects_visible | |
282 | @request.session[:user_id] = 2 # manager who is a member of the private subproject |
|
282 | @request.session[:user_id] = 2 # manager who is a member of the private subproject | |
283 | get :show, :id => 'ecookbook' |
|
283 | get :show, :id => 'ecookbook' | |
284 | assert_response :success |
|
284 | assert_response :success | |
285 | assert_template 'show' |
|
285 | assert_template 'show' | |
286 | assert_tag :tag => 'a', :content => /Private child/ |
|
286 | assert_tag :tag => 'a', :content => /Private child/ | |
287 | end |
|
287 | end | |
288 |
|
288 | |||
289 | def test_settings |
|
289 | def test_settings | |
290 | @request.session[:user_id] = 2 # manager |
|
290 | @request.session[:user_id] = 2 # manager | |
291 | get :settings, :id => 1 |
|
291 | get :settings, :id => 1 | |
292 | assert_response :success |
|
292 | assert_response :success | |
293 | assert_template 'settings' |
|
293 | assert_template 'settings' | |
294 | end |
|
294 | end | |
295 |
|
295 | |||
296 | def test_edit |
|
296 | def test_edit | |
297 | @request.session[:user_id] = 2 # manager |
|
297 | @request.session[:user_id] = 2 # manager | |
298 | post :edit, :id => 1, :project => {:name => 'Test changed name', |
|
298 | post :edit, :id => 1, :project => {:name => 'Test changed name', | |
299 | :issue_custom_field_ids => ['']} |
|
299 | :issue_custom_field_ids => ['']} | |
300 | assert_redirected_to 'projects/ecookbook/settings' |
|
300 | assert_redirected_to 'projects/ecookbook/settings' | |
301 | project = Project.find(1) |
|
301 | project = Project.find(1) | |
302 | assert_equal 'Test changed name', project.name |
|
302 | assert_equal 'Test changed name', project.name | |
303 | end |
|
303 | end | |
304 |
|
304 | |||
305 | def test_get_destroy |
|
305 | def test_get_destroy | |
306 | @request.session[:user_id] = 1 # admin |
|
306 | @request.session[:user_id] = 1 # admin | |
307 | get :destroy, :id => 1 |
|
307 | get :destroy, :id => 1 | |
308 | assert_response :success |
|
308 | assert_response :success | |
309 | assert_template 'destroy' |
|
309 | assert_template 'destroy' | |
310 | assert_not_nil Project.find_by_id(1) |
|
310 | assert_not_nil Project.find_by_id(1) | |
311 | end |
|
311 | end | |
312 |
|
312 | |||
313 | def test_post_destroy |
|
313 | def test_post_destroy | |
314 | @request.session[:user_id] = 1 # admin |
|
314 | @request.session[:user_id] = 1 # admin | |
315 | post :destroy, :id => 1, :confirm => 1 |
|
315 | post :destroy, :id => 1, :confirm => 1 | |
316 | assert_redirected_to 'admin/projects' |
|
316 | assert_redirected_to 'admin/projects' | |
317 | assert_nil Project.find_by_id(1) |
|
317 | assert_nil Project.find_by_id(1) | |
318 | end |
|
318 | end | |
319 |
|
319 | |||
320 | def test_add_file |
|
320 | def test_add_file | |
321 | set_tmp_attachments_directory |
|
321 | set_tmp_attachments_directory | |
322 | @request.session[:user_id] = 2 |
|
322 | @request.session[:user_id] = 2 | |
323 | Setting.notified_events = ['file_added'] |
|
323 | Setting.notified_events = ['file_added'] | |
324 | ActionMailer::Base.deliveries.clear |
|
324 | ActionMailer::Base.deliveries.clear | |
325 |
|
325 | |||
326 | assert_difference 'Attachment.count' do |
|
326 | assert_difference 'Attachment.count' do | |
327 | post :add_file, :id => 1, :version_id => '', |
|
327 | post :add_file, :id => 1, :version_id => '', | |
328 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} |
|
328 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} | |
329 | end |
|
329 | end | |
330 | assert_redirected_to 'projects/ecookbook/files' |
|
330 | assert_redirected_to 'projects/ecookbook/files' | |
331 | a = Attachment.find(:first, :order => 'created_on DESC') |
|
331 | a = Attachment.find(:first, :order => 'created_on DESC') | |
332 | assert_equal 'testfile.txt', a.filename |
|
332 | assert_equal 'testfile.txt', a.filename | |
333 | assert_equal Project.find(1), a.container |
|
333 | assert_equal Project.find(1), a.container | |
334 |
|
334 | |||
335 | mail = ActionMailer::Base.deliveries.last |
|
335 | mail = ActionMailer::Base.deliveries.last | |
336 | assert_kind_of TMail::Mail, mail |
|
336 | assert_kind_of TMail::Mail, mail | |
337 | assert_equal "[eCookbook] New file", mail.subject |
|
337 | assert_equal "[eCookbook] New file", mail.subject | |
338 | assert mail.body.include?('testfile.txt') |
|
338 | assert mail.body.include?('testfile.txt') | |
339 | end |
|
339 | end | |
340 |
|
340 | |||
341 | def test_add_version_file |
|
341 | def test_add_version_file | |
342 | set_tmp_attachments_directory |
|
342 | set_tmp_attachments_directory | |
343 | @request.session[:user_id] = 2 |
|
343 | @request.session[:user_id] = 2 | |
344 | Setting.notified_events = ['file_added'] |
|
344 | Setting.notified_events = ['file_added'] | |
345 |
|
345 | |||
346 | assert_difference 'Attachment.count' do |
|
346 | assert_difference 'Attachment.count' do | |
347 | post :add_file, :id => 1, :version_id => '2', |
|
347 | post :add_file, :id => 1, :version_id => '2', | |
348 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} |
|
348 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} | |
349 | end |
|
349 | end | |
350 | assert_redirected_to 'projects/ecookbook/files' |
|
350 | assert_redirected_to 'projects/ecookbook/files' | |
351 | a = Attachment.find(:first, :order => 'created_on DESC') |
|
351 | a = Attachment.find(:first, :order => 'created_on DESC') | |
352 | assert_equal 'testfile.txt', a.filename |
|
352 | assert_equal 'testfile.txt', a.filename | |
353 | assert_equal Version.find(2), a.container |
|
353 | assert_equal Version.find(2), a.container | |
354 | end |
|
354 | end | |
355 |
|
355 | |||
356 | def test_list_files |
|
356 | def test_list_files | |
357 | get :list_files, :id => 1 |
|
357 | get :list_files, :id => 1 | |
358 | assert_response :success |
|
358 | assert_response :success | |
359 | assert_template 'list_files' |
|
359 | assert_template 'list_files' | |
360 | assert_not_nil assigns(:containers) |
|
360 | assert_not_nil assigns(:containers) | |
361 |
|
361 | |||
362 | # file attached to the project |
|
362 | # file attached to the project | |
363 | assert_tag :a, :content => 'project_file.zip', |
|
363 | assert_tag :a, :content => 'project_file.zip', | |
364 | :attributes => { :href => '/attachments/download/8/project_file.zip' } |
|
364 | :attributes => { :href => '/attachments/download/8/project_file.zip' } | |
365 |
|
365 | |||
366 | # file attached to a project's version |
|
366 | # file attached to a project's version | |
367 | assert_tag :a, :content => 'version_file.zip', |
|
367 | assert_tag :a, :content => 'version_file.zip', | |
368 | :attributes => { :href => '/attachments/download/9/version_file.zip' } |
|
368 | :attributes => { :href => '/attachments/download/9/version_file.zip' } | |
369 | end |
|
369 | end | |
370 |
|
370 | |||
371 | def test_roadmap |
|
|||
372 | get :roadmap, :id => 1 |
|
|||
373 | assert_response :success |
|
|||
374 | assert_template 'roadmap' |
|
|||
375 | assert_not_nil assigns(:versions) |
|
|||
376 | # Version with no date set appears |
|
|||
377 | assert assigns(:versions).include?(Version.find(3)) |
|
|||
378 | # Completed version doesn't appear |
|
|||
379 | assert !assigns(:versions).include?(Version.find(1)) |
|
|||
380 | end |
|
|||
381 |
|
||||
382 | def test_roadmap_with_completed_versions |
|
|||
383 | get :roadmap, :id => 1, :completed => 1 |
|
|||
384 | assert_response :success |
|
|||
385 | assert_template 'roadmap' |
|
|||
386 | assert_not_nil assigns(:versions) |
|
|||
387 | # Version with no date set appears |
|
|||
388 | assert assigns(:versions).include?(Version.find(3)) |
|
|||
389 | # Completed version appears |
|
|||
390 | assert assigns(:versions).include?(Version.find(1)) |
|
|||
391 | end |
|
|||
392 |
|
||||
393 | def test_roadmap_showing_subprojects_versions |
|
|||
394 | @subproject_version = Version.generate!(:project => Project.find(3)) |
|
|||
395 | get :roadmap, :id => 1, :with_subprojects => 1 |
|
|||
396 | assert_response :success |
|
|||
397 | assert_template 'roadmap' |
|
|||
398 | assert_not_nil assigns(:versions) |
|
|||
399 |
|
||||
400 | assert assigns(:versions).include?(Version.find(4)), "Shared version not found" |
|
|||
401 | assert assigns(:versions).include?(@subproject_version), "Subproject version not found" |
|
|||
402 | end |
|
|||
403 | def test_archive |
|
371 | def test_archive | |
404 | @request.session[:user_id] = 1 # admin |
|
372 | @request.session[:user_id] = 1 # admin | |
405 | post :archive, :id => 1 |
|
373 | post :archive, :id => 1 | |
406 | assert_redirected_to 'admin/projects' |
|
374 | assert_redirected_to 'admin/projects' | |
407 | assert !Project.find(1).active? |
|
375 | assert !Project.find(1).active? | |
408 | end |
|
376 | end | |
409 |
|
377 | |||
410 | def test_unarchive |
|
378 | def test_unarchive | |
411 | @request.session[:user_id] = 1 # admin |
|
379 | @request.session[:user_id] = 1 # admin | |
412 | Project.find(1).archive |
|
380 | Project.find(1).archive | |
413 | post :unarchive, :id => 1 |
|
381 | post :unarchive, :id => 1 | |
414 | assert_redirected_to 'admin/projects' |
|
382 | assert_redirected_to 'admin/projects' | |
415 | assert Project.find(1).active? |
|
383 | assert Project.find(1).active? | |
416 | end |
|
384 | end | |
417 |
|
385 | |||
418 | def test_project_breadcrumbs_should_be_limited_to_3_ancestors |
|
386 | def test_project_breadcrumbs_should_be_limited_to_3_ancestors | |
419 | CustomField.delete_all |
|
387 | CustomField.delete_all | |
420 | parent = nil |
|
388 | parent = nil | |
421 | 6.times do |i| |
|
389 | 6.times do |i| | |
422 | p = Project.create!(:name => "Breadcrumbs #{i}", :identifier => "breadcrumbs-#{i}") |
|
390 | p = Project.create!(:name => "Breadcrumbs #{i}", :identifier => "breadcrumbs-#{i}") | |
423 | p.set_parent!(parent) |
|
391 | p.set_parent!(parent) | |
424 | get :show, :id => p |
|
392 | get :show, :id => p | |
425 | assert_tag :h1, :parent => { :attributes => {:id => 'header'}}, |
|
393 | assert_tag :h1, :parent => { :attributes => {:id => 'header'}}, | |
426 | :children => { :count => [i, 3].min, |
|
394 | :children => { :count => [i, 3].min, | |
427 | :only => { :tag => 'a' } } |
|
395 | :only => { :tag => 'a' } } | |
428 |
|
396 | |||
429 | parent = p |
|
397 | parent = p | |
430 | end |
|
398 | end | |
431 | end |
|
399 | end | |
432 |
|
400 | |||
433 | def test_copy_with_project |
|
401 | def test_copy_with_project | |
434 | @request.session[:user_id] = 1 # admin |
|
402 | @request.session[:user_id] = 1 # admin | |
435 | get :copy, :id => 1 |
|
403 | get :copy, :id => 1 | |
436 | assert_response :success |
|
404 | assert_response :success | |
437 | assert_template 'copy' |
|
405 | assert_template 'copy' | |
438 | assert assigns(:project) |
|
406 | assert assigns(:project) | |
439 | assert_equal Project.find(1).description, assigns(:project).description |
|
407 | assert_equal Project.find(1).description, assigns(:project).description | |
440 | assert_nil assigns(:project).id |
|
408 | assert_nil assigns(:project).id | |
441 | end |
|
409 | end | |
442 |
|
410 | |||
443 | def test_copy_without_project |
|
411 | def test_copy_without_project | |
444 | @request.session[:user_id] = 1 # admin |
|
412 | @request.session[:user_id] = 1 # admin | |
445 | get :copy |
|
413 | get :copy | |
446 | assert_response :redirect |
|
414 | assert_response :redirect | |
447 | assert_redirected_to :controller => 'admin', :action => 'projects' |
|
415 | assert_redirected_to :controller => 'admin', :action => 'projects' | |
448 | end |
|
416 | end | |
449 |
|
417 | |||
450 | def test_jump_should_redirect_to_active_tab |
|
418 | def test_jump_should_redirect_to_active_tab | |
451 | get :show, :id => 1, :jump => 'issues' |
|
419 | get :show, :id => 1, :jump => 'issues' | |
452 | assert_redirected_to 'projects/ecookbook/issues' |
|
420 | assert_redirected_to 'projects/ecookbook/issues' | |
453 | end |
|
421 | end | |
454 |
|
422 | |||
455 | def test_jump_should_not_redirect_to_inactive_tab |
|
423 | def test_jump_should_not_redirect_to_inactive_tab | |
456 | get :show, :id => 3, :jump => 'documents' |
|
424 | get :show, :id => 3, :jump => 'documents' | |
457 | assert_response :success |
|
425 | assert_response :success | |
458 | assert_template 'show' |
|
426 | assert_template 'show' | |
459 | end |
|
427 | end | |
460 |
|
428 | |||
461 | def test_jump_should_not_redirect_to_unknown_tab |
|
429 | def test_jump_should_not_redirect_to_unknown_tab | |
462 | get :show, :id => 3, :jump => 'foobar' |
|
430 | get :show, :id => 3, :jump => 'foobar' | |
463 | assert_response :success |
|
431 | assert_response :success | |
464 | assert_template 'show' |
|
432 | assert_template 'show' | |
465 | end |
|
433 | end | |
466 |
|
434 | |||
467 | def test_reset_activities |
|
435 | def test_reset_activities | |
468 | @request.session[:user_id] = 2 # manager |
|
436 | @request.session[:user_id] = 2 # manager | |
469 | project_activity = TimeEntryActivity.new({ |
|
437 | project_activity = TimeEntryActivity.new({ | |
470 | :name => 'Project Specific', |
|
438 | :name => 'Project Specific', | |
471 | :parent => TimeEntryActivity.find(:first), |
|
439 | :parent => TimeEntryActivity.find(:first), | |
472 | :project => Project.find(1), |
|
440 | :project => Project.find(1), | |
473 | :active => true |
|
441 | :active => true | |
474 | }) |
|
442 | }) | |
475 | assert project_activity.save |
|
443 | assert project_activity.save | |
476 | project_activity_two = TimeEntryActivity.new({ |
|
444 | project_activity_two = TimeEntryActivity.new({ | |
477 | :name => 'Project Specific Two', |
|
445 | :name => 'Project Specific Two', | |
478 | :parent => TimeEntryActivity.find(:last), |
|
446 | :parent => TimeEntryActivity.find(:last), | |
479 | :project => Project.find(1), |
|
447 | :project => Project.find(1), | |
480 | :active => true |
|
448 | :active => true | |
481 | }) |
|
449 | }) | |
482 | assert project_activity_two.save |
|
450 | assert project_activity_two.save | |
483 |
|
451 | |||
484 | delete :reset_activities, :id => 1 |
|
452 | delete :reset_activities, :id => 1 | |
485 | assert_response :redirect |
|
453 | assert_response :redirect | |
486 | assert_redirected_to 'projects/ecookbook/settings/activities' |
|
454 | assert_redirected_to 'projects/ecookbook/settings/activities' | |
487 |
|
455 | |||
488 | assert_nil TimeEntryActivity.find_by_id(project_activity.id) |
|
456 | assert_nil TimeEntryActivity.find_by_id(project_activity.id) | |
489 | assert_nil TimeEntryActivity.find_by_id(project_activity_two.id) |
|
457 | assert_nil TimeEntryActivity.find_by_id(project_activity_two.id) | |
490 | end |
|
458 | end | |
491 |
|
459 | |||
492 | def test_reset_activities_should_reassign_time_entries_back_to_the_system_activity |
|
460 | def test_reset_activities_should_reassign_time_entries_back_to_the_system_activity | |
493 | @request.session[:user_id] = 2 # manager |
|
461 | @request.session[:user_id] = 2 # manager | |
494 | project_activity = TimeEntryActivity.new({ |
|
462 | project_activity = TimeEntryActivity.new({ | |
495 | :name => 'Project Specific Design', |
|
463 | :name => 'Project Specific Design', | |
496 | :parent => TimeEntryActivity.find(9), |
|
464 | :parent => TimeEntryActivity.find(9), | |
497 | :project => Project.find(1), |
|
465 | :project => Project.find(1), | |
498 | :active => true |
|
466 | :active => true | |
499 | }) |
|
467 | }) | |
500 | assert project_activity.save |
|
468 | assert project_activity.save | |
501 | assert TimeEntry.update_all("activity_id = '#{project_activity.id}'", ["project_id = ? AND activity_id = ?", 1, 9]) |
|
469 | assert TimeEntry.update_all("activity_id = '#{project_activity.id}'", ["project_id = ? AND activity_id = ?", 1, 9]) | |
502 | assert 3, TimeEntry.find_all_by_activity_id_and_project_id(project_activity.id, 1).size |
|
470 | assert 3, TimeEntry.find_all_by_activity_id_and_project_id(project_activity.id, 1).size | |
503 |
|
471 | |||
504 | delete :reset_activities, :id => 1 |
|
472 | delete :reset_activities, :id => 1 | |
505 | assert_response :redirect |
|
473 | assert_response :redirect | |
506 | assert_redirected_to 'projects/ecookbook/settings/activities' |
|
474 | assert_redirected_to 'projects/ecookbook/settings/activities' | |
507 |
|
475 | |||
508 | assert_nil TimeEntryActivity.find_by_id(project_activity.id) |
|
476 | assert_nil TimeEntryActivity.find_by_id(project_activity.id) | |
509 | assert_equal 0, TimeEntry.find_all_by_activity_id_and_project_id(project_activity.id, 1).size, "TimeEntries still assigned to project specific activity" |
|
477 | assert_equal 0, TimeEntry.find_all_by_activity_id_and_project_id(project_activity.id, 1).size, "TimeEntries still assigned to project specific activity" | |
510 | assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size, "TimeEntries still assigned to project specific activity" |
|
478 | assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size, "TimeEntries still assigned to project specific activity" | |
511 | end |
|
479 | end | |
512 |
|
480 | |||
513 | def test_save_activities_to_override_system_activities |
|
481 | def test_save_activities_to_override_system_activities | |
514 | @request.session[:user_id] = 2 # manager |
|
482 | @request.session[:user_id] = 2 # manager | |
515 | billable_field = TimeEntryActivityCustomField.find_by_name("Billable") |
|
483 | billable_field = TimeEntryActivityCustomField.find_by_name("Billable") | |
516 |
|
484 | |||
517 | post :save_activities, :id => 1, :enumerations => { |
|
485 | post :save_activities, :id => 1, :enumerations => { | |
518 | "9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"}, # Design, De-activate |
|
486 | "9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"}, # Design, De-activate | |
519 | "10"=> {"parent_id"=>"10", "custom_field_values"=>{"7"=>"0"}, "active"=>"1"}, # Development, Change custom value |
|
487 | "10"=> {"parent_id"=>"10", "custom_field_values"=>{"7"=>"0"}, "active"=>"1"}, # Development, Change custom value | |
520 | "14"=>{"parent_id"=>"14", "custom_field_values"=>{"7"=>"1"}, "active"=>"1"}, # Inactive Activity, Activate with custom value |
|
488 | "14"=>{"parent_id"=>"14", "custom_field_values"=>{"7"=>"1"}, "active"=>"1"}, # Inactive Activity, Activate with custom value | |
521 | "11"=>{"parent_id"=>"11", "custom_field_values"=>{"7"=>"1"}, "active"=>"1"} # QA, no changes |
|
489 | "11"=>{"parent_id"=>"11", "custom_field_values"=>{"7"=>"1"}, "active"=>"1"} # QA, no changes | |
522 | } |
|
490 | } | |
523 |
|
491 | |||
524 | assert_response :redirect |
|
492 | assert_response :redirect | |
525 | assert_redirected_to 'projects/ecookbook/settings/activities' |
|
493 | assert_redirected_to 'projects/ecookbook/settings/activities' | |
526 |
|
494 | |||
527 | # Created project specific activities... |
|
495 | # Created project specific activities... | |
528 | project = Project.find('ecookbook') |
|
496 | project = Project.find('ecookbook') | |
529 |
|
497 | |||
530 | # ... Design |
|
498 | # ... Design | |
531 | design = project.time_entry_activities.find_by_name("Design") |
|
499 | design = project.time_entry_activities.find_by_name("Design") | |
532 | assert design, "Project activity not found" |
|
500 | assert design, "Project activity not found" | |
533 |
|
501 | |||
534 | assert_equal 9, design.parent_id # Relate to the system activity |
|
502 | assert_equal 9, design.parent_id # Relate to the system activity | |
535 | assert_not_equal design.parent.id, design.id # Different records |
|
503 | assert_not_equal design.parent.id, design.id # Different records | |
536 | assert_equal design.parent.name, design.name # Same name |
|
504 | assert_equal design.parent.name, design.name # Same name | |
537 | assert !design.active? |
|
505 | assert !design.active? | |
538 |
|
506 | |||
539 | # ... Development |
|
507 | # ... Development | |
540 | development = project.time_entry_activities.find_by_name("Development") |
|
508 | development = project.time_entry_activities.find_by_name("Development") | |
541 | assert development, "Project activity not found" |
|
509 | assert development, "Project activity not found" | |
542 |
|
510 | |||
543 | assert_equal 10, development.parent_id # Relate to the system activity |
|
511 | assert_equal 10, development.parent_id # Relate to the system activity | |
544 | assert_not_equal development.parent.id, development.id # Different records |
|
512 | assert_not_equal development.parent.id, development.id # Different records | |
545 | assert_equal development.parent.name, development.name # Same name |
|
513 | assert_equal development.parent.name, development.name # Same name | |
546 | assert development.active? |
|
514 | assert development.active? | |
547 | assert_equal "0", development.custom_value_for(billable_field).value |
|
515 | assert_equal "0", development.custom_value_for(billable_field).value | |
548 |
|
516 | |||
549 | # ... Inactive Activity |
|
517 | # ... Inactive Activity | |
550 | previously_inactive = project.time_entry_activities.find_by_name("Inactive Activity") |
|
518 | previously_inactive = project.time_entry_activities.find_by_name("Inactive Activity") | |
551 | assert previously_inactive, "Project activity not found" |
|
519 | assert previously_inactive, "Project activity not found" | |
552 |
|
520 | |||
553 | assert_equal 14, previously_inactive.parent_id # Relate to the system activity |
|
521 | assert_equal 14, previously_inactive.parent_id # Relate to the system activity | |
554 | assert_not_equal previously_inactive.parent.id, previously_inactive.id # Different records |
|
522 | assert_not_equal previously_inactive.parent.id, previously_inactive.id # Different records | |
555 | assert_equal previously_inactive.parent.name, previously_inactive.name # Same name |
|
523 | assert_equal previously_inactive.parent.name, previously_inactive.name # Same name | |
556 | assert previously_inactive.active? |
|
524 | assert previously_inactive.active? | |
557 | assert_equal "1", previously_inactive.custom_value_for(billable_field).value |
|
525 | assert_equal "1", previously_inactive.custom_value_for(billable_field).value | |
558 |
|
526 | |||
559 | # ... QA |
|
527 | # ... QA | |
560 | assert_equal nil, project.time_entry_activities.find_by_name("QA"), "Custom QA activity created when it wasn't modified" |
|
528 | assert_equal nil, project.time_entry_activities.find_by_name("QA"), "Custom QA activity created when it wasn't modified" | |
561 | end |
|
529 | end | |
562 |
|
530 | |||
563 | def test_save_activities_will_update_project_specific_activities |
|
531 | def test_save_activities_will_update_project_specific_activities | |
564 | @request.session[:user_id] = 2 # manager |
|
532 | @request.session[:user_id] = 2 # manager | |
565 |
|
533 | |||
566 | project_activity = TimeEntryActivity.new({ |
|
534 | project_activity = TimeEntryActivity.new({ | |
567 | :name => 'Project Specific', |
|
535 | :name => 'Project Specific', | |
568 | :parent => TimeEntryActivity.find(:first), |
|
536 | :parent => TimeEntryActivity.find(:first), | |
569 | :project => Project.find(1), |
|
537 | :project => Project.find(1), | |
570 | :active => true |
|
538 | :active => true | |
571 | }) |
|
539 | }) | |
572 | assert project_activity.save |
|
540 | assert project_activity.save | |
573 | project_activity_two = TimeEntryActivity.new({ |
|
541 | project_activity_two = TimeEntryActivity.new({ | |
574 | :name => 'Project Specific Two', |
|
542 | :name => 'Project Specific Two', | |
575 | :parent => TimeEntryActivity.find(:last), |
|
543 | :parent => TimeEntryActivity.find(:last), | |
576 | :project => Project.find(1), |
|
544 | :project => Project.find(1), | |
577 | :active => true |
|
545 | :active => true | |
578 | }) |
|
546 | }) | |
579 | assert project_activity_two.save |
|
547 | assert project_activity_two.save | |
580 |
|
548 | |||
581 |
|
549 | |||
582 | post :save_activities, :id => 1, :enumerations => { |
|
550 | post :save_activities, :id => 1, :enumerations => { | |
583 | project_activity.id => {"custom_field_values"=>{"7" => "1"}, "active"=>"0"}, # De-activate |
|
551 | project_activity.id => {"custom_field_values"=>{"7" => "1"}, "active"=>"0"}, # De-activate | |
584 | project_activity_two.id => {"custom_field_values"=>{"7" => "1"}, "active"=>"0"} # De-activate |
|
552 | project_activity_two.id => {"custom_field_values"=>{"7" => "1"}, "active"=>"0"} # De-activate | |
585 | } |
|
553 | } | |
586 |
|
554 | |||
587 | assert_response :redirect |
|
555 | assert_response :redirect | |
588 | assert_redirected_to 'projects/ecookbook/settings/activities' |
|
556 | assert_redirected_to 'projects/ecookbook/settings/activities' | |
589 |
|
557 | |||
590 | # Created project specific activities... |
|
558 | # Created project specific activities... | |
591 | project = Project.find('ecookbook') |
|
559 | project = Project.find('ecookbook') | |
592 | assert_equal 2, project.time_entry_activities.count |
|
560 | assert_equal 2, project.time_entry_activities.count | |
593 |
|
561 | |||
594 | activity_one = project.time_entry_activities.find_by_name(project_activity.name) |
|
562 | activity_one = project.time_entry_activities.find_by_name(project_activity.name) | |
595 | assert activity_one, "Project activity not found" |
|
563 | assert activity_one, "Project activity not found" | |
596 | assert_equal project_activity.id, activity_one.id |
|
564 | assert_equal project_activity.id, activity_one.id | |
597 | assert !activity_one.active? |
|
565 | assert !activity_one.active? | |
598 |
|
566 | |||
599 | activity_two = project.time_entry_activities.find_by_name(project_activity_two.name) |
|
567 | activity_two = project.time_entry_activities.find_by_name(project_activity_two.name) | |
600 | assert activity_two, "Project activity not found" |
|
568 | assert activity_two, "Project activity not found" | |
601 | assert_equal project_activity_two.id, activity_two.id |
|
569 | assert_equal project_activity_two.id, activity_two.id | |
602 | assert !activity_two.active? |
|
570 | assert !activity_two.active? | |
603 | end |
|
571 | end | |
604 |
|
572 | |||
605 | def test_save_activities_when_creating_new_activities_will_convert_existing_data |
|
573 | def test_save_activities_when_creating_new_activities_will_convert_existing_data | |
606 | assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size |
|
574 | assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size | |
607 |
|
575 | |||
608 | @request.session[:user_id] = 2 # manager |
|
576 | @request.session[:user_id] = 2 # manager | |
609 | post :save_activities, :id => 1, :enumerations => { |
|
577 | post :save_activities, :id => 1, :enumerations => { | |
610 | "9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"} # Design, De-activate |
|
578 | "9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"} # Design, De-activate | |
611 | } |
|
579 | } | |
612 | assert_response :redirect |
|
580 | assert_response :redirect | |
613 |
|
581 | |||
614 | # No more TimeEntries using the system activity |
|
582 | # No more TimeEntries using the system activity | |
615 | assert_equal 0, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size, "Time Entries still assigned to system activities" |
|
583 | assert_equal 0, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size, "Time Entries still assigned to system activities" | |
616 | # All TimeEntries using project activity |
|
584 | # All TimeEntries using project activity | |
617 | project_specific_activity = TimeEntryActivity.find_by_parent_id_and_project_id(9, 1) |
|
585 | project_specific_activity = TimeEntryActivity.find_by_parent_id_and_project_id(9, 1) | |
618 | assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(project_specific_activity.id, 1).size, "No Time Entries assigned to the project activity" |
|
586 | assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(project_specific_activity.id, 1).size, "No Time Entries assigned to the project activity" | |
619 | end |
|
587 | end | |
620 |
|
588 | |||
621 | def test_save_activities_when_creating_new_activities_will_not_convert_existing_data_if_an_exception_is_raised |
|
589 | def test_save_activities_when_creating_new_activities_will_not_convert_existing_data_if_an_exception_is_raised | |
622 | # TODO: Need to cause an exception on create but these tests |
|
590 | # TODO: Need to cause an exception on create but these tests | |
623 | # aren't setup for mocking. Just create a record now so the |
|
591 | # aren't setup for mocking. Just create a record now so the | |
624 | # second one is a dupicate |
|
592 | # second one is a dupicate | |
625 | parent = TimeEntryActivity.find(9) |
|
593 | parent = TimeEntryActivity.find(9) | |
626 | TimeEntryActivity.create!({:name => parent.name, :project_id => 1, :position => parent.position, :active => true}) |
|
594 | TimeEntryActivity.create!({:name => parent.name, :project_id => 1, :position => parent.position, :active => true}) | |
627 | TimeEntry.create!({:project_id => 1, :hours => 1.0, :user => User.find(1), :issue_id => 3, :activity_id => 10, :spent_on => '2009-01-01'}) |
|
595 | TimeEntry.create!({:project_id => 1, :hours => 1.0, :user => User.find(1), :issue_id => 3, :activity_id => 10, :spent_on => '2009-01-01'}) | |
628 |
|
596 | |||
629 | assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size |
|
597 | assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size | |
630 | assert_equal 1, TimeEntry.find_all_by_activity_id_and_project_id(10, 1).size |
|
598 | assert_equal 1, TimeEntry.find_all_by_activity_id_and_project_id(10, 1).size | |
631 |
|
599 | |||
632 | @request.session[:user_id] = 2 # manager |
|
600 | @request.session[:user_id] = 2 # manager | |
633 | post :save_activities, :id => 1, :enumerations => { |
|
601 | post :save_activities, :id => 1, :enumerations => { | |
634 | "9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"}, # Design |
|
602 | "9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"}, # Design | |
635 | "10"=> {"parent_id"=>"10", "custom_field_values"=>{"7"=>"0"}, "active"=>"1"} # Development, Change custom value |
|
603 | "10"=> {"parent_id"=>"10", "custom_field_values"=>{"7"=>"0"}, "active"=>"1"} # Development, Change custom value | |
636 | } |
|
604 | } | |
637 | assert_response :redirect |
|
605 | assert_response :redirect | |
638 |
|
606 | |||
639 | # TimeEntries shouldn't have been reassigned on the failed record |
|
607 | # TimeEntries shouldn't have been reassigned on the failed record | |
640 | assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size, "Time Entries are not assigned to system activities" |
|
608 | assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size, "Time Entries are not assigned to system activities" | |
641 | # TimeEntries shouldn't have been reassigned on the saved record either |
|
609 | # TimeEntries shouldn't have been reassigned on the saved record either | |
642 | assert_equal 1, TimeEntry.find_all_by_activity_id_and_project_id(10, 1).size, "Time Entries are not assigned to system activities" |
|
610 | assert_equal 1, TimeEntry.find_all_by_activity_id_and_project_id(10, 1).size, "Time Entries are not assigned to system activities" | |
643 | end |
|
611 | end | |
644 |
|
612 | |||
645 | # A hook that is manually registered later |
|
613 | # A hook that is manually registered later | |
646 | class ProjectBasedTemplate < Redmine::Hook::ViewListener |
|
614 | class ProjectBasedTemplate < Redmine::Hook::ViewListener | |
647 | def view_layouts_base_html_head(context) |
|
615 | def view_layouts_base_html_head(context) | |
648 | # Adds a project stylesheet |
|
616 | # Adds a project stylesheet | |
649 | stylesheet_link_tag(context[:project].identifier) if context[:project] |
|
617 | stylesheet_link_tag(context[:project].identifier) if context[:project] | |
650 | end |
|
618 | end | |
651 | end |
|
619 | end | |
652 | # Don't use this hook now |
|
620 | # Don't use this hook now | |
653 | Redmine::Hook.clear_listeners |
|
621 | Redmine::Hook.clear_listeners | |
654 |
|
622 | |||
655 | def test_hook_response |
|
623 | def test_hook_response | |
656 | Redmine::Hook.add_listener(ProjectBasedTemplate) |
|
624 | Redmine::Hook.add_listener(ProjectBasedTemplate) | |
657 | get :show, :id => 1 |
|
625 | get :show, :id => 1 | |
658 | assert_tag :tag => 'link', :attributes => {:href => '/stylesheets/ecookbook.css'}, |
|
626 | assert_tag :tag => 'link', :attributes => {:href => '/stylesheets/ecookbook.css'}, | |
659 | :parent => {:tag => 'head'} |
|
627 | :parent => {:tag => 'head'} | |
660 |
|
628 | |||
661 | Redmine::Hook.clear_listeners |
|
629 | Redmine::Hook.clear_listeners | |
662 | end |
|
630 | end | |
663 | end |
|
631 | end |
@@ -1,104 +1,137 | |||||
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 | require File.dirname(__FILE__) + '/../test_helper' |
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |
19 | require 'versions_controller' |
|
19 | require 'versions_controller' | |
20 |
|
20 | |||
21 | # Re-raise errors caught by the controller. |
|
21 | # Re-raise errors caught by the controller. | |
22 | class VersionsController; def rescue_action(e) raise e end; end |
|
22 | class VersionsController; def rescue_action(e) raise e end; end | |
23 |
|
23 | |||
24 | class VersionsControllerTest < ActionController::TestCase |
|
24 | class VersionsControllerTest < ActionController::TestCase | |
25 | fixtures :projects, :versions, :issues, :users, :roles, :members, :member_roles, :enabled_modules |
|
25 | fixtures :projects, :versions, :issues, :users, :roles, :members, :member_roles, :enabled_modules | |
26 |
|
26 | |||
27 | def setup |
|
27 | def setup | |
28 | @controller = VersionsController.new |
|
28 | @controller = VersionsController.new | |
29 | @request = ActionController::TestRequest.new |
|
29 | @request = ActionController::TestRequest.new | |
30 | @response = ActionController::TestResponse.new |
|
30 | @response = ActionController::TestResponse.new | |
31 | User.current = nil |
|
31 | User.current = nil | |
32 | end |
|
32 | end | |
33 |
|
33 | |||
|
34 | def test_index | |||
|
35 | get :index, :project_id => 1 | |||
|
36 | assert_response :success | |||
|
37 | assert_template 'index' | |||
|
38 | assert_not_nil assigns(:versions) | |||
|
39 | # Version with no date set appears | |||
|
40 | assert assigns(:versions).include?(Version.find(3)) | |||
|
41 | # Completed version doesn't appear | |||
|
42 | assert !assigns(:versions).include?(Version.find(1)) | |||
|
43 | end | |||
|
44 | ||||
|
45 | def test_index_with_completed_versions | |||
|
46 | get :index, :project_id => 1, :completed => 1 | |||
|
47 | assert_response :success | |||
|
48 | assert_template 'index' | |||
|
49 | assert_not_nil assigns(:versions) | |||
|
50 | # Version with no date set appears | |||
|
51 | assert assigns(:versions).include?(Version.find(3)) | |||
|
52 | # Completed version appears | |||
|
53 | assert assigns(:versions).include?(Version.find(1)) | |||
|
54 | end | |||
|
55 | ||||
|
56 | def test_index_showing_subprojects_versions | |||
|
57 | @subproject_version = Version.generate!(:project => Project.find(3)) | |||
|
58 | get :index, :project_id => 1, :with_subprojects => 1 | |||
|
59 | assert_response :success | |||
|
60 | assert_template 'index' | |||
|
61 | assert_not_nil assigns(:versions) | |||
|
62 | ||||
|
63 | assert assigns(:versions).include?(Version.find(4)), "Shared version not found" | |||
|
64 | assert assigns(:versions).include?(@subproject_version), "Subproject version not found" | |||
|
65 | end | |||
|
66 | ||||
34 | def test_show |
|
67 | def test_show | |
35 | get :show, :id => 2 |
|
68 | get :show, :id => 2 | |
36 | assert_response :success |
|
69 | assert_response :success | |
37 | assert_template 'show' |
|
70 | assert_template 'show' | |
38 | assert_not_nil assigns(:version) |
|
71 | assert_not_nil assigns(:version) | |
39 |
|
72 | |||
40 | assert_tag :tag => 'h2', :content => /1.0/ |
|
73 | assert_tag :tag => 'h2', :content => /1.0/ | |
41 | end |
|
74 | end | |
42 |
|
75 | |||
43 | def test_new |
|
76 | def test_new | |
44 | @request.session[:user_id] = 2 # manager |
|
77 | @request.session[:user_id] = 2 # manager | |
45 | assert_difference 'Version.count' do |
|
78 | assert_difference 'Version.count' do | |
46 | post :new, :project_id => '1', :version => {:name => 'test_add_version'} |
|
79 | post :new, :project_id => '1', :version => {:name => 'test_add_version'} | |
47 | end |
|
80 | end | |
48 | assert_redirected_to '/projects/ecookbook/settings/versions' |
|
81 | assert_redirected_to '/projects/ecookbook/settings/versions' | |
49 | version = Version.find_by_name('test_add_version') |
|
82 | version = Version.find_by_name('test_add_version') | |
50 | assert_not_nil version |
|
83 | assert_not_nil version | |
51 | assert_equal 1, version.project_id |
|
84 | assert_equal 1, version.project_id | |
52 | end |
|
85 | end | |
53 |
|
86 | |||
54 | def test_new_from_issue_form |
|
87 | def test_new_from_issue_form | |
55 | @request.session[:user_id] = 2 # manager |
|
88 | @request.session[:user_id] = 2 # manager | |
56 | assert_difference 'Version.count' do |
|
89 | assert_difference 'Version.count' do | |
57 | xhr :post, :new, :project_id => '1', :version => {:name => 'test_add_version_from_issue_form'} |
|
90 | xhr :post, :new, :project_id => '1', :version => {:name => 'test_add_version_from_issue_form'} | |
58 | end |
|
91 | end | |
59 | assert_response :success |
|
92 | assert_response :success | |
60 | assert_select_rjs :replace, 'issue_fixed_version_id' |
|
93 | assert_select_rjs :replace, 'issue_fixed_version_id' | |
61 | version = Version.find_by_name('test_add_version_from_issue_form') |
|
94 | version = Version.find_by_name('test_add_version_from_issue_form') | |
62 | assert_not_nil version |
|
95 | assert_not_nil version | |
63 | assert_equal 1, version.project_id |
|
96 | assert_equal 1, version.project_id | |
64 | end |
|
97 | end | |
65 |
|
98 | |||
66 | def test_get_edit |
|
99 | def test_get_edit | |
67 | @request.session[:user_id] = 2 |
|
100 | @request.session[:user_id] = 2 | |
68 | get :edit, :id => 2 |
|
101 | get :edit, :id => 2 | |
69 | assert_response :success |
|
102 | assert_response :success | |
70 | assert_template 'edit' |
|
103 | assert_template 'edit' | |
71 | end |
|
104 | end | |
72 |
|
105 | |||
73 | def test_close_completed |
|
106 | def test_close_completed | |
74 | Version.update_all("status = 'open'") |
|
107 | Version.update_all("status = 'open'") | |
75 | @request.session[:user_id] = 2 |
|
108 | @request.session[:user_id] = 2 | |
76 | post :close_completed, :project_id => 'ecookbook' |
|
109 | post :close_completed, :project_id => 'ecookbook' | |
77 | assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook' |
|
110 | assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook' | |
78 | assert_not_nil Version.find_by_status('closed') |
|
111 | assert_not_nil Version.find_by_status('closed') | |
79 | end |
|
112 | end | |
80 |
|
113 | |||
81 | def test_post_edit |
|
114 | def test_post_edit | |
82 | @request.session[:user_id] = 2 |
|
115 | @request.session[:user_id] = 2 | |
83 | post :edit, :id => 2, |
|
116 | post :edit, :id => 2, | |
84 | :version => { :name => 'New version name', |
|
117 | :version => { :name => 'New version name', | |
85 | :effective_date => Date.today.strftime("%Y-%m-%d")} |
|
118 | :effective_date => Date.today.strftime("%Y-%m-%d")} | |
86 | assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook' |
|
119 | assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook' | |
87 | version = Version.find(2) |
|
120 | version = Version.find(2) | |
88 | assert_equal 'New version name', version.name |
|
121 | assert_equal 'New version name', version.name | |
89 | assert_equal Date.today, version.effective_date |
|
122 | assert_equal Date.today, version.effective_date | |
90 | end |
|
123 | end | |
91 |
|
124 | |||
92 | def test_destroy |
|
125 | def test_destroy | |
93 | @request.session[:user_id] = 2 |
|
126 | @request.session[:user_id] = 2 | |
94 | post :destroy, :id => 3 |
|
127 | post :destroy, :id => 3 | |
95 | assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook' |
|
128 | assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook' | |
96 | assert_nil Version.find_by_id(3) |
|
129 | assert_nil Version.find_by_id(3) | |
97 | end |
|
130 | end | |
98 |
|
131 | |||
99 | def test_issue_status_by |
|
132 | def test_issue_status_by | |
100 | xhr :get, :status_by, :id => 2 |
|
133 | xhr :get, :status_by, :id => 2 | |
101 | assert_response :success |
|
134 | assert_response :success | |
102 | assert_template '_issue_counts' |
|
135 | assert_template '_issue_counts' | |
103 | end |
|
136 | end | |
104 | end |
|
137 | end |
@@ -1,291 +1,291 | |||||
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 |
|
159 | |||
160 | should_route :post, "/projects/567/news/new", :controller => 'news', :action => 'new', :project_id => '567' |
|
160 | should_route :post, "/projects/567/news/new", :controller => 'news', :action => 'new', :project_id => '567' | |
161 | should_route :post, "/news/567/edit", :controller => 'news', :action => 'edit', :id => '567' |
|
161 | should_route :post, "/news/567/edit", :controller => 'news', :action => 'edit', :id => '567' | |
162 | should_route :post, "/news/567/destroy", :controller => 'news', :action => 'destroy', :id => '567' |
|
162 | should_route :post, "/news/567/destroy", :controller => 'news', :action => 'destroy', :id => '567' | |
163 | end |
|
163 | end | |
164 |
|
164 | |||
165 | context "projects" do |
|
165 | context "projects" do | |
166 | should_route :get, "/projects", :controller => 'projects', :action => 'index' |
|
166 | should_route :get, "/projects", :controller => 'projects', :action => 'index' | |
167 | should_route :get, "/projects.atom", :controller => 'projects', :action => 'index', :format => 'atom' |
|
167 | should_route :get, "/projects.atom", :controller => 'projects', :action => 'index', :format => 'atom' | |
168 | should_route :get, "/projects.xml", :controller => 'projects', :action => 'index', :format => 'xml' |
|
168 | should_route :get, "/projects.xml", :controller => 'projects', :action => 'index', :format => 'xml' | |
169 | should_route :get, "/projects/new", :controller => 'projects', :action => 'add' |
|
169 | should_route :get, "/projects/new", :controller => 'projects', :action => 'add' | |
170 | should_route :get, "/projects/test", :controller => 'projects', :action => 'show', :id => 'test' |
|
170 | should_route :get, "/projects/test", :controller => 'projects', :action => 'show', :id => 'test' | |
171 | should_route :get, "/projects/1.xml", :controller => 'projects', :action => 'show', :id => '1', :format => 'xml' |
|
171 | should_route :get, "/projects/1.xml", :controller => 'projects', :action => 'show', :id => '1', :format => 'xml' | |
172 | should_route :get, "/projects/4223/settings", :controller => 'projects', :action => 'settings', :id => '4223' |
|
172 | should_route :get, "/projects/4223/settings", :controller => 'projects', :action => 'settings', :id => '4223' | |
173 | should_route :get, "/projects/4223/settings/members", :controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members' |
|
173 | should_route :get, "/projects/4223/settings/members", :controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members' | |
174 | should_route :get, "/projects/567/destroy", :controller => 'projects', :action => 'destroy', :id => '567' |
|
174 | should_route :get, "/projects/567/destroy", :controller => 'projects', :action => 'destroy', :id => '567' | |
175 | should_route :get, "/projects/33/files", :controller => 'projects', :action => 'list_files', :id => '33' |
|
175 | should_route :get, "/projects/33/files", :controller => 'projects', :action => 'list_files', :id => '33' | |
176 | should_route :get, "/projects/33/files/new", :controller => 'projects', :action => 'add_file', :id => '33' |
|
176 | should_route :get, "/projects/33/files/new", :controller => 'projects', :action => 'add_file', :id => '33' | |
177 |
should_route :get, "/projects/33/roadmap", :controller => ' |
|
177 | should_route :get, "/projects/33/roadmap", :controller => 'versions', :action => 'index', :project_id => '33' | |
178 | should_route :get, "/projects/33/activity", :controller => 'activities', :action => 'index', :id => '33' |
|
178 | should_route :get, "/projects/33/activity", :controller => 'activities', :action => 'index', :id => '33' | |
179 | should_route :get, "/projects/33/activity.atom", :controller => 'activities', :action => 'index', :id => '33', :format => 'atom' |
|
179 | should_route :get, "/projects/33/activity.atom", :controller => 'activities', :action => 'index', :id => '33', :format => 'atom' | |
180 |
|
180 | |||
181 | should_route :post, "/projects/new", :controller => 'projects', :action => 'add' |
|
181 | should_route :post, "/projects/new", :controller => 'projects', :action => 'add' | |
182 | should_route :post, "/projects.xml", :controller => 'projects', :action => 'add', :format => 'xml' |
|
182 | should_route :post, "/projects.xml", :controller => 'projects', :action => 'add', :format => 'xml' | |
183 | should_route :post, "/projects/4223/edit", :controller => 'projects', :action => 'edit', :id => '4223' |
|
183 | should_route :post, "/projects/4223/edit", :controller => 'projects', :action => 'edit', :id => '4223' | |
184 | should_route :post, "/projects/64/destroy", :controller => 'projects', :action => 'destroy', :id => '64' |
|
184 | should_route :post, "/projects/64/destroy", :controller => 'projects', :action => 'destroy', :id => '64' | |
185 | should_route :post, "/projects/33/files/new", :controller => 'projects', :action => 'add_file', :id => '33' |
|
185 | should_route :post, "/projects/33/files/new", :controller => 'projects', :action => 'add_file', :id => '33' | |
186 | should_route :post, "/projects/64/archive", :controller => 'projects', :action => 'archive', :id => '64' |
|
186 | should_route :post, "/projects/64/archive", :controller => 'projects', :action => 'archive', :id => '64' | |
187 | should_route :post, "/projects/64/unarchive", :controller => 'projects', :action => 'unarchive', :id => '64' |
|
187 | should_route :post, "/projects/64/unarchive", :controller => 'projects', :action => 'unarchive', :id => '64' | |
188 | should_route :post, "/projects/64/activities/save", :controller => 'projects', :action => 'save_activities', :id => '64' |
|
188 | should_route :post, "/projects/64/activities/save", :controller => 'projects', :action => 'save_activities', :id => '64' | |
189 |
|
189 | |||
190 | should_route :put, "/projects/1.xml", :controller => 'projects', :action => 'edit', :id => '1', :format => 'xml' |
|
190 | should_route :put, "/projects/1.xml", :controller => 'projects', :action => 'edit', :id => '1', :format => 'xml' | |
191 |
|
191 | |||
192 | should_route :delete, "/projects/1.xml", :controller => 'projects', :action => 'destroy', :id => '1', :format => 'xml' |
|
192 | should_route :delete, "/projects/1.xml", :controller => 'projects', :action => 'destroy', :id => '1', :format => 'xml' | |
193 | should_route :delete, "/projects/64/reset_activities", :controller => 'projects', :action => 'reset_activities', :id => '64' |
|
193 | should_route :delete, "/projects/64/reset_activities", :controller => 'projects', :action => 'reset_activities', :id => '64' | |
194 | end |
|
194 | end | |
195 |
|
195 | |||
196 | context "repositories" do |
|
196 | context "repositories" do | |
197 | should_route :get, "/projects/redmine/repository", :controller => 'repositories', :action => 'show', :id => 'redmine' |
|
197 | should_route :get, "/projects/redmine/repository", :controller => 'repositories', :action => 'show', :id => 'redmine' | |
198 | should_route :get, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine' |
|
198 | should_route :get, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine' | |
199 | should_route :get, "/projects/redmine/repository/revisions", :controller => 'repositories', :action => 'revisions', :id => 'redmine' |
|
199 | should_route :get, "/projects/redmine/repository/revisions", :controller => 'repositories', :action => 'revisions', :id => 'redmine' | |
200 | should_route :get, "/projects/redmine/repository/revisions.atom", :controller => 'repositories', :action => 'revisions', :id => 'redmine', :format => 'atom' |
|
200 | should_route :get, "/projects/redmine/repository/revisions.atom", :controller => 'repositories', :action => 'revisions', :id => 'redmine', :format => 'atom' | |
201 | should_route :get, "/projects/redmine/repository/revisions/2457", :controller => 'repositories', :action => 'revision', :id => 'redmine', :rev => '2457' |
|
201 | should_route :get, "/projects/redmine/repository/revisions/2457", :controller => 'repositories', :action => 'revision', :id => 'redmine', :rev => '2457' | |
202 | should_route :get, "/projects/redmine/repository/revisions/2457/diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457' |
|
202 | should_route :get, "/projects/redmine/repository/revisions/2457/diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457' | |
203 | should_route :get, "/projects/redmine/repository/revisions/2457/diff.diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457', :format => 'diff' |
|
203 | should_route :get, "/projects/redmine/repository/revisions/2457/diff.diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457', :format => 'diff' | |
204 | should_route :get, "/projects/redmine/repository/diff/path/to/file.c", :controller => 'repositories', :action => 'diff', :id => 'redmine', :path => %w[path to file.c] |
|
204 | should_route :get, "/projects/redmine/repository/diff/path/to/file.c", :controller => 'repositories', :action => 'diff', :id => 'redmine', :path => %w[path to file.c] | |
205 | 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' |
|
205 | should_route :get, "/projects/redmine/repository/revisions/2/diff/path/to/file.c", :controller => 'repositories', :action => 'diff', :id => 'redmine', :path => %w[path to file.c], :rev => '2' | |
206 | should_route :get, "/projects/redmine/repository/browse/path/to/file.c", :controller => 'repositories', :action => 'browse', :id => 'redmine', :path => %w[path to file.c] |
|
206 | should_route :get, "/projects/redmine/repository/browse/path/to/file.c", :controller => 'repositories', :action => 'browse', :id => 'redmine', :path => %w[path to file.c] | |
207 | should_route :get, "/projects/redmine/repository/entry/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c] |
|
207 | should_route :get, "/projects/redmine/repository/entry/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c] | |
208 | 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' |
|
208 | should_route :get, "/projects/redmine/repository/revisions/2/entry/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :rev => '2' | |
209 | 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' |
|
209 | should_route :get, "/projects/redmine/repository/raw/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :format => 'raw' | |
210 | 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' |
|
210 | should_route :get, "/projects/redmine/repository/revisions/2/raw/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :rev => '2', :format => 'raw' | |
211 | should_route :get, "/projects/redmine/repository/annotate/path/to/file.c", :controller => 'repositories', :action => 'annotate', :id => 'redmine', :path => %w[path to file.c] |
|
211 | should_route :get, "/projects/redmine/repository/annotate/path/to/file.c", :controller => 'repositories', :action => 'annotate', :id => 'redmine', :path => %w[path to file.c] | |
212 | should_route :get, "/projects/redmine/repository/changes/path/to/file.c", :controller => 'repositories', :action => 'changes', :id => 'redmine', :path => %w[path to file.c] |
|
212 | should_route :get, "/projects/redmine/repository/changes/path/to/file.c", :controller => 'repositories', :action => 'changes', :id => 'redmine', :path => %w[path to file.c] | |
213 | should_route :get, "/projects/redmine/repository/statistics", :controller => 'repositories', :action => 'stats', :id => 'redmine' |
|
213 | should_route :get, "/projects/redmine/repository/statistics", :controller => 'repositories', :action => 'stats', :id => 'redmine' | |
214 |
|
214 | |||
215 |
|
215 | |||
216 | should_route :post, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine' |
|
216 | should_route :post, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine' | |
217 | end |
|
217 | end | |
218 |
|
218 | |||
219 | context "timelogs" do |
|
219 | context "timelogs" do | |
220 | should_route :get, "/issues/567/time_entries/new", :controller => 'timelog', :action => 'edit', :issue_id => '567' |
|
220 | should_route :get, "/issues/567/time_entries/new", :controller => 'timelog', :action => 'edit', :issue_id => '567' | |
221 | should_route :get, "/projects/ecookbook/time_entries/new", :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook' |
|
221 | should_route :get, "/projects/ecookbook/time_entries/new", :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook' | |
222 | should_route :get, "/projects/ecookbook/issues/567/time_entries/new", :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook', :issue_id => '567' |
|
222 | should_route :get, "/projects/ecookbook/issues/567/time_entries/new", :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook', :issue_id => '567' | |
223 | should_route :get, "/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22' |
|
223 | should_route :get, "/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22' | |
224 | should_route :get, "/time_entries/report", :controller => 'timelog', :action => 'report' |
|
224 | should_route :get, "/time_entries/report", :controller => 'timelog', :action => 'report' | |
225 | should_route :get, "/projects/567/time_entries/report", :controller => 'timelog', :action => 'report', :project_id => '567' |
|
225 | should_route :get, "/projects/567/time_entries/report", :controller => 'timelog', :action => 'report', :project_id => '567' | |
226 | should_route :get, "/projects/567/time_entries/report.csv", :controller => 'timelog', :action => 'report', :project_id => '567', :format => 'csv' |
|
226 | should_route :get, "/projects/567/time_entries/report.csv", :controller => 'timelog', :action => 'report', :project_id => '567', :format => 'csv' | |
227 | should_route :get, "/time_entries", :controller => 'timelog', :action => 'details' |
|
227 | should_route :get, "/time_entries", :controller => 'timelog', :action => 'details' | |
228 | should_route :get, "/time_entries.csv", :controller => 'timelog', :action => 'details', :format => 'csv' |
|
228 | should_route :get, "/time_entries.csv", :controller => 'timelog', :action => 'details', :format => 'csv' | |
229 | should_route :get, "/time_entries.atom", :controller => 'timelog', :action => 'details', :format => 'atom' |
|
229 | should_route :get, "/time_entries.atom", :controller => 'timelog', :action => 'details', :format => 'atom' | |
230 | should_route :get, "/projects/567/time_entries", :controller => 'timelog', :action => 'details', :project_id => '567' |
|
230 | should_route :get, "/projects/567/time_entries", :controller => 'timelog', :action => 'details', :project_id => '567' | |
231 | should_route :get, "/projects/567/time_entries.csv", :controller => 'timelog', :action => 'details', :project_id => '567', :format => 'csv' |
|
231 | should_route :get, "/projects/567/time_entries.csv", :controller => 'timelog', :action => 'details', :project_id => '567', :format => 'csv' | |
232 | should_route :get, "/projects/567/time_entries.atom", :controller => 'timelog', :action => 'details', :project_id => '567', :format => 'atom' |
|
232 | should_route :get, "/projects/567/time_entries.atom", :controller => 'timelog', :action => 'details', :project_id => '567', :format => 'atom' | |
233 | should_route :get, "/issues/234/time_entries", :controller => 'timelog', :action => 'details', :issue_id => '234' |
|
233 | should_route :get, "/issues/234/time_entries", :controller => 'timelog', :action => 'details', :issue_id => '234' | |
234 | should_route :get, "/issues/234/time_entries.csv", :controller => 'timelog', :action => 'details', :issue_id => '234', :format => 'csv' |
|
234 | should_route :get, "/issues/234/time_entries.csv", :controller => 'timelog', :action => 'details', :issue_id => '234', :format => 'csv' | |
235 | should_route :get, "/issues/234/time_entries.atom", :controller => 'timelog', :action => 'details', :issue_id => '234', :format => 'atom' |
|
235 | should_route :get, "/issues/234/time_entries.atom", :controller => 'timelog', :action => 'details', :issue_id => '234', :format => 'atom' | |
236 | should_route :get, "/projects/ecookbook/issues/123/time_entries", :controller => 'timelog', :action => 'details', :project_id => 'ecookbook', :issue_id => '123' |
|
236 | should_route :get, "/projects/ecookbook/issues/123/time_entries", :controller => 'timelog', :action => 'details', :project_id => 'ecookbook', :issue_id => '123' | |
237 |
|
237 | |||
238 | should_route :post, "/time_entries/55/destroy", :controller => 'timelog', :action => 'destroy', :id => '55' |
|
238 | should_route :post, "/time_entries/55/destroy", :controller => 'timelog', :action => 'destroy', :id => '55' | |
239 | end |
|
239 | end | |
240 |
|
240 | |||
241 | context "users" do |
|
241 | context "users" do | |
242 | should_route :get, "/users", :controller => 'users', :action => 'index' |
|
242 | should_route :get, "/users", :controller => 'users', :action => 'index' | |
243 | should_route :get, "/users/44", :controller => 'users', :action => 'show', :id => '44' |
|
243 | should_route :get, "/users/44", :controller => 'users', :action => 'show', :id => '44' | |
244 | should_route :get, "/users/new", :controller => 'users', :action => 'add' |
|
244 | should_route :get, "/users/new", :controller => 'users', :action => 'add' | |
245 | should_route :get, "/users/444/edit", :controller => 'users', :action => 'edit', :id => '444' |
|
245 | should_route :get, "/users/444/edit", :controller => 'users', :action => 'edit', :id => '444' | |
246 | should_route :get, "/users/222/edit/membership", :controller => 'users', :action => 'edit', :id => '222', :tab => 'membership' |
|
246 | should_route :get, "/users/222/edit/membership", :controller => 'users', :action => 'edit', :id => '222', :tab => 'membership' | |
247 |
|
247 | |||
248 | should_route :post, "/users/new", :controller => 'users', :action => 'add' |
|
248 | should_route :post, "/users/new", :controller => 'users', :action => 'add' | |
249 | should_route :post, "/users/444/edit", :controller => 'users', :action => 'edit', :id => '444' |
|
249 | should_route :post, "/users/444/edit", :controller => 'users', :action => 'edit', :id => '444' | |
250 | should_route :post, "/users/123/memberships", :controller => 'users', :action => 'edit_membership', :id => '123' |
|
250 | should_route :post, "/users/123/memberships", :controller => 'users', :action => 'edit_membership', :id => '123' | |
251 | should_route :post, "/users/123/memberships/55", :controller => 'users', :action => 'edit_membership', :id => '123', :membership_id => '55' |
|
251 | should_route :post, "/users/123/memberships/55", :controller => 'users', :action => 'edit_membership', :id => '123', :membership_id => '55' | |
252 | should_route :post, "/users/567/memberships/12/destroy", :controller => 'users', :action => 'destroy_membership', :id => '567', :membership_id => '12' |
|
252 | should_route :post, "/users/567/memberships/12/destroy", :controller => 'users', :action => 'destroy_membership', :id => '567', :membership_id => '12' | |
253 | end |
|
253 | end | |
254 |
|
254 | |||
255 | context "versions" do |
|
255 | context "versions" do | |
256 | should_route :get, "/projects/foo/versions/new", :controller => 'versions', :action => 'new', :project_id => 'foo' |
|
256 | should_route :get, "/projects/foo/versions/new", :controller => 'versions', :action => 'new', :project_id => 'foo' | |
257 |
|
257 | |||
258 | should_route :post, "/projects/foo/versions/new", :controller => 'versions', :action => 'new', :project_id => 'foo' |
|
258 | should_route :post, "/projects/foo/versions/new", :controller => 'versions', :action => 'new', :project_id => 'foo' | |
259 | end |
|
259 | end | |
260 |
|
260 | |||
261 | context "wiki (singular, project's pages)" do |
|
261 | context "wiki (singular, project's pages)" do | |
262 | should_route :get, "/projects/567/wiki", :controller => 'wiki', :action => 'index', :id => '567' |
|
262 | should_route :get, "/projects/567/wiki", :controller => 'wiki', :action => 'index', :id => '567' | |
263 | should_route :get, "/projects/567/wiki/lalala", :controller => 'wiki', :action => 'index', :id => '567', :page => 'lalala' |
|
263 | should_route :get, "/projects/567/wiki/lalala", :controller => 'wiki', :action => 'index', :id => '567', :page => 'lalala' | |
264 | should_route :get, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page' |
|
264 | should_route :get, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page' | |
265 | should_route :get, "/projects/1/wiki/CookBook_documentation/history", :controller => 'wiki', :action => 'history', :id => '1', :page => 'CookBook_documentation' |
|
265 | should_route :get, "/projects/1/wiki/CookBook_documentation/history", :controller => 'wiki', :action => 'history', :id => '1', :page => 'CookBook_documentation' | |
266 | 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' |
|
266 | should_route :get, "/projects/1/wiki/CookBook_documentation/diff/2/vs/1", :controller => 'wiki', :action => 'diff', :id => '1', :page => 'CookBook_documentation', :version => '2', :version_from => '1' | |
267 | should_route :get, "/projects/1/wiki/CookBook_documentation/annotate/2", :controller => 'wiki', :action => 'annotate', :id => '1', :page => 'CookBook_documentation', :version => '2' |
|
267 | should_route :get, "/projects/1/wiki/CookBook_documentation/annotate/2", :controller => 'wiki', :action => 'annotate', :id => '1', :page => 'CookBook_documentation', :version => '2' | |
268 | should_route :get, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida' |
|
268 | should_route :get, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida' | |
269 | should_route :get, "/projects/567/wiki/page_index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'page_index' |
|
269 | should_route :get, "/projects/567/wiki/page_index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'page_index' | |
270 | should_route :get, "/projects/567/wiki/Page_Index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'Page_Index' |
|
270 | should_route :get, "/projects/567/wiki/Page_Index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'Page_Index' | |
271 | should_route :get, "/projects/567/wiki/date_index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'date_index' |
|
271 | should_route :get, "/projects/567/wiki/date_index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'date_index' | |
272 | should_route :get, "/projects/567/wiki/export", :controller => 'wiki', :action => 'special', :id => '567', :page => 'export' |
|
272 | should_route :get, "/projects/567/wiki/export", :controller => 'wiki', :action => 'special', :id => '567', :page => 'export' | |
273 |
|
273 | |||
274 | should_route :post, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page' |
|
274 | should_route :post, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page' | |
275 | should_route :post, "/projects/567/wiki/CookBook_documentation/preview", :controller => 'wiki', :action => 'preview', :id => '567', :page => 'CookBook_documentation' |
|
275 | should_route :post, "/projects/567/wiki/CookBook_documentation/preview", :controller => 'wiki', :action => 'preview', :id => '567', :page => 'CookBook_documentation' | |
276 | should_route :post, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida' |
|
276 | should_route :post, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida' | |
277 | should_route :post, "/projects/22/wiki/ladida/destroy", :controller => 'wiki', :action => 'destroy', :id => '22', :page => 'ladida' |
|
277 | should_route :post, "/projects/22/wiki/ladida/destroy", :controller => 'wiki', :action => 'destroy', :id => '22', :page => 'ladida' | |
278 | should_route :post, "/projects/22/wiki/ladida/protect", :controller => 'wiki', :action => 'protect', :id => '22', :page => 'ladida' |
|
278 | should_route :post, "/projects/22/wiki/ladida/protect", :controller => 'wiki', :action => 'protect', :id => '22', :page => 'ladida' | |
279 | end |
|
279 | end | |
280 |
|
280 | |||
281 | context "wikis (plural, admin setup)" do |
|
281 | context "wikis (plural, admin setup)" do | |
282 | should_route :get, "/projects/ladida/wiki/destroy", :controller => 'wikis', :action => 'destroy', :id => 'ladida' |
|
282 | should_route :get, "/projects/ladida/wiki/destroy", :controller => 'wikis', :action => 'destroy', :id => 'ladida' | |
283 |
|
283 | |||
284 | should_route :post, "/projects/ladida/wiki", :controller => 'wikis', :action => 'edit', :id => 'ladida' |
|
284 | should_route :post, "/projects/ladida/wiki", :controller => 'wikis', :action => 'edit', :id => 'ladida' | |
285 | should_route :post, "/projects/ladida/wiki/destroy", :controller => 'wikis', :action => 'destroy', :id => 'ladida' |
|
285 | should_route :post, "/projects/ladida/wiki/destroy", :controller => 'wikis', :action => 'destroy', :id => 'ladida' | |
286 | end |
|
286 | end | |
287 |
|
287 | |||
288 | context "administration panel" do |
|
288 | context "administration panel" do | |
289 | should_route :get, "/admin/projects", :controller => 'admin', :action => 'projects' |
|
289 | should_route :get, "/admin/projects", :controller => 'admin', :action => 'projects' | |
290 | end |
|
290 | end | |
291 | end |
|
291 | end |
General Comments 0
You need to be logged in to leave comments.
Login now