##// END OF EJS Templates
Refactor: rename method ProjectsController#add to ProjectsController#new...
Eric Davis -
r3955:2295b61cb6fd
parent child
Show More
@@ -1,270 +1,269
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2009 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 class ProjectsController < ApplicationController
19 19 menu_item :overview
20 20 menu_item :roadmap, :only => :roadmap
21 21 menu_item :settings, :only => :settings
22 22
23 before_filter :find_project, :except => [ :index, :list, :add, :create, :copy ]
24 before_filter :authorize, :except => [ :index, :list, :add, :create, :copy, :archive, :unarchive, :destroy]
25 before_filter :authorize_global, :only => [:add, :create]
23 before_filter :find_project, :except => [ :index, :list, :new, :create, :copy ]
24 before_filter :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy]
25 before_filter :authorize_global, :only => [:new, :create]
26 26 before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
27 27 accept_key_auth :index
28 28
29 29 after_filter :only => [:create, :edit, :archive, :unarchive, :destroy] do |controller|
30 30 if controller.request.post?
31 31 controller.send :expire_action, :controller => 'welcome', :action => 'robots.txt'
32 32 end
33 33 end
34 34
35 35 helper :sort
36 36 include SortHelper
37 37 helper :custom_fields
38 38 include CustomFieldsHelper
39 39 helper :issues
40 40 helper :queries
41 41 include QueriesHelper
42 42 helper :repositories
43 43 include RepositoriesHelper
44 44 include ProjectsHelper
45 45
46 46 # Lists visible projects
47 47 def index
48 48 respond_to do |format|
49 49 format.html {
50 50 @projects = Project.visible.find(:all, :order => 'lft')
51 51 }
52 52 format.xml {
53 53 @projects = Project.visible.find(:all, :order => 'lft')
54 54 }
55 55 format.atom {
56 56 projects = Project.visible.find(:all, :order => 'created_on DESC',
57 57 :limit => Setting.feeds_limit.to_i)
58 58 render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
59 59 }
60 60 end
61 61 end
62 62
63 # Add a new project
64 def add
63 def new
65 64 @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
66 65 @trackers = Tracker.all
67 66 @project = Project.new(params[:project])
68 67
69 68 @project.identifier = Project.next_identifier if Setting.sequential_project_identifiers?
70 69 @project.trackers = Tracker.all
71 70 @project.is_public = Setting.default_projects_public?
72 71 @project.enabled_module_names = Setting.default_projects_modules
73 72 end
74 73
75 74 def create
76 75 @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
77 76 @trackers = Tracker.all
78 77 @project = Project.new(params[:project])
79 78
80 79 @project.enabled_module_names = params[:enabled_modules]
81 80 if validate_parent_id && @project.save
82 81 @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
83 82 # Add current user as a project member if he is not admin
84 83 unless User.current.admin?
85 84 r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
86 85 m = Member.new(:user => User.current, :roles => [r])
87 86 @project.members << m
88 87 end
89 88 respond_to do |format|
90 89 format.html {
91 90 flash[:notice] = l(:notice_successful_create)
92 91 redirect_to :controller => 'projects', :action => 'settings', :id => @project
93 92 }
94 93 format.xml { head :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
95 94 end
96 95 else
97 96 respond_to do |format|
98 format.html { render :action => 'add' }
97 format.html { render :action => 'new' }
99 98 format.xml { render :xml => @project.errors, :status => :unprocessable_entity }
100 99 end
101 100 end
102 101
103 102 end
104 103
105 104 def copy
106 105 @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
107 106 @trackers = Tracker.all
108 107 @root_projects = Project.find(:all,
109 108 :conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}",
110 109 :order => 'name')
111 110 @source_project = Project.find(params[:id])
112 111 if request.get?
113 112 @project = Project.copy_from(@source_project)
114 113 if @project
115 114 @project.identifier = Project.next_identifier if Setting.sequential_project_identifiers?
116 115 else
117 116 redirect_to :controller => 'admin', :action => 'projects'
118 117 end
119 118 else
120 119 Mailer.with_deliveries(params[:notifications] == '1') do
121 120 @project = Project.new(params[:project])
122 121 @project.enabled_module_names = params[:enabled_modules]
123 122 if validate_parent_id && @project.copy(@source_project, :only => params[:only])
124 123 @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
125 124 flash[:notice] = l(:notice_successful_create)
126 125 redirect_to :controller => 'admin', :action => 'projects'
127 126 elsif !@project.new_record?
128 127 # Project was created
129 128 # But some objects were not copied due to validation failures
130 129 # (eg. issues from disabled trackers)
131 130 # TODO: inform about that
132 131 redirect_to :controller => 'admin', :action => 'projects'
133 132 end
134 133 end
135 134 end
136 135 rescue ActiveRecord::RecordNotFound
137 136 redirect_to :controller => 'admin', :action => 'projects'
138 137 end
139 138
140 139 # Show @project
141 140 def show
142 141 if params[:jump]
143 142 # try to redirect to the requested menu item
144 143 redirect_to_project_menu_item(@project, params[:jump]) && return
145 144 end
146 145
147 146 @users_by_role = @project.users_by_role
148 147 @subprojects = @project.children.visible
149 148 @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC")
150 149 @trackers = @project.rolled_up_trackers
151 150
152 151 cond = @project.project_condition(Setting.display_subprojects_issues?)
153 152
154 153 @open_issues_by_tracker = Issue.visible.count(:group => :tracker,
155 154 :include => [:project, :status, :tracker],
156 155 :conditions => ["(#{cond}) AND #{IssueStatus.table_name}.is_closed=?", false])
157 156 @total_issues_by_tracker = Issue.visible.count(:group => :tracker,
158 157 :include => [:project, :status, :tracker],
159 158 :conditions => cond)
160 159
161 160 TimeEntry.visible_by(User.current) do
162 161 @total_hours = TimeEntry.sum(:hours,
163 162 :include => :project,
164 163 :conditions => cond).to_f
165 164 end
166 165 @key = User.current.rss_key
167 166
168 167 respond_to do |format|
169 168 format.html
170 169 format.xml
171 170 end
172 171 end
173 172
174 173 def settings
175 174 @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
176 175 @issue_category ||= IssueCategory.new
177 176 @member ||= @project.members.new
178 177 @trackers = Tracker.all
179 178 @repository ||= @project.repository
180 179 @wiki ||= @project.wiki
181 180 end
182 181
183 182 # Edit @project
184 183 def edit
185 184 if request.get?
186 185 else
187 186 @project.attributes = params[:project]
188 187 if validate_parent_id && @project.save
189 188 @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
190 189 respond_to do |format|
191 190 format.html {
192 191 flash[:notice] = l(:notice_successful_update)
193 192 redirect_to :action => 'settings', :id => @project
194 193 }
195 194 format.xml { head :ok }
196 195 end
197 196 else
198 197 respond_to do |format|
199 198 format.html {
200 199 settings
201 200 render :action => 'settings'
202 201 }
203 202 format.xml { render :xml => @project.errors, :status => :unprocessable_entity }
204 203 end
205 204 end
206 205 end
207 206 end
208 207
209 208 def modules
210 209 @project.enabled_module_names = params[:enabled_modules]
211 210 flash[:notice] = l(:notice_successful_update)
212 211 redirect_to :action => 'settings', :id => @project, :tab => 'modules'
213 212 end
214 213
215 214 def archive
216 215 if request.post?
217 216 unless @project.archive
218 217 flash[:error] = l(:error_can_not_archive_project)
219 218 end
220 219 end
221 220 redirect_to(url_for(:controller => 'admin', :action => 'projects', :status => params[:status]))
222 221 end
223 222
224 223 def unarchive
225 224 @project.unarchive if request.post? && !@project.active?
226 225 redirect_to(url_for(:controller => 'admin', :action => 'projects', :status => params[:status]))
227 226 end
228 227
229 228 # Delete @project
230 229 def destroy
231 230 @project_to_destroy = @project
232 231 if request.get?
233 232 # display confirmation view
234 233 else
235 234 if params[:format] == 'xml' || params[:confirm]
236 235 @project_to_destroy.destroy
237 236 respond_to do |format|
238 237 format.html { redirect_to :controller => 'admin', :action => 'projects' }
239 238 format.xml { head :ok }
240 239 end
241 240 end
242 241 end
243 242 # hide project in layout
244 243 @project = nil
245 244 end
246 245
247 246 private
248 247 def find_optional_project
249 248 return true unless params[:id]
250 249 @project = Project.find(params[:id])
251 250 authorize
252 251 rescue ActiveRecord::RecordNotFound
253 252 render_404
254 253 end
255 254
256 255 # Validates parent_id param according to user's permissions
257 256 # TODO: move it to Project model in a validation that depends on User.current
258 257 def validate_parent_id
259 258 return true if User.current.admin?
260 259 parent_id = params[:project] && params[:project][:parent_id]
261 260 if parent_id || @project.new_record?
262 261 parent = parent_id.blank? ? nil : Project.find_by_id(parent_id.to_i)
263 262 unless @project.allowed_parents.include?(parent)
264 263 @project.errors.add :parent_id, :invalid
265 264 return false
266 265 end
267 266 end
268 267 true
269 268 end
270 269 end
@@ -1,46 +1,46
1 1 <div class="contextual">
2 <%= link_to l(:label_project_new), {:controller => 'projects', :action => 'add'}, :class => 'icon icon-add' %>
2 <%= link_to l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add' %>
3 3 </div>
4 4
5 5 <h2><%=l(:label_project_plural)%></h2>
6 6
7 7 <% form_tag({}, :method => :get) do %>
8 8 <fieldset><legend><%= l(:label_filter_plural) %></legend>
9 9 <label><%= l(:field_status) %> :</label>
10 10 <%= select_tag 'status', project_status_options_for_select(@status), :class => "small", :onchange => "this.form.submit(); return false;" %>
11 11 <label><%= l(:label_project) %>:</label>
12 12 <%= text_field_tag 'name', params[:name], :size => 30 %>
13 13 <%= submit_tag l(:button_apply), :class => "small", :name => nil %>
14 14 </fieldset>
15 15 <% end %>
16 16 &nbsp;
17 17
18 18 <div class="autoscroll">
19 19 <table class="list">
20 20 <thead><tr>
21 21 <th><%=l(:label_project)%></th>
22 22 <th><%=l(:field_description)%></th>
23 23 <th><%=l(:field_is_public)%></th>
24 24 <th><%=l(:field_created_on)%></th>
25 25 <th></th>
26 26 </tr></thead>
27 27 <tbody>
28 28 <% project_tree(@projects) do |project, level| %>
29 29 <tr class="<%= cycle("odd", "even") %> <%= css_project_classes(project) %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
30 30 <td class="name"><%= link_to_project(project, :action => 'settings') %></td>
31 31 <td><%= textilizable project.short_description, :project => project %></td>
32 32 <td align="center"><%= checked_image project.is_public? %></td>
33 33 <td align="center"><%= format_date(project.created_on) %></td>
34 34 <td class="buttons">
35 35 <%= link_to(l(:button_archive), { :controller => 'projects', :action => 'archive', :id => project, :status => params[:status] }, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-lock') if project.active? %>
36 36 <%= link_to(l(:button_unarchive), { :controller => 'projects', :action => 'unarchive', :id => project, :status => params[:status] }, :method => :post, :class => 'icon icon-unlock') if !project.active? && (project.parent.nil? || project.parent.active?) %>
37 37 <%= link_to(l(:button_copy), { :controller => 'projects', :action => 'copy', :id => project }, :class => 'icon icon-copy') %>
38 38 <%= link_to(l(:button_delete), { :controller => 'projects', :action => 'destroy', :id => project }, :class => 'icon icon-del') %>
39 39 </td>
40 40 </tr>
41 41 <% end %>
42 42 </tbody>
43 43 </table>
44 44 </div>
45 45
46 46 <% html_title(l(:label_project_plural)) -%>
@@ -1,26 +1,26
1 1 <% content_for :header_tags do %>
2 2 <%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %>
3 3 <% end %>
4 4
5 5 <div class="contextual">
6 <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'add'}, :class => 'icon icon-add') + ' |' if User.current.allowed_to?(:add_project, nil, :global => true) %>
6 <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') + ' |' if User.current.allowed_to?(:add_project, nil, :global => true) %>
7 7 <%= link_to(l(:label_issue_view_all), { :controller => 'issues' }) + ' |' if User.current.allowed_to?(:view_issues, nil, :global => true) %>
8 8 <%= link_to(l(:label_overall_spent_time), { :controller => 'time_entries' }) + ' |' if User.current.allowed_to?(:view_time_entries, nil, :global => true) %>
9 9 <%= link_to l(:label_overall_activity), { :controller => 'activities', :action => 'index' }%>
10 10 </div>
11 11
12 12 <h2><%=l(:label_project_plural)%></h2>
13 13
14 14 <%= render_project_hierarchy(@projects)%>
15 15
16 16 <% if User.current.logged? %>
17 17 <p style="text-align:right;">
18 18 <span class="my-project"><%= l(:label_my_projects) %></span>
19 19 </p>
20 20 <% end %>
21 21
22 22 <% other_formats_links do |f| %>
23 23 <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %>
24 24 <% end %>
25 25
26 26 <% html_title(l(:label_project_plural)) -%>
1 NO CONTENT: file renamed from app/views/projects/add.rhtml to app/views/projects/new.html.erb
@@ -1,283 +1,283
1 1 ActionController::Routing::Routes.draw do |map|
2 2 # Add your own custom routes here.
3 3 # The priority is based upon order of creation: first created -> highest priority.
4 4
5 5 # Here's a sample route:
6 6 # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
7 7 # Keep in mind you can assign values other than :controller and :action
8 8
9 9 map.home '', :controller => 'welcome'
10 10
11 11 map.signin 'login', :controller => 'account', :action => 'login'
12 12 map.signout 'logout', :controller => 'account', :action => 'logout'
13 13
14 14 map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow'
15 15 map.connect 'help/:ctrl/:page', :controller => 'help'
16 16
17 17 map.connect 'time_entries/:id/edit', :action => 'edit', :controller => 'timelog'
18 18 map.connect 'projects/:project_id/time_entries/new', :action => 'edit', :controller => 'timelog'
19 19 map.connect 'projects/:project_id/issues/:issue_id/time_entries/new', :action => 'edit', :controller => 'timelog'
20 20
21 21 map.with_options :controller => 'timelog' do |timelog|
22 22 timelog.connect 'projects/:project_id/time_entries', :action => 'details'
23 23
24 24 timelog.with_options :action => 'details', :conditions => {:method => :get} do |time_details|
25 25 time_details.connect 'time_entries'
26 26 time_details.connect 'time_entries.:format'
27 27 time_details.connect 'issues/:issue_id/time_entries'
28 28 time_details.connect 'issues/:issue_id/time_entries.:format'
29 29 time_details.connect 'projects/:project_id/time_entries.:format'
30 30 time_details.connect 'projects/:project_id/issues/:issue_id/time_entries'
31 31 time_details.connect 'projects/:project_id/issues/:issue_id/time_entries.:format'
32 32 end
33 33 timelog.connect 'projects/:project_id/time_entries/report', :action => 'report'
34 34 timelog.with_options :action => 'report',:conditions => {:method => :get} do |time_report|
35 35 time_report.connect 'time_entries/report'
36 36 time_report.connect 'time_entries/report.:format'
37 37 time_report.connect 'projects/:project_id/time_entries/report.:format'
38 38 end
39 39
40 40 timelog.with_options :action => 'edit', :conditions => {:method => :get} do |time_edit|
41 41 time_edit.connect 'issues/:issue_id/time_entries/new'
42 42 end
43 43
44 44 timelog.connect 'time_entries/:id/destroy', :action => 'destroy', :conditions => {:method => :post}
45 45 end
46 46
47 47 map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post}
48 48 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get}
49 49 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post}
50 50 map.with_options :controller => 'wiki' do |wiki_routes|
51 51 wiki_routes.with_options :conditions => {:method => :get} do |wiki_views|
52 52 wiki_views.connect 'projects/:id/wiki/:page', :action => 'special', :page => /page_index|date_index|export/i
53 53 wiki_views.connect 'projects/:id/wiki/:page', :action => 'index', :page => nil
54 54 wiki_views.connect 'projects/:id/wiki/:page/edit', :action => 'edit'
55 55 wiki_views.connect 'projects/:id/wiki/:page/rename', :action => 'rename'
56 56 wiki_views.connect 'projects/:id/wiki/:page/history', :action => 'history'
57 57 wiki_views.connect 'projects/:id/wiki/:page/diff/:version/vs/:version_from', :action => 'diff'
58 58 wiki_views.connect 'projects/:id/wiki/:page/annotate/:version', :action => 'annotate'
59 59 end
60 60
61 61 wiki_routes.connect 'projects/:id/wiki/:page/:action',
62 62 :action => /edit|rename|destroy|preview|protect/,
63 63 :conditions => {:method => :post}
64 64 end
65 65
66 66 map.with_options :controller => 'messages' do |messages_routes|
67 67 messages_routes.with_options :conditions => {:method => :get} do |messages_views|
68 68 messages_views.connect 'boards/:board_id/topics/new', :action => 'new'
69 69 messages_views.connect 'boards/:board_id/topics/:id', :action => 'show'
70 70 messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit'
71 71 end
72 72 messages_routes.with_options :conditions => {:method => :post} do |messages_actions|
73 73 messages_actions.connect 'boards/:board_id/topics/new', :action => 'new'
74 74 messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply'
75 75 messages_actions.connect 'boards/:board_id/topics/:id/:action', :action => /edit|destroy/
76 76 end
77 77 end
78 78
79 79 map.with_options :controller => 'boards' do |board_routes|
80 80 board_routes.with_options :conditions => {:method => :get} do |board_views|
81 81 board_views.connect 'projects/:project_id/boards', :action => 'index'
82 82 board_views.connect 'projects/:project_id/boards/new', :action => 'new'
83 83 board_views.connect 'projects/:project_id/boards/:id', :action => 'show'
84 84 board_views.connect 'projects/:project_id/boards/:id.:format', :action => 'show'
85 85 board_views.connect 'projects/:project_id/boards/:id/edit', :action => 'edit'
86 86 end
87 87 board_routes.with_options :conditions => {:method => :post} do |board_actions|
88 88 board_actions.connect 'projects/:project_id/boards', :action => 'new'
89 89 board_actions.connect 'projects/:project_id/boards/:id/:action', :action => /edit|destroy/
90 90 end
91 91 end
92 92
93 93 map.with_options :controller => 'documents' do |document_routes|
94 94 document_routes.with_options :conditions => {:method => :get} do |document_views|
95 95 document_views.connect 'projects/:project_id/documents', :action => 'index'
96 96 document_views.connect 'projects/:project_id/documents/new', :action => 'new'
97 97 document_views.connect 'documents/:id', :action => 'show'
98 98 document_views.connect 'documents/:id/edit', :action => 'edit'
99 99 end
100 100 document_routes.with_options :conditions => {:method => :post} do |document_actions|
101 101 document_actions.connect 'projects/:project_id/documents', :action => 'new'
102 102 document_actions.connect 'documents/:id/:action', :action => /destroy|edit/
103 103 end
104 104 end
105 105
106 106 map.resources :issue_moves, :only => [:new, :create], :path_prefix => '/issues', :as => 'move'
107 107
108 108 # Misc issue routes. TODO: move into resources
109 109 map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', :action => 'issues'
110 110 map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue' # TODO: would look nicer as /issues/:id/preview
111 111 map.issues_context_menu '/issues/context_menu', :controller => 'context_menus', :action => 'issues'
112 112 map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index'
113 113 map.bulk_edit_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_edit', :conditions => { :method => :get }
114 114 map.bulk_update_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_update', :conditions => { :method => :post }
115 115 map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/, :conditions => { :method => :post }
116 116 map.connect '/issues/:id/destroy', :controller => 'issues', :action => 'destroy', :conditions => { :method => :post } # legacy
117 117
118 118 map.resource :gantt, :path_prefix => '/issues', :controller => 'gantts', :only => [:show, :update]
119 119 map.resource :gantt, :path_prefix => '/projects/:project_id/issues', :controller => 'gantts', :only => [:show, :update]
120 120 map.resource :calendar, :path_prefix => '/issues', :controller => 'calendars', :only => [:show, :update]
121 121 map.resource :calendar, :path_prefix => '/projects/:project_id/issues', :controller => 'calendars', :only => [:show, :update]
122 122
123 123 map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports|
124 124 reports.connect 'projects/:id/issues/report', :action => 'issue_report'
125 125 reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details'
126 126 end
127 127
128 128 # Following two routes conflict with the resources because #index allows POST
129 129 map.connect '/issues', :controller => 'issues', :action => 'index', :conditions => { :method => :post }
130 130 map.connect '/issues/create', :controller => 'issues', :action => 'index', :conditions => { :method => :post }
131 131
132 132 map.resources :issues, :member => { :edit => :post }, :collection => {}
133 133 map.resources :issues, :path_prefix => '/projects/:project_id', :collection => { :create => :post }
134 134
135 135 map.with_options :controller => 'issue_relations', :conditions => {:method => :post} do |relations|
136 136 relations.connect 'issues/:issue_id/relations/:id', :action => 'new'
137 137 relations.connect 'issues/:issue_id/relations/:id/destroy', :action => 'destroy'
138 138 end
139 139
140 140 map.with_options :controller => 'news' do |news_routes|
141 141 news_routes.with_options :conditions => {:method => :get} do |news_views|
142 142 news_views.connect 'news', :action => 'index'
143 143 news_views.connect 'projects/:project_id/news', :action => 'index'
144 144 news_views.connect 'projects/:project_id/news.:format', :action => 'index'
145 145 news_views.connect 'news.:format', :action => 'index'
146 146 news_views.connect 'projects/:project_id/news/new', :action => 'new'
147 147 news_views.connect 'news/:id', :action => 'show'
148 148 news_views.connect 'news/:id/edit', :action => 'edit'
149 149 end
150 150 news_routes.with_options do |news_actions|
151 151 news_actions.connect 'projects/:project_id/news', :action => 'new'
152 152 news_actions.connect 'news/:id/edit', :action => 'edit'
153 153 news_actions.connect 'news/:id/destroy', :action => 'destroy'
154 154 end
155 155 end
156 156
157 157 map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new'
158 158
159 159 map.with_options :controller => 'users' do |users|
160 160 users.with_options :conditions => {:method => :get} do |user_views|
161 161 user_views.connect 'users', :action => 'index'
162 162 user_views.connect 'users/:id', :action => 'show', :id => /\d+/
163 163 user_views.connect 'users/new', :action => 'add'
164 164 user_views.connect 'users/:id/edit/:tab', :action => 'edit', :tab => nil
165 165 end
166 166 users.with_options :conditions => {:method => :post} do |user_actions|
167 167 user_actions.connect 'users', :action => 'add'
168 168 user_actions.connect 'users/new', :action => 'add'
169 169 user_actions.connect 'users/:id/edit', :action => 'edit'
170 170 user_actions.connect 'users/:id/memberships', :action => 'edit_membership'
171 171 user_actions.connect 'users/:id/memberships/:membership_id', :action => 'edit_membership'
172 172 user_actions.connect 'users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership'
173 173 end
174 174 end
175 175
176 176 map.with_options :controller => 'projects' do |projects|
177 177 projects.with_options :conditions => {:method => :get} do |project_views|
178 178 project_views.connect 'projects', :action => 'index'
179 179 project_views.connect 'projects.:format', :action => 'index'
180 project_views.connect 'projects/new', :action => 'add'
180 project_views.connect 'projects/new', :action => 'new'
181 181 project_views.connect 'projects/:id', :action => 'show'
182 182 project_views.connect 'projects/:id.:format', :action => 'show'
183 183 project_views.connect 'projects/:id/:action', :action => /destroy|settings/
184 184 project_views.connect 'projects/:id/files', :controller => 'files', :action => 'index'
185 185 project_views.connect 'projects/:id/files/new', :controller => 'files', :action => 'new'
186 186 project_views.connect 'projects/:id/settings/:tab', :action => 'settings'
187 187 project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new'
188 188 end
189 189
190 190 projects.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity|
191 191 activity.connect 'projects/:id/activity'
192 192 activity.connect 'projects/:id/activity.:format'
193 193 activity.connect 'activity', :id => nil
194 194 activity.connect 'activity.:format', :id => nil
195 195 end
196 196
197 197 projects.with_options :conditions => {:method => :post} do |project_actions|
198 198 project_actions.connect 'projects/new', :action => 'create'
199 199 project_actions.connect 'projects', :action => 'create'
200 200 project_actions.connect 'projects.:format', :action => 'create', :format => /xml/
201 201 project_actions.connect 'projects/:id/:action', :action => /edit|destroy|archive|unarchive/
202 202 project_actions.connect 'projects/:id/files/new', :controller => 'files', :action => 'new'
203 203 project_actions.connect 'projects/:id/activities/save', :controller => 'project_enumerations', :action => 'save'
204 204 end
205 205
206 206 projects.with_options :conditions => {:method => :put} do |project_actions|
207 207 project_actions.conditions 'projects/:id.:format', :action => 'edit', :format => /xml/
208 208 end
209 209
210 210 projects.with_options :conditions => {:method => :delete} do |project_actions|
211 211 project_actions.conditions 'projects/:id.:format', :action => 'destroy', :format => /xml/
212 212 project_actions.conditions 'projects/:id/reset_activities', :controller => 'project_enumerations', :action => 'destroy'
213 213 end
214 214 end
215 215
216 216 map.with_options :controller => 'versions' do |versions|
217 217 versions.connect 'projects/:project_id/versions/new', :action => 'new'
218 218 versions.connect 'projects/:project_id/roadmap', :action => 'index'
219 219 versions.with_options :conditions => {:method => :post} do |version_actions|
220 220 version_actions.connect 'projects/:project_id/versions/close_completed', :action => 'close_completed'
221 221 end
222 222 end
223 223
224 224 map.with_options :controller => 'issue_categories' do |categories|
225 225 categories.connect 'projects/:project_id/issue_categories/new', :action => 'new'
226 226 end
227 227
228 228 map.with_options :controller => 'repositories' do |repositories|
229 229 repositories.with_options :conditions => {:method => :get} do |repository_views|
230 230 repository_views.connect 'projects/:id/repository', :action => 'show'
231 231 repository_views.connect 'projects/:id/repository/edit', :action => 'edit'
232 232 repository_views.connect 'projects/:id/repository/statistics', :action => 'stats'
233 233 repository_views.connect 'projects/:id/repository/revisions', :action => 'revisions'
234 234 repository_views.connect 'projects/:id/repository/revisions.:format', :action => 'revisions'
235 235 repository_views.connect 'projects/:id/repository/revisions/:rev', :action => 'revision'
236 236 repository_views.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff'
237 237 repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff'
238 238 repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path', :action => 'entry', :format => 'raw', :requirements => { :rev => /[a-z0-9\.\-_]+/ }
239 239 repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path', :requirements => { :rev => /[a-z0-9\.\-_]+/ }
240 240 repository_views.connect 'projects/:id/repository/raw/*path', :action => 'entry', :format => 'raw'
241 241 # TODO: why the following route is required?
242 242 repository_views.connect 'projects/:id/repository/entry/*path', :action => 'entry'
243 243 repository_views.connect 'projects/:id/repository/:action/*path'
244 244 end
245 245
246 246 repositories.connect 'projects/:id/repository/:action', :conditions => {:method => :post}
247 247 end
248 248
249 249 map.connect 'attachments/:id', :controller => 'attachments', :action => 'show', :id => /\d+/
250 250 map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/
251 251 map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/
252 252
253 253 map.resources :groups
254 254
255 255 #left old routes at the bottom for backwards compat
256 256 map.connect 'projects/:project_id/issues/:action', :controller => 'issues'
257 257 map.connect 'projects/:project_id/documents/:action', :controller => 'documents'
258 258 map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards'
259 259 map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages'
260 260 map.connect 'wiki/:id/:page/:action', :page => nil, :controller => 'wiki'
261 261 map.connect 'issues/:issue_id/relations/:action/:id', :controller => 'issue_relations'
262 262 map.connect 'projects/:project_id/news/:action', :controller => 'news'
263 263 map.connect 'projects/:project_id/timelog/:action/:id', :controller => 'timelog', :project_id => /.+/
264 264 map.with_options :controller => 'repositories' do |omap|
265 265 omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse'
266 266 omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes'
267 267 omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff'
268 268 omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry'
269 269 omap.repositories_entry 'repositories/annotate/:id/*path', :action => 'annotate'
270 270 omap.connect 'repositories/revision/:id/:rev', :action => 'revision'
271 271 end
272 272
273 273 map.with_options :controller => 'sys' do |sys|
274 274 sys.connect 'sys/projects.:format', :action => 'projects', :conditions => {:method => :get}
275 275 sys.connect 'sys/projects/:id/repository.:format', :action => 'create_project_repository', :conditions => {:method => :post}
276 276 end
277 277
278 278 # Install the default route as the lowest priority.
279 279 map.connect ':controller/:action/:id'
280 280 map.connect 'robots.txt', :controller => 'welcome', :action => 'robots'
281 281 # Used for OpenID
282 282 map.root :controller => 'account', :action => 'login'
283 283 end
@@ -1,230 +1,230
1 1 require 'redmine/access_control'
2 2 require 'redmine/menu_manager'
3 3 require 'redmine/activity'
4 4 require 'redmine/search'
5 5 require 'redmine/custom_field_format'
6 6 require 'redmine/mime_type'
7 7 require 'redmine/core_ext'
8 8 require 'redmine/themes'
9 9 require 'redmine/hook'
10 10 require 'redmine/plugin'
11 11 require 'redmine/wiki_formatting'
12 12 require 'redmine/scm/base'
13 13
14 14 begin
15 15 require_library_or_gem 'RMagick' unless Object.const_defined?(:Magick)
16 16 rescue LoadError
17 17 # RMagick is not available
18 18 end
19 19
20 20 if RUBY_VERSION < '1.9'
21 21 require 'faster_csv'
22 22 else
23 23 require 'csv'
24 24 FCSV = CSV
25 25 end
26 26
27 27 Redmine::Scm::Base.add "Subversion"
28 28 Redmine::Scm::Base.add "Darcs"
29 29 Redmine::Scm::Base.add "Mercurial"
30 30 Redmine::Scm::Base.add "Cvs"
31 31 Redmine::Scm::Base.add "Bazaar"
32 32 Redmine::Scm::Base.add "Git"
33 33 Redmine::Scm::Base.add "Filesystem"
34 34
35 35 Redmine::CustomFieldFormat.map do |fields|
36 36 fields.register Redmine::CustomFieldFormat.new('string', :label => :label_string, :order => 1)
37 37 fields.register Redmine::CustomFieldFormat.new('text', :label => :label_text, :order => 2)
38 38 fields.register Redmine::CustomFieldFormat.new('int', :label => :label_integer, :order => 3)
39 39 fields.register Redmine::CustomFieldFormat.new('float', :label => :label_float, :order => 4)
40 40 fields.register Redmine::CustomFieldFormat.new('list', :label => :label_list, :order => 5)
41 41 fields.register Redmine::CustomFieldFormat.new('date', :label => :label_date, :order => 6)
42 42 fields.register Redmine::CustomFieldFormat.new('bool', :label => :label_boolean, :order => 7)
43 43 end
44 44
45 45 # Permissions
46 46 Redmine::AccessControl.map do |map|
47 47 map.permission :view_project, {:projects => [:show], :activities => [:index]}, :public => true
48 48 map.permission :search_project, {:search => :index}, :public => true
49 map.permission :add_project, {:projects => [:add, :create]}, :require => :loggedin
49 map.permission :add_project, {:projects => [:new, :create]}, :require => :loggedin
50 50 map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member
51 51 map.permission :select_project_modules, {:projects => :modules}, :require => :member
52 52 map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy, :autocomplete_for_member]}, :require => :member
53 53 map.permission :manage_versions, {:projects => :settings, :versions => [:new, :edit, :close_completed, :destroy]}, :require => :member
54 map.permission :add_subprojects, {:projects => [:add, :create]}, :require => :member
54 map.permission :add_subprojects, {:projects => [:new, :create]}, :require => :member
55 55
56 56 map.project_module :issue_tracking do |map|
57 57 # Issue categories
58 58 map.permission :manage_categories, {:projects => :settings, :issue_categories => [:new, :edit, :destroy]}, :require => :member
59 59 # Issues
60 60 map.permission :view_issues, {:issues => [:index, :show],
61 61 :auto_complete => [:issues],
62 62 :context_menus => [:issues],
63 63 :versions => [:index, :show, :status_by],
64 64 :journals => :index,
65 65 :queries => :index,
66 66 :reports => [:issue_report, :issue_report_details]}
67 67 map.permission :add_issues, {:issues => [:new, :create, :update_form]}
68 68 map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :bulk_update, :update_form], :journals => [:new]}
69 69 map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]}
70 70 map.permission :manage_subtasks, {}
71 71 map.permission :add_issue_notes, {:issues => [:edit, :update], :journals => [:new]}
72 72 map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin
73 73 map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin
74 74 map.permission :move_issues, {:issue_moves => [:new, :create]}, :require => :loggedin
75 75 map.permission :delete_issues, {:issues => :destroy}, :require => :member
76 76 # Queries
77 77 map.permission :manage_public_queries, {:queries => [:new, :edit, :destroy]}, :require => :member
78 78 map.permission :save_queries, {:queries => [:new, :edit, :destroy]}, :require => :loggedin
79 79 # Watchers
80 80 map.permission :view_issue_watchers, {}
81 81 map.permission :add_issue_watchers, {:watchers => :new}
82 82 map.permission :delete_issue_watchers, {:watchers => :destroy}
83 83 end
84 84
85 85 map.project_module :time_tracking do |map|
86 86 map.permission :log_time, {:timelog => :edit}, :require => :loggedin
87 87 map.permission :view_time_entries, :timelog => [:details, :report]
88 88 map.permission :edit_time_entries, {:timelog => [:edit, :destroy]}, :require => :member
89 89 map.permission :edit_own_time_entries, {:timelog => [:edit, :destroy]}, :require => :loggedin
90 90 map.permission :manage_project_activities, {:project_enumerations => [:save, :destroy]}, :require => :member
91 91 end
92 92
93 93 map.project_module :news do |map|
94 94 map.permission :manage_news, {:news => [:new, :edit, :destroy, :destroy_comment]}, :require => :member
95 95 map.permission :view_news, {:news => [:index, :show]}, :public => true
96 96 map.permission :comment_news, {:news => :add_comment}
97 97 end
98 98
99 99 map.project_module :documents do |map|
100 100 map.permission :manage_documents, {:documents => [:new, :edit, :destroy, :add_attachment]}, :require => :loggedin
101 101 map.permission :view_documents, :documents => [:index, :show, :download]
102 102 end
103 103
104 104 map.project_module :files do |map|
105 105 map.permission :manage_files, {:files => :new}, :require => :loggedin
106 106 map.permission :view_files, :files => :index, :versions => :download
107 107 end
108 108
109 109 map.project_module :wiki do |map|
110 110 map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member
111 111 map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member
112 112 map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member
113 113 map.permission :view_wiki_pages, :wiki => [:index, :special]
114 114 map.permission :export_wiki_pages, {}
115 115 map.permission :view_wiki_edits, :wiki => [:history, :diff, :annotate]
116 116 map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment]
117 117 map.permission :delete_wiki_pages_attachments, {}
118 118 map.permission :protect_wiki_pages, {:wiki => :protect}, :require => :member
119 119 end
120 120
121 121 map.project_module :repository do |map|
122 122 map.permission :manage_repository, {:repositories => [:edit, :committers, :destroy]}, :require => :member
123 123 map.permission :browse_repository, :repositories => [:show, :browse, :entry, :annotate, :changes, :diff, :stats, :graph]
124 124 map.permission :view_changesets, :repositories => [:show, :revisions, :revision]
125 125 map.permission :commit_access, {}
126 126 end
127 127
128 128 map.project_module :boards do |map|
129 129 map.permission :manage_boards, {:boards => [:new, :edit, :destroy]}, :require => :member
130 130 map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true
131 131 map.permission :add_messages, {:messages => [:new, :reply, :quote]}
132 132 map.permission :edit_messages, {:messages => :edit}, :require => :member
133 133 map.permission :edit_own_messages, {:messages => :edit}, :require => :loggedin
134 134 map.permission :delete_messages, {:messages => :destroy}, :require => :member
135 135 map.permission :delete_own_messages, {:messages => :destroy}, :require => :loggedin
136 136 end
137 137
138 138 map.project_module :calendar do |map|
139 139 map.permission :view_calendar, :calendars => [:show, :update]
140 140 end
141 141
142 142 map.project_module :gantt do |map|
143 143 map.permission :view_gantt, :gantts => [:show, :update]
144 144 end
145 145 end
146 146
147 147 Redmine::MenuManager.map :top_menu do |menu|
148 148 menu.push :home, :home_path
149 149 menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? }
150 150 menu.push :projects, { :controller => 'projects', :action => 'index' }, :caption => :label_project_plural
151 151 menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true
152 152 menu.push :help, Redmine::Info.help_url, :last => true
153 153 end
154 154
155 155 Redmine::MenuManager.map :account_menu do |menu|
156 156 menu.push :login, :signin_path, :if => Proc.new { !User.current.logged? }
157 157 menu.push :register, { :controller => 'account', :action => 'register' }, :if => Proc.new { !User.current.logged? && Setting.self_registration? }
158 158 menu.push :my_account, { :controller => 'my', :action => 'account' }, :if => Proc.new { User.current.logged? }
159 159 menu.push :logout, :signout_path, :if => Proc.new { User.current.logged? }
160 160 end
161 161
162 162 Redmine::MenuManager.map :application_menu do |menu|
163 163 # Empty
164 164 end
165 165
166 166 Redmine::MenuManager.map :admin_menu do |menu|
167 167 menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural
168 168 menu.push :users, {:controller => 'users'}, :caption => :label_user_plural
169 169 menu.push :groups, {:controller => 'groups'}, :caption => :label_group_plural
170 170 menu.push :roles, {:controller => 'roles'}, :caption => :label_role_and_permissions
171 171 menu.push :trackers, {:controller => 'trackers'}, :caption => :label_tracker_plural
172 172 menu.push :issue_statuses, {:controller => 'issue_statuses'}, :caption => :label_issue_status_plural,
173 173 :html => {:class => 'issue_statuses'}
174 174 menu.push :workflows, {:controller => 'workflows', :action => 'edit'}, :caption => :label_workflow
175 175 menu.push :custom_fields, {:controller => 'custom_fields'}, :caption => :label_custom_field_plural,
176 176 :html => {:class => 'custom_fields'}
177 177 menu.push :enumerations, {:controller => 'enumerations'}
178 178 menu.push :settings, {:controller => 'settings'}
179 179 menu.push :ldap_authentication, {:controller => 'ldap_auth_sources', :action => 'index'},
180 180 :html => {:class => 'server_authentication'}
181 181 menu.push :plugins, {:controller => 'admin', :action => 'plugins'}, :last => true
182 182 menu.push :info, {:controller => 'admin', :action => 'info'}, :caption => :label_information_plural, :last => true
183 183 end
184 184
185 185 Redmine::MenuManager.map :project_menu do |menu|
186 186 menu.push :overview, { :controller => 'projects', :action => 'show' }
187 187 menu.push :activity, { :controller => 'activities', :action => 'index' }
188 188 menu.push :roadmap, { :controller => 'versions', :action => 'index' }, :param => :project_id,
189 189 :if => Proc.new { |p| p.shared_versions.any? }
190 190 menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural
191 191 menu.push :new_issue, { :controller => 'issues', :action => 'new' }, :param => :project_id, :caption => :label_issue_new,
192 192 :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) }
193 193 menu.push :gantt, { :controller => 'gantts', :action => 'show' }, :param => :project_id, :caption => :label_gantt
194 194 menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :param => :project_id, :caption => :label_calendar
195 195 menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural
196 196 menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural
197 197 menu.push :wiki, { :controller => 'wiki', :action => 'index', :page => nil },
198 198 :if => Proc.new { |p| p.wiki && !p.wiki.new_record? }
199 199 menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id,
200 200 :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural
201 201 menu.push :files, { :controller => 'files', :action => 'index' }, :caption => :label_file_plural
202 202 menu.push :repository, { :controller => 'repositories', :action => 'show' },
203 203 :if => Proc.new { |p| p.repository && !p.repository.new_record? }
204 204 menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true
205 205 end
206 206
207 207 Redmine::Activity.map do |activity|
208 208 activity.register :issues, :class_name => %w(Issue Journal)
209 209 activity.register :changesets
210 210 activity.register :news
211 211 activity.register :documents, :class_name => %w(Document Attachment)
212 212 activity.register :files, :class_name => 'Attachment'
213 213 activity.register :wiki_edits, :class_name => 'WikiContent::Version', :default => false
214 214 activity.register :messages, :default => false
215 215 activity.register :time_entries, :default => false
216 216 end
217 217
218 218 Redmine::Search.map do |search|
219 219 search.register :issues
220 220 search.register :news
221 221 search.register :documents
222 222 search.register :changesets
223 223 search.register :wiki_pages
224 224 search.register :messages
225 225 search.register :projects
226 226 end
227 227
228 228 Redmine::WikiFormatting.map do |format|
229 229 format.register :textile, Redmine::WikiFormatting::Textile::Formatter, Redmine::WikiFormatting::Textile::Helper
230 230 end
@@ -1,427 +1,427
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2008 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.dirname(__FILE__) + '/../test_helper'
19 19 require 'projects_controller'
20 20
21 21 # Re-raise errors caught by the controller.
22 22 class ProjectsController; def rescue_action(e) raise e end; end
23 23
24 24 class ProjectsControllerTest < ActionController::TestCase
25 25 fixtures :projects, :versions, :users, :roles, :members, :member_roles, :issues, :journals, :journal_details,
26 26 :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages,
27 27 :attachments, :custom_fields, :custom_values, :time_entries
28 28
29 29 def setup
30 30 @controller = ProjectsController.new
31 31 @request = ActionController::TestRequest.new
32 32 @response = ActionController::TestResponse.new
33 33 @request.session[:user_id] = nil
34 34 Setting.default_language = 'en'
35 35 end
36 36
37 37 def test_index
38 38 get :index
39 39 assert_response :success
40 40 assert_template 'index'
41 41 assert_not_nil assigns(:projects)
42 42
43 43 assert_tag :ul, :child => {:tag => 'li',
44 44 :descendant => {:tag => 'a', :content => 'eCookbook'},
45 45 :child => { :tag => 'ul',
46 46 :descendant => { :tag => 'a',
47 47 :content => 'Child of private child'
48 48 }
49 49 }
50 50 }
51 51
52 52 assert_no_tag :a, :content => /Private child of eCookbook/
53 53 end
54 54
55 55 def test_index_atom
56 56 get :index, :format => 'atom'
57 57 assert_response :success
58 58 assert_template 'common/feed.atom.rxml'
59 59 assert_select 'feed>title', :text => 'Redmine: Latest projects'
60 60 assert_select 'feed>entry', :count => Project.count(:conditions => Project.visible_by(User.current))
61 61 end
62 62
63 63 context "#index" do
64 64 context "by non-admin user with view_time_entries permission" do
65 65 setup do
66 66 @request.session[:user_id] = 3
67 67 end
68 68 should "show overall spent time link" do
69 69 get :index
70 70 assert_template 'index'
71 71 assert_tag :a, :attributes => {:href => '/time_entries'}
72 72 end
73 73 end
74 74
75 75 context "by non-admin user without view_time_entries permission" do
76 76 setup do
77 77 Role.find(2).remove_permission! :view_time_entries
78 78 Role.non_member.remove_permission! :view_time_entries
79 79 Role.anonymous.remove_permission! :view_time_entries
80 80 @request.session[:user_id] = 3
81 81 end
82 82 should "not show overall spent time link" do
83 83 get :index
84 84 assert_template 'index'
85 85 assert_no_tag :a, :attributes => {:href => '/time_entries'}
86 86 end
87 87 end
88 88 end
89 89
90 context "#add" do
90 context "#new" do
91 91 context "by admin user" do
92 92 setup do
93 93 @request.session[:user_id] = 1
94 94 end
95 95
96 96 should "accept get" do
97 get :add
97 get :new
98 98 assert_response :success
99 assert_template 'add'
99 assert_template 'new'
100 100 end
101 101
102 102 end
103 103
104 104 context "by non-admin user with add_project permission" do
105 105 setup do
106 106 Role.non_member.add_permission! :add_project
107 107 @request.session[:user_id] = 9
108 108 end
109 109
110 110 should "accept get" do
111 get :add
111 get :new
112 112 assert_response :success
113 assert_template 'add'
113 assert_template 'new'
114 114 assert_no_tag :select, :attributes => {:name => 'project[parent_id]'}
115 115 end
116 116 end
117 117
118 118 context "by non-admin user with add_subprojects permission" do
119 119 setup do
120 120 Role.find(1).remove_permission! :add_project
121 121 Role.find(1).add_permission! :add_subprojects
122 122 @request.session[:user_id] = 2
123 123 end
124 124
125 125 should "accept get" do
126 get :add, :parent_id => 'ecookbook'
126 get :new, :parent_id => 'ecookbook'
127 127 assert_response :success
128 assert_template 'add'
128 assert_template 'new'
129 129 # parent project selected
130 130 assert_tag :select, :attributes => {:name => 'project[parent_id]'},
131 131 :child => {:tag => 'option', :attributes => {:value => '1', :selected => 'selected'}}
132 132 # no empty value
133 133 assert_no_tag :select, :attributes => {:name => 'project[parent_id]'},
134 134 :child => {:tag => 'option', :attributes => {:value => ''}}
135 135 end
136 136 end
137 137
138 138 end
139 139
140 140 context "POST :create" do
141 141 context "by admin user" do
142 142 setup do
143 143 @request.session[:user_id] = 1
144 144 end
145 145
146 146 should "create a new project" do
147 147 post :create, :project => { :name => "blog",
148 148 :description => "weblog",
149 149 :identifier => "blog",
150 150 :is_public => 1,
151 151 :custom_field_values => { '3' => 'Beta' }
152 152 }
153 153 assert_redirected_to '/projects/blog/settings'
154 154
155 155 project = Project.find_by_name('blog')
156 156 assert_kind_of Project, project
157 157 assert_equal 'weblog', project.description
158 158 assert_equal true, project.is_public?
159 159 assert_nil project.parent
160 160 end
161 161
162 162 should "create a new subproject" do
163 163 post :create, :project => { :name => "blog",
164 164 :description => "weblog",
165 165 :identifier => "blog",
166 166 :is_public => 1,
167 167 :custom_field_values => { '3' => 'Beta' },
168 168 :parent_id => 1
169 169 }
170 170 assert_redirected_to '/projects/blog/settings'
171 171
172 172 project = Project.find_by_name('blog')
173 173 assert_kind_of Project, project
174 174 assert_equal Project.find(1), project.parent
175 175 end
176 176 end
177 177
178 178 context "by non-admin user with add_project permission" do
179 179 setup do
180 180 Role.non_member.add_permission! :add_project
181 181 @request.session[:user_id] = 9
182 182 end
183 183
184 184 should "accept create a Project" do
185 185 post :create, :project => { :name => "blog",
186 186 :description => "weblog",
187 187 :identifier => "blog",
188 188 :is_public => 1,
189 189 :custom_field_values => { '3' => 'Beta' }
190 190 }
191 191
192 192 assert_redirected_to '/projects/blog/settings'
193 193
194 194 project = Project.find_by_name('blog')
195 195 assert_kind_of Project, project
196 196 assert_equal 'weblog', project.description
197 197 assert_equal true, project.is_public?
198 198
199 199 # User should be added as a project member
200 200 assert User.find(9).member_of?(project)
201 201 assert_equal 1, project.members.size
202 202 end
203 203
204 204 should "fail with parent_id" do
205 205 assert_no_difference 'Project.count' do
206 206 post :create, :project => { :name => "blog",
207 207 :description => "weblog",
208 208 :identifier => "blog",
209 209 :is_public => 1,
210 210 :custom_field_values => { '3' => 'Beta' },
211 211 :parent_id => 1
212 212 }
213 213 end
214 214 assert_response :success
215 215 project = assigns(:project)
216 216 assert_kind_of Project, project
217 217 assert_not_nil project.errors.on(:parent_id)
218 218 end
219 219 end
220 220
221 221 context "by non-admin user with add_subprojects permission" do
222 222 setup do
223 223 Role.find(1).remove_permission! :add_project
224 224 Role.find(1).add_permission! :add_subprojects
225 225 @request.session[:user_id] = 2
226 226 end
227 227
228 228 should "create a project with a parent_id" do
229 229 post :create, :project => { :name => "blog",
230 230 :description => "weblog",
231 231 :identifier => "blog",
232 232 :is_public => 1,
233 233 :custom_field_values => { '3' => 'Beta' },
234 234 :parent_id => 1
235 235 }
236 236 assert_redirected_to '/projects/blog/settings'
237 237 project = Project.find_by_name('blog')
238 238 end
239 239
240 240 should "fail without parent_id" do
241 241 assert_no_difference 'Project.count' do
242 242 post :create, :project => { :name => "blog",
243 243 :description => "weblog",
244 244 :identifier => "blog",
245 245 :is_public => 1,
246 246 :custom_field_values => { '3' => 'Beta' }
247 247 }
248 248 end
249 249 assert_response :success
250 250 project = assigns(:project)
251 251 assert_kind_of Project, project
252 252 assert_not_nil project.errors.on(:parent_id)
253 253 end
254 254
255 255 should "fail with unauthorized parent_id" do
256 256 assert !User.find(2).member_of?(Project.find(6))
257 257 assert_no_difference 'Project.count' do
258 258 post :create, :project => { :name => "blog",
259 259 :description => "weblog",
260 260 :identifier => "blog",
261 261 :is_public => 1,
262 262 :custom_field_values => { '3' => 'Beta' },
263 263 :parent_id => 6
264 264 }
265 265 end
266 266 assert_response :success
267 267 project = assigns(:project)
268 268 assert_kind_of Project, project
269 269 assert_not_nil project.errors.on(:parent_id)
270 270 end
271 271 end
272 272 end
273 273
274 274 def test_show_by_id
275 275 get :show, :id => 1
276 276 assert_response :success
277 277 assert_template 'show'
278 278 assert_not_nil assigns(:project)
279 279 end
280 280
281 281 def test_show_by_identifier
282 282 get :show, :id => 'ecookbook'
283 283 assert_response :success
284 284 assert_template 'show'
285 285 assert_not_nil assigns(:project)
286 286 assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
287 287 end
288 288
289 289 def test_show_should_not_fail_when_custom_values_are_nil
290 290 project = Project.find_by_identifier('ecookbook')
291 291 project.custom_values.first.update_attribute(:value, nil)
292 292 get :show, :id => 'ecookbook'
293 293 assert_response :success
294 294 assert_template 'show'
295 295 assert_not_nil assigns(:project)
296 296 assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
297 297 end
298 298
299 299 def test_private_subprojects_hidden
300 300 get :show, :id => 'ecookbook'
301 301 assert_response :success
302 302 assert_template 'show'
303 303 assert_no_tag :tag => 'a', :content => /Private child/
304 304 end
305 305
306 306 def test_private_subprojects_visible
307 307 @request.session[:user_id] = 2 # manager who is a member of the private subproject
308 308 get :show, :id => 'ecookbook'
309 309 assert_response :success
310 310 assert_template 'show'
311 311 assert_tag :tag => 'a', :content => /Private child/
312 312 end
313 313
314 314 def test_settings
315 315 @request.session[:user_id] = 2 # manager
316 316 get :settings, :id => 1
317 317 assert_response :success
318 318 assert_template 'settings'
319 319 end
320 320
321 321 def test_edit
322 322 @request.session[:user_id] = 2 # manager
323 323 post :edit, :id => 1, :project => {:name => 'Test changed name',
324 324 :issue_custom_field_ids => ['']}
325 325 assert_redirected_to 'projects/ecookbook/settings'
326 326 project = Project.find(1)
327 327 assert_equal 'Test changed name', project.name
328 328 end
329 329
330 330 def test_get_destroy
331 331 @request.session[:user_id] = 1 # admin
332 332 get :destroy, :id => 1
333 333 assert_response :success
334 334 assert_template 'destroy'
335 335 assert_not_nil Project.find_by_id(1)
336 336 end
337 337
338 338 def test_post_destroy
339 339 @request.session[:user_id] = 1 # admin
340 340 post :destroy, :id => 1, :confirm => 1
341 341 assert_redirected_to 'admin/projects'
342 342 assert_nil Project.find_by_id(1)
343 343 end
344 344
345 345 def test_archive
346 346 @request.session[:user_id] = 1 # admin
347 347 post :archive, :id => 1
348 348 assert_redirected_to 'admin/projects'
349 349 assert !Project.find(1).active?
350 350 end
351 351
352 352 def test_unarchive
353 353 @request.session[:user_id] = 1 # admin
354 354 Project.find(1).archive
355 355 post :unarchive, :id => 1
356 356 assert_redirected_to 'admin/projects'
357 357 assert Project.find(1).active?
358 358 end
359 359
360 360 def test_project_breadcrumbs_should_be_limited_to_3_ancestors
361 361 CustomField.delete_all
362 362 parent = nil
363 363 6.times do |i|
364 364 p = Project.create!(:name => "Breadcrumbs #{i}", :identifier => "breadcrumbs-#{i}")
365 365 p.set_parent!(parent)
366 366 get :show, :id => p
367 367 assert_tag :h1, :parent => { :attributes => {:id => 'header'}},
368 368 :children => { :count => [i, 3].min,
369 369 :only => { :tag => 'a' } }
370 370
371 371 parent = p
372 372 end
373 373 end
374 374
375 375 def test_copy_with_project
376 376 @request.session[:user_id] = 1 # admin
377 377 get :copy, :id => 1
378 378 assert_response :success
379 379 assert_template 'copy'
380 380 assert assigns(:project)
381 381 assert_equal Project.find(1).description, assigns(:project).description
382 382 assert_nil assigns(:project).id
383 383 end
384 384
385 385 def test_copy_without_project
386 386 @request.session[:user_id] = 1 # admin
387 387 get :copy
388 388 assert_response :redirect
389 389 assert_redirected_to :controller => 'admin', :action => 'projects'
390 390 end
391 391
392 392 def test_jump_should_redirect_to_active_tab
393 393 get :show, :id => 1, :jump => 'issues'
394 394 assert_redirected_to 'projects/ecookbook/issues'
395 395 end
396 396
397 397 def test_jump_should_not_redirect_to_inactive_tab
398 398 get :show, :id => 3, :jump => 'documents'
399 399 assert_response :success
400 400 assert_template 'show'
401 401 end
402 402
403 403 def test_jump_should_not_redirect_to_unknown_tab
404 404 get :show, :id => 3, :jump => 'foobar'
405 405 assert_response :success
406 406 assert_template 'show'
407 407 end
408 408
409 409 # A hook that is manually registered later
410 410 class ProjectBasedTemplate < Redmine::Hook::ViewListener
411 411 def view_layouts_base_html_head(context)
412 412 # Adds a project stylesheet
413 413 stylesheet_link_tag(context[:project].identifier) if context[:project]
414 414 end
415 415 end
416 416 # Don't use this hook now
417 417 Redmine::Hook.clear_listeners
418 418
419 419 def test_hook_response
420 420 Redmine::Hook.add_listener(ProjectBasedTemplate)
421 421 get :show, :id => 1
422 422 assert_tag :tag => 'link', :attributes => {:href => '/stylesheets/ecookbook.css'},
423 423 :parent => {:tag => 'head'}
424 424
425 425 Redmine::Hook.clear_listeners
426 426 end
427 427 end
@@ -1,291 +1,291
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2010 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require "#{File.dirname(__FILE__)}/../test_helper"
19 19
20 20 class RoutingTest < ActionController::IntegrationTest
21 21 context "activities" do
22 22 should_route :get, "/activity", :controller => 'activities', :action => 'index', :id => nil
23 23 should_route :get, "/activity.atom", :controller => 'activities', :action => 'index', :id => nil, :format => 'atom'
24 24 end
25 25
26 26 context "attachments" do
27 27 should_route :get, "/attachments/1", :controller => 'attachments', :action => 'show', :id => '1'
28 28 should_route :get, "/attachments/1/filename.ext", :controller => 'attachments', :action => 'show', :id => '1', :filename => 'filename.ext'
29 29 should_route :get, "/attachments/download/1", :controller => 'attachments', :action => 'download', :id => '1'
30 30 should_route :get, "/attachments/download/1/filename.ext", :controller => 'attachments', :action => 'download', :id => '1', :filename => 'filename.ext'
31 31 end
32 32
33 33 context "boards" do
34 34 should_route :get, "/projects/world_domination/boards", :controller => 'boards', :action => 'index', :project_id => 'world_domination'
35 35 should_route :get, "/projects/world_domination/boards/new", :controller => 'boards', :action => 'new', :project_id => 'world_domination'
36 36 should_route :get, "/projects/world_domination/boards/44", :controller => 'boards', :action => 'show', :project_id => 'world_domination', :id => '44'
37 37 should_route :get, "/projects/world_domination/boards/44.atom", :controller => 'boards', :action => 'show', :project_id => 'world_domination', :id => '44', :format => 'atom'
38 38 should_route :get, "/projects/world_domination/boards/44/edit", :controller => 'boards', :action => 'edit', :project_id => 'world_domination', :id => '44'
39 39
40 40 should_route :post, "/projects/world_domination/boards/new", :controller => 'boards', :action => 'new', :project_id => 'world_domination'
41 41 should_route :post, "/projects/world_domination/boards/44/edit", :controller => 'boards', :action => 'edit', :project_id => 'world_domination', :id => '44'
42 42 should_route :post, "/projects/world_domination/boards/44/destroy", :controller => 'boards', :action => 'destroy', :project_id => 'world_domination', :id => '44'
43 43
44 44 end
45 45
46 46 context "documents" do
47 47 should_route :get, "/projects/567/documents", :controller => 'documents', :action => 'index', :project_id => '567'
48 48 should_route :get, "/projects/567/documents/new", :controller => 'documents', :action => 'new', :project_id => '567'
49 49 should_route :get, "/documents/22", :controller => 'documents', :action => 'show', :id => '22'
50 50 should_route :get, "/documents/22/edit", :controller => 'documents', :action => 'edit', :id => '22'
51 51
52 52 should_route :post, "/projects/567/documents/new", :controller => 'documents', :action => 'new', :project_id => '567'
53 53 should_route :post, "/documents/567/edit", :controller => 'documents', :action => 'edit', :id => '567'
54 54 should_route :post, "/documents/567/destroy", :controller => 'documents', :action => 'destroy', :id => '567'
55 55 end
56 56
57 57 context "issues" do
58 58 # REST actions
59 59 should_route :get, "/issues", :controller => 'issues', :action => 'index'
60 60 should_route :get, "/issues.pdf", :controller => 'issues', :action => 'index', :format => 'pdf'
61 61 should_route :get, "/issues.atom", :controller => 'issues', :action => 'index', :format => 'atom'
62 62 should_route :get, "/issues.xml", :controller => 'issues', :action => 'index', :format => 'xml'
63 63 should_route :get, "/projects/23/issues", :controller => 'issues', :action => 'index', :project_id => '23'
64 64 should_route :get, "/projects/23/issues.pdf", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'pdf'
65 65 should_route :get, "/projects/23/issues.atom", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'atom'
66 66 should_route :get, "/projects/23/issues.xml", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'xml'
67 67 should_route :get, "/issues/64", :controller => 'issues', :action => 'show', :id => '64'
68 68 should_route :get, "/issues/64.pdf", :controller => 'issues', :action => 'show', :id => '64', :format => 'pdf'
69 69 should_route :get, "/issues/64.atom", :controller => 'issues', :action => 'show', :id => '64', :format => 'atom'
70 70 should_route :get, "/issues/64.xml", :controller => 'issues', :action => 'show', :id => '64', :format => 'xml'
71 71
72 72 should_route :get, "/projects/23/issues/new", :controller => 'issues', :action => 'new', :project_id => '23'
73 73 should_route :post, "/projects/23/issues", :controller => 'issues', :action => 'create', :project_id => '23'
74 74 should_route :post, "/issues.xml", :controller => 'issues', :action => 'create', :format => 'xml'
75 75
76 76 should_route :get, "/issues/64/edit", :controller => 'issues', :action => 'edit', :id => '64'
77 77 # TODO: Should use PUT
78 78 should_route :post, "/issues/64/edit", :controller => 'issues', :action => 'edit', :id => '64'
79 79 should_route :put, "/issues/1.xml", :controller => 'issues', :action => 'update', :id => '1', :format => 'xml'
80 80
81 81 # TODO: Should use DELETE
82 82 should_route :post, "/issues/64/destroy", :controller => 'issues', :action => 'destroy', :id => '64'
83 83 should_route :delete, "/issues/1.xml", :controller => 'issues', :action => 'destroy', :id => '1', :format => 'xml'
84 84
85 85 # Extra actions
86 86 should_route :get, "/projects/23/issues/64/copy", :controller => 'issues', :action => 'new', :project_id => '23', :copy_from => '64'
87 87
88 88 should_route :get, "/issues/move/new", :controller => 'issue_moves', :action => 'new'
89 89 should_route :post, "/issues/move", :controller => 'issue_moves', :action => 'create'
90 90
91 91 should_route :post, "/issues/1/quoted", :controller => 'journals', :action => 'new', :id => '1'
92 92
93 93 should_route :get, "/issues/calendar", :controller => 'calendars', :action => 'show'
94 94 should_route :put, "/issues/calendar", :controller => 'calendars', :action => 'update'
95 95 should_route :get, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'show', :project_id => 'project-name'
96 96 should_route :put, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'update', :project_id => 'project-name'
97 97
98 98 should_route :get, "/issues/gantt", :controller => 'gantts', :action => 'show'
99 99 should_route :put, "/issues/gantt", :controller => 'gantts', :action => 'update'
100 100 should_route :get, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'show', :project_id => 'project-name'
101 101 should_route :put, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'update', :project_id => 'project-name'
102 102
103 103 should_route :get, "/issues/auto_complete", :controller => 'auto_completes', :action => 'issues'
104 104
105 105 should_route :get, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123'
106 106 should_route :post, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123'
107 107 should_route :get, "/issues/context_menu", :controller => 'context_menus', :action => 'issues'
108 108 should_route :post, "/issues/context_menu", :controller => 'context_menus', :action => 'issues'
109 109
110 110 should_route :get, "/issues/changes", :controller => 'journals', :action => 'index'
111 111
112 112 should_route :get, "/issues/bulk_edit", :controller => 'issues', :action => 'bulk_edit'
113 113 should_route :post, "/issues/bulk_edit", :controller => 'issues', :action => 'bulk_update'
114 114 end
115 115
116 116 context "issue categories" do
117 117 should_route :get, "/projects/test/issue_categories/new", :controller => 'issue_categories', :action => 'new', :project_id => 'test'
118 118
119 119 should_route :post, "/projects/test/issue_categories/new", :controller => 'issue_categories', :action => 'new', :project_id => 'test'
120 120 end
121 121
122 122 context "issue relations" do
123 123 should_route :post, "/issues/1/relations", :controller => 'issue_relations', :action => 'new', :issue_id => '1'
124 124 should_route :post, "/issues/1/relations/23/destroy", :controller => 'issue_relations', :action => 'destroy', :issue_id => '1', :id => '23'
125 125 end
126 126
127 127 context "issue reports" do
128 128 should_route :get, "/projects/567/issues/report", :controller => 'reports', :action => 'issue_report', :id => '567'
129 129 should_route :get, "/projects/567/issues/report/assigned_to", :controller => 'reports', :action => 'issue_report_details', :id => '567', :detail => 'assigned_to'
130 130 end
131 131
132 132 context "members" do
133 133 should_route :post, "/projects/5234/members/new", :controller => 'members', :action => 'new', :id => '5234'
134 134 end
135 135
136 136 context "messages" do
137 137 should_route :get, "/boards/22/topics/2", :controller => 'messages', :action => 'show', :id => '2', :board_id => '22'
138 138 should_route :get, "/boards/lala/topics/new", :controller => 'messages', :action => 'new', :board_id => 'lala'
139 139 should_route :get, "/boards/lala/topics/22/edit", :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala'
140 140
141 141 should_route :post, "/boards/lala/topics/new", :controller => 'messages', :action => 'new', :board_id => 'lala'
142 142 should_route :post, "/boards/lala/topics/22/edit", :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala'
143 143 should_route :post, "/boards/22/topics/555/replies", :controller => 'messages', :action => 'reply', :id => '555', :board_id => '22'
144 144 should_route :post, "/boards/22/topics/555/destroy", :controller => 'messages', :action => 'destroy', :id => '555', :board_id => '22'
145 145 end
146 146
147 147 context "news" do
148 148 should_route :get, "/news", :controller => 'news', :action => 'index'
149 149 should_route :get, "/news.atom", :controller => 'news', :action => 'index', :format => 'atom'
150 150 should_route :get, "/news.xml", :controller => 'news', :action => 'index', :format => 'xml'
151 151 should_route :get, "/news.json", :controller => 'news', :action => 'index', :format => 'json'
152 152 should_route :get, "/projects/567/news", :controller => 'news', :action => 'index', :project_id => '567'
153 153 should_route :get, "/projects/567/news.atom", :controller => 'news', :action => 'index', :format => 'atom', :project_id => '567'
154 154 should_route :get, "/projects/567/news.xml", :controller => 'news', :action => 'index', :format => 'xml', :project_id => '567'
155 155 should_route :get, "/projects/567/news.json", :controller => 'news', :action => 'index', :format => 'json', :project_id => '567'
156 156 should_route :get, "/news/2", :controller => 'news', :action => 'show', :id => '2'
157 157 should_route :get, "/projects/567/news/new", :controller => 'news', :action => 'new', :project_id => '567'
158 158 should_route :get, "/news/234", :controller => 'news', :action => 'show', :id => '234'
159 159
160 160 should_route :post, "/projects/567/news/new", :controller => 'news', :action => 'new', :project_id => '567'
161 161 should_route :post, "/news/567/edit", :controller => 'news', :action => 'edit', :id => '567'
162 162 should_route :post, "/news/567/destroy", :controller => 'news', :action => 'destroy', :id => '567'
163 163 end
164 164
165 165 context "projects" do
166 166 should_route :get, "/projects", :controller => 'projects', :action => 'index'
167 167 should_route :get, "/projects.atom", :controller => 'projects', :action => 'index', :format => 'atom'
168 168 should_route :get, "/projects.xml", :controller => 'projects', :action => 'index', :format => 'xml'
169 should_route :get, "/projects/new", :controller => 'projects', :action => 'add'
169 should_route :get, "/projects/new", :controller => 'projects', :action => 'new'
170 170 should_route :get, "/projects/test", :controller => 'projects', :action => 'show', :id => 'test'
171 171 should_route :get, "/projects/1.xml", :controller => 'projects', :action => 'show', :id => '1', :format => 'xml'
172 172 should_route :get, "/projects/4223/settings", :controller => 'projects', :action => 'settings', :id => '4223'
173 173 should_route :get, "/projects/4223/settings/members", :controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members'
174 174 should_route :get, "/projects/567/destroy", :controller => 'projects', :action => 'destroy', :id => '567'
175 175 should_route :get, "/projects/33/files", :controller => 'files', :action => 'index', :id => '33'
176 176 should_route :get, "/projects/33/files/new", :controller => 'files', :action => 'new', :id => '33'
177 177 should_route :get, "/projects/33/roadmap", :controller => 'versions', :action => 'index', :project_id => '33'
178 178 should_route :get, "/projects/33/activity", :controller => 'activities', :action => 'index', :id => '33'
179 179 should_route :get, "/projects/33/activity.atom", :controller => 'activities', :action => 'index', :id => '33', :format => 'atom'
180 180
181 181 should_route :post, "/projects/new", :controller => 'projects', :action => 'create'
182 182 should_route :post, "/projects.xml", :controller => 'projects', :action => 'create', :format => 'xml'
183 183 should_route :post, "/projects/4223/edit", :controller => 'projects', :action => 'edit', :id => '4223'
184 184 should_route :post, "/projects/64/destroy", :controller => 'projects', :action => 'destroy', :id => '64'
185 185 should_route :post, "/projects/33/files/new", :controller => 'files', :action => 'new', :id => '33'
186 186 should_route :post, "/projects/64/archive", :controller => 'projects', :action => 'archive', :id => '64'
187 187 should_route :post, "/projects/64/unarchive", :controller => 'projects', :action => 'unarchive', :id => '64'
188 188 should_route :post, "/projects/64/activities/save", :controller => 'project_enumerations', :action => 'save', :id => '64'
189 189
190 190 should_route :put, "/projects/1.xml", :controller => 'projects', :action => 'edit', :id => '1', :format => 'xml'
191 191
192 192 should_route :delete, "/projects/1.xml", :controller => 'projects', :action => 'destroy', :id => '1', :format => 'xml'
193 193 should_route :delete, "/projects/64/reset_activities", :controller => 'project_enumerations', :action => 'destroy', :id => '64'
194 194 end
195 195
196 196 context "repositories" do
197 197 should_route :get, "/projects/redmine/repository", :controller => 'repositories', :action => 'show', :id => 'redmine'
198 198 should_route :get, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine'
199 199 should_route :get, "/projects/redmine/repository/revisions", :controller => 'repositories', :action => 'revisions', :id => 'redmine'
200 200 should_route :get, "/projects/redmine/repository/revisions.atom", :controller => 'repositories', :action => 'revisions', :id => 'redmine', :format => 'atom'
201 201 should_route :get, "/projects/redmine/repository/revisions/2457", :controller => 'repositories', :action => 'revision', :id => 'redmine', :rev => '2457'
202 202 should_route :get, "/projects/redmine/repository/revisions/2457/diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457'
203 203 should_route :get, "/projects/redmine/repository/revisions/2457/diff.diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457', :format => 'diff'
204 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 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 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 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 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 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 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 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 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 213 should_route :get, "/projects/redmine/repository/statistics", :controller => 'repositories', :action => 'stats', :id => 'redmine'
214 214
215 215
216 216 should_route :post, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine'
217 217 end
218 218
219 219 context "timelogs" do
220 220 should_route :get, "/issues/567/time_entries/new", :controller => 'timelog', :action => 'edit', :issue_id => '567'
221 221 should_route :get, "/projects/ecookbook/time_entries/new", :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook'
222 222 should_route :get, "/projects/ecookbook/issues/567/time_entries/new", :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook', :issue_id => '567'
223 223 should_route :get, "/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22'
224 224 should_route :get, "/time_entries/report", :controller => 'timelog', :action => 'report'
225 225 should_route :get, "/projects/567/time_entries/report", :controller => 'timelog', :action => 'report', :project_id => '567'
226 226 should_route :get, "/projects/567/time_entries/report.csv", :controller => 'timelog', :action => 'report', :project_id => '567', :format => 'csv'
227 227 should_route :get, "/time_entries", :controller => 'timelog', :action => 'details'
228 228 should_route :get, "/time_entries.csv", :controller => 'timelog', :action => 'details', :format => 'csv'
229 229 should_route :get, "/time_entries.atom", :controller => 'timelog', :action => 'details', :format => 'atom'
230 230 should_route :get, "/projects/567/time_entries", :controller => 'timelog', :action => 'details', :project_id => '567'
231 231 should_route :get, "/projects/567/time_entries.csv", :controller => 'timelog', :action => 'details', :project_id => '567', :format => 'csv'
232 232 should_route :get, "/projects/567/time_entries.atom", :controller => 'timelog', :action => 'details', :project_id => '567', :format => 'atom'
233 233 should_route :get, "/issues/234/time_entries", :controller => 'timelog', :action => 'details', :issue_id => '234'
234 234 should_route :get, "/issues/234/time_entries.csv", :controller => 'timelog', :action => 'details', :issue_id => '234', :format => 'csv'
235 235 should_route :get, "/issues/234/time_entries.atom", :controller => 'timelog', :action => 'details', :issue_id => '234', :format => 'atom'
236 236 should_route :get, "/projects/ecookbook/issues/123/time_entries", :controller => 'timelog', :action => 'details', :project_id => 'ecookbook', :issue_id => '123'
237 237
238 238 should_route :post, "/time_entries/55/destroy", :controller => 'timelog', :action => 'destroy', :id => '55'
239 239 end
240 240
241 241 context "users" do
242 242 should_route :get, "/users", :controller => 'users', :action => 'index'
243 243 should_route :get, "/users/44", :controller => 'users', :action => 'show', :id => '44'
244 244 should_route :get, "/users/new", :controller => 'users', :action => 'add'
245 245 should_route :get, "/users/444/edit", :controller => 'users', :action => 'edit', :id => '444'
246 246 should_route :get, "/users/222/edit/membership", :controller => 'users', :action => 'edit', :id => '222', :tab => 'membership'
247 247
248 248 should_route :post, "/users/new", :controller => 'users', :action => 'add'
249 249 should_route :post, "/users/444/edit", :controller => 'users', :action => 'edit', :id => '444'
250 250 should_route :post, "/users/123/memberships", :controller => 'users', :action => 'edit_membership', :id => '123'
251 251 should_route :post, "/users/123/memberships/55", :controller => 'users', :action => 'edit_membership', :id => '123', :membership_id => '55'
252 252 should_route :post, "/users/567/memberships/12/destroy", :controller => 'users', :action => 'destroy_membership', :id => '567', :membership_id => '12'
253 253 end
254 254
255 255 context "versions" do
256 256 should_route :get, "/projects/foo/versions/new", :controller => 'versions', :action => 'new', :project_id => 'foo'
257 257
258 258 should_route :post, "/projects/foo/versions/new", :controller => 'versions', :action => 'new', :project_id => 'foo'
259 259 end
260 260
261 261 context "wiki (singular, project's pages)" do
262 262 should_route :get, "/projects/567/wiki", :controller => 'wiki', :action => 'index', :id => '567'
263 263 should_route :get, "/projects/567/wiki/lalala", :controller => 'wiki', :action => 'index', :id => '567', :page => 'lalala'
264 264 should_route :get, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page'
265 265 should_route :get, "/projects/1/wiki/CookBook_documentation/history", :controller => 'wiki', :action => 'history', :id => '1', :page => 'CookBook_documentation'
266 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 267 should_route :get, "/projects/1/wiki/CookBook_documentation/annotate/2", :controller => 'wiki', :action => 'annotate', :id => '1', :page => 'CookBook_documentation', :version => '2'
268 268 should_route :get, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida'
269 269 should_route :get, "/projects/567/wiki/page_index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'page_index'
270 270 should_route :get, "/projects/567/wiki/Page_Index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'Page_Index'
271 271 should_route :get, "/projects/567/wiki/date_index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'date_index'
272 272 should_route :get, "/projects/567/wiki/export", :controller => 'wiki', :action => 'special', :id => '567', :page => 'export'
273 273
274 274 should_route :post, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page'
275 275 should_route :post, "/projects/567/wiki/CookBook_documentation/preview", :controller => 'wiki', :action => 'preview', :id => '567', :page => 'CookBook_documentation'
276 276 should_route :post, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida'
277 277 should_route :post, "/projects/22/wiki/ladida/destroy", :controller => 'wiki', :action => 'destroy', :id => '22', :page => 'ladida'
278 278 should_route :post, "/projects/22/wiki/ladida/protect", :controller => 'wiki', :action => 'protect', :id => '22', :page => 'ladida'
279 279 end
280 280
281 281 context "wikis (plural, admin setup)" do
282 282 should_route :get, "/projects/ladida/wiki/destroy", :controller => 'wikis', :action => 'destroy', :id => 'ladida'
283 283
284 284 should_route :post, "/projects/ladida/wiki", :controller => 'wikis', :action => 'edit', :id => 'ladida'
285 285 should_route :post, "/projects/ladida/wiki/destroy", :controller => 'wikis', :action => 'destroy', :id => 'ladida'
286 286 end
287 287
288 288 context "administration panel" do
289 289 should_route :get, "/admin/projects", :controller => 'admin', :action => 'projects'
290 290 end
291 291 end
General Comments 0
You need to be logged in to leave comments. Login now