##// END OF EJS Templates
Merged r4047 from trunk....
Eric Davis -
r4003:8fa5019e69f6
parent child
Show More
@@ -0,0 +1,59
1 class ActivitiesController < ApplicationController
2 menu_item :activity
3 before_filter :find_optional_project
4 accept_key_auth :index
5
6 def index
7 @days = Setting.activity_days_default.to_i
8
9 if params[:from]
10 begin; @date_to = params[:from].to_date + 1; rescue; end
11 end
12
13 @date_to ||= Date.today + 1
14 @date_from = @date_to - @days
15 @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
16 @author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
17
18 @activity = Redmine::Activity::Fetcher.new(User.current, :project => @project,
19 :with_subprojects => @with_subprojects,
20 :author => @author)
21 @activity.scope_select {|t| !params["show_#{t}"].nil?}
22 @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty?
23
24 events = @activity.events(@date_from, @date_to)
25
26 if events.empty? || stale?(:etag => [events.first, User.current])
27 respond_to do |format|
28 format.html {
29 @events_by_day = events.group_by(&:event_date)
30 render :layout => false if request.xhr?
31 }
32 format.atom {
33 title = l(:label_activity)
34 if @author
35 title = @author.name
36 elsif @activity.scope.size == 1
37 title = l("label_#{@activity.scope.first.singularize}_plural")
38 end
39 render_feed(events, :title => "#{@project || Setting.app_title}: #{title}")
40 }
41 end
42 end
43
44 rescue ActiveRecord::RecordNotFound
45 render_404
46 end
47
48 private
49
50 # TODO: refactor, duplicated in projects_controller
51 def find_optional_project
52 return true unless params[:id]
53 @project = Project.find(params[:id])
54 authorize
55 rescue ActiveRecord::RecordNotFound
56 render_404
57 end
58
59 end
@@ -0,0 +1,87
1 require File.dirname(__FILE__) + '/../test_helper'
2
3 class ActivitiesControllerTest < ActionController::TestCase
4 fixtures :all
5
6 def test_project_index
7 get :index, :id => 1, :with_subprojects => 0
8 assert_response :success
9 assert_template 'index'
10 assert_not_nil assigns(:events_by_day)
11
12 assert_tag :tag => "h3",
13 :content => /#{2.days.ago.to_date.day}/,
14 :sibling => { :tag => "dl",
15 :child => { :tag => "dt",
16 :attributes => { :class => /issue-edit/ },
17 :child => { :tag => "a",
18 :content => /(#{IssueStatus.find(2).name})/,
19 }
20 }
21 }
22 end
23
24 def test_previous_project_index
25 get :index, :id => 1, :from => 3.days.ago.to_date
26 assert_response :success
27 assert_template 'index'
28 assert_not_nil assigns(:events_by_day)
29
30 assert_tag :tag => "h3",
31 :content => /#{3.day.ago.to_date.day}/,
32 :sibling => { :tag => "dl",
33 :child => { :tag => "dt",
34 :attributes => { :class => /issue/ },
35 :child => { :tag => "a",
36 :content => /#{Issue.find(1).subject}/,
37 }
38 }
39 }
40 end
41
42 def test_global_index
43 get :index
44 assert_response :success
45 assert_template 'index'
46 assert_not_nil assigns(:events_by_day)
47
48 assert_tag :tag => "h3",
49 :content => /#{5.day.ago.to_date.day}/,
50 :sibling => { :tag => "dl",
51 :child => { :tag => "dt",
52 :attributes => { :class => /issue/ },
53 :child => { :tag => "a",
54 :content => /#{Issue.find(5).subject}/,
55 }
56 }
57 }
58 end
59
60 def test_user_index
61 get :index, :user_id => 2
62 assert_response :success
63 assert_template 'index'
64 assert_not_nil assigns(:events_by_day)
65
66 assert_tag :tag => "h3",
67 :content => /#{3.day.ago.to_date.day}/,
68 :sibling => { :tag => "dl",
69 :child => { :tag => "dt",
70 :attributes => { :class => /issue/ },
71 :child => { :tag => "a",
72 :content => /#{Issue.find(1).subject}/,
73 }
74 }
75 }
76 end
77
78 def test_index_atom_feed
79 get :index, :format => 'atom'
80 assert_response :success
81 assert_template 'common/feed.atom.rxml'
82 assert_tag :tag => 'entry', :child => {
83 :tag => 'link',
84 :attributes => {:href => 'http://test.host/issues/11'}}
85 end
86
87 end
@@ -1,389 +1,345
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 menu_item :activity, :only => :activity
21 20 menu_item :roadmap, :only => :roadmap
22 21 menu_item :files, :only => [:list_files, :add_file]
23 22 menu_item :settings, :only => :settings
24 23
25 before_filter :find_project, :except => [ :index, :list, :add, :copy, :activity ]
26 before_filter :find_optional_project, :only => :activity
27 before_filter :authorize, :except => [ :index, :list, :add, :copy, :archive, :unarchive, :destroy, :activity ]
24 before_filter :find_project, :except => [ :index, :list, :add, :copy ]
25 before_filter :authorize, :except => [ :index, :list, :add, :copy, :archive, :unarchive, :destroy]
28 26 before_filter :authorize_global, :only => :add
29 27 before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
30 accept_key_auth :activity, :index
28 accept_key_auth :index
31 29
32 30 after_filter :only => [:add, :edit, :archive, :unarchive, :destroy] do |controller|
33 31 if controller.request.post?
34 32 controller.send :expire_action, :controller => 'welcome', :action => 'robots.txt'
35 33 end
36 34 end
37 35
38 36 helper :sort
39 37 include SortHelper
40 38 helper :custom_fields
41 39 include CustomFieldsHelper
42 40 helper :issues
43 41 helper :queries
44 42 include QueriesHelper
45 43 helper :repositories
46 44 include RepositoriesHelper
47 45 include ProjectsHelper
48 46
49 47 # Lists visible projects
50 48 def index
51 49 respond_to do |format|
52 50 format.html {
53 51 @projects = Project.visible.find(:all, :order => 'lft')
54 52 }
55 53 format.xml {
56 54 @projects = Project.visible.find(:all, :order => 'lft')
57 55 }
58 56 format.atom {
59 57 projects = Project.visible.find(:all, :order => 'created_on DESC',
60 58 :limit => Setting.feeds_limit.to_i)
61 59 render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
62 60 }
63 61 end
64 62 end
65 63
66 64 # Add a new project
67 65 def add
68 66 @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
69 67 @trackers = Tracker.all
70 68 @project = Project.new(params[:project])
71 69 if request.get?
72 70 @project.identifier = Project.next_identifier if Setting.sequential_project_identifiers?
73 71 @project.trackers = Tracker.all
74 72 @project.is_public = Setting.default_projects_public?
75 73 @project.enabled_module_names = Setting.default_projects_modules
76 74 else
77 75 @project.enabled_module_names = params[:enabled_modules]
78 76 if validate_parent_id && @project.save
79 77 @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
80 78 # Add current user as a project member if he is not admin
81 79 unless User.current.admin?
82 80 r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
83 81 m = Member.new(:user => User.current, :roles => [r])
84 82 @project.members << m
85 83 end
86 84 respond_to do |format|
87 85 format.html {
88 86 flash[:notice] = l(:notice_successful_create)
89 87 redirect_to :controller => 'projects', :action => 'settings', :id => @project
90 88 }
91 89 format.xml { head :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
92 90 end
93 91 else
94 92 respond_to do |format|
95 93 format.html
96 94 format.xml { render :xml => @project.errors, :status => :unprocessable_entity }
97 95 end
98 96 end
99 97 end
100 98 end
101 99
102 100 def copy
103 101 @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
104 102 @trackers = Tracker.all
105 103 @root_projects = Project.find(:all,
106 104 :conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}",
107 105 :order => 'name')
108 106 @source_project = Project.find(params[:id])
109 107 if request.get?
110 108 @project = Project.copy_from(@source_project)
111 109 if @project
112 110 @project.identifier = Project.next_identifier if Setting.sequential_project_identifiers?
113 111 else
114 112 redirect_to :controller => 'admin', :action => 'projects'
115 113 end
116 114 else
117 115 Mailer.with_deliveries(params[:notifications] == '1') do
118 116 @project = Project.new(params[:project])
119 117 @project.enabled_module_names = params[:enabled_modules]
120 118 if validate_parent_id && @project.copy(@source_project, :only => params[:only])
121 119 @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
122 120 flash[:notice] = l(:notice_successful_create)
123 121 redirect_to :controller => 'admin', :action => 'projects'
124 122 elsif !@project.new_record?
125 123 # Project was created
126 124 # But some objects were not copied due to validation failures
127 125 # (eg. issues from disabled trackers)
128 126 # TODO: inform about that
129 127 redirect_to :controller => 'admin', :action => 'projects'
130 128 end
131 129 end
132 130 end
133 131 rescue ActiveRecord::RecordNotFound
134 132 redirect_to :controller => 'admin', :action => 'projects'
135 133 end
136 134
137 135 # Show @project
138 136 def show
139 137 if params[:jump]
140 138 # try to redirect to the requested menu item
141 139 redirect_to_project_menu_item(@project, params[:jump]) && return
142 140 end
143 141
144 142 @users_by_role = @project.users_by_role
145 143 @subprojects = @project.children.visible
146 144 @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC")
147 145 @trackers = @project.rolled_up_trackers
148 146
149 147 cond = @project.project_condition(Setting.display_subprojects_issues?)
150 148
151 149 @open_issues_by_tracker = Issue.visible.count(:group => :tracker,
152 150 :include => [:project, :status, :tracker],
153 151 :conditions => ["(#{cond}) AND #{IssueStatus.table_name}.is_closed=?", false])
154 152 @total_issues_by_tracker = Issue.visible.count(:group => :tracker,
155 153 :include => [:project, :status, :tracker],
156 154 :conditions => cond)
157 155
158 156 TimeEntry.visible_by(User.current) do
159 157 @total_hours = TimeEntry.sum(:hours,
160 158 :include => :project,
161 159 :conditions => cond).to_f
162 160 end
163 161 @key = User.current.rss_key
164 162
165 163 respond_to do |format|
166 164 format.html
167 165 format.xml
168 166 end
169 167 end
170 168
171 169 def settings
172 170 @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
173 171 @issue_category ||= IssueCategory.new
174 172 @member ||= @project.members.new
175 173 @trackers = Tracker.all
176 174 @repository ||= @project.repository
177 175 @wiki ||= @project.wiki
178 176 end
179 177
180 178 # Edit @project
181 179 def edit
182 180 if request.get?
183 181 else
184 182 @project.attributes = params[:project]
185 183 if validate_parent_id && @project.save
186 184 @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
187 185 respond_to do |format|
188 186 format.html {
189 187 flash[:notice] = l(:notice_successful_update)
190 188 redirect_to :action => 'settings', :id => @project
191 189 }
192 190 format.xml { head :ok }
193 191 end
194 192 else
195 193 respond_to do |format|
196 194 format.html {
197 195 settings
198 196 render :action => 'settings'
199 197 }
200 198 format.xml { render :xml => @project.errors, :status => :unprocessable_entity }
201 199 end
202 200 end
203 201 end
204 202 end
205 203
206 204 def modules
207 205 @project.enabled_module_names = params[:enabled_modules]
208 206 flash[:notice] = l(:notice_successful_update)
209 207 redirect_to :action => 'settings', :id => @project, :tab => 'modules'
210 208 end
211 209
212 210 def archive
213 211 if request.post?
214 212 unless @project.archive
215 213 flash[:error] = l(:error_can_not_archive_project)
216 214 end
217 215 end
218 216 redirect_to(url_for(:controller => 'admin', :action => 'projects', :status => params[:status]))
219 217 end
220 218
221 219 def unarchive
222 220 @project.unarchive if request.post? && !@project.active?
223 221 redirect_to(url_for(:controller => 'admin', :action => 'projects', :status => params[:status]))
224 222 end
225 223
226 224 # Delete @project
227 225 def destroy
228 226 @project_to_destroy = @project
229 227 if request.get?
230 228 # display confirmation view
231 229 else
232 230 if params[:format] == 'xml' || params[:confirm]
233 231 @project_to_destroy.destroy
234 232 respond_to do |format|
235 233 format.html { redirect_to :controller => 'admin', :action => 'projects' }
236 234 format.xml { head :ok }
237 235 end
238 236 end
239 237 end
240 238 # hide project in layout
241 239 @project = nil
242 240 end
243 241
244 242 def add_file
245 243 if request.post?
246 244 container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id]))
247 245 attachments = Attachment.attach_files(container, params[:attachments])
248 246 render_attachment_warning_if_needed(container)
249 247
250 248 if !attachments.empty? && Setting.notified_events.include?('file_added')
251 249 Mailer.deliver_attachments_added(attachments[:files])
252 250 end
253 251 redirect_to :controller => 'projects', :action => 'list_files', :id => @project
254 252 return
255 253 end
256 254 @versions = @project.versions.sort
257 255 end
258 256
259 257 def save_activities
260 258 if request.post? && params[:enumerations]
261 259 Project.transaction do
262 260 params[:enumerations].each do |id, activity|
263 261 @project.update_or_create_time_entry_activity(id, activity)
264 262 end
265 263 end
266 264 flash[:notice] = l(:notice_successful_update)
267 265 end
268 266
269 267 redirect_to :controller => 'projects', :action => 'settings', :tab => 'activities', :id => @project
270 268 end
271 269
272 270 def reset_activities
273 271 @project.time_entry_activities.each do |time_entry_activity|
274 272 time_entry_activity.destroy(time_entry_activity.parent)
275 273 end
276 274 flash[:notice] = l(:notice_successful_update)
277 275 redirect_to :controller => 'projects', :action => 'settings', :tab => 'activities', :id => @project
278 276 end
279 277
280 278 def list_files
281 279 sort_init 'filename', 'asc'
282 280 sort_update 'filename' => "#{Attachment.table_name}.filename",
283 281 'created_on' => "#{Attachment.table_name}.created_on",
284 282 'size' => "#{Attachment.table_name}.filesize",
285 283 'downloads' => "#{Attachment.table_name}.downloads"
286 284
287 285 @containers = [ Project.find(@project.id, :include => :attachments, :order => sort_clause)]
288 286 @containers += @project.versions.find(:all, :include => :attachments, :order => sort_clause).sort.reverse
289 287 render :layout => !request.xhr?
290 288 end
291 289
292 290 def roadmap
293 291 @trackers = @project.trackers.find(:all, :order => 'position')
294 292 retrieve_selected_tracker_ids(@trackers, @trackers.select {|t| t.is_in_roadmap?})
295 293 @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
296 294 project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id]
297 295
298 296 @versions = @project.shared_versions || []
299 297 @versions += @project.rolled_up_versions.visible if @with_subprojects
300 298 @versions = @versions.uniq.sort
301 299 @versions.reject! {|version| version.closed? || version.completed? } unless params[:completed]
302 300
303 301 @issues_by_version = {}
304 302 unless @selected_tracker_ids.empty?
305 303 @versions.each do |version|
306 304 issues = version.fixed_issues.visible.find(:all,
307 305 :include => [:project, :status, :tracker, :priority],
308 306 :conditions => {:tracker_id => @selected_tracker_ids, :project_id => project_ids},
309 307 :order => "#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id")
310 308 @issues_by_version[version] = issues
311 309 end
312 310 end
313 311 @versions.reject! {|version| !project_ids.include?(version.project_id) && @issues_by_version[version].blank?}
314 312 end
315 313
316 def activity
317 @days = Setting.activity_days_default.to_i
318
319 if params[:from]
320 begin; @date_to = params[:from].to_date + 1; rescue; end
321 end
322
323 @date_to ||= Date.today + 1
324 @date_from = @date_to - @days
325 @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
326 @author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
327
328 @activity = Redmine::Activity::Fetcher.new(User.current, :project => @project,
329 :with_subprojects => @with_subprojects,
330 :author => @author)
331 @activity.scope_select {|t| !params["show_#{t}"].nil?}
332 @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty?
333
334 events = @activity.events(@date_from, @date_to)
335
336 if events.empty? || stale?(:etag => [events.first, User.current])
337 respond_to do |format|
338 format.html {
339 @events_by_day = events.group_by(&:event_date)
340 render :layout => false if request.xhr?
341 }
342 format.atom {
343 title = l(:label_activity)
344 if @author
345 title = @author.name
346 elsif @activity.scope.size == 1
347 title = l("label_#{@activity.scope.first.singularize}_plural")
348 end
349 render_feed(events, :title => "#{@project || Setting.app_title}: #{title}")
350 }
351 end
352 end
353
354 rescue ActiveRecord::RecordNotFound
355 render_404
356 end
357
358 314 private
359 315 def find_optional_project
360 316 return true unless params[:id]
361 317 @project = Project.find(params[:id])
362 318 authorize
363 319 rescue ActiveRecord::RecordNotFound
364 320 render_404
365 321 end
366 322
367 323 def retrieve_selected_tracker_ids(selectable_trackers, default_trackers=nil)
368 324 if ids = params[:tracker_ids]
369 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 }
370 326 else
371 327 @selected_tracker_ids = (default_trackers || selectable_trackers).collect {|t| t.id.to_s }
372 328 end
373 329 end
374 330
375 331 # Validates parent_id param according to user's permissions
376 332 # TODO: move it to Project model in a validation that depends on User.current
377 333 def validate_parent_id
378 334 return true if User.current.admin?
379 335 parent_id = params[:project] && params[:project][:parent_id]
380 336 if parent_id || @project.new_record?
381 337 parent = parent_id.blank? ? nil : Project.find_by_id(parent_id.to_i)
382 338 unless @project.allowed_parents.include?(parent)
383 339 @project.errors.add :parent_id, :invalid
384 340 return false
385 341 end
386 342 end
387 343 true
388 344 end
389 345 end
1 NO CONTENT: file renamed from app/views/projects/activity.rhtml to app/views/activities/index.html.erb
@@ -1,40 +1,40
1 1 <h2><%= l(:label_board_plural) %></h2>
2 2
3 3 <table class="list boards">
4 4 <thead><tr>
5 5 <th><%= l(:label_board) %></th>
6 6 <th><%= l(:label_topic_plural) %></th>
7 7 <th><%= l(:label_message_plural) %></th>
8 8 <th><%= l(:label_message_last) %></th>
9 9 </tr></thead>
10 10 <tbody>
11 11 <% for board in @boards %>
12 12 <tr class="<%= cycle 'odd', 'even' %>">
13 13 <td>
14 14 <%= link_to h(board.name), {:action => 'show', :id => board}, :class => "board" %><br />
15 15 <%=h board.description %>
16 16 </td>
17 17 <td align="center"><%= board.topics_count %></td>
18 18 <td align="center"><%= board.messages_count %></td>
19 19 <td>
20 20 <small>
21 21 <% if board.last_message %>
22 22 <%= authoring board.last_message.created_on, board.last_message.author %><br />
23 23 <%= link_to_message board.last_message %>
24 24 <% end %>
25 25 </small>
26 26 </td>
27 27 </tr>
28 28 <% end %>
29 29 </tbody>
30 30 </table>
31 31
32 32 <% other_formats_links do |f| %>
33 <%= f.link_to 'Atom', :url => {:controller => 'projects', :action => 'activity', :id => @project, :show_messages => 1, :key => User.current.rss_key} %>
33 <%= f.link_to 'Atom', :url => {:controller => 'activities', :action => 'index', :id => @project, :show_messages => 1, :key => User.current.rss_key} %>
34 34 <% end %>
35 35
36 36 <% content_for :header_tags do %>
37 <%= auto_discovery_link_tag(:atom, {:controller => 'projects', :action => 'activity', :id => @project, :format => 'atom', :show_messages => 1, :key => User.current.rss_key}) %>
37 <%= auto_discovery_link_tag(:atom, {:controller => 'activities', :action => 'index', :id => @project, :format => 'atom', :show_messages => 1, :key => User.current.rss_key}) %>
38 38 <% end %>
39 39
40 40 <% html_title l(:label_board_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 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) %>
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 <%= link_to l(:label_overall_activity), { :controller => 'projects', :action => 'activity' }%>
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,80 +1,80
1 1 <div class="contextual">
2 2 <% if User.current.allowed_to?(:add_subprojects, @project) %>
3 3 <%= link_to l(:label_subproject_new), {:controller => 'projects', :action => 'add', :parent_id => @project}, :class => 'icon icon-add' %>
4 4 <% end %>
5 5 </div>
6 6
7 7 <h2><%=l(:label_overview)%></h2>
8 8
9 9 <div class="splitcontentleft">
10 10 <div class="wiki">
11 11 <%= textilizable @project.description %>
12 12 </div>
13 13 <ul>
14 14 <% unless @project.homepage.blank? %><li><%=l(:field_homepage)%>: <%= auto_link(h(@project.homepage)) %></li><% end %>
15 15 <% if @subprojects.any? %>
16 16 <li><%=l(:label_subproject_plural)%>:
17 17 <%= @subprojects.collect{|p| link_to(h(p), :action => 'show', :id => p)}.join(", ") %></li>
18 18 <% end %>
19 19 <% @project.custom_values.each do |custom_value| %>
20 20 <% if !custom_value.value.blank? %>
21 21 <li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
22 22 <% end %>
23 23 <% end %>
24 24 </ul>
25 25
26 26 <% if User.current.allowed_to?(:view_issues, @project) %>
27 27 <div class="issues box">
28 28 <h3><%=l(:label_issue_tracking)%></h3>
29 29 <ul>
30 30 <% for tracker in @trackers %>
31 31 <li><%= link_to tracker.name, :controller => 'issues', :action => 'index', :project_id => @project,
32 32 :set_filter => 1,
33 33 "tracker_id" => tracker.id %>:
34 34 <%= l(:label_x_open_issues_abbr_on_total, :count => @open_issues_by_tracker[tracker].to_i,
35 35 :total => @total_issues_by_tracker[tracker].to_i) %>
36 36 </li>
37 37 <% end %>
38 38 </ul>
39 39 <p>
40 40 <%= link_to l(:label_issue_view_all), :controller => 'issues', :action => 'index', :project_id => @project, :set_filter => 1 %>
41 41 <% if User.current.allowed_to?(:view_calendar, @project, :global => true) %>
42 42 | <%= link_to(l(:label_calendar), :controller => 'calendars', :action => 'show', :project_id => @project) %>
43 43 <% end %>
44 44 <% if User.current.allowed_to?(:view_gantt, @project, :global => true) %>
45 45 | <%= link_to(l(:label_gantt), :controller => 'gantts', :action => 'show', :project_id => @project) %>
46 46 <% end %>
47 47 </p>
48 48 </div>
49 49 <% end %>
50 50 <%= call_hook(:view_projects_show_left, :project => @project) %>
51 51 </div>
52 52
53 53 <div class="splitcontentright">
54 54 <%= render :partial => 'members_box' %>
55 55
56 56 <% if @news.any? && authorize_for('news', 'index') %>
57 57 <div class="news box">
58 58 <h3><%=l(:label_news_latest)%></h3>
59 59 <%= render :partial => 'news/news', :collection => @news %>
60 60 <p><%= link_to l(:label_news_view_all), :controller => 'news', :action => 'index', :project_id => @project %></p>
61 61 </div>
62 62 <% end %>
63 63 <%= call_hook(:view_projects_show_right, :project => @project) %>
64 64 </div>
65 65
66 66 <% content_for :sidebar do %>
67 67 <% if @total_hours && User.current.allowed_to?(:view_time_entries, @project) %>
68 68 <h3><%= l(:label_spent_time) %></h3>
69 69 <p><span class="icon icon-time"><%= l_hours(@total_hours) %></span></p>
70 70 <p><%= link_to(l(:label_details), {:controller => 'timelog', :action => 'details', :project_id => @project}) %> |
71 71 <%= link_to(l(:label_report), {:controller => 'timelog', :action => 'report', :project_id => @project}) %></p>
72 72 <% end %>
73 73 <%= call_hook(:view_projects_show_sidebar_bottom, :project => @project) %>
74 74 <% end %>
75 75
76 76 <% content_for :header_tags do %>
77 <%= auto_discovery_link_tag(:atom, {:action => 'activity', :id => @project, :format => 'atom', :key => User.current.rss_key}) %>
77 <%= auto_discovery_link_tag(:atom, {:controller => 'activities', :action => 'index', :id => @project, :format => 'atom', :key => User.current.rss_key}) %>
78 78 <% end %>
79 79
80 80 <% html_title(l(:label_overview)) -%>
@@ -1,70 +1,70
1 1 <div class="contextual">
2 2 <%= link_to(l(:button_edit), {:controller => 'users', :action => 'edit', :id => @user}, :class => 'icon icon-edit') if User.current.admin? %>
3 3 </div>
4 4
5 5 <h2><%= avatar @user, :size => "50" %> <%=h @user.name %></h2>
6 6
7 7 <div class="splitcontentleft">
8 8 <ul>
9 9 <% unless @user.pref.hide_mail %>
10 10 <li><%=l(:field_mail)%>: <%= mail_to(h(@user.mail), nil, :encode => 'javascript') %></li>
11 11 <% end %>
12 12 <% for custom_value in @custom_values %>
13 13 <% if !custom_value.value.blank? %>
14 14 <li><%=h custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
15 15 <% end %>
16 16 <% end %>
17 17 <li><%=l(:label_registered_on)%>: <%= format_date(@user.created_on) %></li>
18 18 <% unless @user.last_login_on.nil? %>
19 19 <li><%=l(:field_last_login_on)%>: <%= format_date(@user.last_login_on) %></li>
20 20 <% end %>
21 21 </ul>
22 22
23 23 <% unless @memberships.empty? %>
24 24 <h3><%=l(:label_project_plural)%></h3>
25 25 <ul>
26 26 <% for membership in @memberships %>
27 27 <li><%= link_to_project(membership.project) %>
28 28 (<%=h membership.roles.sort.collect(&:to_s).join(', ') %>, <%= format_date(membership.created_on) %>)</li>
29 29 <% end %>
30 30 </ul>
31 31 <% end %>
32 32 <%= call_hook :view_account_left_bottom, :user => @user %>
33 33 </div>
34 34
35 35 <div class="splitcontentright">
36 36
37 37 <% unless @events_by_day.empty? %>
38 <h3><%= link_to l(:label_activity), :controller => 'projects', :action => 'activity', :id => nil, :user_id => @user, :from => @events_by_day.keys.first %></h3>
38 <h3><%= link_to l(:label_activity), :controller => 'activities', :action => 'index', :id => nil, :user_id => @user, :from => @events_by_day.keys.first %></h3>
39 39
40 40 <p>
41 41 <%=l(:label_reported_issues)%>: <%= Issue.count(:conditions => ["author_id=?", @user.id]) %>
42 42 </p>
43 43
44 44 <div id="activity">
45 45 <% @events_by_day.keys.sort.reverse.each do |day| %>
46 46 <h4><%= format_activity_day(day) %></h4>
47 47 <dl>
48 48 <% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%>
49 49 <dt class="<%= e.event_type %>">
50 50 <span class="time"><%= format_time(e.event_datetime, false) %></span>
51 51 <%= content_tag('span', h(e.project), :class => 'project') %>
52 52 <%= link_to format_activity_title(e.event_title), e.event_url %></dt>
53 53 <dd><span class="description"><%= format_activity_description(e.event_description) %></span></dd>
54 54 <% end -%>
55 55 </dl>
56 56 <% end -%>
57 57 </div>
58 58
59 59 <% other_formats_links do |f| %>
60 <%= f.link_to 'Atom', :url => {:controller => 'projects', :action => 'activity', :id => nil, :user_id => @user, :key => User.current.rss_key} %>
60 <%= f.link_to 'Atom', :url => {:controller => 'activities', :action => 'index', :id => nil, :user_id => @user, :key => User.current.rss_key} %>
61 61 <% end %>
62 62
63 63 <% content_for :header_tags do %>
64 <%= auto_discovery_link_tag(:atom, :controller => 'projects', :action => 'activity', :user_id => @user, :format => :atom, :key => User.current.rss_key) %>
64 <%= auto_discovery_link_tag(:atom, :controller => 'activities', :action => 'index', :user_id => @user, :format => :atom, :key => User.current.rss_key) %>
65 65 <% end %>
66 66 <% end %>
67 67 <%= call_hook :view_account_right_bottom, :user => @user %>
68 68 </div>
69 69
70 70 <% html_title @user.name %>
@@ -1,39 +1,39
1 1 <h2><%= l(:label_home) %></h2>
2 2
3 3 <div class="splitcontentleft">
4 4 <%= textilizable Setting.welcome_text %>
5 5 <% if @news.any? %>
6 6 <div class="news box">
7 7 <h3><%=l(:label_news_latest)%></h3>
8 8 <%= render :partial => 'news/news', :collection => @news %>
9 9 <%= link_to l(:label_news_view_all), :controller => 'news' %>
10 10 </div>
11 11 <% end %>
12 12 <%= call_hook(:view_welcome_index_left, :projects => @projects) %>
13 13 </div>
14 14
15 15 <div class="splitcontentright">
16 16 <% if @projects.any? %>
17 17 <div class="projects box">
18 18 <h3><%=l(:label_project_latest)%></h3>
19 19 <ul>
20 20 <% for project in @projects %>
21 21 <% @project = project %>
22 22 <li>
23 23 <%= link_to_project project %> (<%= format_time(project.created_on) %>)
24 24 <%= textilizable project.short_description, :project => project %>
25 25 </li>
26 26 <% end %>
27 27 <% @project = nil %>
28 28 </ul>
29 29 </div>
30 30 <% end %>
31 31 <%= call_hook(:view_welcome_index_right, :projects => @projects) %>
32 32 </div>
33 33
34 34 <% content_for :header_tags do %>
35 35 <%= auto_discovery_link_tag(:atom, {:controller => 'news', :action => 'index', :key => User.current.rss_key, :format => 'atom'},
36 36 :title => "#{Setting.app_title}: #{l(:label_news_latest)}") %>
37 <%= auto_discovery_link_tag(:atom, {:controller => 'projects', :action => 'activity', :key => User.current.rss_key, :format => 'atom'},
37 <%= auto_discovery_link_tag(:atom, {:controller => 'activities', :action => 'index', :key => User.current.rss_key, :format => 'atom'},
38 38 :title => "#{Setting.app_title}: #{l(:label_activity)}") %>
39 39 <% end %>
@@ -1,33 +1,33
1 1 <div class="contextual">
2 2 <%= watcher_tag(@wiki, User.current) %>
3 3 </div>
4 4
5 5 <h2><%= l(:label_index_by_date) %></h2>
6 6
7 7 <% if @pages.empty? %>
8 8 <p class="nodata"><%= l(:label_no_data) %></p>
9 9 <% end %>
10 10
11 11 <% @pages_by_date.keys.sort.reverse.each do |date| %>
12 12 <h3><%= format_date(date) %></h3>
13 13 <ul>
14 14 <% @pages_by_date[date].each do |page| %>
15 15 <li><%= link_to page.pretty_title, :action => 'index', :page => page.title %></li>
16 16 <% end %>
17 17 </ul>
18 18 <% end %>
19 19
20 20 <% content_for :sidebar do %>
21 21 <%= render :partial => 'sidebar' %>
22 22 <% end %>
23 23
24 24 <% unless @pages.empty? %>
25 25 <% other_formats_links do |f| %>
26 <%= f.link_to 'Atom', :url => {:controller => 'projects', :action => 'activity', :id => @project, :show_wiki_edits => 1, :key => User.current.rss_key} %>
26 <%= f.link_to 'Atom', :url => {:controller => 'activities', :action => 'index', :id => @project, :show_wiki_edits => 1, :key => User.current.rss_key} %>
27 27 <%= f.link_to('HTML', :url => {:action => 'special', :page => 'export'}) if User.current.allowed_to?(:export_wiki_pages, @project) %>
28 28 <% end %>
29 29 <% end %>
30 30
31 31 <% content_for :header_tags do %>
32 <%= auto_discovery_link_tag(:atom, :controller => 'projects', :action => 'activity', :id => @project, :show_wiki_edits => 1, :format => 'atom', :key => User.current.rss_key) %>
32 <%= auto_discovery_link_tag(:atom, :controller => 'activities', :action => 'index', :id => @project, :show_wiki_edits => 1, :format => 'atom', :key => User.current.rss_key) %>
33 33 <% end %>
@@ -1,300 +1,300
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 map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', :action => 'issues'
108 108 # TODO: would look nicer as /issues/:id/preview
109 109 map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue'
110 110 map.issues_context_menu '/issues/context_menu', :controller => 'context_menus', :action => 'issues'
111 111 map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index'
112 112
113 113 map.with_options :controller => 'issues' do |issues_routes|
114 114 issues_routes.with_options :conditions => {:method => :get} do |issues_views|
115 115 issues_views.connect 'issues', :action => 'index'
116 116 issues_views.connect 'issues.:format', :action => 'index'
117 117 issues_views.connect 'projects/:project_id/issues', :action => 'index'
118 118 issues_views.connect 'projects/:project_id/issues.:format', :action => 'index'
119 119 issues_views.connect 'projects/:project_id/issues/new', :action => 'new'
120 120 issues_views.connect 'projects/:project_id/issues/gantt', :controller => 'gantts', :action => 'show'
121 121 issues_views.connect 'projects/:project_id/issues/calendar', :controller => 'calendars', :action => 'show'
122 122 issues_views.connect 'projects/:project_id/issues/:copy_from/copy', :action => 'new'
123 123 issues_views.connect 'issues/:id', :action => 'show', :id => /\d+/
124 124 issues_views.connect 'issues/:id.:format', :action => 'show', :id => /\d+/
125 125 issues_views.connect 'issues/:id/edit', :action => 'edit', :id => /\d+/
126 126 end
127 127 issues_routes.with_options :conditions => {:method => :post} do |issues_actions|
128 128 issues_actions.connect 'issues', :action => 'index'
129 129 issues_actions.connect 'projects/:project_id/issues', :action => 'create'
130 130 issues_actions.connect 'projects/:project_id/issues/gantt', :controller => 'gantts', :action => 'show'
131 131 issues_actions.connect 'projects/:project_id/issues/calendar', :controller => 'calendars', :action => 'show'
132 132 issues_actions.connect 'issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/
133 133 issues_actions.connect 'issues/:id/:action', :action => /edit|destroy/, :id => /\d+/
134 134 issues_actions.connect 'issues.:format', :action => 'create', :format => /xml/
135 135 issues_actions.connect 'issues/bulk_edit', :action => 'bulk_update'
136 136 end
137 137 issues_routes.with_options :conditions => {:method => :put} do |issues_actions|
138 138 issues_actions.connect 'issues/:id/edit', :action => 'update', :id => /\d+/
139 139 issues_actions.connect 'issues/:id.:format', :action => 'update', :id => /\d+/, :format => /xml/
140 140 end
141 141 issues_routes.with_options :conditions => {:method => :delete} do |issues_actions|
142 142 issues_actions.connect 'issues/:id.:format', :action => 'destroy', :id => /\d+/, :format => /xml/
143 143 end
144 144 issues_routes.connect 'issues/gantt', :controller => 'gantts', :action => 'show'
145 145 issues_routes.connect 'issues/calendar', :controller => 'calendars', :action => 'show'
146 146 issues_routes.connect 'issues/:action'
147 147 end
148 148
149 149 map.with_options :controller => 'issue_relations', :conditions => {:method => :post} do |relations|
150 150 relations.connect 'issues/:issue_id/relations/:id', :action => 'new'
151 151 relations.connect 'issues/:issue_id/relations/:id/destroy', :action => 'destroy'
152 152 end
153 153
154 154 map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports|
155 155 reports.connect 'projects/:id/issues/report', :action => 'issue_report'
156 156 reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details'
157 157 end
158 158
159 159 map.with_options :controller => 'news' do |news_routes|
160 160 news_routes.with_options :conditions => {:method => :get} do |news_views|
161 161 news_views.connect 'news', :action => 'index'
162 162 news_views.connect 'projects/:project_id/news', :action => 'index'
163 163 news_views.connect 'projects/:project_id/news.:format', :action => 'index'
164 164 news_views.connect 'news.:format', :action => 'index'
165 165 news_views.connect 'projects/:project_id/news/new', :action => 'new'
166 166 news_views.connect 'news/:id', :action => 'show'
167 167 news_views.connect 'news/:id/edit', :action => 'edit'
168 168 end
169 169 news_routes.with_options do |news_actions|
170 170 news_actions.connect 'projects/:project_id/news', :action => 'new'
171 171 news_actions.connect 'news/:id/edit', :action => 'edit'
172 172 news_actions.connect 'news/:id/destroy', :action => 'destroy'
173 173 end
174 174 end
175 175
176 176 map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new'
177 177
178 178 map.with_options :controller => 'users' do |users|
179 179 users.with_options :conditions => {:method => :get} do |user_views|
180 180 user_views.connect 'users', :action => 'index'
181 181 user_views.connect 'users/:id', :action => 'show', :id => /\d+/
182 182 user_views.connect 'users/new', :action => 'add'
183 183 user_views.connect 'users/:id/edit/:tab', :action => 'edit', :tab => nil
184 184 end
185 185 users.with_options :conditions => {:method => :post} do |user_actions|
186 186 user_actions.connect 'users', :action => 'add'
187 187 user_actions.connect 'users/new', :action => 'add'
188 188 user_actions.connect 'users/:id/edit', :action => 'edit'
189 189 user_actions.connect 'users/:id/memberships', :action => 'edit_membership'
190 190 user_actions.connect 'users/:id/memberships/:membership_id', :action => 'edit_membership'
191 191 user_actions.connect 'users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership'
192 192 end
193 193 end
194 194
195 195 map.with_options :controller => 'projects' do |projects|
196 196 projects.with_options :conditions => {:method => :get} do |project_views|
197 197 project_views.connect 'projects', :action => 'index'
198 198 project_views.connect 'projects.:format', :action => 'index'
199 199 project_views.connect 'projects/new', :action => 'add'
200 200 project_views.connect 'projects/:id', :action => 'show'
201 201 project_views.connect 'projects/:id.:format', :action => 'show'
202 202 project_views.connect 'projects/:id/:action', :action => /roadmap|destroy|settings/
203 203 project_views.connect 'projects/:id/files', :action => 'list_files'
204 204 project_views.connect 'projects/:id/files/new', :action => 'add_file'
205 205 project_views.connect 'projects/:id/settings/:tab', :action => 'settings'
206 206 end
207 207
208 projects.with_options :action => 'activity', :conditions => {:method => :get} do |activity|
208 projects.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity|
209 209 activity.connect 'projects/:id/activity'
210 210 activity.connect 'projects/:id/activity.:format'
211 211 activity.connect 'activity', :id => nil
212 212 activity.connect 'activity.:format', :id => nil
213 213 end
214 214
215 215 projects.with_options :conditions => {:method => :post} do |project_actions|
216 216 project_actions.connect 'projects/new', :action => 'add'
217 217 project_actions.connect 'projects', :action => 'add'
218 218 project_actions.connect 'projects.:format', :action => 'add', :format => /xml/
219 219 project_actions.connect 'projects/:id/:action', :action => /edit|destroy|archive|unarchive/
220 220 project_actions.connect 'projects/:id/files/new', :action => 'add_file'
221 221 project_actions.connect 'projects/:id/activities/save', :action => 'save_activities'
222 222 end
223 223
224 224 projects.with_options :conditions => {:method => :put} do |project_actions|
225 225 project_actions.conditions 'projects/:id.:format', :action => 'edit', :format => /xml/
226 226 end
227 227
228 228 projects.with_options :conditions => {:method => :delete} do |project_actions|
229 229 project_actions.conditions 'projects/:id.:format', :action => 'destroy', :format => /xml/
230 230 project_actions.conditions 'projects/:id/reset_activities', :action => 'reset_activities'
231 231 end
232 232 end
233 233
234 234 map.with_options :controller => 'versions' do |versions|
235 235 versions.connect 'projects/:project_id/versions/new', :action => 'new'
236 236 versions.with_options :conditions => {:method => :post} do |version_actions|
237 237 version_actions.connect 'projects/:project_id/versions/close_completed', :action => 'close_completed'
238 238 end
239 239 end
240 240
241 241 map.with_options :controller => 'issue_categories' do |categories|
242 242 categories.connect 'projects/:project_id/issue_categories/new', :action => 'new'
243 243 end
244 244
245 245 map.with_options :controller => 'repositories' do |repositories|
246 246 repositories.with_options :conditions => {:method => :get} do |repository_views|
247 247 repository_views.connect 'projects/:id/repository', :action => 'show'
248 248 repository_views.connect 'projects/:id/repository/edit', :action => 'edit'
249 249 repository_views.connect 'projects/:id/repository/statistics', :action => 'stats'
250 250 repository_views.connect 'projects/:id/repository/revisions', :action => 'revisions'
251 251 repository_views.connect 'projects/:id/repository/revisions.:format', :action => 'revisions'
252 252 repository_views.connect 'projects/:id/repository/revisions/:rev', :action => 'revision'
253 253 repository_views.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff'
254 254 repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff'
255 255 repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path', :action => 'entry', :format => 'raw', :requirements => { :rev => /[a-z0-9\.\-_]+/ }
256 256 repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path', :requirements => { :rev => /[a-z0-9\.\-_]+/ }
257 257 repository_views.connect 'projects/:id/repository/raw/*path', :action => 'entry', :format => 'raw'
258 258 # TODO: why the following route is required?
259 259 repository_views.connect 'projects/:id/repository/entry/*path', :action => 'entry'
260 260 repository_views.connect 'projects/:id/repository/:action/*path'
261 261 end
262 262
263 263 repositories.connect 'projects/:id/repository/:action', :conditions => {:method => :post}
264 264 end
265 265
266 266 map.connect 'attachments/:id', :controller => 'attachments', :action => 'show', :id => /\d+/
267 267 map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/
268 268 map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/
269 269
270 270 map.resources :groups
271 271
272 272 #left old routes at the bottom for backwards compat
273 273 map.connect 'projects/:project_id/issues/:action', :controller => 'issues'
274 274 map.connect 'projects/:project_id/documents/:action', :controller => 'documents'
275 275 map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards'
276 276 map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages'
277 277 map.connect 'wiki/:id/:page/:action', :page => nil, :controller => 'wiki'
278 278 map.connect 'issues/:issue_id/relations/:action/:id', :controller => 'issue_relations'
279 279 map.connect 'projects/:project_id/news/:action', :controller => 'news'
280 280 map.connect 'projects/:project_id/timelog/:action/:id', :controller => 'timelog', :project_id => /.+/
281 281 map.with_options :controller => 'repositories' do |omap|
282 282 omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse'
283 283 omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes'
284 284 omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff'
285 285 omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry'
286 286 omap.repositories_entry 'repositories/annotate/:id/*path', :action => 'annotate'
287 287 omap.connect 'repositories/revision/:id/:rev', :action => 'revision'
288 288 end
289 289
290 290 map.with_options :controller => 'sys' do |sys|
291 291 sys.connect 'sys/projects.:format', :action => 'projects', :conditions => {:method => :get}
292 292 sys.connect 'sys/projects/:id/repository.:format', :action => 'create_project_repository', :conditions => {:method => :post}
293 293 end
294 294
295 295 # Install the default route as the lowest priority.
296 296 map.connect ':controller/:action/:id'
297 297 map.connect 'robots.txt', :controller => 'welcome', :action => 'robots'
298 298 # Used for OpenID
299 299 map.root :controller => 'account', :action => 'login'
300 300 end
@@ -1,231 +1,231
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 map.permission :view_project, {:projects => [:show, :activity]}, :public => true
47 map.permission :view_project, {:projects => [:show], :activities => [:index]}, :public => true
48 48 map.permission :search_project, {:search => :index}, :public => true
49 49 map.permission :add_project, {:projects => :add}, :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 54 map.permission :add_subprojects, {:projects => :add}, :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, {:projects => :roadmap,
61 61 :issues => [:index, :show],
62 62 :auto_complete => [:issues],
63 63 :context_menus => [:issues],
64 64 :versions => [:show, :status_by],
65 65 :journals => :index,
66 66 :queries => :index,
67 67 :reports => [:issue_report, :issue_report_details]}
68 68 map.permission :add_issues, {:issues => [:new, :create, :update_form]}
69 69 map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :bulk_update, :update_form], :journals => [:new]}
70 70 map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]}
71 71 map.permission :manage_subtasks, {}
72 72 map.permission :add_issue_notes, {:issues => [:edit, :update], :journals => [:new]}
73 73 map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin
74 74 map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin
75 75 map.permission :move_issues, {:issue_moves => [:new, :create]}, :require => :loggedin
76 76 map.permission :delete_issues, {:issues => :destroy}, :require => :member
77 77 # Queries
78 78 map.permission :manage_public_queries, {:queries => [:new, :edit, :destroy]}, :require => :member
79 79 map.permission :save_queries, {:queries => [:new, :edit, :destroy]}, :require => :loggedin
80 80 # Watchers
81 81 map.permission :view_issue_watchers, {}
82 82 map.permission :add_issue_watchers, {:watchers => :new}
83 83 map.permission :delete_issue_watchers, {:watchers => :destroy}
84 84 end
85 85
86 86 map.project_module :time_tracking do |map|
87 87 map.permission :log_time, {:timelog => :edit}, :require => :loggedin
88 88 map.permission :view_time_entries, :timelog => [:details, :report]
89 89 map.permission :edit_time_entries, {:timelog => [:edit, :destroy]}, :require => :member
90 90 map.permission :edit_own_time_entries, {:timelog => [:edit, :destroy]}, :require => :loggedin
91 91 map.permission :manage_project_activities, {:projects => [:save_activities, :reset_activities]}, :require => :member
92 92 end
93 93
94 94 map.project_module :news do |map|
95 95 map.permission :manage_news, {:news => [:new, :edit, :destroy, :destroy_comment]}, :require => :member
96 96 map.permission :view_news, {:news => [:index, :show]}, :public => true
97 97 map.permission :comment_news, {:news => :add_comment}
98 98 end
99 99
100 100 map.project_module :documents do |map|
101 101 map.permission :manage_documents, {:documents => [:new, :edit, :destroy, :add_attachment]}, :require => :loggedin
102 102 map.permission :view_documents, :documents => [:index, :show, :download]
103 103 end
104 104
105 105 map.project_module :files do |map|
106 106 map.permission :manage_files, {:projects => :add_file}, :require => :loggedin
107 107 map.permission :view_files, :projects => :list_files, :versions => :download
108 108 end
109 109
110 110 map.project_module :wiki do |map|
111 111 map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member
112 112 map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member
113 113 map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member
114 114 map.permission :view_wiki_pages, :wiki => [:index, :special]
115 115 map.permission :export_wiki_pages, {}
116 116 map.permission :view_wiki_edits, :wiki => [:history, :diff, :annotate]
117 117 map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment]
118 118 map.permission :delete_wiki_pages_attachments, {}
119 119 map.permission :protect_wiki_pages, {:wiki => :protect}, :require => :member
120 120 end
121 121
122 122 map.project_module :repository do |map|
123 123 map.permission :manage_repository, {:repositories => [:edit, :committers, :destroy]}, :require => :member
124 124 map.permission :browse_repository, :repositories => [:show, :browse, :entry, :annotate, :changes, :diff, :stats, :graph]
125 125 map.permission :view_changesets, :repositories => [:show, :revisions, :revision]
126 126 map.permission :commit_access, {}
127 127 end
128 128
129 129 map.project_module :boards do |map|
130 130 map.permission :manage_boards, {:boards => [:new, :edit, :destroy]}, :require => :member
131 131 map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true
132 132 map.permission :add_messages, {:messages => [:new, :reply, :quote]}
133 133 map.permission :edit_messages, {:messages => :edit}, :require => :member
134 134 map.permission :edit_own_messages, {:messages => :edit}, :require => :loggedin
135 135 map.permission :delete_messages, {:messages => :destroy}, :require => :member
136 136 map.permission :delete_own_messages, {:messages => :destroy}, :require => :loggedin
137 137 end
138 138
139 139 map.project_module :calendar do |map|
140 140 map.permission :view_calendar, :calendars => :show
141 141 end
142 142
143 143 map.project_module :gantt do |map|
144 144 map.permission :view_gantt, :gantts => :show
145 145 end
146 146 end
147 147
148 148 Redmine::MenuManager.map :top_menu do |menu|
149 149 menu.push :home, :home_path
150 150 menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? }
151 151 menu.push :projects, { :controller => 'projects', :action => 'index' }, :caption => :label_project_plural
152 152 menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true
153 153 menu.push :help, Redmine::Info.help_url, :last => true
154 154 end
155 155
156 156 Redmine::MenuManager.map :account_menu do |menu|
157 157 menu.push :login, :signin_path, :if => Proc.new { !User.current.logged? }
158 158 menu.push :register, { :controller => 'account', :action => 'register' }, :if => Proc.new { !User.current.logged? && Setting.self_registration? }
159 159 menu.push :my_account, { :controller => 'my', :action => 'account' }, :if => Proc.new { User.current.logged? }
160 160 menu.push :logout, :signout_path, :if => Proc.new { User.current.logged? }
161 161 end
162 162
163 163 Redmine::MenuManager.map :application_menu do |menu|
164 164 # Empty
165 165 end
166 166
167 167 Redmine::MenuManager.map :admin_menu do |menu|
168 168 menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural
169 169 menu.push :users, {:controller => 'users'}, :caption => :label_user_plural
170 170 menu.push :groups, {:controller => 'groups'}, :caption => :label_group_plural
171 171 menu.push :roles, {:controller => 'roles'}, :caption => :label_role_and_permissions
172 172 menu.push :trackers, {:controller => 'trackers'}, :caption => :label_tracker_plural
173 173 menu.push :issue_statuses, {:controller => 'issue_statuses'}, :caption => :label_issue_status_plural,
174 174 :html => {:class => 'issue_statuses'}
175 175 menu.push :workflows, {:controller => 'workflows', :action => 'edit'}, :caption => :label_workflow
176 176 menu.push :custom_fields, {:controller => 'custom_fields'}, :caption => :label_custom_field_plural,
177 177 :html => {:class => 'custom_fields'}
178 178 menu.push :enumerations, {:controller => 'enumerations'}
179 179 menu.push :settings, {:controller => 'settings'}
180 180 menu.push :ldap_authentication, {:controller => 'ldap_auth_sources', :action => 'index'},
181 181 :html => {:class => 'server_authentication'}
182 182 menu.push :plugins, {:controller => 'admin', :action => 'plugins'}, :last => true
183 183 menu.push :info, {:controller => 'admin', :action => 'info'}, :caption => :label_information_plural, :last => true
184 184 end
185 185
186 186 Redmine::MenuManager.map :project_menu do |menu|
187 187 menu.push :overview, { :controller => 'projects', :action => 'show' }
188 menu.push :activity, { :controller => 'projects', :action => 'activity' }
188 menu.push :activity, { :controller => 'activities', :action => 'index' }
189 189 menu.push :roadmap, { :controller => 'projects', :action => 'roadmap' },
190 190 :if => Proc.new { |p| p.shared_versions.any? }
191 191 menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural
192 192 menu.push :new_issue, { :controller => 'issues', :action => 'new' }, :param => :project_id, :caption => :label_issue_new,
193 193 :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) }
194 194 menu.push :gantt, { :controller => 'gantts', :action => 'show' }, :param => :project_id, :caption => :label_gantt
195 195 menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :param => :project_id, :caption => :label_calendar
196 196 menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural
197 197 menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural
198 198 menu.push :wiki, { :controller => 'wiki', :action => 'index', :page => nil },
199 199 :if => Proc.new { |p| p.wiki && !p.wiki.new_record? }
200 200 menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id,
201 201 :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural
202 202 menu.push :files, { :controller => 'projects', :action => 'list_files' }, :caption => :label_file_plural
203 203 menu.push :repository, { :controller => 'repositories', :action => 'show' },
204 204 :if => Proc.new { |p| p.repository && !p.repository.new_record? }
205 205 menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true
206 206 end
207 207
208 208 Redmine::Activity.map do |activity|
209 209 activity.register :issues, :class_name => %w(Issue Journal)
210 210 activity.register :changesets
211 211 activity.register :news
212 212 activity.register :documents, :class_name => %w(Document Attachment)
213 213 activity.register :files, :class_name => 'Attachment'
214 214 activity.register :wiki_edits, :class_name => 'WikiContent::Version', :default => false
215 215 activity.register :messages, :default => false
216 216 activity.register :time_entries, :default => false
217 217 end
218 218
219 219 Redmine::Search.map do |search|
220 220 search.register :issues
221 221 search.register :news
222 222 search.register :documents
223 223 search.register :changesets
224 224 search.register :wiki_pages
225 225 search.register :messages
226 226 search.register :projects
227 227 end
228 228
229 229 Redmine::WikiFormatting.map do |format|
230 230 format.register :textile, Redmine::WikiFormatting::Textile::Formatter, Redmine::WikiFormatting::Textile::Helper
231 231 end
@@ -1,744 +1,663
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 90 context "#add" 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 97 get :add
98 98 assert_response :success
99 99 assert_template 'add'
100 100 end
101 101
102 102 should "accept post" do
103 103 post :add, :project => { :name => "blog",
104 104 :description => "weblog",
105 105 :identifier => "blog",
106 106 :is_public => 1,
107 107 :custom_field_values => { '3' => 'Beta' }
108 108 }
109 109 assert_redirected_to '/projects/blog/settings'
110 110
111 111 project = Project.find_by_name('blog')
112 112 assert_kind_of Project, project
113 113 assert_equal 'weblog', project.description
114 114 assert_equal true, project.is_public?
115 115 assert_nil project.parent
116 116 end
117 117
118 118 should "accept post with parent" do
119 119 post :add, :project => { :name => "blog",
120 120 :description => "weblog",
121 121 :identifier => "blog",
122 122 :is_public => 1,
123 123 :custom_field_values => { '3' => 'Beta' },
124 124 :parent_id => 1
125 125 }
126 126 assert_redirected_to '/projects/blog/settings'
127 127
128 128 project = Project.find_by_name('blog')
129 129 assert_kind_of Project, project
130 130 assert_equal Project.find(1), project.parent
131 131 end
132 132 end
133 133
134 134 context "by non-admin user with add_project permission" do
135 135 setup do
136 136 Role.non_member.add_permission! :add_project
137 137 @request.session[:user_id] = 9
138 138 end
139 139
140 140 should "accept get" do
141 141 get :add
142 142 assert_response :success
143 143 assert_template 'add'
144 144 assert_no_tag :select, :attributes => {:name => 'project[parent_id]'}
145 145 end
146 146
147 147 should "accept post" do
148 148 post :add, :project => { :name => "blog",
149 149 :description => "weblog",
150 150 :identifier => "blog",
151 151 :is_public => 1,
152 152 :custom_field_values => { '3' => 'Beta' }
153 153 }
154 154
155 155 assert_redirected_to '/projects/blog/settings'
156 156
157 157 project = Project.find_by_name('blog')
158 158 assert_kind_of Project, project
159 159 assert_equal 'weblog', project.description
160 160 assert_equal true, project.is_public?
161 161
162 162 # User should be added as a project member
163 163 assert User.find(9).member_of?(project)
164 164 assert_equal 1, project.members.size
165 165 end
166 166
167 167 should "fail with parent_id" do
168 168 assert_no_difference 'Project.count' do
169 169 post :add, :project => { :name => "blog",
170 170 :description => "weblog",
171 171 :identifier => "blog",
172 172 :is_public => 1,
173 173 :custom_field_values => { '3' => 'Beta' },
174 174 :parent_id => 1
175 175 }
176 176 end
177 177 assert_response :success
178 178 project = assigns(:project)
179 179 assert_kind_of Project, project
180 180 assert_not_nil project.errors.on(:parent_id)
181 181 end
182 182 end
183 183
184 184 context "by non-admin user with add_subprojects permission" do
185 185 setup do
186 186 Role.find(1).remove_permission! :add_project
187 187 Role.find(1).add_permission! :add_subprojects
188 188 @request.session[:user_id] = 2
189 189 end
190 190
191 191 should "accept get" do
192 192 get :add, :parent_id => 'ecookbook'
193 193 assert_response :success
194 194 assert_template 'add'
195 195 # parent project selected
196 196 assert_tag :select, :attributes => {:name => 'project[parent_id]'},
197 197 :child => {:tag => 'option', :attributes => {:value => '1', :selected => 'selected'}}
198 198 # no empty value
199 199 assert_no_tag :select, :attributes => {:name => 'project[parent_id]'},
200 200 :child => {:tag => 'option', :attributes => {:value => ''}}
201 201 end
202 202
203 203 should "accept post with parent_id" do
204 204 post :add, :project => { :name => "blog",
205 205 :description => "weblog",
206 206 :identifier => "blog",
207 207 :is_public => 1,
208 208 :custom_field_values => { '3' => 'Beta' },
209 209 :parent_id => 1
210 210 }
211 211 assert_redirected_to '/projects/blog/settings'
212 212 project = Project.find_by_name('blog')
213 213 end
214 214
215 215 should "fail without parent_id" do
216 216 assert_no_difference 'Project.count' do
217 217 post :add, :project => { :name => "blog",
218 218 :description => "weblog",
219 219 :identifier => "blog",
220 220 :is_public => 1,
221 221 :custom_field_values => { '3' => 'Beta' }
222 222 }
223 223 end
224 224 assert_response :success
225 225 project = assigns(:project)
226 226 assert_kind_of Project, project
227 227 assert_not_nil project.errors.on(:parent_id)
228 228 end
229 229
230 230 should "fail with unauthorized parent_id" do
231 231 assert !User.find(2).member_of?(Project.find(6))
232 232 assert_no_difference 'Project.count' do
233 233 post :add, :project => { :name => "blog",
234 234 :description => "weblog",
235 235 :identifier => "blog",
236 236 :is_public => 1,
237 237 :custom_field_values => { '3' => 'Beta' },
238 238 :parent_id => 6
239 239 }
240 240 end
241 241 assert_response :success
242 242 project = assigns(:project)
243 243 assert_kind_of Project, project
244 244 assert_not_nil project.errors.on(:parent_id)
245 245 end
246 246 end
247 247 end
248 248
249 249 def test_show_by_id
250 250 get :show, :id => 1
251 251 assert_response :success
252 252 assert_template 'show'
253 253 assert_not_nil assigns(:project)
254 254 end
255 255
256 256 def test_show_by_identifier
257 257 get :show, :id => 'ecookbook'
258 258 assert_response :success
259 259 assert_template 'show'
260 260 assert_not_nil assigns(:project)
261 261 assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
262 262 end
263 263
264 264 def test_show_should_not_fail_when_custom_values_are_nil
265 265 project = Project.find_by_identifier('ecookbook')
266 266 project.custom_values.first.update_attribute(:value, nil)
267 267 get :show, :id => 'ecookbook'
268 268 assert_response :success
269 269 assert_template 'show'
270 270 assert_not_nil assigns(:project)
271 271 assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
272 272 end
273 273
274 274 def test_private_subprojects_hidden
275 275 get :show, :id => 'ecookbook'
276 276 assert_response :success
277 277 assert_template 'show'
278 278 assert_no_tag :tag => 'a', :content => /Private child/
279 279 end
280 280
281 281 def test_private_subprojects_visible
282 282 @request.session[:user_id] = 2 # manager who is a member of the private subproject
283 283 get :show, :id => 'ecookbook'
284 284 assert_response :success
285 285 assert_template 'show'
286 286 assert_tag :tag => 'a', :content => /Private child/
287 287 end
288 288
289 289 def test_settings
290 290 @request.session[:user_id] = 2 # manager
291 291 get :settings, :id => 1
292 292 assert_response :success
293 293 assert_template 'settings'
294 294 end
295 295
296 296 def test_edit
297 297 @request.session[:user_id] = 2 # manager
298 298 post :edit, :id => 1, :project => {:name => 'Test changed name',
299 299 :issue_custom_field_ids => ['']}
300 300 assert_redirected_to 'projects/ecookbook/settings'
301 301 project = Project.find(1)
302 302 assert_equal 'Test changed name', project.name
303 303 end
304 304
305 305 def test_get_destroy
306 306 @request.session[:user_id] = 1 # admin
307 307 get :destroy, :id => 1
308 308 assert_response :success
309 309 assert_template 'destroy'
310 310 assert_not_nil Project.find_by_id(1)
311 311 end
312 312
313 313 def test_post_destroy
314 314 @request.session[:user_id] = 1 # admin
315 315 post :destroy, :id => 1, :confirm => 1
316 316 assert_redirected_to 'admin/projects'
317 317 assert_nil Project.find_by_id(1)
318 318 end
319 319
320 320 def test_add_file
321 321 set_tmp_attachments_directory
322 322 @request.session[:user_id] = 2
323 323 Setting.notified_events = ['file_added']
324 324 ActionMailer::Base.deliveries.clear
325 325
326 326 assert_difference 'Attachment.count' do
327 327 post :add_file, :id => 1, :version_id => '',
328 328 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
329 329 end
330 330 assert_redirected_to 'projects/ecookbook/files'
331 331 a = Attachment.find(:first, :order => 'created_on DESC')
332 332 assert_equal 'testfile.txt', a.filename
333 333 assert_equal Project.find(1), a.container
334 334
335 335 mail = ActionMailer::Base.deliveries.last
336 336 assert_kind_of TMail::Mail, mail
337 337 assert_equal "[eCookbook] New file", mail.subject
338 338 assert mail.body.include?('testfile.txt')
339 339 end
340 340
341 341 def test_add_version_file
342 342 set_tmp_attachments_directory
343 343 @request.session[:user_id] = 2
344 344 Setting.notified_events = ['file_added']
345 345
346 346 assert_difference 'Attachment.count' do
347 347 post :add_file, :id => 1, :version_id => '2',
348 348 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
349 349 end
350 350 assert_redirected_to 'projects/ecookbook/files'
351 351 a = Attachment.find(:first, :order => 'created_on DESC')
352 352 assert_equal 'testfile.txt', a.filename
353 353 assert_equal Version.find(2), a.container
354 354 end
355 355
356 356 def test_list_files
357 357 get :list_files, :id => 1
358 358 assert_response :success
359 359 assert_template 'list_files'
360 360 assert_not_nil assigns(:containers)
361 361
362 362 # file attached to the project
363 363 assert_tag :a, :content => 'project_file.zip',
364 364 :attributes => { :href => '/attachments/download/8/project_file.zip' }
365 365
366 366 # file attached to a project's version
367 367 assert_tag :a, :content => 'version_file.zip',
368 368 :attributes => { :href => '/attachments/download/9/version_file.zip' }
369 369 end
370 370
371 371 def test_roadmap
372 372 get :roadmap, :id => 1
373 373 assert_response :success
374 374 assert_template 'roadmap'
375 375 assert_not_nil assigns(:versions)
376 376 # Version with no date set appears
377 377 assert assigns(:versions).include?(Version.find(3))
378 378 # Completed version doesn't appear
379 379 assert !assigns(:versions).include?(Version.find(1))
380 380 end
381 381
382 382 def test_roadmap_with_completed_versions
383 383 get :roadmap, :id => 1, :completed => 1
384 384 assert_response :success
385 385 assert_template 'roadmap'
386 386 assert_not_nil assigns(:versions)
387 387 # Version with no date set appears
388 388 assert assigns(:versions).include?(Version.find(3))
389 389 # Completed version appears
390 390 assert assigns(:versions).include?(Version.find(1))
391 391 end
392 392
393 393 def test_roadmap_showing_subprojects_versions
394 394 @subproject_version = Version.generate!(:project => Project.find(3))
395 395 get :roadmap, :id => 1, :with_subprojects => 1
396 396 assert_response :success
397 397 assert_template 'roadmap'
398 398 assert_not_nil assigns(:versions)
399 399
400 400 assert assigns(:versions).include?(Version.find(4)), "Shared version not found"
401 401 assert assigns(:versions).include?(@subproject_version), "Subproject version not found"
402 402 end
403 def test_project_activity
404 get :activity, :id => 1, :with_subprojects => 0
405 assert_response :success
406 assert_template 'activity'
407 assert_not_nil assigns(:events_by_day)
408
409 assert_tag :tag => "h3",
410 :content => /#{2.days.ago.to_date.day}/,
411 :sibling => { :tag => "dl",
412 :child => { :tag => "dt",
413 :attributes => { :class => /issue-edit/ },
414 :child => { :tag => "a",
415 :content => /(#{IssueStatus.find(2).name})/,
416 }
417 }
418 }
419 end
420
421 def test_previous_project_activity
422 get :activity, :id => 1, :from => 3.days.ago.to_date
423 assert_response :success
424 assert_template 'activity'
425 assert_not_nil assigns(:events_by_day)
426
427 assert_tag :tag => "h3",
428 :content => /#{3.day.ago.to_date.day}/,
429 :sibling => { :tag => "dl",
430 :child => { :tag => "dt",
431 :attributes => { :class => /issue/ },
432 :child => { :tag => "a",
433 :content => /#{Issue.find(1).subject}/,
434 }
435 }
436 }
437 end
438
439 def test_global_activity
440 get :activity
441 assert_response :success
442 assert_template 'activity'
443 assert_not_nil assigns(:events_by_day)
444
445 assert_tag :tag => "h3",
446 :content => /#{5.day.ago.to_date.day}/,
447 :sibling => { :tag => "dl",
448 :child => { :tag => "dt",
449 :attributes => { :class => /issue/ },
450 :child => { :tag => "a",
451 :content => /#{Issue.find(5).subject}/,
452 }
453 }
454 }
455 end
456
457 def test_user_activity
458 get :activity, :user_id => 2
459 assert_response :success
460 assert_template 'activity'
461 assert_not_nil assigns(:events_by_day)
462
463 assert_tag :tag => "h3",
464 :content => /#{3.day.ago.to_date.day}/,
465 :sibling => { :tag => "dl",
466 :child => { :tag => "dt",
467 :attributes => { :class => /issue/ },
468 :child => { :tag => "a",
469 :content => /#{Issue.find(1).subject}/,
470 }
471 }
472 }
473 end
474
475 def test_activity_atom_feed
476 get :activity, :format => 'atom'
477 assert_response :success
478 assert_template 'common/feed.atom.rxml'
479 assert_tag :tag => 'entry', :child => {
480 :tag => 'link',
481 :attributes => {:href => 'http://test.host/issues/11'}}
482 end
483
484 403 def test_archive
485 404 @request.session[:user_id] = 1 # admin
486 405 post :archive, :id => 1
487 406 assert_redirected_to 'admin/projects'
488 407 assert !Project.find(1).active?
489 408 end
490 409
491 410 def test_unarchive
492 411 @request.session[:user_id] = 1 # admin
493 412 Project.find(1).archive
494 413 post :unarchive, :id => 1
495 414 assert_redirected_to 'admin/projects'
496 415 assert Project.find(1).active?
497 416 end
498 417
499 418 def test_project_breadcrumbs_should_be_limited_to_3_ancestors
500 419 CustomField.delete_all
501 420 parent = nil
502 421 6.times do |i|
503 422 p = Project.create!(:name => "Breadcrumbs #{i}", :identifier => "breadcrumbs-#{i}")
504 423 p.set_parent!(parent)
505 424 get :show, :id => p
506 425 assert_tag :h1, :parent => { :attributes => {:id => 'header'}},
507 426 :children => { :count => [i, 3].min,
508 427 :only => { :tag => 'a' } }
509 428
510 429 parent = p
511 430 end
512 431 end
513 432
514 433 def test_copy_with_project
515 434 @request.session[:user_id] = 1 # admin
516 435 get :copy, :id => 1
517 436 assert_response :success
518 437 assert_template 'copy'
519 438 assert assigns(:project)
520 439 assert_equal Project.find(1).description, assigns(:project).description
521 440 assert_nil assigns(:project).id
522 441 end
523 442
524 443 def test_copy_without_project
525 444 @request.session[:user_id] = 1 # admin
526 445 get :copy
527 446 assert_response :redirect
528 447 assert_redirected_to :controller => 'admin', :action => 'projects'
529 448 end
530 449
531 450 def test_jump_should_redirect_to_active_tab
532 451 get :show, :id => 1, :jump => 'issues'
533 452 assert_redirected_to 'projects/ecookbook/issues'
534 453 end
535 454
536 455 def test_jump_should_not_redirect_to_inactive_tab
537 456 get :show, :id => 3, :jump => 'documents'
538 457 assert_response :success
539 458 assert_template 'show'
540 459 end
541 460
542 461 def test_jump_should_not_redirect_to_unknown_tab
543 462 get :show, :id => 3, :jump => 'foobar'
544 463 assert_response :success
545 464 assert_template 'show'
546 465 end
547 466
548 467 def test_reset_activities
549 468 @request.session[:user_id] = 2 # manager
550 469 project_activity = TimeEntryActivity.new({
551 470 :name => 'Project Specific',
552 471 :parent => TimeEntryActivity.find(:first),
553 472 :project => Project.find(1),
554 473 :active => true
555 474 })
556 475 assert project_activity.save
557 476 project_activity_two = TimeEntryActivity.new({
558 477 :name => 'Project Specific Two',
559 478 :parent => TimeEntryActivity.find(:last),
560 479 :project => Project.find(1),
561 480 :active => true
562 481 })
563 482 assert project_activity_two.save
564 483
565 484 delete :reset_activities, :id => 1
566 485 assert_response :redirect
567 486 assert_redirected_to 'projects/ecookbook/settings/activities'
568 487
569 488 assert_nil TimeEntryActivity.find_by_id(project_activity.id)
570 489 assert_nil TimeEntryActivity.find_by_id(project_activity_two.id)
571 490 end
572 491
573 492 def test_reset_activities_should_reassign_time_entries_back_to_the_system_activity
574 493 @request.session[:user_id] = 2 # manager
575 494 project_activity = TimeEntryActivity.new({
576 495 :name => 'Project Specific Design',
577 496 :parent => TimeEntryActivity.find(9),
578 497 :project => Project.find(1),
579 498 :active => true
580 499 })
581 500 assert project_activity.save
582 501 assert TimeEntry.update_all("activity_id = '#{project_activity.id}'", ["project_id = ? AND activity_id = ?", 1, 9])
583 502 assert 3, TimeEntry.find_all_by_activity_id_and_project_id(project_activity.id, 1).size
584 503
585 504 delete :reset_activities, :id => 1
586 505 assert_response :redirect
587 506 assert_redirected_to 'projects/ecookbook/settings/activities'
588 507
589 508 assert_nil TimeEntryActivity.find_by_id(project_activity.id)
590 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"
591 510 assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size, "TimeEntries still assigned to project specific activity"
592 511 end
593 512
594 513 def test_save_activities_to_override_system_activities
595 514 @request.session[:user_id] = 2 # manager
596 515 billable_field = TimeEntryActivityCustomField.find_by_name("Billable")
597 516
598 517 post :save_activities, :id => 1, :enumerations => {
599 518 "9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"}, # Design, De-activate
600 519 "10"=> {"parent_id"=>"10", "custom_field_values"=>{"7"=>"0"}, "active"=>"1"}, # Development, Change custom value
601 520 "14"=>{"parent_id"=>"14", "custom_field_values"=>{"7"=>"1"}, "active"=>"1"}, # Inactive Activity, Activate with custom value
602 521 "11"=>{"parent_id"=>"11", "custom_field_values"=>{"7"=>"1"}, "active"=>"1"} # QA, no changes
603 522 }
604 523
605 524 assert_response :redirect
606 525 assert_redirected_to 'projects/ecookbook/settings/activities'
607 526
608 527 # Created project specific activities...
609 528 project = Project.find('ecookbook')
610 529
611 530 # ... Design
612 531 design = project.time_entry_activities.find_by_name("Design")
613 532 assert design, "Project activity not found"
614 533
615 534 assert_equal 9, design.parent_id # Relate to the system activity
616 535 assert_not_equal design.parent.id, design.id # Different records
617 536 assert_equal design.parent.name, design.name # Same name
618 537 assert !design.active?
619 538
620 539 # ... Development
621 540 development = project.time_entry_activities.find_by_name("Development")
622 541 assert development, "Project activity not found"
623 542
624 543 assert_equal 10, development.parent_id # Relate to the system activity
625 544 assert_not_equal development.parent.id, development.id # Different records
626 545 assert_equal development.parent.name, development.name # Same name
627 546 assert development.active?
628 547 assert_equal "0", development.custom_value_for(billable_field).value
629 548
630 549 # ... Inactive Activity
631 550 previously_inactive = project.time_entry_activities.find_by_name("Inactive Activity")
632 551 assert previously_inactive, "Project activity not found"
633 552
634 553 assert_equal 14, previously_inactive.parent_id # Relate to the system activity
635 554 assert_not_equal previously_inactive.parent.id, previously_inactive.id # Different records
636 555 assert_equal previously_inactive.parent.name, previously_inactive.name # Same name
637 556 assert previously_inactive.active?
638 557 assert_equal "1", previously_inactive.custom_value_for(billable_field).value
639 558
640 559 # ... QA
641 560 assert_equal nil, project.time_entry_activities.find_by_name("QA"), "Custom QA activity created when it wasn't modified"
642 561 end
643 562
644 563 def test_save_activities_will_update_project_specific_activities
645 564 @request.session[:user_id] = 2 # manager
646 565
647 566 project_activity = TimeEntryActivity.new({
648 567 :name => 'Project Specific',
649 568 :parent => TimeEntryActivity.find(:first),
650 569 :project => Project.find(1),
651 570 :active => true
652 571 })
653 572 assert project_activity.save
654 573 project_activity_two = TimeEntryActivity.new({
655 574 :name => 'Project Specific Two',
656 575 :parent => TimeEntryActivity.find(:last),
657 576 :project => Project.find(1),
658 577 :active => true
659 578 })
660 579 assert project_activity_two.save
661 580
662 581
663 582 post :save_activities, :id => 1, :enumerations => {
664 583 project_activity.id => {"custom_field_values"=>{"7" => "1"}, "active"=>"0"}, # De-activate
665 584 project_activity_two.id => {"custom_field_values"=>{"7" => "1"}, "active"=>"0"} # De-activate
666 585 }
667 586
668 587 assert_response :redirect
669 588 assert_redirected_to 'projects/ecookbook/settings/activities'
670 589
671 590 # Created project specific activities...
672 591 project = Project.find('ecookbook')
673 592 assert_equal 2, project.time_entry_activities.count
674 593
675 594 activity_one = project.time_entry_activities.find_by_name(project_activity.name)
676 595 assert activity_one, "Project activity not found"
677 596 assert_equal project_activity.id, activity_one.id
678 597 assert !activity_one.active?
679 598
680 599 activity_two = project.time_entry_activities.find_by_name(project_activity_two.name)
681 600 assert activity_two, "Project activity not found"
682 601 assert_equal project_activity_two.id, activity_two.id
683 602 assert !activity_two.active?
684 603 end
685 604
686 605 def test_save_activities_when_creating_new_activities_will_convert_existing_data
687 606 assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size
688 607
689 608 @request.session[:user_id] = 2 # manager
690 609 post :save_activities, :id => 1, :enumerations => {
691 610 "9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"} # Design, De-activate
692 611 }
693 612 assert_response :redirect
694 613
695 614 # No more TimeEntries using the system activity
696 615 assert_equal 0, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size, "Time Entries still assigned to system activities"
697 616 # All TimeEntries using project activity
698 617 project_specific_activity = TimeEntryActivity.find_by_parent_id_and_project_id(9, 1)
699 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"
700 619 end
701 620
702 621 def test_save_activities_when_creating_new_activities_will_not_convert_existing_data_if_an_exception_is_raised
703 622 # TODO: Need to cause an exception on create but these tests
704 623 # aren't setup for mocking. Just create a record now so the
705 624 # second one is a dupicate
706 625 parent = TimeEntryActivity.find(9)
707 626 TimeEntryActivity.create!({:name => parent.name, :project_id => 1, :position => parent.position, :active => true})
708 627 TimeEntry.create!({:project_id => 1, :hours => 1.0, :user => User.find(1), :issue_id => 3, :activity_id => 10, :spent_on => '2009-01-01'})
709 628
710 629 assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size
711 630 assert_equal 1, TimeEntry.find_all_by_activity_id_and_project_id(10, 1).size
712 631
713 632 @request.session[:user_id] = 2 # manager
714 633 post :save_activities, :id => 1, :enumerations => {
715 634 "9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"}, # Design
716 635 "10"=> {"parent_id"=>"10", "custom_field_values"=>{"7"=>"0"}, "active"=>"1"} # Development, Change custom value
717 636 }
718 637 assert_response :redirect
719 638
720 639 # TimeEntries shouldn't have been reassigned on the failed record
721 640 assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size, "Time Entries are not assigned to system activities"
722 641 # TimeEntries shouldn't have been reassigned on the saved record either
723 642 assert_equal 1, TimeEntry.find_all_by_activity_id_and_project_id(10, 1).size, "Time Entries are not assigned to system activities"
724 643 end
725 644
726 645 # A hook that is manually registered later
727 646 class ProjectBasedTemplate < Redmine::Hook::ViewListener
728 647 def view_layouts_base_html_head(context)
729 648 # Adds a project stylesheet
730 649 stylesheet_link_tag(context[:project].identifier) if context[:project]
731 650 end
732 651 end
733 652 # Don't use this hook now
734 653 Redmine::Hook.clear_listeners
735 654
736 655 def test_hook_response
737 656 Redmine::Hook.add_listener(ProjectBasedTemplate)
738 657 get :show, :id => 1
739 658 assert_tag :tag => 'link', :attributes => {:href => '/stylesheets/ecookbook.css'},
740 659 :parent => {:tag => 'head'}
741 660
742 661 Redmine::Hook.clear_listeners
743 662 end
744 663 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 should_route :get, "/activity", :controller => 'projects', :action => 'activity', :id => nil
23 should_route :get, "/activity.atom", :controller => 'projects', :action => 'activity', :id => nil, :format => 'atom'
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'
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 :post, "/issues/calendar", :controller => 'calendars', :action => 'show'
95 95 should_route :get, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'show', :project_id => 'project-name'
96 96 should_route :post, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'show', :project_id => 'project-name'
97 97
98 98 should_route :get, "/issues/gantt", :controller => 'gantts', :action => 'show'
99 99 should_route :post, "/issues/gantt", :controller => 'gantts', :action => 'show'
100 100 should_route :get, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'show', :project_id => 'project-name'
101 101 should_route :post, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'show', :project_id => 'project-name'
102 102
103 103 should_route :get, "/issues/auto_complete", :controller => 'auto_completes', :action => 'issues'
104 104
105 105 should_route :get, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123'
106 106 should_route :post, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123'
107 107 should_route :get, "/issues/context_menu", :controller => 'context_menus', :action => 'issues'
108 108 should_route :post, "/issues/context_menu", :controller => 'context_menus', :action => 'issues'
109 109
110 110 should_route :get, "/issues/changes", :controller => 'journals', :action => 'index'
111 111
112 112 should_route :get, "/issues/bulk_edit", :controller => 'issues', :action => 'bulk_edit'
113 113 should_route :post, "/issues/bulk_edit", :controller => 'issues', :action => 'bulk_update'
114 114 end
115 115
116 116 context "issue categories" do
117 117 should_route :get, "/projects/test/issue_categories/new", :controller => 'issue_categories', :action => 'new', :project_id => 'test'
118 118
119 119 should_route :post, "/projects/test/issue_categories/new", :controller => 'issue_categories', :action => 'new', :project_id => 'test'
120 120 end
121 121
122 122 context "issue relations" do
123 123 should_route :post, "/issues/1/relations", :controller => 'issue_relations', :action => 'new', :issue_id => '1'
124 124 should_route :post, "/issues/1/relations/23/destroy", :controller => 'issue_relations', :action => 'destroy', :issue_id => '1', :id => '23'
125 125 end
126 126
127 127 context "issue reports" do
128 128 should_route :get, "/projects/567/issues/report", :controller => 'reports', :action => 'issue_report', :id => '567'
129 129 should_route :get, "/projects/567/issues/report/assigned_to", :controller => 'reports', :action => 'issue_report_details', :id => '567', :detail => 'assigned_to'
130 130 end
131 131
132 132 context "members" do
133 133 should_route :post, "/projects/5234/members/new", :controller => 'members', :action => 'new', :id => '5234'
134 134 end
135 135
136 136 context "messages" do
137 137 should_route :get, "/boards/22/topics/2", :controller => 'messages', :action => 'show', :id => '2', :board_id => '22'
138 138 should_route :get, "/boards/lala/topics/new", :controller => 'messages', :action => 'new', :board_id => 'lala'
139 139 should_route :get, "/boards/lala/topics/22/edit", :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala'
140 140
141 141 should_route :post, "/boards/lala/topics/new", :controller => 'messages', :action => 'new', :board_id => 'lala'
142 142 should_route :post, "/boards/lala/topics/22/edit", :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala'
143 143 should_route :post, "/boards/22/topics/555/replies", :controller => 'messages', :action => 'reply', :id => '555', :board_id => '22'
144 144 should_route :post, "/boards/22/topics/555/destroy", :controller => 'messages', :action => 'destroy', :id => '555', :board_id => '22'
145 145 end
146 146
147 147 context "news" do
148 148 should_route :get, "/news", :controller => 'news', :action => 'index'
149 149 should_route :get, "/news.atom", :controller => 'news', :action => 'index', :format => 'atom'
150 150 should_route :get, "/news.xml", :controller => 'news', :action => 'index', :format => 'xml'
151 151 should_route :get, "/news.json", :controller => 'news', :action => 'index', :format => 'json'
152 152 should_route :get, "/projects/567/news", :controller => 'news', :action => 'index', :project_id => '567'
153 153 should_route :get, "/projects/567/news.atom", :controller => 'news', :action => 'index', :format => 'atom', :project_id => '567'
154 154 should_route :get, "/projects/567/news.xml", :controller => 'news', :action => 'index', :format => 'xml', :project_id => '567'
155 155 should_route :get, "/projects/567/news.json", :controller => 'news', :action => 'index', :format => 'json', :project_id => '567'
156 156 should_route :get, "/news/2", :controller => 'news', :action => 'show', :id => '2'
157 157 should_route :get, "/projects/567/news/new", :controller => 'news', :action => 'new', :project_id => '567'
158 158 should_route :get, "/news/234", :controller => 'news', :action => 'show', :id => '234'
159 159
160 160 should_route :post, "/projects/567/news/new", :controller => 'news', :action => 'new', :project_id => '567'
161 161 should_route :post, "/news/567/edit", :controller => 'news', :action => 'edit', :id => '567'
162 162 should_route :post, "/news/567/destroy", :controller => 'news', :action => 'destroy', :id => '567'
163 163 end
164 164
165 165 context "projects" do
166 166 should_route :get, "/projects", :controller => 'projects', :action => 'index'
167 167 should_route :get, "/projects.atom", :controller => 'projects', :action => 'index', :format => 'atom'
168 168 should_route :get, "/projects.xml", :controller => 'projects', :action => 'index', :format => 'xml'
169 169 should_route :get, "/projects/new", :controller => 'projects', :action => 'add'
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 => 'projects', :action => 'list_files', :id => '33'
176 176 should_route :get, "/projects/33/files/new", :controller => 'projects', :action => 'add_file', :id => '33'
177 177 should_route :get, "/projects/33/roadmap", :controller => 'projects', :action => 'roadmap', :id => '33'
178 should_route :get, "/projects/33/activity", :controller => 'projects', :action => 'activity', :id => '33'
179 should_route :get, "/projects/33/activity.atom", :controller => 'projects', :action => 'activity', :id => '33', :format => 'atom'
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'
180 180
181 181 should_route :post, "/projects/new", :controller => 'projects', :action => 'add'
182 182 should_route :post, "/projects.xml", :controller => 'projects', :action => 'add', :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 => 'projects', :action => 'add_file', :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 => 'projects', :action => 'save_activities', :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 => 'projects', :action => 'reset_activities', :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