@@ -1,155 +1,155 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | class VersionsController < ApplicationController |
|
18 | class VersionsController < ApplicationController | |
19 | menu_item :roadmap |
|
19 | menu_item :roadmap | |
20 | model_object Version |
|
20 | model_object Version | |
21 | before_filter :find_model_object, :except => [:index, :new, :create, :close_completed] |
|
21 | before_filter :find_model_object, :except => [:index, :new, :create, :close_completed] | |
22 | before_filter :find_project_from_association, :except => [:index, :new, :create, :close_completed] |
|
22 | before_filter :find_project_from_association, :except => [:index, :new, :create, :close_completed] | |
23 | before_filter :find_project, :only => [:index, :new, :create, :close_completed] |
|
23 | before_filter :find_project, :only => [:index, :new, :create, :close_completed] | |
24 | before_filter :authorize |
|
24 | before_filter :authorize | |
25 |
|
25 | |||
26 | helper :custom_fields |
|
26 | helper :custom_fields | |
27 | helper :projects |
|
27 | helper :projects | |
28 |
|
28 | |||
29 | def index |
|
29 | def index | |
30 | @trackers = @project.trackers.find(:all, :order => 'position') |
|
30 | @trackers = @project.trackers.find(:all, :order => 'position') | |
31 | retrieve_selected_tracker_ids(@trackers, @trackers.select {|t| t.is_in_roadmap?}) |
|
31 | retrieve_selected_tracker_ids(@trackers, @trackers.select {|t| t.is_in_roadmap?}) | |
32 | @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') |
|
32 | @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') | |
33 | project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id] |
|
33 | project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id] | |
34 |
|
34 | |||
35 | @versions = @project.shared_versions || [] |
|
35 | @versions = @project.shared_versions || [] | |
36 | @versions += @project.rolled_up_versions.visible if @with_subprojects |
|
36 | @versions += @project.rolled_up_versions.visible if @with_subprojects | |
37 | @versions = @versions.uniq.sort |
|
37 | @versions = @versions.uniq.sort | |
38 | @versions.reject! {|version| version.closed? || version.completed? } unless params[:completed] |
|
38 | @versions.reject! {|version| version.closed? || version.completed? } unless params[:completed] | |
39 |
|
39 | |||
40 | @issues_by_version = {} |
|
40 | @issues_by_version = {} | |
41 | unless @selected_tracker_ids.empty? |
|
41 | unless @selected_tracker_ids.empty? | |
42 | @versions.each do |version| |
|
42 | @versions.each do |version| | |
43 | issues = version.fixed_issues.visible.find(:all, |
|
43 | issues = version.fixed_issues.visible.find(:all, | |
44 | :include => [:project, :status, :tracker, :priority], |
|
44 | :include => [:project, :status, :tracker, :priority], | |
45 | :conditions => {:tracker_id => @selected_tracker_ids, :project_id => project_ids}, |
|
45 | :conditions => {:tracker_id => @selected_tracker_ids, :project_id => project_ids}, | |
46 | :order => "#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id") |
|
46 | :order => "#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id") | |
47 | @issues_by_version[version] = issues |
|
47 | @issues_by_version[version] = issues | |
48 | end |
|
48 | end | |
49 | end |
|
49 | end | |
50 | @versions.reject! {|version| !project_ids.include?(version.project_id) && @issues_by_version[version].blank?} |
|
50 | @versions.reject! {|version| !project_ids.include?(version.project_id) && @issues_by_version[version].blank?} | |
51 | end |
|
51 | end | |
52 |
|
52 | |||
53 | def show |
|
53 | def show | |
54 | @issues = @version.fixed_issues.visible.find(:all, |
|
54 | @issues = @version.fixed_issues.visible.find(:all, | |
55 | :include => [:status, :tracker, :priority], |
|
55 | :include => [:status, :tracker, :priority], | |
56 | :order => "#{Tracker.table_name}.position, #{Issue.table_name}.id") |
|
56 | :order => "#{Tracker.table_name}.position, #{Issue.table_name}.id") | |
57 | end |
|
57 | end | |
58 |
|
58 | |||
59 | def new |
|
59 | def new | |
60 | @version = @project.versions.build |
|
60 | @version = @project.versions.build | |
61 | if params[:version] |
|
61 | if params[:version] | |
62 | attributes = params[:version].dup |
|
62 | attributes = params[:version].dup | |
63 | attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing']) |
|
63 | attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing']) | |
64 | @version.attributes = attributes |
|
64 | @version.attributes = attributes | |
65 | end |
|
65 | end | |
66 | end |
|
66 | end | |
67 |
|
67 | |||
68 | def create |
|
68 | def create | |
69 | # TODO: refactor with code above in #new |
|
69 | # TODO: refactor with code above in #new | |
70 | @version = @project.versions.build |
|
70 | @version = @project.versions.build | |
71 | if params[:version] |
|
71 | if params[:version] | |
72 | attributes = params[:version].dup |
|
72 | attributes = params[:version].dup | |
73 | attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing']) |
|
73 | attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing']) | |
74 | @version.attributes = attributes |
|
74 | @version.attributes = attributes | |
75 | end |
|
75 | end | |
76 |
|
76 | |||
77 | if request.post? |
|
77 | if request.post? | |
78 | if @version.save |
|
78 | if @version.save | |
79 | respond_to do |format| |
|
79 | respond_to do |format| | |
80 | format.html do |
|
80 | format.html do | |
81 | flash[:notice] = l(:notice_successful_create) |
|
81 | flash[:notice] = l(:notice_successful_create) | |
82 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
82 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project | |
83 | end |
|
83 | end | |
84 | format.js do |
|
84 | format.js do | |
85 | # IE doesn't support the replace_html rjs method for select box options |
|
85 | # IE doesn't support the replace_html rjs method for select box options | |
86 | render(:update) {|page| page.replace "issue_fixed_version_id", |
|
86 | render(:update) {|page| page.replace "issue_fixed_version_id", | |
87 | content_tag('select', '<option></option>' + version_options_for_select(@project.shared_versions.open, @version), :id => 'issue_fixed_version_id', :name => 'issue[fixed_version_id]') |
|
87 | content_tag('select', '<option></option>' + version_options_for_select(@project.shared_versions.open, @version), :id => 'issue_fixed_version_id', :name => 'issue[fixed_version_id]') | |
88 | } |
|
88 | } | |
89 | end |
|
89 | end | |
90 | end |
|
90 | end | |
91 | else |
|
91 | else | |
92 | respond_to do |format| |
|
92 | respond_to do |format| | |
93 | format.html { render :action => 'new' } |
|
93 | format.html { render :action => 'new' } | |
94 | format.js do |
|
94 | format.js do | |
95 | render(:update) {|page| page.alert(@version.errors.full_messages.join('\n')) } |
|
95 | render(:update) {|page| page.alert(@version.errors.full_messages.join('\n')) } | |
96 | end |
|
96 | end | |
97 | end |
|
97 | end | |
98 | end |
|
98 | end | |
99 | end |
|
99 | end | |
100 | end |
|
100 | end | |
101 |
|
101 | |||
102 | def edit |
|
102 | def edit | |
103 | end |
|
103 | end | |
104 |
|
104 | |||
105 | def update |
|
105 | def update | |
106 |
if request.p |
|
106 | if request.put? && params[:version] | |
107 | attributes = params[:version].dup |
|
107 | attributes = params[:version].dup | |
108 | attributes.delete('sharing') unless @version.allowed_sharings.include?(attributes['sharing']) |
|
108 | attributes.delete('sharing') unless @version.allowed_sharings.include?(attributes['sharing']) | |
109 | if @version.update_attributes(attributes) |
|
109 | if @version.update_attributes(attributes) | |
110 | flash[:notice] = l(:notice_successful_update) |
|
110 | flash[:notice] = l(:notice_successful_update) | |
111 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
111 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project | |
112 | end |
|
112 | end | |
113 | end |
|
113 | end | |
114 | end |
|
114 | end | |
115 |
|
115 | |||
116 | def close_completed |
|
116 | def close_completed | |
117 |
if request.p |
|
117 | if request.put? | |
118 | @project.close_completed_versions |
|
118 | @project.close_completed_versions | |
119 | end |
|
119 | end | |
120 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
120 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project | |
121 | end |
|
121 | end | |
122 |
|
122 | |||
123 | def destroy |
|
123 | def destroy | |
124 | if @version.fixed_issues.empty? |
|
124 | if @version.fixed_issues.empty? | |
125 | @version.destroy |
|
125 | @version.destroy | |
126 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
126 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project | |
127 | else |
|
127 | else | |
128 | flash[:error] = l(:notice_unable_delete_version) |
|
128 | flash[:error] = l(:notice_unable_delete_version) | |
129 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
129 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project | |
130 | end |
|
130 | end | |
131 | end |
|
131 | end | |
132 |
|
132 | |||
133 | def status_by |
|
133 | def status_by | |
134 | respond_to do |format| |
|
134 | respond_to do |format| | |
135 | format.html { render :action => 'show' } |
|
135 | format.html { render :action => 'show' } | |
136 | format.js { render(:update) {|page| page.replace_html 'status_by', render_issue_status_by(@version, params[:status_by])} } |
|
136 | format.js { render(:update) {|page| page.replace_html 'status_by', render_issue_status_by(@version, params[:status_by])} } | |
137 | end |
|
137 | end | |
138 | end |
|
138 | end | |
139 |
|
139 | |||
140 | private |
|
140 | private | |
141 | def find_project |
|
141 | def find_project | |
142 | @project = Project.find(params[:project_id]) |
|
142 | @project = Project.find(params[:project_id]) | |
143 | rescue ActiveRecord::RecordNotFound |
|
143 | rescue ActiveRecord::RecordNotFound | |
144 | render_404 |
|
144 | render_404 | |
145 | end |
|
145 | end | |
146 |
|
146 | |||
147 | def retrieve_selected_tracker_ids(selectable_trackers, default_trackers=nil) |
|
147 | def retrieve_selected_tracker_ids(selectable_trackers, default_trackers=nil) | |
148 | if ids = params[:tracker_ids] |
|
148 | if ids = params[:tracker_ids] | |
149 | @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s } |
|
149 | @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s } | |
150 | else |
|
150 | else | |
151 | @selected_tracker_ids = (default_trackers || selectable_trackers).collect {|t| t.id.to_s } |
|
151 | @selected_tracker_ids = (default_trackers || selectable_trackers).collect {|t| t.id.to_s } | |
152 | end |
|
152 | end | |
153 | end |
|
153 | end | |
154 |
|
154 | |||
155 | end |
|
155 | end |
@@ -1,41 +1,41 | |||||
1 | <% if @project.shared_versions.any? %> |
|
1 | <% if @project.shared_versions.any? %> | |
2 | <table class="list versions"> |
|
2 | <table class="list versions"> | |
3 | <thead><tr> |
|
3 | <thead><tr> | |
4 | <th><%= l(:label_version) %></th> |
|
4 | <th><%= l(:label_version) %></th> | |
5 | <th><%= l(:field_effective_date) %></th> |
|
5 | <th><%= l(:field_effective_date) %></th> | |
6 | <th><%= l(:field_description) %></th> |
|
6 | <th><%= l(:field_description) %></th> | |
7 | <th><%= l(:field_status) %></th> |
|
7 | <th><%= l(:field_status) %></th> | |
8 | <th><%= l(:field_sharing) %></th> |
|
8 | <th><%= l(:field_sharing) %></th> | |
9 | <th><%= l(:label_wiki_page) unless @project.wiki.nil? %></th> |
|
9 | <th><%= l(:label_wiki_page) unless @project.wiki.nil? %></th> | |
10 | <th style="width:15%"></th> |
|
10 | <th style="width:15%"></th> | |
11 | </tr></thead> |
|
11 | </tr></thead> | |
12 | <tbody> |
|
12 | <tbody> | |
13 | <% for version in @project.shared_versions.sort %> |
|
13 | <% for version in @project.shared_versions.sort %> | |
14 | <tr class="version <%= cycle 'odd', 'even' %> <%=h version.status %> <%= 'shared' if version.project != @project %>"> |
|
14 | <tr class="version <%= cycle 'odd', 'even' %> <%=h version.status %> <%= 'shared' if version.project != @project %>"> | |
15 | <td class="name"><%= link_to_version version %></td> |
|
15 | <td class="name"><%= link_to_version version %></td> | |
16 | <td class="date"><%= format_date(version.effective_date) %></td> |
|
16 | <td class="date"><%= format_date(version.effective_date) %></td> | |
17 | <td class="description"><%=h version.description %></td> |
|
17 | <td class="description"><%=h version.description %></td> | |
18 | <td class="status"><%= l("version_status_#{version.status}") %></td> |
|
18 | <td class="status"><%= l("version_status_#{version.status}") %></td> | |
19 | <td class="sharing"><%=h format_version_sharing(version.sharing) %></td> |
|
19 | <td class="sharing"><%=h format_version_sharing(version.sharing) %></td> | |
20 | <td><%= link_to(h(version.wiki_page_title), :controller => 'wiki', :page => Wiki.titleize(version.wiki_page_title)) unless version.wiki_page_title.blank? || @project.wiki.nil? %></td> |
|
20 | <td><%= link_to(h(version.wiki_page_title), :controller => 'wiki', :page => Wiki.titleize(version.wiki_page_title)) unless version.wiki_page_title.blank? || @project.wiki.nil? %></td> | |
21 | <td class="buttons"> |
|
21 | <td class="buttons"> | |
22 | <% if version.project == @project %> |
|
22 | <% if version.project == @project %> | |
23 | <%= link_to_if_authorized l(:button_edit), {:controller => 'versions', :action => 'edit', :id => version }, :class => 'icon icon-edit' %> |
|
23 | <%= link_to_if_authorized l(:button_edit), {:controller => 'versions', :action => 'edit', :id => version }, :class => 'icon icon-edit' %> | |
24 |
<%= link_to_if_authorized l(:button_delete), {:controller => 'versions', :action => 'destroy', :id => version}, :confirm => l(:text_are_you_sure), :method => : |
|
24 | <%= link_to_if_authorized l(:button_delete), {:controller => 'versions', :action => 'destroy', :id => version}, :confirm => l(:text_are_you_sure), :method => :delete, :class => 'icon icon-del' %> | |
25 | <% end %> |
|
25 | <% end %> | |
26 | </td> |
|
26 | </td> | |
27 | </tr> |
|
27 | </tr> | |
28 | <% end; reset_cycle %> |
|
28 | <% end; reset_cycle %> | |
29 | </tbody> |
|
29 | </tbody> | |
30 | </table> |
|
30 | </table> | |
31 | <% else %> |
|
31 | <% else %> | |
32 | <p class="nodata"><%= l(:label_no_data) %></p> |
|
32 | <p class="nodata"><%= l(:label_no_data) %></p> | |
33 | <% end %> |
|
33 | <% end %> | |
34 |
|
34 | |||
35 | <div class="contextual"> |
|
35 | <div class="contextual"> | |
36 | <% if @project.versions.any? %> |
|
36 | <% if @project.versions.any? %> | |
37 |
<%= link_to l(:label_close_versions), |
|
37 | <%= link_to l(:label_close_versions), close_completed_project_versions_path(@project), :method => :put %> | |
38 | <% end %> |
|
38 | <% end %> | |
39 | </div> |
|
39 | </div> | |
40 |
|
40 | |||
41 | <p><%= link_to_if_authorized l(:label_version_new), :controller => 'versions', :action => 'new', :project_id => @project %></p> |
|
41 | <p><%= link_to_if_authorized l(:label_version_new), :controller => 'versions', :action => 'new', :project_id => @project %></p> |
@@ -1,7 +1,7 | |||||
1 | <h2><%=l(:label_version)%></h2> |
|
1 | <h2><%=l(:label_version)%></h2> | |
2 |
|
2 | |||
3 |
<% labelled_tabular_form_for :version, @version, :url => |
|
3 | <% labelled_tabular_form_for :version, @version, :url => project_version_path(@project, @version), :html => {:method => :put} do |f| %> | |
4 | <%= render :partial => 'form', :locals => { :f => f } %> |
|
4 | <%= render :partial => 'form', :locals => { :f => f } %> | |
5 | <%= submit_tag l(:button_save) %> |
|
5 | <%= submit_tag l(:button_save) %> | |
6 | <% end %> |
|
6 | <% end %> | |
7 |
|
7 |
@@ -1,6 +1,6 | |||||
1 | <h2><%=l(:label_version_new)%></h2> |
|
1 | <h2><%=l(:label_version_new)%></h2> | |
2 |
|
2 | |||
3 |
<% labelled_tabular_form_for :version, @version, :url => |
|
3 | <% labelled_tabular_form_for :version, @version, :url => project_versions_path(@project) do |f| %> | |
4 | <%= render :partial => 'versions/form', :locals => { :f => f } %> |
|
4 | <%= render :partial => 'versions/form', :locals => { :f => f } %> | |
5 | <%= submit_tag l(:button_create) %> |
|
5 | <%= submit_tag l(:button_create) %> | |
6 | <% end %> |
|
6 | <% end %> |
@@ -1,276 +1,269 | |||||
1 | ActionController::Routing::Routes.draw do |map| |
|
1 | ActionController::Routing::Routes.draw do |map| | |
2 | # Add your own custom routes here. |
|
2 | # Add your own custom routes here. | |
3 | # The priority is based upon order of creation: first created -> highest priority. |
|
3 | # The priority is based upon order of creation: first created -> highest priority. | |
4 |
|
4 | |||
5 | # Here's a sample route: |
|
5 | # Here's a sample route: | |
6 | # map.connect 'products/:id', :controller => 'catalog', :action => 'view' |
|
6 | # map.connect 'products/:id', :controller => 'catalog', :action => 'view' | |
7 | # Keep in mind you can assign values other than :controller and :action |
|
7 | # Keep in mind you can assign values other than :controller and :action | |
8 |
|
8 | |||
9 | map.home '', :controller => 'welcome' |
|
9 | map.home '', :controller => 'welcome' | |
10 |
|
10 | |||
11 | map.signin 'login', :controller => 'account', :action => 'login' |
|
11 | map.signin 'login', :controller => 'account', :action => 'login' | |
12 | map.signout 'logout', :controller => 'account', :action => 'logout' |
|
12 | map.signout 'logout', :controller => 'account', :action => 'logout' | |
13 |
|
13 | |||
14 | map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow' |
|
14 | map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow' | |
15 | map.connect 'help/:ctrl/:page', :controller => 'help' |
|
15 | map.connect 'help/:ctrl/:page', :controller => 'help' | |
16 |
|
16 | |||
17 | map.connect 'time_entries/:id/edit', :action => 'edit', :controller => 'timelog' |
|
17 | map.connect 'time_entries/:id/edit', :action => 'edit', :controller => 'timelog' | |
18 | map.connect 'projects/:project_id/time_entries/new', :action => 'edit', :controller => 'timelog' |
|
18 | map.connect 'projects/:project_id/time_entries/new', :action => 'edit', :controller => 'timelog' | |
19 | map.connect 'projects/:project_id/issues/:issue_id/time_entries/new', :action => 'edit', :controller => 'timelog' |
|
19 | map.connect 'projects/:project_id/issues/:issue_id/time_entries/new', :action => 'edit', :controller => 'timelog' | |
20 |
|
20 | |||
21 | map.with_options :controller => 'timelog' do |timelog| |
|
21 | map.with_options :controller => 'timelog' do |timelog| | |
22 | timelog.connect 'projects/:project_id/time_entries', :action => 'details' |
|
22 | timelog.connect 'projects/:project_id/time_entries', :action => 'details' | |
23 |
|
23 | |||
24 | timelog.with_options :action => 'details', :conditions => {:method => :get} do |time_details| |
|
24 | timelog.with_options :action => 'details', :conditions => {:method => :get} do |time_details| | |
25 | time_details.connect 'time_entries' |
|
25 | time_details.connect 'time_entries' | |
26 | time_details.connect 'time_entries.:format' |
|
26 | time_details.connect 'time_entries.:format' | |
27 | time_details.connect 'issues/:issue_id/time_entries' |
|
27 | time_details.connect 'issues/:issue_id/time_entries' | |
28 | time_details.connect 'issues/:issue_id/time_entries.:format' |
|
28 | time_details.connect 'issues/:issue_id/time_entries.:format' | |
29 | time_details.connect 'projects/:project_id/time_entries.:format' |
|
29 | time_details.connect 'projects/:project_id/time_entries.:format' | |
30 | time_details.connect 'projects/:project_id/issues/:issue_id/time_entries' |
|
30 | time_details.connect 'projects/:project_id/issues/:issue_id/time_entries' | |
31 | time_details.connect 'projects/:project_id/issues/:issue_id/time_entries.:format' |
|
31 | time_details.connect 'projects/:project_id/issues/:issue_id/time_entries.:format' | |
32 | end |
|
32 | end | |
33 | timelog.connect 'projects/:project_id/time_entries/report', :action => 'report' |
|
33 | timelog.connect 'projects/:project_id/time_entries/report', :action => 'report' | |
34 | timelog.with_options :action => 'report',:conditions => {:method => :get} do |time_report| |
|
34 | timelog.with_options :action => 'report',:conditions => {:method => :get} do |time_report| | |
35 | time_report.connect 'time_entries/report' |
|
35 | time_report.connect 'time_entries/report' | |
36 | time_report.connect 'time_entries/report.:format' |
|
36 | time_report.connect 'time_entries/report.:format' | |
37 | time_report.connect 'projects/:project_id/time_entries/report.:format' |
|
37 | time_report.connect 'projects/:project_id/time_entries/report.:format' | |
38 | end |
|
38 | end | |
39 |
|
39 | |||
40 | timelog.with_options :action => 'edit', :conditions => {:method => :get} do |time_edit| |
|
40 | timelog.with_options :action => 'edit', :conditions => {:method => :get} do |time_edit| | |
41 | time_edit.connect 'issues/:issue_id/time_entries/new' |
|
41 | time_edit.connect 'issues/:issue_id/time_entries/new' | |
42 | end |
|
42 | end | |
43 |
|
43 | |||
44 | timelog.connect 'time_entries/:id/destroy', :action => 'destroy', :conditions => {:method => :post} |
|
44 | timelog.connect 'time_entries/:id/destroy', :action => 'destroy', :conditions => {:method => :post} | |
45 | end |
|
45 | end | |
46 |
|
46 | |||
47 | map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post} |
|
47 | map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post} | |
48 | map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get} |
|
48 | map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get} | |
49 | map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post} |
|
49 | map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post} | |
50 | map.with_options :controller => 'wiki' do |wiki_routes| |
|
50 | map.with_options :controller => 'wiki' do |wiki_routes| | |
51 | wiki_routes.with_options :conditions => {:method => :get} do |wiki_views| |
|
51 | wiki_routes.with_options :conditions => {:method => :get} do |wiki_views| | |
52 | wiki_views.connect 'projects/:id/wiki/:page', :action => 'special', :page => /page_index|date_index|export/i |
|
52 | wiki_views.connect 'projects/:id/wiki/:page', :action => 'special', :page => /page_index|date_index|export/i | |
53 | wiki_views.connect 'projects/:id/wiki/:page', :action => 'index', :page => nil |
|
53 | wiki_views.connect 'projects/:id/wiki/:page', :action => 'index', :page => nil | |
54 | wiki_views.connect 'projects/:id/wiki/:page/edit', :action => 'edit' |
|
54 | wiki_views.connect 'projects/:id/wiki/:page/edit', :action => 'edit' | |
55 | wiki_views.connect 'projects/:id/wiki/:page/rename', :action => 'rename' |
|
55 | wiki_views.connect 'projects/:id/wiki/:page/rename', :action => 'rename' | |
56 | wiki_views.connect 'projects/:id/wiki/:page/history', :action => 'history' |
|
56 | wiki_views.connect 'projects/:id/wiki/:page/history', :action => 'history' | |
57 | wiki_views.connect 'projects/:id/wiki/:page/diff/:version/vs/:version_from', :action => 'diff' |
|
57 | wiki_views.connect 'projects/:id/wiki/:page/diff/:version/vs/:version_from', :action => 'diff' | |
58 | wiki_views.connect 'projects/:id/wiki/:page/annotate/:version', :action => 'annotate' |
|
58 | wiki_views.connect 'projects/:id/wiki/:page/annotate/:version', :action => 'annotate' | |
59 | end |
|
59 | end | |
60 |
|
60 | |||
61 | wiki_routes.connect 'projects/:id/wiki/:page/:action', |
|
61 | wiki_routes.connect 'projects/:id/wiki/:page/:action', | |
62 | :action => /edit|rename|destroy|preview|protect/, |
|
62 | :action => /edit|rename|destroy|preview|protect/, | |
63 | :conditions => {:method => :post} |
|
63 | :conditions => {:method => :post} | |
64 | end |
|
64 | end | |
65 |
|
65 | |||
66 | map.with_options :controller => 'messages' do |messages_routes| |
|
66 | map.with_options :controller => 'messages' do |messages_routes| | |
67 | messages_routes.with_options :conditions => {:method => :get} do |messages_views| |
|
67 | messages_routes.with_options :conditions => {:method => :get} do |messages_views| | |
68 | messages_views.connect 'boards/:board_id/topics/new', :action => 'new' |
|
68 | messages_views.connect 'boards/:board_id/topics/new', :action => 'new' | |
69 | messages_views.connect 'boards/:board_id/topics/:id', :action => 'show' |
|
69 | messages_views.connect 'boards/:board_id/topics/:id', :action => 'show' | |
70 | messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit' |
|
70 | messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit' | |
71 | end |
|
71 | end | |
72 | messages_routes.with_options :conditions => {:method => :post} do |messages_actions| |
|
72 | messages_routes.with_options :conditions => {:method => :post} do |messages_actions| | |
73 | messages_actions.connect 'boards/:board_id/topics/new', :action => 'new' |
|
73 | messages_actions.connect 'boards/:board_id/topics/new', :action => 'new' | |
74 | messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply' |
|
74 | messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply' | |
75 | messages_actions.connect 'boards/:board_id/topics/:id/:action', :action => /edit|destroy/ |
|
75 | messages_actions.connect 'boards/:board_id/topics/:id/:action', :action => /edit|destroy/ | |
76 | end |
|
76 | end | |
77 | end |
|
77 | end | |
78 |
|
78 | |||
79 | map.with_options :controller => 'boards' do |board_routes| |
|
79 | map.with_options :controller => 'boards' do |board_routes| | |
80 | board_routes.with_options :conditions => {:method => :get} do |board_views| |
|
80 | board_routes.with_options :conditions => {:method => :get} do |board_views| | |
81 | board_views.connect 'projects/:project_id/boards', :action => 'index' |
|
81 | board_views.connect 'projects/:project_id/boards', :action => 'index' | |
82 | board_views.connect 'projects/:project_id/boards/new', :action => 'new' |
|
82 | board_views.connect 'projects/:project_id/boards/new', :action => 'new' | |
83 | board_views.connect 'projects/:project_id/boards/:id', :action => 'show' |
|
83 | board_views.connect 'projects/:project_id/boards/:id', :action => 'show' | |
84 | board_views.connect 'projects/:project_id/boards/:id.:format', :action => 'show' |
|
84 | board_views.connect 'projects/:project_id/boards/:id.:format', :action => 'show' | |
85 | board_views.connect 'projects/:project_id/boards/:id/edit', :action => 'edit' |
|
85 | board_views.connect 'projects/:project_id/boards/:id/edit', :action => 'edit' | |
86 | end |
|
86 | end | |
87 | board_routes.with_options :conditions => {:method => :post} do |board_actions| |
|
87 | board_routes.with_options :conditions => {:method => :post} do |board_actions| | |
88 | board_actions.connect 'projects/:project_id/boards', :action => 'new' |
|
88 | board_actions.connect 'projects/:project_id/boards', :action => 'new' | |
89 | board_actions.connect 'projects/:project_id/boards/:id/:action', :action => /edit|destroy/ |
|
89 | board_actions.connect 'projects/:project_id/boards/:id/:action', :action => /edit|destroy/ | |
90 | end |
|
90 | end | |
91 | end |
|
91 | end | |
92 |
|
92 | |||
93 | map.with_options :controller => 'documents' do |document_routes| |
|
93 | map.with_options :controller => 'documents' do |document_routes| | |
94 | document_routes.with_options :conditions => {:method => :get} do |document_views| |
|
94 | document_routes.with_options :conditions => {:method => :get} do |document_views| | |
95 | document_views.connect 'projects/:project_id/documents', :action => 'index' |
|
95 | document_views.connect 'projects/:project_id/documents', :action => 'index' | |
96 | document_views.connect 'projects/:project_id/documents/new', :action => 'new' |
|
96 | document_views.connect 'projects/:project_id/documents/new', :action => 'new' | |
97 | document_views.connect 'documents/:id', :action => 'show' |
|
97 | document_views.connect 'documents/:id', :action => 'show' | |
98 | document_views.connect 'documents/:id/edit', :action => 'edit' |
|
98 | document_views.connect 'documents/:id/edit', :action => 'edit' | |
99 | end |
|
99 | end | |
100 | document_routes.with_options :conditions => {:method => :post} do |document_actions| |
|
100 | document_routes.with_options :conditions => {:method => :post} do |document_actions| | |
101 | document_actions.connect 'projects/:project_id/documents', :action => 'new' |
|
101 | document_actions.connect 'projects/:project_id/documents', :action => 'new' | |
102 | document_actions.connect 'documents/:id/:action', :action => /destroy|edit/ |
|
102 | document_actions.connect 'documents/:id/:action', :action => /destroy|edit/ | |
103 | end |
|
103 | end | |
104 | end |
|
104 | end | |
105 |
|
105 | |||
106 | map.resources :issue_moves, :only => [:new, :create], :path_prefix => '/issues', :as => 'move' |
|
106 | map.resources :issue_moves, :only => [:new, :create], :path_prefix => '/issues', :as => 'move' | |
107 |
|
107 | |||
108 | # Misc issue routes. TODO: move into resources |
|
108 | # Misc issue routes. TODO: move into resources | |
109 | map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', :action => 'issues' |
|
109 | map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', :action => 'issues' | |
110 | map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue' # TODO: would look nicer as /issues/:id/preview |
|
110 | map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue' # TODO: would look nicer as /issues/:id/preview | |
111 | map.issues_context_menu '/issues/context_menu', :controller => 'context_menus', :action => 'issues' |
|
111 | map.issues_context_menu '/issues/context_menu', :controller => 'context_menus', :action => 'issues' | |
112 | map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index' |
|
112 | map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index' | |
113 | map.bulk_edit_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_edit', :conditions => { :method => :get } |
|
113 | map.bulk_edit_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_edit', :conditions => { :method => :get } | |
114 | map.bulk_update_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_update', :conditions => { :method => :post } |
|
114 | map.bulk_update_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_update', :conditions => { :method => :post } | |
115 | map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/, :conditions => { :method => :post } |
|
115 | map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/, :conditions => { :method => :post } | |
116 | map.connect '/issues/:id/destroy', :controller => 'issues', :action => 'destroy', :conditions => { :method => :post } # legacy |
|
116 | map.connect '/issues/:id/destroy', :controller => 'issues', :action => 'destroy', :conditions => { :method => :post } # legacy | |
117 |
|
117 | |||
118 | map.resource :gantt, :path_prefix => '/issues', :controller => 'gantts', :only => [:show, :update] |
|
118 | map.resource :gantt, :path_prefix => '/issues', :controller => 'gantts', :only => [:show, :update] | |
119 | map.resource :gantt, :path_prefix => '/projects/:project_id/issues', :controller => 'gantts', :only => [:show, :update] |
|
119 | map.resource :gantt, :path_prefix => '/projects/:project_id/issues', :controller => 'gantts', :only => [:show, :update] | |
120 | map.resource :calendar, :path_prefix => '/issues', :controller => 'calendars', :only => [:show, :update] |
|
120 | map.resource :calendar, :path_prefix => '/issues', :controller => 'calendars', :only => [:show, :update] | |
121 | map.resource :calendar, :path_prefix => '/projects/:project_id/issues', :controller => 'calendars', :only => [:show, :update] |
|
121 | map.resource :calendar, :path_prefix => '/projects/:project_id/issues', :controller => 'calendars', :only => [:show, :update] | |
122 |
|
122 | |||
123 | map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports| |
|
123 | map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports| | |
124 | reports.connect 'projects/:id/issues/report', :action => 'issue_report' |
|
124 | reports.connect 'projects/:id/issues/report', :action => 'issue_report' | |
125 | reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details' |
|
125 | reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details' | |
126 | end |
|
126 | end | |
127 |
|
127 | |||
128 | # Following two routes conflict with the resources because #index allows POST |
|
128 | # Following two routes conflict with the resources because #index allows POST | |
129 | map.connect '/issues', :controller => 'issues', :action => 'index', :conditions => { :method => :post } |
|
129 | map.connect '/issues', :controller => 'issues', :action => 'index', :conditions => { :method => :post } | |
130 | map.connect '/issues/create', :controller => 'issues', :action => 'index', :conditions => { :method => :post } |
|
130 | map.connect '/issues/create', :controller => 'issues', :action => 'index', :conditions => { :method => :post } | |
131 |
|
131 | |||
132 | map.resources :issues, :member => { :edit => :post }, :collection => {} |
|
132 | map.resources :issues, :member => { :edit => :post }, :collection => {} | |
133 | map.resources :issues, :path_prefix => '/projects/:project_id', :collection => { :create => :post } |
|
133 | map.resources :issues, :path_prefix => '/projects/:project_id', :collection => { :create => :post } | |
134 |
|
134 | |||
135 | map.with_options :controller => 'issue_relations', :conditions => {:method => :post} do |relations| |
|
135 | map.with_options :controller => 'issue_relations', :conditions => {:method => :post} do |relations| | |
136 | relations.connect 'issues/:issue_id/relations/:id', :action => 'new' |
|
136 | relations.connect 'issues/:issue_id/relations/:id', :action => 'new' | |
137 | relations.connect 'issues/:issue_id/relations/:id/destroy', :action => 'destroy' |
|
137 | relations.connect 'issues/:issue_id/relations/:id/destroy', :action => 'destroy' | |
138 | end |
|
138 | end | |
139 |
|
139 | |||
140 | map.with_options :controller => 'news' do |news_routes| |
|
140 | map.with_options :controller => 'news' do |news_routes| | |
141 | news_routes.with_options :conditions => {:method => :get} do |news_views| |
|
141 | news_routes.with_options :conditions => {:method => :get} do |news_views| | |
142 | news_views.connect 'news', :action => 'index' |
|
142 | news_views.connect 'news', :action => 'index' | |
143 | news_views.connect 'projects/:project_id/news', :action => 'index' |
|
143 | news_views.connect 'projects/:project_id/news', :action => 'index' | |
144 | news_views.connect 'projects/:project_id/news.:format', :action => 'index' |
|
144 | news_views.connect 'projects/:project_id/news.:format', :action => 'index' | |
145 | news_views.connect 'news.:format', :action => 'index' |
|
145 | news_views.connect 'news.:format', :action => 'index' | |
146 | news_views.connect 'projects/:project_id/news/new', :action => 'new' |
|
146 | news_views.connect 'projects/:project_id/news/new', :action => 'new' | |
147 | news_views.connect 'news/:id', :action => 'show' |
|
147 | news_views.connect 'news/:id', :action => 'show' | |
148 | news_views.connect 'news/:id/edit', :action => 'edit' |
|
148 | news_views.connect 'news/:id/edit', :action => 'edit' | |
149 | end |
|
149 | end | |
150 | news_routes.with_options do |news_actions| |
|
150 | news_routes.with_options do |news_actions| | |
151 | news_actions.connect 'projects/:project_id/news', :action => 'new' |
|
151 | news_actions.connect 'projects/:project_id/news', :action => 'new' | |
152 | news_actions.connect 'news/:id/edit', :action => 'edit' |
|
152 | news_actions.connect 'news/:id/edit', :action => 'edit' | |
153 | news_actions.connect 'news/:id/destroy', :action => 'destroy' |
|
153 | news_actions.connect 'news/:id/destroy', :action => 'destroy' | |
154 | end |
|
154 | end | |
155 | end |
|
155 | end | |
156 |
|
156 | |||
157 | map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new' |
|
157 | map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new' | |
158 |
|
158 | |||
159 | map.with_options :controller => 'users' do |users| |
|
159 | map.with_options :controller => 'users' do |users| | |
160 | users.with_options :conditions => {:method => :get} do |user_views| |
|
160 | users.with_options :conditions => {:method => :get} do |user_views| | |
161 | user_views.connect 'users', :action => 'index' |
|
161 | user_views.connect 'users', :action => 'index' | |
162 | user_views.connect 'users/:id', :action => 'show', :id => /\d+/ |
|
162 | user_views.connect 'users/:id', :action => 'show', :id => /\d+/ | |
163 | user_views.connect 'users/new', :action => 'add' |
|
163 | user_views.connect 'users/new', :action => 'add' | |
164 | user_views.connect 'users/:id/edit/:tab', :action => 'edit', :tab => nil |
|
164 | user_views.connect 'users/:id/edit/:tab', :action => 'edit', :tab => nil | |
165 | end |
|
165 | end | |
166 | users.with_options :conditions => {:method => :post} do |user_actions| |
|
166 | users.with_options :conditions => {:method => :post} do |user_actions| | |
167 | user_actions.connect 'users', :action => 'add' |
|
167 | user_actions.connect 'users', :action => 'add' | |
168 | user_actions.connect 'users/new', :action => 'add' |
|
168 | user_actions.connect 'users/new', :action => 'add' | |
169 | user_actions.connect 'users/:id/edit', :action => 'edit' |
|
169 | user_actions.connect 'users/:id/edit', :action => 'edit' | |
170 | user_actions.connect 'users/:id/memberships', :action => 'edit_membership' |
|
170 | user_actions.connect 'users/:id/memberships', :action => 'edit_membership' | |
171 | user_actions.connect 'users/:id/memberships/:membership_id', :action => 'edit_membership' |
|
171 | user_actions.connect 'users/:id/memberships/:membership_id', :action => 'edit_membership' | |
172 | user_actions.connect 'users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership' |
|
172 | user_actions.connect 'users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership' | |
173 | end |
|
173 | end | |
174 | end |
|
174 | end | |
175 |
|
175 | |||
|
176 | # For nice "roadmap" in the url for the index action | |||
|
177 | map.connect 'projects/:project_id/roadmap', :controller => 'versions', :action => 'index' | |||
|
178 | ||||
176 | map.resources :projects, :member => { |
|
179 | map.resources :projects, :member => { | |
177 | :copy => [:get, :post], |
|
180 | :copy => [:get, :post], | |
178 | :settings => :get, |
|
181 | :settings => :get, | |
179 | :modules => :post, |
|
182 | :modules => :post, | |
180 | :archive => :post, |
|
183 | :archive => :post, | |
181 | :unarchive => :post |
|
184 | :unarchive => :post | |
182 | } do |project| |
|
185 | } do |project| | |
183 | project.resource :project_enumerations, :as => 'enumerations', :only => [:update, :destroy] |
|
186 | project.resource :project_enumerations, :as => 'enumerations', :only => [:update, :destroy] | |
184 | project.resources :files, :only => [:index, :new, :create] |
|
187 | project.resources :files, :only => [:index, :new, :create] | |
|
188 | project.resources :versions, :collection => {:close_completed => :put} | |||
185 | end |
|
189 | end | |
186 |
|
190 | |||
187 | # Destroy uses a get request to prompt the user before the actual DELETE request |
|
191 | # Destroy uses a get request to prompt the user before the actual DELETE request | |
188 | map.project_destroy_confirm 'projects/:id/destroy', :controller => 'projects', :action => 'destroy', :conditions => {:method => :get} |
|
192 | map.project_destroy_confirm 'projects/:id/destroy', :controller => 'projects', :action => 'destroy', :conditions => {:method => :get} | |
189 |
|
193 | |||
190 | # TODO: port to be part of the resources route(s) |
|
194 | # TODO: port to be part of the resources route(s) | |
191 | map.with_options :controller => 'projects' do |project_mapper| |
|
195 | map.with_options :controller => 'projects' do |project_mapper| | |
192 | project_mapper.with_options :conditions => {:method => :get} do |project_views| |
|
196 | project_mapper.with_options :conditions => {:method => :get} do |project_views| | |
193 | project_views.connect 'projects/:id/settings/:tab', :controller => 'projects', :action => 'settings' |
|
197 | project_views.connect 'projects/:id/settings/:tab', :controller => 'projects', :action => 'settings' | |
194 | project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new' |
|
198 | project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new' | |
195 | end |
|
199 | end | |
196 | end |
|
200 | end | |
197 |
|
201 | |||
198 | map.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity| |
|
202 | map.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity| | |
199 | activity.connect 'projects/:id/activity' |
|
203 | activity.connect 'projects/:id/activity' | |
200 | activity.connect 'projects/:id/activity.:format' |
|
204 | activity.connect 'projects/:id/activity.:format' | |
201 | activity.connect 'activity', :id => nil |
|
205 | activity.connect 'activity', :id => nil | |
202 | activity.connect 'activity.:format', :id => nil |
|
206 | activity.connect 'activity.:format', :id => nil | |
203 | end |
|
207 | end | |
|
208 | ||||
204 |
|
209 | |||
205 | map.with_options :controller => 'versions' do |versions| |
|
|||
206 | versions.connect 'projects/:project_id/versions/new', :action => 'new' |
|
|||
207 | versions.connect 'projects/:project_id/roadmap', :action => 'index' |
|
|||
208 | versions.connect 'versions/:action/:id', :conditions => {:method => :get} |
|
|||
209 |
|
||||
210 | versions.with_options :conditions => {:method => :post} do |version_actions| |
|
|||
211 | version_actions.connect 'projects/:project_id/versions', :action => 'create' |
|
|||
212 | version_actions.connect 'versions/update/:id', :action => 'update' |
|
|||
213 | version_actions.connect 'projects/:project_id/versions/close_completed', :action => 'close_completed' |
|
|||
214 | end |
|
|||
215 | end |
|
|||
216 |
|
||||
217 | map.with_options :controller => 'issue_categories' do |categories| |
|
210 | map.with_options :controller => 'issue_categories' do |categories| | |
218 | categories.connect 'projects/:project_id/issue_categories/new', :action => 'new' |
|
211 | categories.connect 'projects/:project_id/issue_categories/new', :action => 'new' | |
219 | end |
|
212 | end | |
220 |
|
213 | |||
221 | map.with_options :controller => 'repositories' do |repositories| |
|
214 | map.with_options :controller => 'repositories' do |repositories| | |
222 | repositories.with_options :conditions => {:method => :get} do |repository_views| |
|
215 | repositories.with_options :conditions => {:method => :get} do |repository_views| | |
223 | repository_views.connect 'projects/:id/repository', :action => 'show' |
|
216 | repository_views.connect 'projects/:id/repository', :action => 'show' | |
224 | repository_views.connect 'projects/:id/repository/edit', :action => 'edit' |
|
217 | repository_views.connect 'projects/:id/repository/edit', :action => 'edit' | |
225 | repository_views.connect 'projects/:id/repository/statistics', :action => 'stats' |
|
218 | repository_views.connect 'projects/:id/repository/statistics', :action => 'stats' | |
226 | repository_views.connect 'projects/:id/repository/revisions', :action => 'revisions' |
|
219 | repository_views.connect 'projects/:id/repository/revisions', :action => 'revisions' | |
227 | repository_views.connect 'projects/:id/repository/revisions.:format', :action => 'revisions' |
|
220 | repository_views.connect 'projects/:id/repository/revisions.:format', :action => 'revisions' | |
228 | repository_views.connect 'projects/:id/repository/revisions/:rev', :action => 'revision' |
|
221 | repository_views.connect 'projects/:id/repository/revisions/:rev', :action => 'revision' | |
229 | repository_views.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff' |
|
222 | repository_views.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff' | |
230 | repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff' |
|
223 | repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff' | |
231 | repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path', :action => 'entry', :format => 'raw', :requirements => { :rev => /[a-z0-9\.\-_]+/ } |
|
224 | repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path', :action => 'entry', :format => 'raw', :requirements => { :rev => /[a-z0-9\.\-_]+/ } | |
232 | repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path', :requirements => { :rev => /[a-z0-9\.\-_]+/ } |
|
225 | repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path', :requirements => { :rev => /[a-z0-9\.\-_]+/ } | |
233 | repository_views.connect 'projects/:id/repository/raw/*path', :action => 'entry', :format => 'raw' |
|
226 | repository_views.connect 'projects/:id/repository/raw/*path', :action => 'entry', :format => 'raw' | |
234 | # TODO: why the following route is required? |
|
227 | # TODO: why the following route is required? | |
235 | repository_views.connect 'projects/:id/repository/entry/*path', :action => 'entry' |
|
228 | repository_views.connect 'projects/:id/repository/entry/*path', :action => 'entry' | |
236 | repository_views.connect 'projects/:id/repository/:action/*path' |
|
229 | repository_views.connect 'projects/:id/repository/:action/*path' | |
237 | end |
|
230 | end | |
238 |
|
231 | |||
239 | repositories.connect 'projects/:id/repository/:action', :conditions => {:method => :post} |
|
232 | repositories.connect 'projects/:id/repository/:action', :conditions => {:method => :post} | |
240 | end |
|
233 | end | |
241 |
|
234 | |||
242 | map.connect 'attachments/:id', :controller => 'attachments', :action => 'show', :id => /\d+/ |
|
235 | map.connect 'attachments/:id', :controller => 'attachments', :action => 'show', :id => /\d+/ | |
243 | map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/ |
|
236 | map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/ | |
244 | map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/ |
|
237 | map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/ | |
245 |
|
238 | |||
246 | map.resources :groups |
|
239 | map.resources :groups | |
247 |
|
240 | |||
248 | #left old routes at the bottom for backwards compat |
|
241 | #left old routes at the bottom for backwards compat | |
249 | map.connect 'projects/:project_id/issues/:action', :controller => 'issues' |
|
242 | map.connect 'projects/:project_id/issues/:action', :controller => 'issues' | |
250 | map.connect 'projects/:project_id/documents/:action', :controller => 'documents' |
|
243 | map.connect 'projects/:project_id/documents/:action', :controller => 'documents' | |
251 | map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards' |
|
244 | map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards' | |
252 | map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages' |
|
245 | map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages' | |
253 | map.connect 'wiki/:id/:page/:action', :page => nil, :controller => 'wiki' |
|
246 | map.connect 'wiki/:id/:page/:action', :page => nil, :controller => 'wiki' | |
254 | map.connect 'issues/:issue_id/relations/:action/:id', :controller => 'issue_relations' |
|
247 | map.connect 'issues/:issue_id/relations/:action/:id', :controller => 'issue_relations' | |
255 | map.connect 'projects/:project_id/news/:action', :controller => 'news' |
|
248 | map.connect 'projects/:project_id/news/:action', :controller => 'news' | |
256 | map.connect 'projects/:project_id/timelog/:action/:id', :controller => 'timelog', :project_id => /.+/ |
|
249 | map.connect 'projects/:project_id/timelog/:action/:id', :controller => 'timelog', :project_id => /.+/ | |
257 | map.with_options :controller => 'repositories' do |omap| |
|
250 | map.with_options :controller => 'repositories' do |omap| | |
258 | omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse' |
|
251 | omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse' | |
259 | omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes' |
|
252 | omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes' | |
260 | omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff' |
|
253 | omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff' | |
261 | omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry' |
|
254 | omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry' | |
262 | omap.repositories_entry 'repositories/annotate/:id/*path', :action => 'annotate' |
|
255 | omap.repositories_entry 'repositories/annotate/:id/*path', :action => 'annotate' | |
263 | omap.connect 'repositories/revision/:id/:rev', :action => 'revision' |
|
256 | omap.connect 'repositories/revision/:id/:rev', :action => 'revision' | |
264 | end |
|
257 | end | |
265 |
|
258 | |||
266 | map.with_options :controller => 'sys' do |sys| |
|
259 | map.with_options :controller => 'sys' do |sys| | |
267 | sys.connect 'sys/projects.:format', :action => 'projects', :conditions => {:method => :get} |
|
260 | sys.connect 'sys/projects.:format', :action => 'projects', :conditions => {:method => :get} | |
268 | sys.connect 'sys/projects/:id/repository.:format', :action => 'create_project_repository', :conditions => {:method => :post} |
|
261 | sys.connect 'sys/projects/:id/repository.:format', :action => 'create_project_repository', :conditions => {:method => :post} | |
269 | end |
|
262 | end | |
270 |
|
263 | |||
271 | # Install the default route as the lowest priority. |
|
264 | # Install the default route as the lowest priority. | |
272 | map.connect ':controller/:action/:id' |
|
265 | map.connect ':controller/:action/:id' | |
273 | map.connect 'robots.txt', :controller => 'welcome', :action => 'robots' |
|
266 | map.connect 'robots.txt', :controller => 'welcome', :action => 'robots' | |
274 | # Used for OpenID |
|
267 | # Used for OpenID | |
275 | map.root :controller => 'account', :action => 'login' |
|
268 | map.root :controller => 'account', :action => 'login' | |
276 | end |
|
269 | end |
@@ -1,139 +1,139 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.dirname(__FILE__) + '/../test_helper' |
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |
19 | require 'versions_controller' |
|
19 | require 'versions_controller' | |
20 |
|
20 | |||
21 | # Re-raise errors caught by the controller. |
|
21 | # Re-raise errors caught by the controller. | |
22 | class VersionsController; def rescue_action(e) raise e end; end |
|
22 | class VersionsController; def rescue_action(e) raise e end; end | |
23 |
|
23 | |||
24 | class VersionsControllerTest < ActionController::TestCase |
|
24 | class VersionsControllerTest < ActionController::TestCase | |
25 | fixtures :projects, :versions, :issues, :users, :roles, :members, :member_roles, :enabled_modules |
|
25 | fixtures :projects, :versions, :issues, :users, :roles, :members, :member_roles, :enabled_modules | |
26 |
|
26 | |||
27 | def setup |
|
27 | def setup | |
28 | @controller = VersionsController.new |
|
28 | @controller = VersionsController.new | |
29 | @request = ActionController::TestRequest.new |
|
29 | @request = ActionController::TestRequest.new | |
30 | @response = ActionController::TestResponse.new |
|
30 | @response = ActionController::TestResponse.new | |
31 | User.current = nil |
|
31 | User.current = nil | |
32 | end |
|
32 | end | |
33 |
|
33 | |||
34 | def test_index |
|
34 | def test_index | |
35 | get :index, :project_id => 1 |
|
35 | get :index, :project_id => 1 | |
36 | assert_response :success |
|
36 | assert_response :success | |
37 | assert_template 'index' |
|
37 | assert_template 'index' | |
38 | assert_not_nil assigns(:versions) |
|
38 | assert_not_nil assigns(:versions) | |
39 | # Version with no date set appears |
|
39 | # Version with no date set appears | |
40 | assert assigns(:versions).include?(Version.find(3)) |
|
40 | assert assigns(:versions).include?(Version.find(3)) | |
41 | # Completed version doesn't appear |
|
41 | # Completed version doesn't appear | |
42 | assert !assigns(:versions).include?(Version.find(1)) |
|
42 | assert !assigns(:versions).include?(Version.find(1)) | |
43 | # Context menu on issues |
|
43 | # Context menu on issues | |
44 | assert_select "script", :text => Regexp.new(Regexp.escape("new ContextMenu('/issues/context_menu')")) |
|
44 | assert_select "script", :text => Regexp.new(Regexp.escape("new ContextMenu('/issues/context_menu')")) | |
45 | end |
|
45 | end | |
46 |
|
46 | |||
47 | def test_index_with_completed_versions |
|
47 | def test_index_with_completed_versions | |
48 | get :index, :project_id => 1, :completed => 1 |
|
48 | get :index, :project_id => 1, :completed => 1 | |
49 | assert_response :success |
|
49 | assert_response :success | |
50 | assert_template 'index' |
|
50 | assert_template 'index' | |
51 | assert_not_nil assigns(:versions) |
|
51 | assert_not_nil assigns(:versions) | |
52 | # Version with no date set appears |
|
52 | # Version with no date set appears | |
53 | assert assigns(:versions).include?(Version.find(3)) |
|
53 | assert assigns(:versions).include?(Version.find(3)) | |
54 | # Completed version appears |
|
54 | # Completed version appears | |
55 | assert assigns(:versions).include?(Version.find(1)) |
|
55 | assert assigns(:versions).include?(Version.find(1)) | |
56 | end |
|
56 | end | |
57 |
|
57 | |||
58 | def test_index_showing_subprojects_versions |
|
58 | def test_index_showing_subprojects_versions | |
59 | @subproject_version = Version.generate!(:project => Project.find(3)) |
|
59 | @subproject_version = Version.generate!(:project => Project.find(3)) | |
60 | get :index, :project_id => 1, :with_subprojects => 1 |
|
60 | get :index, :project_id => 1, :with_subprojects => 1 | |
61 | assert_response :success |
|
61 | assert_response :success | |
62 | assert_template 'index' |
|
62 | assert_template 'index' | |
63 | assert_not_nil assigns(:versions) |
|
63 | assert_not_nil assigns(:versions) | |
64 |
|
64 | |||
65 | assert assigns(:versions).include?(Version.find(4)), "Shared version not found" |
|
65 | assert assigns(:versions).include?(Version.find(4)), "Shared version not found" | |
66 | assert assigns(:versions).include?(@subproject_version), "Subproject version not found" |
|
66 | assert assigns(:versions).include?(@subproject_version), "Subproject version not found" | |
67 | end |
|
67 | end | |
68 |
|
68 | |||
69 | def test_show |
|
69 | def test_show | |
70 | get :show, :id => 2 |
|
70 | get :show, :id => 2 | |
71 | assert_response :success |
|
71 | assert_response :success | |
72 | assert_template 'show' |
|
72 | assert_template 'show' | |
73 | assert_not_nil assigns(:version) |
|
73 | assert_not_nil assigns(:version) | |
74 |
|
74 | |||
75 | assert_tag :tag => 'h2', :content => /1.0/ |
|
75 | assert_tag :tag => 'h2', :content => /1.0/ | |
76 | end |
|
76 | end | |
77 |
|
77 | |||
78 | def test_create |
|
78 | def test_create | |
79 | @request.session[:user_id] = 2 # manager |
|
79 | @request.session[:user_id] = 2 # manager | |
80 | assert_difference 'Version.count' do |
|
80 | assert_difference 'Version.count' do | |
81 | post :create, :project_id => '1', :version => {:name => 'test_add_version'} |
|
81 | post :create, :project_id => '1', :version => {:name => 'test_add_version'} | |
82 | end |
|
82 | end | |
83 | assert_redirected_to '/projects/ecookbook/settings/versions' |
|
83 | assert_redirected_to '/projects/ecookbook/settings/versions' | |
84 | version = Version.find_by_name('test_add_version') |
|
84 | version = Version.find_by_name('test_add_version') | |
85 | assert_not_nil version |
|
85 | assert_not_nil version | |
86 | assert_equal 1, version.project_id |
|
86 | assert_equal 1, version.project_id | |
87 | end |
|
87 | end | |
88 |
|
88 | |||
89 | def test_create_from_issue_form |
|
89 | def test_create_from_issue_form | |
90 | @request.session[:user_id] = 2 # manager |
|
90 | @request.session[:user_id] = 2 # manager | |
91 | assert_difference 'Version.count' do |
|
91 | assert_difference 'Version.count' do | |
92 | xhr :post, :create, :project_id => '1', :version => {:name => 'test_add_version_from_issue_form'} |
|
92 | xhr :post, :create, :project_id => '1', :version => {:name => 'test_add_version_from_issue_form'} | |
93 | end |
|
93 | end | |
94 | assert_response :success |
|
94 | assert_response :success | |
95 | assert_select_rjs :replace, 'issue_fixed_version_id' |
|
95 | assert_select_rjs :replace, 'issue_fixed_version_id' | |
96 | version = Version.find_by_name('test_add_version_from_issue_form') |
|
96 | version = Version.find_by_name('test_add_version_from_issue_form') | |
97 | assert_not_nil version |
|
97 | assert_not_nil version | |
98 | assert_equal 1, version.project_id |
|
98 | assert_equal 1, version.project_id | |
99 | end |
|
99 | end | |
100 |
|
100 | |||
101 | def test_get_edit |
|
101 | def test_get_edit | |
102 | @request.session[:user_id] = 2 |
|
102 | @request.session[:user_id] = 2 | |
103 | get :edit, :id => 2 |
|
103 | get :edit, :id => 2 | |
104 | assert_response :success |
|
104 | assert_response :success | |
105 | assert_template 'edit' |
|
105 | assert_template 'edit' | |
106 | end |
|
106 | end | |
107 |
|
107 | |||
108 | def test_close_completed |
|
108 | def test_close_completed | |
109 | Version.update_all("status = 'open'") |
|
109 | Version.update_all("status = 'open'") | |
110 | @request.session[:user_id] = 2 |
|
110 | @request.session[:user_id] = 2 | |
111 |
p |
|
111 | put :close_completed, :project_id => 'ecookbook' | |
112 | assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook' |
|
112 | assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook' | |
113 | assert_not_nil Version.find_by_status('closed') |
|
113 | assert_not_nil Version.find_by_status('closed') | |
114 | end |
|
114 | end | |
115 |
|
115 | |||
116 | def test_post_update |
|
116 | def test_post_update | |
117 | @request.session[:user_id] = 2 |
|
117 | @request.session[:user_id] = 2 | |
118 |
p |
|
118 | put :update, :id => 2, | |
119 | :version => { :name => 'New version name', |
|
119 | :version => { :name => 'New version name', | |
120 | :effective_date => Date.today.strftime("%Y-%m-%d")} |
|
120 | :effective_date => Date.today.strftime("%Y-%m-%d")} | |
121 | assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook' |
|
121 | assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook' | |
122 | version = Version.find(2) |
|
122 | version = Version.find(2) | |
123 | assert_equal 'New version name', version.name |
|
123 | assert_equal 'New version name', version.name | |
124 | assert_equal Date.today, version.effective_date |
|
124 | assert_equal Date.today, version.effective_date | |
125 | end |
|
125 | end | |
126 |
|
126 | |||
127 | def test_destroy |
|
127 | def test_destroy | |
128 | @request.session[:user_id] = 2 |
|
128 | @request.session[:user_id] = 2 | |
129 |
|
|
129 | delete :destroy, :id => 3 | |
130 | assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook' |
|
130 | assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook' | |
131 | assert_nil Version.find_by_id(3) |
|
131 | assert_nil Version.find_by_id(3) | |
132 | end |
|
132 | end | |
133 |
|
133 | |||
134 | def test_issue_status_by |
|
134 | def test_issue_status_by | |
135 | xhr :get, :status_by, :id => 2 |
|
135 | xhr :get, :status_by, :id => 2 | |
136 | assert_response :success |
|
136 | assert_response :success | |
137 | assert_template '_issue_counts' |
|
137 | assert_template '_issue_counts' | |
138 | end |
|
138 | end | |
139 | end |
|
139 | end |
General Comments 0
You need to be logged in to leave comments.
Login now