@@ -1,440 +1,435 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | class ProjectsController < ApplicationController |
|
18 | class ProjectsController < ApplicationController | |
19 | layout 'base' |
|
19 | layout 'base' | |
20 | menu_item :overview |
|
20 | menu_item :overview | |
21 | menu_item :activity, :only => :activity |
|
21 | menu_item :activity, :only => :activity | |
22 | menu_item :roadmap, :only => :roadmap |
|
22 | menu_item :roadmap, :only => :roadmap | |
23 | menu_item :files, :only => [:list_files, :add_file] |
|
23 | menu_item :files, :only => [:list_files, :add_file] | |
24 | menu_item :settings, :only => :settings |
|
24 | menu_item :settings, :only => :settings | |
25 | menu_item :issues, :only => [:changelog] |
|
25 | menu_item :issues, :only => [:changelog] | |
26 |
|
26 | |||
27 | before_filter :find_project, :except => [ :index, :list, :add, :activity ] |
|
27 | before_filter :find_project, :except => [ :index, :list, :add, :activity ] | |
28 | before_filter :find_optional_project, :only => :activity |
|
28 | before_filter :find_optional_project, :only => :activity | |
29 | before_filter :authorize, :except => [ :index, :list, :add, :archive, :unarchive, :destroy, :activity ] |
|
29 | before_filter :authorize, :except => [ :index, :list, :add, :archive, :unarchive, :destroy, :activity ] | |
30 | before_filter :require_admin, :only => [ :add, :archive, :unarchive, :destroy ] |
|
30 | before_filter :require_admin, :only => [ :add, :archive, :unarchive, :destroy ] | |
31 | accept_key_auth :activity, :calendar |
|
31 | accept_key_auth :activity, :calendar | |
32 |
|
32 | |||
33 | helper :sort |
|
33 | helper :sort | |
34 | include SortHelper |
|
34 | include SortHelper | |
35 | helper :custom_fields |
|
35 | helper :custom_fields | |
36 | include CustomFieldsHelper |
|
36 | include CustomFieldsHelper | |
37 | helper :ifpdf |
|
37 | helper :ifpdf | |
38 | include IfpdfHelper |
|
38 | include IfpdfHelper | |
39 | helper :issues |
|
39 | helper :issues | |
40 | helper IssuesHelper |
|
40 | helper IssuesHelper | |
41 | helper :queries |
|
41 | helper :queries | |
42 | include QueriesHelper |
|
42 | include QueriesHelper | |
43 | helper :repositories |
|
43 | helper :repositories | |
44 | include RepositoriesHelper |
|
44 | include RepositoriesHelper | |
45 | include ProjectsHelper |
|
45 | include ProjectsHelper | |
46 |
|
46 | |||
47 | def index |
|
|||
48 | list |
|
|||
49 | render :action => 'list' unless request.xhr? |
|
|||
50 | end |
|
|||
51 |
|
||||
52 | # Lists visible projects |
|
47 | # Lists visible projects | |
53 |
def |
|
48 | def index | |
54 | projects = Project.find :all, |
|
49 | projects = Project.find :all, | |
55 | :conditions => Project.visible_by(User.current), |
|
50 | :conditions => Project.visible_by(User.current), | |
56 | :include => :parent |
|
51 | :include => :parent | |
57 | @project_tree = projects.group_by {|p| p.parent || p} |
|
52 | @project_tree = projects.group_by {|p| p.parent || p} | |
58 | @project_tree.each_key {|p| @project_tree[p] -= [p]} |
|
53 | @project_tree.each_key {|p| @project_tree[p] -= [p]} | |
59 | end |
|
54 | end | |
60 |
|
55 | |||
61 | # Add a new project |
|
56 | # Add a new project | |
62 | def add |
|
57 | def add | |
63 | @custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") |
|
58 | @custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") | |
64 | @trackers = Tracker.all |
|
59 | @trackers = Tracker.all | |
65 | @root_projects = Project.find(:all, |
|
60 | @root_projects = Project.find(:all, | |
66 | :conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}", |
|
61 | :conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}", | |
67 | :order => 'name') |
|
62 | :order => 'name') | |
68 | @project = Project.new(params[:project]) |
|
63 | @project = Project.new(params[:project]) | |
69 | if request.get? |
|
64 | if request.get? | |
70 | @custom_values = ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| CustomValue.new(:custom_field => x, :customized => @project) } |
|
65 | @custom_values = ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| CustomValue.new(:custom_field => x, :customized => @project) } | |
71 | @project.trackers = Tracker.all |
|
66 | @project.trackers = Tracker.all | |
72 | @project.is_public = Setting.default_projects_public? |
|
67 | @project.is_public = Setting.default_projects_public? | |
73 | @project.enabled_module_names = Redmine::AccessControl.available_project_modules |
|
68 | @project.enabled_module_names = Redmine::AccessControl.available_project_modules | |
74 | else |
|
69 | else | |
75 | @project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids] |
|
70 | @project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids] | |
76 | @custom_values = ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => (params[:custom_fields] ? params["custom_fields"][x.id.to_s] : nil)) } |
|
71 | @custom_values = ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => (params[:custom_fields] ? params["custom_fields"][x.id.to_s] : nil)) } | |
77 | @project.custom_values = @custom_values |
|
72 | @project.custom_values = @custom_values | |
78 | @project.enabled_module_names = params[:enabled_modules] |
|
73 | @project.enabled_module_names = params[:enabled_modules] | |
79 | if @project.save |
|
74 | if @project.save | |
80 | flash[:notice] = l(:notice_successful_create) |
|
75 | flash[:notice] = l(:notice_successful_create) | |
81 | redirect_to :controller => 'admin', :action => 'projects' |
|
76 | redirect_to :controller => 'admin', :action => 'projects' | |
82 | end |
|
77 | end | |
83 | end |
|
78 | end | |
84 | end |
|
79 | end | |
85 |
|
80 | |||
86 | # Show @project |
|
81 | # Show @project | |
87 | def show |
|
82 | def show | |
88 | @custom_values = @project.custom_values.find(:all, :include => :custom_field, :order => "#{CustomField.table_name}.position") |
|
83 | @custom_values = @project.custom_values.find(:all, :include => :custom_field, :order => "#{CustomField.table_name}.position") | |
89 | @members_by_role = @project.members.find(:all, :include => [:user, :role], :order => 'position').group_by {|m| m.role} |
|
84 | @members_by_role = @project.members.find(:all, :include => [:user, :role], :order => 'position').group_by {|m| m.role} | |
90 | @subprojects = @project.children.find(:all, :conditions => Project.visible_by(User.current)) |
|
85 | @subprojects = @project.children.find(:all, :conditions => Project.visible_by(User.current)) | |
91 | @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC") |
|
86 | @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC") | |
92 | @trackers = @project.rolled_up_trackers |
|
87 | @trackers = @project.rolled_up_trackers | |
93 |
|
88 | |||
94 | cond = @project.project_condition(Setting.display_subprojects_issues?) |
|
89 | cond = @project.project_condition(Setting.display_subprojects_issues?) | |
95 | Issue.visible_by(User.current) do |
|
90 | Issue.visible_by(User.current) do | |
96 | @open_issues_by_tracker = Issue.count(:group => :tracker, |
|
91 | @open_issues_by_tracker = Issue.count(:group => :tracker, | |
97 | :include => [:project, :status, :tracker], |
|
92 | :include => [:project, :status, :tracker], | |
98 | :conditions => ["(#{cond}) AND #{IssueStatus.table_name}.is_closed=?", false]) |
|
93 | :conditions => ["(#{cond}) AND #{IssueStatus.table_name}.is_closed=?", false]) | |
99 | @total_issues_by_tracker = Issue.count(:group => :tracker, |
|
94 | @total_issues_by_tracker = Issue.count(:group => :tracker, | |
100 | :include => [:project, :status, :tracker], |
|
95 | :include => [:project, :status, :tracker], | |
101 | :conditions => cond) |
|
96 | :conditions => cond) | |
102 | end |
|
97 | end | |
103 | TimeEntry.visible_by(User.current) do |
|
98 | TimeEntry.visible_by(User.current) do | |
104 | @total_hours = TimeEntry.sum(:hours, |
|
99 | @total_hours = TimeEntry.sum(:hours, | |
105 | :include => :project, |
|
100 | :include => :project, | |
106 | :conditions => cond).to_f |
|
101 | :conditions => cond).to_f | |
107 | end |
|
102 | end | |
108 | @key = User.current.rss_key |
|
103 | @key = User.current.rss_key | |
109 | end |
|
104 | end | |
110 |
|
105 | |||
111 | def settings |
|
106 | def settings | |
112 | @root_projects = Project.find(:all, |
|
107 | @root_projects = Project.find(:all, | |
113 | :conditions => ["parent_id IS NULL AND status = #{Project::STATUS_ACTIVE} AND id <> ?", @project.id], |
|
108 | :conditions => ["parent_id IS NULL AND status = #{Project::STATUS_ACTIVE} AND id <> ?", @project.id], | |
114 | :order => 'name') |
|
109 | :order => 'name') | |
115 | @custom_fields = IssueCustomField.find(:all) |
|
110 | @custom_fields = IssueCustomField.find(:all) | |
116 | @issue_category ||= IssueCategory.new |
|
111 | @issue_category ||= IssueCategory.new | |
117 | @member ||= @project.members.new |
|
112 | @member ||= @project.members.new | |
118 | @trackers = Tracker.all |
|
113 | @trackers = Tracker.all | |
119 | @custom_values ||= ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) } |
|
114 | @custom_values ||= ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) } | |
120 | @repository ||= @project.repository |
|
115 | @repository ||= @project.repository | |
121 | @wiki ||= @project.wiki |
|
116 | @wiki ||= @project.wiki | |
122 | end |
|
117 | end | |
123 |
|
118 | |||
124 | # Edit @project |
|
119 | # Edit @project | |
125 | def edit |
|
120 | def edit | |
126 | if request.post? |
|
121 | if request.post? | |
127 | if params[:custom_fields] |
|
122 | if params[:custom_fields] | |
128 | @custom_values = ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) } |
|
123 | @custom_values = ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) } | |
129 | @project.custom_values = @custom_values |
|
124 | @project.custom_values = @custom_values | |
130 | end |
|
125 | end | |
131 | @project.attributes = params[:project] |
|
126 | @project.attributes = params[:project] | |
132 | if @project.save |
|
127 | if @project.save | |
133 | flash[:notice] = l(:notice_successful_update) |
|
128 | flash[:notice] = l(:notice_successful_update) | |
134 | redirect_to :action => 'settings', :id => @project |
|
129 | redirect_to :action => 'settings', :id => @project | |
135 | else |
|
130 | else | |
136 | settings |
|
131 | settings | |
137 | render :action => 'settings' |
|
132 | render :action => 'settings' | |
138 | end |
|
133 | end | |
139 | end |
|
134 | end | |
140 | end |
|
135 | end | |
141 |
|
136 | |||
142 | def modules |
|
137 | def modules | |
143 | @project.enabled_module_names = params[:enabled_modules] |
|
138 | @project.enabled_module_names = params[:enabled_modules] | |
144 | redirect_to :action => 'settings', :id => @project, :tab => 'modules' |
|
139 | redirect_to :action => 'settings', :id => @project, :tab => 'modules' | |
145 | end |
|
140 | end | |
146 |
|
141 | |||
147 | def archive |
|
142 | def archive | |
148 | @project.archive if request.post? && @project.active? |
|
143 | @project.archive if request.post? && @project.active? | |
149 | redirect_to :controller => 'admin', :action => 'projects' |
|
144 | redirect_to :controller => 'admin', :action => 'projects' | |
150 | end |
|
145 | end | |
151 |
|
146 | |||
152 | def unarchive |
|
147 | def unarchive | |
153 | @project.unarchive if request.post? && !@project.active? |
|
148 | @project.unarchive if request.post? && !@project.active? | |
154 | redirect_to :controller => 'admin', :action => 'projects' |
|
149 | redirect_to :controller => 'admin', :action => 'projects' | |
155 | end |
|
150 | end | |
156 |
|
151 | |||
157 | # Delete @project |
|
152 | # Delete @project | |
158 | def destroy |
|
153 | def destroy | |
159 | @project_to_destroy = @project |
|
154 | @project_to_destroy = @project | |
160 | if request.post? and params[:confirm] |
|
155 | if request.post? and params[:confirm] | |
161 | @project_to_destroy.destroy |
|
156 | @project_to_destroy.destroy | |
162 | redirect_to :controller => 'admin', :action => 'projects' |
|
157 | redirect_to :controller => 'admin', :action => 'projects' | |
163 | end |
|
158 | end | |
164 | # hide project in layout |
|
159 | # hide project in layout | |
165 | @project = nil |
|
160 | @project = nil | |
166 | end |
|
161 | end | |
167 |
|
162 | |||
168 | # Add a new issue category to @project |
|
163 | # Add a new issue category to @project | |
169 | def add_issue_category |
|
164 | def add_issue_category | |
170 | @category = @project.issue_categories.build(params[:category]) |
|
165 | @category = @project.issue_categories.build(params[:category]) | |
171 | if request.post? and @category.save |
|
166 | if request.post? and @category.save | |
172 | respond_to do |format| |
|
167 | respond_to do |format| | |
173 | format.html do |
|
168 | format.html do | |
174 | flash[:notice] = l(:notice_successful_create) |
|
169 | flash[:notice] = l(:notice_successful_create) | |
175 | redirect_to :action => 'settings', :tab => 'categories', :id => @project |
|
170 | redirect_to :action => 'settings', :tab => 'categories', :id => @project | |
176 | end |
|
171 | end | |
177 | format.js do |
|
172 | format.js do | |
178 | # IE doesn't support the replace_html rjs method for select box options |
|
173 | # IE doesn't support the replace_html rjs method for select box options | |
179 | render(:update) {|page| page.replace "issue_category_id", |
|
174 | render(:update) {|page| page.replace "issue_category_id", | |
180 | content_tag('select', '<option></option>' + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]') |
|
175 | content_tag('select', '<option></option>' + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]') | |
181 | } |
|
176 | } | |
182 | end |
|
177 | end | |
183 | end |
|
178 | end | |
184 | end |
|
179 | end | |
185 | end |
|
180 | end | |
186 |
|
181 | |||
187 | # Add a new version to @project |
|
182 | # Add a new version to @project | |
188 | def add_version |
|
183 | def add_version | |
189 | @version = @project.versions.build(params[:version]) |
|
184 | @version = @project.versions.build(params[:version]) | |
190 | if request.post? and @version.save |
|
185 | if request.post? and @version.save | |
191 | flash[:notice] = l(:notice_successful_create) |
|
186 | flash[:notice] = l(:notice_successful_create) | |
192 | redirect_to :action => 'settings', :tab => 'versions', :id => @project |
|
187 | redirect_to :action => 'settings', :tab => 'versions', :id => @project | |
193 | end |
|
188 | end | |
194 | end |
|
189 | end | |
195 |
|
190 | |||
196 | def add_file |
|
191 | def add_file | |
197 | if request.post? |
|
192 | if request.post? | |
198 | @version = @project.versions.find_by_id(params[:version_id]) |
|
193 | @version = @project.versions.find_by_id(params[:version_id]) | |
199 | attachments = attach_files(@version, params[:attachments]) |
|
194 | attachments = attach_files(@version, params[:attachments]) | |
200 | Mailer.deliver_attachments_added(attachments) if !attachments.empty? && Setting.notified_events.include?('file_added') |
|
195 | Mailer.deliver_attachments_added(attachments) if !attachments.empty? && Setting.notified_events.include?('file_added') | |
201 | redirect_to :controller => 'projects', :action => 'list_files', :id => @project |
|
196 | redirect_to :controller => 'projects', :action => 'list_files', :id => @project | |
202 | end |
|
197 | end | |
203 | @versions = @project.versions.sort |
|
198 | @versions = @project.versions.sort | |
204 | end |
|
199 | end | |
205 |
|
200 | |||
206 | def list_files |
|
201 | def list_files | |
207 | sort_init "#{Attachment.table_name}.filename", "asc" |
|
202 | sort_init "#{Attachment.table_name}.filename", "asc" | |
208 | sort_update |
|
203 | sort_update | |
209 | @versions = @project.versions.find(:all, :include => :attachments, :order => sort_clause).sort.reverse |
|
204 | @versions = @project.versions.find(:all, :include => :attachments, :order => sort_clause).sort.reverse | |
210 | render :layout => !request.xhr? |
|
205 | render :layout => !request.xhr? | |
211 | end |
|
206 | end | |
212 |
|
207 | |||
213 | # Show changelog for @project |
|
208 | # Show changelog for @project | |
214 | def changelog |
|
209 | def changelog | |
215 | @trackers = @project.trackers.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position') |
|
210 | @trackers = @project.trackers.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position') | |
216 | retrieve_selected_tracker_ids(@trackers) |
|
211 | retrieve_selected_tracker_ids(@trackers) | |
217 | @versions = @project.versions.sort |
|
212 | @versions = @project.versions.sort | |
218 | end |
|
213 | end | |
219 |
|
214 | |||
220 | def roadmap |
|
215 | def roadmap | |
221 | @trackers = @project.trackers.find(:all, :conditions => ["is_in_roadmap=?", true]) |
|
216 | @trackers = @project.trackers.find(:all, :conditions => ["is_in_roadmap=?", true]) | |
222 | retrieve_selected_tracker_ids(@trackers) |
|
217 | retrieve_selected_tracker_ids(@trackers) | |
223 | @versions = @project.versions.sort |
|
218 | @versions = @project.versions.sort | |
224 | @versions = @versions.select {|v| !v.completed? } unless params[:completed] |
|
219 | @versions = @versions.select {|v| !v.completed? } unless params[:completed] | |
225 | end |
|
220 | end | |
226 |
|
221 | |||
227 | def activity |
|
222 | def activity | |
228 | @days = Setting.activity_days_default.to_i |
|
223 | @days = Setting.activity_days_default.to_i | |
229 |
|
224 | |||
230 | if params[:from] |
|
225 | if params[:from] | |
231 | begin; @date_to = params[:from].to_date; rescue; end |
|
226 | begin; @date_to = params[:from].to_date; rescue; end | |
232 | end |
|
227 | end | |
233 |
|
228 | |||
234 | @date_to ||= Date.today + 1 |
|
229 | @date_to ||= Date.today + 1 | |
235 | @date_from = @date_to - @days |
|
230 | @date_from = @date_to - @days | |
236 |
|
231 | |||
237 | @event_types = %w(issues news files documents changesets wiki_pages messages) |
|
232 | @event_types = %w(issues news files documents changesets wiki_pages messages) | |
238 | if @project |
|
233 | if @project | |
239 | @event_types.delete('wiki_pages') unless @project.wiki |
|
234 | @event_types.delete('wiki_pages') unless @project.wiki | |
240 | @event_types.delete('changesets') unless @project.repository |
|
235 | @event_types.delete('changesets') unless @project.repository | |
241 | @event_types.delete('messages') unless @project.boards.any? |
|
236 | @event_types.delete('messages') unless @project.boards.any? | |
242 | # only show what the user is allowed to view |
|
237 | # only show what the user is allowed to view | |
243 | @event_types = @event_types.select {|o| User.current.allowed_to?("view_#{o}".to_sym, @project)} |
|
238 | @event_types = @event_types.select {|o| User.current.allowed_to?("view_#{o}".to_sym, @project)} | |
244 | @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') |
|
239 | @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') | |
245 | end |
|
240 | end | |
246 | @scope = @event_types.select {|t| params["show_#{t}"]} |
|
241 | @scope = @event_types.select {|t| params["show_#{t}"]} | |
247 | # default events if none is specified in parameters |
|
242 | # default events if none is specified in parameters | |
248 | @scope = (@event_types - %w(wiki_pages messages))if @scope.empty? |
|
243 | @scope = (@event_types - %w(wiki_pages messages))if @scope.empty? | |
249 |
|
244 | |||
250 | @events = [] |
|
245 | @events = [] | |
251 |
|
246 | |||
252 | if @scope.include?('issues') |
|
247 | if @scope.include?('issues') | |
253 | cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_issues, :project => @project, :with_subprojects => @with_subprojects)) |
|
248 | cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_issues, :project => @project, :with_subprojects => @with_subprojects)) | |
254 | cond.add(["#{Issue.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to]) |
|
249 | cond.add(["#{Issue.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to]) | |
255 | @events += Issue.find(:all, :include => [:project, :author, :tracker], :conditions => cond.conditions) |
|
250 | @events += Issue.find(:all, :include => [:project, :author, :tracker], :conditions => cond.conditions) | |
256 |
|
251 | |||
257 | cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_issues, :project => @project, :with_subprojects => @with_subprojects)) |
|
252 | cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_issues, :project => @project, :with_subprojects => @with_subprojects)) | |
258 | cond.add(["#{Journal.table_name}.journalized_type = 'Issue' AND #{JournalDetail.table_name}.prop_key = 'status_id' AND #{Journal.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to]) |
|
253 | cond.add(["#{Journal.table_name}.journalized_type = 'Issue' AND #{JournalDetail.table_name}.prop_key = 'status_id' AND #{Journal.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to]) | |
259 | @events += Journal.find(:all, :include => [{:issue => :project}, :details, :user], :conditions => cond.conditions) |
|
254 | @events += Journal.find(:all, :include => [{:issue => :project}, :details, :user], :conditions => cond.conditions) | |
260 | end |
|
255 | end | |
261 |
|
256 | |||
262 | if @scope.include?('news') |
|
257 | if @scope.include?('news') | |
263 | cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_news, :project => @project, :with_subprojects => @with_subprojects)) |
|
258 | cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_news, :project => @project, :with_subprojects => @with_subprojects)) | |
264 | cond.add(["#{News.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to]) |
|
259 | cond.add(["#{News.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to]) | |
265 | @events += News.find(:all, :include => [:project, :author], :conditions => cond.conditions) |
|
260 | @events += News.find(:all, :include => [:project, :author], :conditions => cond.conditions) | |
266 | end |
|
261 | end | |
267 |
|
262 | |||
268 | if @scope.include?('files') |
|
263 | if @scope.include?('files') | |
269 | cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_files, :project => @project, :with_subprojects => @with_subprojects)) |
|
264 | cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_files, :project => @project, :with_subprojects => @with_subprojects)) | |
270 | cond.add(["#{Attachment.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to]) |
|
265 | cond.add(["#{Attachment.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to]) | |
271 | @events += Attachment.find(:all, :select => "#{Attachment.table_name}.*", |
|
266 | @events += Attachment.find(:all, :select => "#{Attachment.table_name}.*", | |
272 | :joins => "LEFT JOIN #{Version.table_name} ON #{Attachment.table_name}.container_type='Version' AND #{Version.table_name}.id = #{Attachment.table_name}.container_id " + |
|
267 | :joins => "LEFT JOIN #{Version.table_name} ON #{Attachment.table_name}.container_type='Version' AND #{Version.table_name}.id = #{Attachment.table_name}.container_id " + | |
273 | "LEFT JOIN #{Project.table_name} ON #{Version.table_name}.project_id = #{Project.table_name}.id", |
|
268 | "LEFT JOIN #{Project.table_name} ON #{Version.table_name}.project_id = #{Project.table_name}.id", | |
274 | :conditions => cond.conditions) |
|
269 | :conditions => cond.conditions) | |
275 | end |
|
270 | end | |
276 |
|
271 | |||
277 | if @scope.include?('documents') |
|
272 | if @scope.include?('documents') | |
278 | cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_documents, :project => @project, :with_subprojects => @with_subprojects)) |
|
273 | cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_documents, :project => @project, :with_subprojects => @with_subprojects)) | |
279 | cond.add(["#{Document.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to]) |
|
274 | cond.add(["#{Document.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to]) | |
280 | @events += Document.find(:all, :include => :project, :conditions => cond.conditions) |
|
275 | @events += Document.find(:all, :include => :project, :conditions => cond.conditions) | |
281 |
|
276 | |||
282 | cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_documents, :project => @project, :with_subprojects => @with_subprojects)) |
|
277 | cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_documents, :project => @project, :with_subprojects => @with_subprojects)) | |
283 | cond.add(["#{Attachment.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to]) |
|
278 | cond.add(["#{Attachment.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to]) | |
284 | @events += Attachment.find(:all, :select => "#{Attachment.table_name}.*", |
|
279 | @events += Attachment.find(:all, :select => "#{Attachment.table_name}.*", | |
285 | :joins => "LEFT JOIN #{Document.table_name} ON #{Attachment.table_name}.container_type='Document' AND #{Document.table_name}.id = #{Attachment.table_name}.container_id " + |
|
280 | :joins => "LEFT JOIN #{Document.table_name} ON #{Attachment.table_name}.container_type='Document' AND #{Document.table_name}.id = #{Attachment.table_name}.container_id " + | |
286 | "LEFT JOIN #{Project.table_name} ON #{Document.table_name}.project_id = #{Project.table_name}.id", |
|
281 | "LEFT JOIN #{Project.table_name} ON #{Document.table_name}.project_id = #{Project.table_name}.id", | |
287 | :conditions => cond.conditions) |
|
282 | :conditions => cond.conditions) | |
288 | end |
|
283 | end | |
289 |
|
284 | |||
290 | if @scope.include?('wiki_pages') |
|
285 | if @scope.include?('wiki_pages') | |
291 | select = "#{WikiContent.versioned_table_name}.updated_on, #{WikiContent.versioned_table_name}.comments, " + |
|
286 | select = "#{WikiContent.versioned_table_name}.updated_on, #{WikiContent.versioned_table_name}.comments, " + | |
292 | "#{WikiContent.versioned_table_name}.#{WikiContent.version_column}, #{WikiPage.table_name}.title, " + |
|
287 | "#{WikiContent.versioned_table_name}.#{WikiContent.version_column}, #{WikiPage.table_name}.title, " + | |
293 | "#{WikiContent.versioned_table_name}.page_id, #{WikiContent.versioned_table_name}.author_id, " + |
|
288 | "#{WikiContent.versioned_table_name}.page_id, #{WikiContent.versioned_table_name}.author_id, " + | |
294 | "#{WikiContent.versioned_table_name}.id" |
|
289 | "#{WikiContent.versioned_table_name}.id" | |
295 | joins = "LEFT JOIN #{WikiPage.table_name} ON #{WikiPage.table_name}.id = #{WikiContent.versioned_table_name}.page_id " + |
|
290 | joins = "LEFT JOIN #{WikiPage.table_name} ON #{WikiPage.table_name}.id = #{WikiContent.versioned_table_name}.page_id " + | |
296 | "LEFT JOIN #{Wiki.table_name} ON #{Wiki.table_name}.id = #{WikiPage.table_name}.wiki_id " + |
|
291 | "LEFT JOIN #{Wiki.table_name} ON #{Wiki.table_name}.id = #{WikiPage.table_name}.wiki_id " + | |
297 | "LEFT JOIN #{Project.table_name} ON #{Project.table_name}.id = #{Wiki.table_name}.project_id" |
|
292 | "LEFT JOIN #{Project.table_name} ON #{Project.table_name}.id = #{Wiki.table_name}.project_id" | |
298 |
|
293 | |||
299 | cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_wiki_pages, :project => @project, :with_subprojects => @with_subprojects)) |
|
294 | cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_wiki_pages, :project => @project, :with_subprojects => @with_subprojects)) | |
300 | cond.add(["#{WikiContent.versioned_table_name}.updated_on BETWEEN ? AND ?", @date_from, @date_to]) |
|
295 | cond.add(["#{WikiContent.versioned_table_name}.updated_on BETWEEN ? AND ?", @date_from, @date_to]) | |
301 | @events += WikiContent.versioned_class.find(:all, :select => select, :joins => joins, :conditions => cond.conditions) |
|
296 | @events += WikiContent.versioned_class.find(:all, :select => select, :joins => joins, :conditions => cond.conditions) | |
302 | end |
|
297 | end | |
303 |
|
298 | |||
304 | if @scope.include?('changesets') |
|
299 | if @scope.include?('changesets') | |
305 | cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_changesets, :project => @project, :with_subprojects => @with_subprojects)) |
|
300 | cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_changesets, :project => @project, :with_subprojects => @with_subprojects)) | |
306 | cond.add(["#{Changeset.table_name}.committed_on BETWEEN ? AND ?", @date_from, @date_to]) |
|
301 | cond.add(["#{Changeset.table_name}.committed_on BETWEEN ? AND ?", @date_from, @date_to]) | |
307 | @events += Changeset.find(:all, :include => {:repository => :project}, :conditions => cond.conditions) |
|
302 | @events += Changeset.find(:all, :include => {:repository => :project}, :conditions => cond.conditions) | |
308 | end |
|
303 | end | |
309 |
|
304 | |||
310 | if @scope.include?('messages') |
|
305 | if @scope.include?('messages') | |
311 | cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_messages, :project => @project, :with_subprojects => @with_subprojects)) |
|
306 | cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_messages, :project => @project, :with_subprojects => @with_subprojects)) | |
312 | cond.add(["#{Message.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to]) |
|
307 | cond.add(["#{Message.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to]) | |
313 | @events += Message.find(:all, :include => [{:board => :project}, :author], :conditions => cond.conditions) |
|
308 | @events += Message.find(:all, :include => [{:board => :project}, :author], :conditions => cond.conditions) | |
314 | end |
|
309 | end | |
315 |
|
310 | |||
316 | @events_by_day = @events.group_by(&:event_date) |
|
311 | @events_by_day = @events.group_by(&:event_date) | |
317 |
|
312 | |||
318 | respond_to do |format| |
|
313 | respond_to do |format| | |
319 | format.html { render :layout => false if request.xhr? } |
|
314 | format.html { render :layout => false if request.xhr? } | |
320 | format.atom { render_feed(@events, :title => "#{@project || Setting.app_title}: #{l(:label_activity)}") } |
|
315 | format.atom { render_feed(@events, :title => "#{@project || Setting.app_title}: #{l(:label_activity)}") } | |
321 | end |
|
316 | end | |
322 | end |
|
317 | end | |
323 |
|
318 | |||
324 | def calendar |
|
319 | def calendar | |
325 | @trackers = @project.rolled_up_trackers |
|
320 | @trackers = @project.rolled_up_trackers | |
326 | retrieve_selected_tracker_ids(@trackers) |
|
321 | retrieve_selected_tracker_ids(@trackers) | |
327 |
|
322 | |||
328 | if params[:year] and params[:year].to_i > 1900 |
|
323 | if params[:year] and params[:year].to_i > 1900 | |
329 | @year = params[:year].to_i |
|
324 | @year = params[:year].to_i | |
330 | if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13 |
|
325 | if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13 | |
331 | @month = params[:month].to_i |
|
326 | @month = params[:month].to_i | |
332 | end |
|
327 | end | |
333 | end |
|
328 | end | |
334 | @year ||= Date.today.year |
|
329 | @year ||= Date.today.year | |
335 | @month ||= Date.today.month |
|
330 | @month ||= Date.today.month | |
336 | @calendar = Redmine::Helpers::Calendar.new(Date.civil(@year, @month, 1), current_language, :month) |
|
331 | @calendar = Redmine::Helpers::Calendar.new(Date.civil(@year, @month, 1), current_language, :month) | |
337 | @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') |
|
332 | @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') | |
338 | events = [] |
|
333 | events = [] | |
339 | @project.issues_with_subprojects(@with_subprojects) do |
|
334 | @project.issues_with_subprojects(@with_subprojects) do | |
340 | events += Issue.find(:all, |
|
335 | events += Issue.find(:all, | |
341 | :include => [:tracker, :status, :assigned_to, :priority, :project], |
|
336 | :include => [:tracker, :status, :assigned_to, :priority, :project], | |
342 | :conditions => ["((start_date BETWEEN ? AND ?) OR (due_date BETWEEN ? AND ?)) AND #{Issue.table_name}.tracker_id IN (#{@selected_tracker_ids.join(',')})", @calendar.startdt, @calendar.enddt, @calendar.startdt, @calendar.enddt] |
|
337 | :conditions => ["((start_date BETWEEN ? AND ?) OR (due_date BETWEEN ? AND ?)) AND #{Issue.table_name}.tracker_id IN (#{@selected_tracker_ids.join(',')})", @calendar.startdt, @calendar.enddt, @calendar.startdt, @calendar.enddt] | |
343 | ) unless @selected_tracker_ids.empty? |
|
338 | ) unless @selected_tracker_ids.empty? | |
344 | events += Version.find(:all, :include => :project, |
|
339 | events += Version.find(:all, :include => :project, | |
345 | :conditions => ["effective_date BETWEEN ? AND ?", @calendar.startdt, @calendar.enddt]) |
|
340 | :conditions => ["effective_date BETWEEN ? AND ?", @calendar.startdt, @calendar.enddt]) | |
346 | end |
|
341 | end | |
347 | @calendar.events = events |
|
342 | @calendar.events = events | |
348 |
|
343 | |||
349 | render :layout => false if request.xhr? |
|
344 | render :layout => false if request.xhr? | |
350 | end |
|
345 | end | |
351 |
|
346 | |||
352 | def gantt |
|
347 | def gantt | |
353 | @trackers = @project.rolled_up_trackers |
|
348 | @trackers = @project.rolled_up_trackers | |
354 | retrieve_selected_tracker_ids(@trackers) |
|
349 | retrieve_selected_tracker_ids(@trackers) | |
355 |
|
350 | |||
356 | if params[:year] and params[:year].to_i >0 |
|
351 | if params[:year] and params[:year].to_i >0 | |
357 | @year_from = params[:year].to_i |
|
352 | @year_from = params[:year].to_i | |
358 | if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12 |
|
353 | if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12 | |
359 | @month_from = params[:month].to_i |
|
354 | @month_from = params[:month].to_i | |
360 | else |
|
355 | else | |
361 | @month_from = 1 |
|
356 | @month_from = 1 | |
362 | end |
|
357 | end | |
363 | else |
|
358 | else | |
364 | @month_from ||= Date.today.month |
|
359 | @month_from ||= Date.today.month | |
365 | @year_from ||= Date.today.year |
|
360 | @year_from ||= Date.today.year | |
366 | end |
|
361 | end | |
367 |
|
362 | |||
368 | zoom = (params[:zoom] || User.current.pref[:gantt_zoom]).to_i |
|
363 | zoom = (params[:zoom] || User.current.pref[:gantt_zoom]).to_i | |
369 | @zoom = (zoom > 0 && zoom < 5) ? zoom : 2 |
|
364 | @zoom = (zoom > 0 && zoom < 5) ? zoom : 2 | |
370 | months = (params[:months] || User.current.pref[:gantt_months]).to_i |
|
365 | months = (params[:months] || User.current.pref[:gantt_months]).to_i | |
371 | @months = (months > 0 && months < 25) ? months : 6 |
|
366 | @months = (months > 0 && months < 25) ? months : 6 | |
372 |
|
367 | |||
373 | # Save gantt paramters as user preference (zoom and months count) |
|
368 | # Save gantt paramters as user preference (zoom and months count) | |
374 | if (User.current.logged? && (@zoom != User.current.pref[:gantt_zoom] || @months != User.current.pref[:gantt_months])) |
|
369 | if (User.current.logged? && (@zoom != User.current.pref[:gantt_zoom] || @months != User.current.pref[:gantt_months])) | |
375 | User.current.pref[:gantt_zoom], User.current.pref[:gantt_months] = @zoom, @months |
|
370 | User.current.pref[:gantt_zoom], User.current.pref[:gantt_months] = @zoom, @months | |
376 | User.current.preference.save |
|
371 | User.current.preference.save | |
377 | end |
|
372 | end | |
378 |
|
373 | |||
379 | @date_from = Date.civil(@year_from, @month_from, 1) |
|
374 | @date_from = Date.civil(@year_from, @month_from, 1) | |
380 | @date_to = (@date_from >> @months) - 1 |
|
375 | @date_to = (@date_from >> @months) - 1 | |
381 | @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') |
|
376 | @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') | |
382 |
|
377 | |||
383 | @events = [] |
|
378 | @events = [] | |
384 | @project.issues_with_subprojects(@with_subprojects) do |
|
379 | @project.issues_with_subprojects(@with_subprojects) do | |
385 | # Issues that have start and due dates |
|
380 | # Issues that have start and due dates | |
386 | @events += Issue.find(:all, |
|
381 | @events += Issue.find(:all, | |
387 | :order => "start_date, due_date", |
|
382 | :order => "start_date, due_date", | |
388 | :include => [:tracker, :status, :assigned_to, :priority, :project], |
|
383 | :include => [:tracker, :status, :assigned_to, :priority, :project], | |
389 | :conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')}))", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to] |
|
384 | :conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')}))", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to] | |
390 | ) unless @selected_tracker_ids.empty? |
|
385 | ) unless @selected_tracker_ids.empty? | |
391 | # Issues that don't have a due date but that are assigned to a version with a date |
|
386 | # Issues that don't have a due date but that are assigned to a version with a date | |
392 | @events += Issue.find(:all, |
|
387 | @events += Issue.find(:all, | |
393 | :order => "start_date, effective_date", |
|
388 | :order => "start_date, effective_date", | |
394 | :include => [:tracker, :status, :assigned_to, :priority, :project, :fixed_version], |
|
389 | :include => [:tracker, :status, :assigned_to, :priority, :project, :fixed_version], | |
395 | :conditions => ["(((start_date>=? and start_date<=?) or (effective_date>=? and effective_date<=?) or (start_date<? and effective_date>?)) and start_date is not null and due_date is null and effective_date is not null and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')}))", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to] |
|
390 | :conditions => ["(((start_date>=? and start_date<=?) or (effective_date>=? and effective_date<=?) or (start_date<? and effective_date>?)) and start_date is not null and due_date is null and effective_date is not null and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')}))", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to] | |
396 | ) unless @selected_tracker_ids.empty? |
|
391 | ) unless @selected_tracker_ids.empty? | |
397 | @events += Version.find(:all, :include => :project, |
|
392 | @events += Version.find(:all, :include => :project, | |
398 | :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to]) |
|
393 | :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to]) | |
399 | end |
|
394 | end | |
400 | @events.sort! {|x,y| x.start_date <=> y.start_date } |
|
395 | @events.sort! {|x,y| x.start_date <=> y.start_date } | |
401 |
|
396 | |||
402 | if params[:format]=='pdf' |
|
397 | if params[:format]=='pdf' | |
403 | @options_for_rfpdf ||= {} |
|
398 | @options_for_rfpdf ||= {} | |
404 | @options_for_rfpdf[:file_name] = "#{@project.identifier}-gantt.pdf" |
|
399 | @options_for_rfpdf[:file_name] = "#{@project.identifier}-gantt.pdf" | |
405 | render :template => "projects/gantt.rfpdf", :layout => false |
|
400 | render :template => "projects/gantt.rfpdf", :layout => false | |
406 | elsif params[:format]=='png' && respond_to?('gantt_image') |
|
401 | elsif params[:format]=='png' && respond_to?('gantt_image') | |
407 | image = gantt_image(@events, @date_from, @months, @zoom) |
|
402 | image = gantt_image(@events, @date_from, @months, @zoom) | |
408 | image.format = 'PNG' |
|
403 | image.format = 'PNG' | |
409 | send_data(image.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "#{@project.identifier}-gantt.png") |
|
404 | send_data(image.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "#{@project.identifier}-gantt.png") | |
410 | else |
|
405 | else | |
411 | render :template => "projects/gantt.rhtml" |
|
406 | render :template => "projects/gantt.rhtml" | |
412 | end |
|
407 | end | |
413 | end |
|
408 | end | |
414 |
|
409 | |||
415 | private |
|
410 | private | |
416 | # Find project of id params[:id] |
|
411 | # Find project of id params[:id] | |
417 | # if not found, redirect to project list |
|
412 | # if not found, redirect to project list | |
418 | # Used as a before_filter |
|
413 | # Used as a before_filter | |
419 | def find_project |
|
414 | def find_project | |
420 | @project = Project.find(params[:id]) |
|
415 | @project = Project.find(params[:id]) | |
421 | rescue ActiveRecord::RecordNotFound |
|
416 | rescue ActiveRecord::RecordNotFound | |
422 | render_404 |
|
417 | render_404 | |
423 | end |
|
418 | end | |
424 |
|
419 | |||
425 | def find_optional_project |
|
420 | def find_optional_project | |
426 | return true unless params[:id] |
|
421 | return true unless params[:id] | |
427 | @project = Project.find(params[:id]) |
|
422 | @project = Project.find(params[:id]) | |
428 | authorize |
|
423 | authorize | |
429 | rescue ActiveRecord::RecordNotFound |
|
424 | rescue ActiveRecord::RecordNotFound | |
430 | render_404 |
|
425 | render_404 | |
431 | end |
|
426 | end | |
432 |
|
427 | |||
433 | def retrieve_selected_tracker_ids(selectable_trackers) |
|
428 | def retrieve_selected_tracker_ids(selectable_trackers) | |
434 | if ids = params[:tracker_ids] |
|
429 | if ids = params[:tracker_ids] | |
435 | @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s } |
|
430 | @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s } | |
436 | else |
|
431 | else | |
437 | @selected_tracker_ids = selectable_trackers.collect {|t| t.id.to_s } |
|
432 | @selected_tracker_ids = selectable_trackers.collect {|t| t.id.to_s } | |
438 | end |
|
433 | end | |
439 | end |
|
434 | end | |
440 | end |
|
435 | end |
1 | NO CONTENT: file renamed from app/views/projects/list.rhtml to app/views/projects/index.rhtml |
|
NO CONTENT: file renamed from app/views/projects/list.rhtml to app/views/projects/index.rhtml |
@@ -1,313 +1,307 | |||||
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 'projects_controller' |
|
19 | require 'projects_controller' | |
20 |
|
20 | |||
21 | # Re-raise errors caught by the controller. |
|
21 | # Re-raise errors caught by the controller. | |
22 | class ProjectsController; def rescue_action(e) raise e end; end |
|
22 | class ProjectsController; def rescue_action(e) raise e end; end | |
23 |
|
23 | |||
24 | class ProjectsControllerTest < Test::Unit::TestCase |
|
24 | class ProjectsControllerTest < Test::Unit::TestCase | |
25 | fixtures :projects, :versions, :users, :roles, :members, :issues, :journals, :journal_details, |
|
25 | fixtures :projects, :versions, :users, :roles, :members, :issues, :journals, :journal_details, | |
26 | :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages |
|
26 | :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages | |
27 |
|
27 | |||
28 | def setup |
|
28 | def setup | |
29 | @controller = ProjectsController.new |
|
29 | @controller = ProjectsController.new | |
30 | @request = ActionController::TestRequest.new |
|
30 | @request = ActionController::TestRequest.new | |
31 | @response = ActionController::TestResponse.new |
|
31 | @response = ActionController::TestResponse.new | |
32 | @request.session[:user_id] = nil |
|
32 | @request.session[:user_id] = nil | |
33 | end |
|
33 | end | |
34 |
|
34 | |||
35 | def test_index |
|
35 | def test_index | |
36 | get :index |
|
36 | get :index | |
37 | assert_response :success |
|
37 | assert_response :success | |
38 |
assert_template ' |
|
38 | assert_template 'index' | |
39 | end |
|
|||
40 |
|
||||
41 | def test_list |
|
|||
42 | get :list |
|
|||
43 | assert_response :success |
|
|||
44 | assert_template 'list' |
|
|||
45 | assert_not_nil assigns(:project_tree) |
|
39 | assert_not_nil assigns(:project_tree) | |
46 | # Root project as hash key |
|
40 | # Root project as hash key | |
47 | assert assigns(:project_tree).has_key?(Project.find(1)) |
|
41 | assert assigns(:project_tree).has_key?(Project.find(1)) | |
48 | # Subproject in corresponding value |
|
42 | # Subproject in corresponding value | |
49 | assert assigns(:project_tree)[Project.find(1)].include?(Project.find(3)) |
|
43 | assert assigns(:project_tree)[Project.find(1)].include?(Project.find(3)) | |
50 | end |
|
44 | end | |
51 |
|
45 | |||
52 | def test_show_by_id |
|
46 | def test_show_by_id | |
53 | get :show, :id => 1 |
|
47 | get :show, :id => 1 | |
54 | assert_response :success |
|
48 | assert_response :success | |
55 | assert_template 'show' |
|
49 | assert_template 'show' | |
56 | assert_not_nil assigns(:project) |
|
50 | assert_not_nil assigns(:project) | |
57 | end |
|
51 | end | |
58 |
|
52 | |||
59 | def test_show_by_identifier |
|
53 | def test_show_by_identifier | |
60 | get :show, :id => 'ecookbook' |
|
54 | get :show, :id => 'ecookbook' | |
61 | assert_response :success |
|
55 | assert_response :success | |
62 | assert_template 'show' |
|
56 | assert_template 'show' | |
63 | assert_not_nil assigns(:project) |
|
57 | assert_not_nil assigns(:project) | |
64 | assert_equal Project.find_by_identifier('ecookbook'), assigns(:project) |
|
58 | assert_equal Project.find_by_identifier('ecookbook'), assigns(:project) | |
65 | end |
|
59 | end | |
66 |
|
60 | |||
67 | def test_private_subprojects_hidden |
|
61 | def test_private_subprojects_hidden | |
68 | get :show, :id => 'ecookbook' |
|
62 | get :show, :id => 'ecookbook' | |
69 | assert_response :success |
|
63 | assert_response :success | |
70 | assert_template 'show' |
|
64 | assert_template 'show' | |
71 | assert_no_tag :tag => 'a', :content => /Private child/ |
|
65 | assert_no_tag :tag => 'a', :content => /Private child/ | |
72 | end |
|
66 | end | |
73 |
|
67 | |||
74 | def test_private_subprojects_visible |
|
68 | def test_private_subprojects_visible | |
75 | @request.session[:user_id] = 2 # manager who is a member of the private subproject |
|
69 | @request.session[:user_id] = 2 # manager who is a member of the private subproject | |
76 | get :show, :id => 'ecookbook' |
|
70 | get :show, :id => 'ecookbook' | |
77 | assert_response :success |
|
71 | assert_response :success | |
78 | assert_template 'show' |
|
72 | assert_template 'show' | |
79 | assert_tag :tag => 'a', :content => /Private child/ |
|
73 | assert_tag :tag => 'a', :content => /Private child/ | |
80 | end |
|
74 | end | |
81 |
|
75 | |||
82 | def test_settings |
|
76 | def test_settings | |
83 | @request.session[:user_id] = 2 # manager |
|
77 | @request.session[:user_id] = 2 # manager | |
84 | get :settings, :id => 1 |
|
78 | get :settings, :id => 1 | |
85 | assert_response :success |
|
79 | assert_response :success | |
86 | assert_template 'settings' |
|
80 | assert_template 'settings' | |
87 | end |
|
81 | end | |
88 |
|
82 | |||
89 | def test_edit |
|
83 | def test_edit | |
90 | @request.session[:user_id] = 2 # manager |
|
84 | @request.session[:user_id] = 2 # manager | |
91 | post :edit, :id => 1, :project => {:name => 'Test changed name', |
|
85 | post :edit, :id => 1, :project => {:name => 'Test changed name', | |
92 | :custom_field_ids => ['']} |
|
86 | :custom_field_ids => ['']} | |
93 | assert_redirected_to 'projects/settings/ecookbook' |
|
87 | assert_redirected_to 'projects/settings/ecookbook' | |
94 | project = Project.find(1) |
|
88 | project = Project.find(1) | |
95 | assert_equal 'Test changed name', project.name |
|
89 | assert_equal 'Test changed name', project.name | |
96 | end |
|
90 | end | |
97 |
|
91 | |||
98 | def test_get_destroy |
|
92 | def test_get_destroy | |
99 | @request.session[:user_id] = 1 # admin |
|
93 | @request.session[:user_id] = 1 # admin | |
100 | get :destroy, :id => 1 |
|
94 | get :destroy, :id => 1 | |
101 | assert_response :success |
|
95 | assert_response :success | |
102 | assert_template 'destroy' |
|
96 | assert_template 'destroy' | |
103 | assert_not_nil Project.find_by_id(1) |
|
97 | assert_not_nil Project.find_by_id(1) | |
104 | end |
|
98 | end | |
105 |
|
99 | |||
106 | def test_post_destroy |
|
100 | def test_post_destroy | |
107 | @request.session[:user_id] = 1 # admin |
|
101 | @request.session[:user_id] = 1 # admin | |
108 | post :destroy, :id => 1, :confirm => 1 |
|
102 | post :destroy, :id => 1, :confirm => 1 | |
109 | assert_redirected_to 'admin/projects' |
|
103 | assert_redirected_to 'admin/projects' | |
110 | assert_nil Project.find_by_id(1) |
|
104 | assert_nil Project.find_by_id(1) | |
111 | end |
|
105 | end | |
112 |
|
106 | |||
113 | def test_list_files |
|
107 | def test_list_files | |
114 | get :list_files, :id => 1 |
|
108 | get :list_files, :id => 1 | |
115 | assert_response :success |
|
109 | assert_response :success | |
116 | assert_template 'list_files' |
|
110 | assert_template 'list_files' | |
117 | assert_not_nil assigns(:versions) |
|
111 | assert_not_nil assigns(:versions) | |
118 | end |
|
112 | end | |
119 |
|
113 | |||
120 | def test_changelog |
|
114 | def test_changelog | |
121 | get :changelog, :id => 1 |
|
115 | get :changelog, :id => 1 | |
122 | assert_response :success |
|
116 | assert_response :success | |
123 | assert_template 'changelog' |
|
117 | assert_template 'changelog' | |
124 | assert_not_nil assigns(:versions) |
|
118 | assert_not_nil assigns(:versions) | |
125 | end |
|
119 | end | |
126 |
|
120 | |||
127 | def test_roadmap |
|
121 | def test_roadmap | |
128 | get :roadmap, :id => 1 |
|
122 | get :roadmap, :id => 1 | |
129 | assert_response :success |
|
123 | assert_response :success | |
130 | assert_template 'roadmap' |
|
124 | assert_template 'roadmap' | |
131 | assert_not_nil assigns(:versions) |
|
125 | assert_not_nil assigns(:versions) | |
132 | # Version with no date set appears |
|
126 | # Version with no date set appears | |
133 | assert assigns(:versions).include?(Version.find(3)) |
|
127 | assert assigns(:versions).include?(Version.find(3)) | |
134 | # Completed version doesn't appear |
|
128 | # Completed version doesn't appear | |
135 | assert !assigns(:versions).include?(Version.find(1)) |
|
129 | assert !assigns(:versions).include?(Version.find(1)) | |
136 | end |
|
130 | end | |
137 |
|
131 | |||
138 | def test_roadmap_with_completed_versions |
|
132 | def test_roadmap_with_completed_versions | |
139 | get :roadmap, :id => 1, :completed => 1 |
|
133 | get :roadmap, :id => 1, :completed => 1 | |
140 | assert_response :success |
|
134 | assert_response :success | |
141 | assert_template 'roadmap' |
|
135 | assert_template 'roadmap' | |
142 | assert_not_nil assigns(:versions) |
|
136 | assert_not_nil assigns(:versions) | |
143 | # Version with no date set appears |
|
137 | # Version with no date set appears | |
144 | assert assigns(:versions).include?(Version.find(3)) |
|
138 | assert assigns(:versions).include?(Version.find(3)) | |
145 | # Completed version appears |
|
139 | # Completed version appears | |
146 | assert assigns(:versions).include?(Version.find(1)) |
|
140 | assert assigns(:versions).include?(Version.find(1)) | |
147 | end |
|
141 | end | |
148 |
|
142 | |||
149 | def test_project_activity |
|
143 | def test_project_activity | |
150 | get :activity, :id => 1, :with_subprojects => 0 |
|
144 | get :activity, :id => 1, :with_subprojects => 0 | |
151 | assert_response :success |
|
145 | assert_response :success | |
152 | assert_template 'activity' |
|
146 | assert_template 'activity' | |
153 | assert_not_nil assigns(:events_by_day) |
|
147 | assert_not_nil assigns(:events_by_day) | |
154 | assert_not_nil assigns(:events) |
|
148 | assert_not_nil assigns(:events) | |
155 |
|
149 | |||
156 | # subproject issue not included by default |
|
150 | # subproject issue not included by default | |
157 | assert !assigns(:events).include?(Issue.find(5)) |
|
151 | assert !assigns(:events).include?(Issue.find(5)) | |
158 |
|
152 | |||
159 | assert_tag :tag => "h3", |
|
153 | assert_tag :tag => "h3", | |
160 | :content => /#{2.days.ago.to_date.day}/, |
|
154 | :content => /#{2.days.ago.to_date.day}/, | |
161 | :sibling => { :tag => "dl", |
|
155 | :sibling => { :tag => "dl", | |
162 | :child => { :tag => "dt", |
|
156 | :child => { :tag => "dt", | |
163 | :attributes => { :class => 'issue-edit' }, |
|
157 | :attributes => { :class => 'issue-edit' }, | |
164 | :child => { :tag => "a", |
|
158 | :child => { :tag => "a", | |
165 | :content => /(#{IssueStatus.find(2).name})/, |
|
159 | :content => /(#{IssueStatus.find(2).name})/, | |
166 | } |
|
160 | } | |
167 | } |
|
161 | } | |
168 | } |
|
162 | } | |
169 |
|
163 | |||
170 | get :activity, :id => 1, :from => 3.days.ago.to_date |
|
164 | get :activity, :id => 1, :from => 3.days.ago.to_date | |
171 | assert_response :success |
|
165 | assert_response :success | |
172 | assert_template 'activity' |
|
166 | assert_template 'activity' | |
173 | assert_not_nil assigns(:events_by_day) |
|
167 | assert_not_nil assigns(:events_by_day) | |
174 |
|
168 | |||
175 | assert_tag :tag => "h3", |
|
169 | assert_tag :tag => "h3", | |
176 | :content => /#{3.day.ago.to_date.day}/, |
|
170 | :content => /#{3.day.ago.to_date.day}/, | |
177 | :sibling => { :tag => "dl", |
|
171 | :sibling => { :tag => "dl", | |
178 | :child => { :tag => "dt", |
|
172 | :child => { :tag => "dt", | |
179 | :attributes => { :class => 'issue' }, |
|
173 | :attributes => { :class => 'issue' }, | |
180 | :child => { :tag => "a", |
|
174 | :child => { :tag => "a", | |
181 | :content => /#{Issue.find(1).subject}/, |
|
175 | :content => /#{Issue.find(1).subject}/, | |
182 | } |
|
176 | } | |
183 | } |
|
177 | } | |
184 | } |
|
178 | } | |
185 | end |
|
179 | end | |
186 |
|
180 | |||
187 | def test_activity_with_subprojects |
|
181 | def test_activity_with_subprojects | |
188 | get :activity, :id => 1, :with_subprojects => 1 |
|
182 | get :activity, :id => 1, :with_subprojects => 1 | |
189 | assert_response :success |
|
183 | assert_response :success | |
190 | assert_template 'activity' |
|
184 | assert_template 'activity' | |
191 | assert_not_nil assigns(:events) |
|
185 | assert_not_nil assigns(:events) | |
192 |
|
186 | |||
193 | assert assigns(:events).include?(Issue.find(1)) |
|
187 | assert assigns(:events).include?(Issue.find(1)) | |
194 | assert !assigns(:events).include?(Issue.find(4)) |
|
188 | assert !assigns(:events).include?(Issue.find(4)) | |
195 | # subproject issue |
|
189 | # subproject issue | |
196 | assert assigns(:events).include?(Issue.find(5)) |
|
190 | assert assigns(:events).include?(Issue.find(5)) | |
197 | end |
|
191 | end | |
198 |
|
192 | |||
199 | def test_global_activity_anonymous |
|
193 | def test_global_activity_anonymous | |
200 | get :activity |
|
194 | get :activity | |
201 | assert_response :success |
|
195 | assert_response :success | |
202 | assert_template 'activity' |
|
196 | assert_template 'activity' | |
203 | assert_not_nil assigns(:events) |
|
197 | assert_not_nil assigns(:events) | |
204 |
|
198 | |||
205 | assert assigns(:events).include?(Issue.find(1)) |
|
199 | assert assigns(:events).include?(Issue.find(1)) | |
206 | # Issue of a private project |
|
200 | # Issue of a private project | |
207 | assert !assigns(:events).include?(Issue.find(4)) |
|
201 | assert !assigns(:events).include?(Issue.find(4)) | |
208 | end |
|
202 | end | |
209 |
|
203 | |||
210 | def test_global_activity_logged_user |
|
204 | def test_global_activity_logged_user | |
211 | @request.session[:user_id] = 2 # manager |
|
205 | @request.session[:user_id] = 2 # manager | |
212 | get :activity |
|
206 | get :activity | |
213 | assert_response :success |
|
207 | assert_response :success | |
214 | assert_template 'activity' |
|
208 | assert_template 'activity' | |
215 | assert_not_nil assigns(:events) |
|
209 | assert_not_nil assigns(:events) | |
216 |
|
210 | |||
217 | assert assigns(:events).include?(Issue.find(1)) |
|
211 | assert assigns(:events).include?(Issue.find(1)) | |
218 | # Issue of a private project the user belongs to |
|
212 | # Issue of a private project the user belongs to | |
219 | assert assigns(:events).include?(Issue.find(4)) |
|
213 | assert assigns(:events).include?(Issue.find(4)) | |
220 | end |
|
214 | end | |
221 |
|
215 | |||
222 |
|
216 | |||
223 | def test_global_activity_with_all_types |
|
217 | def test_global_activity_with_all_types | |
224 | get :activity, :show_issues => 1, :show_news => 1, :show_files => 1, :show_documents => 1, :show_changesets => 1, :show_wiki_pages => 1, :show_messages => 1 |
|
218 | get :activity, :show_issues => 1, :show_news => 1, :show_files => 1, :show_documents => 1, :show_changesets => 1, :show_wiki_pages => 1, :show_messages => 1 | |
225 | assert_response :success |
|
219 | assert_response :success | |
226 | assert_template 'activity' |
|
220 | assert_template 'activity' | |
227 | assert_not_nil assigns(:events) |
|
221 | assert_not_nil assigns(:events) | |
228 |
|
222 | |||
229 | assert assigns(:events).include?(Issue.find(1)) |
|
223 | assert assigns(:events).include?(Issue.find(1)) | |
230 | assert !assigns(:events).include?(Issue.find(4)) |
|
224 | assert !assigns(:events).include?(Issue.find(4)) | |
231 | assert assigns(:events).include?(Message.find(5)) |
|
225 | assert assigns(:events).include?(Message.find(5)) | |
232 | end |
|
226 | end | |
233 |
|
227 | |||
234 | def test_calendar |
|
228 | def test_calendar | |
235 | get :calendar, :id => 1 |
|
229 | get :calendar, :id => 1 | |
236 | assert_response :success |
|
230 | assert_response :success | |
237 | assert_template 'calendar' |
|
231 | assert_template 'calendar' | |
238 | assert_not_nil assigns(:calendar) |
|
232 | assert_not_nil assigns(:calendar) | |
239 | end |
|
233 | end | |
240 |
|
234 | |||
241 | def test_calendar_with_subprojects_should_not_show_private_subprojects |
|
235 | def test_calendar_with_subprojects_should_not_show_private_subprojects | |
242 | get :calendar, :id => 1, :with_subprojects => 1, :tracker_ids => [1, 2] |
|
236 | get :calendar, :id => 1, :with_subprojects => 1, :tracker_ids => [1, 2] | |
243 | assert_response :success |
|
237 | assert_response :success | |
244 | assert_template 'calendar' |
|
238 | assert_template 'calendar' | |
245 | assert_not_nil assigns(:calendar) |
|
239 | assert_not_nil assigns(:calendar) | |
246 | assert_no_tag :tag => 'a', :content => /#6/ |
|
240 | assert_no_tag :tag => 'a', :content => /#6/ | |
247 | end |
|
241 | end | |
248 |
|
242 | |||
249 | def test_calendar_with_subprojects_should_show_private_subprojects |
|
243 | def test_calendar_with_subprojects_should_show_private_subprojects | |
250 | @request.session[:user_id] = 2 |
|
244 | @request.session[:user_id] = 2 | |
251 | get :calendar, :id => 1, :with_subprojects => 1, :tracker_ids => [1, 2] |
|
245 | get :calendar, :id => 1, :with_subprojects => 1, :tracker_ids => [1, 2] | |
252 | assert_response :success |
|
246 | assert_response :success | |
253 | assert_template 'calendar' |
|
247 | assert_template 'calendar' | |
254 | assert_not_nil assigns(:calendar) |
|
248 | assert_not_nil assigns(:calendar) | |
255 | assert_tag :tag => 'a', :content => /#6/ |
|
249 | assert_tag :tag => 'a', :content => /#6/ | |
256 | end |
|
250 | end | |
257 |
|
251 | |||
258 | def test_gantt |
|
252 | def test_gantt | |
259 | get :gantt, :id => 1 |
|
253 | get :gantt, :id => 1 | |
260 | assert_response :success |
|
254 | assert_response :success | |
261 | assert_template 'gantt.rhtml' |
|
255 | assert_template 'gantt.rhtml' | |
262 | events = assigns(:events) |
|
256 | events = assigns(:events) | |
263 | assert_not_nil events |
|
257 | assert_not_nil events | |
264 | # Issue with start and due dates |
|
258 | # Issue with start and due dates | |
265 | i = Issue.find(1) |
|
259 | i = Issue.find(1) | |
266 | assert_not_nil i.due_date |
|
260 | assert_not_nil i.due_date | |
267 | assert events.include?(Issue.find(1)) |
|
261 | assert events.include?(Issue.find(1)) | |
268 | # Issue with without due date but targeted to a version with date |
|
262 | # Issue with without due date but targeted to a version with date | |
269 | i = Issue.find(2) |
|
263 | i = Issue.find(2) | |
270 | assert_nil i.due_date |
|
264 | assert_nil i.due_date | |
271 | assert events.include?(i) |
|
265 | assert events.include?(i) | |
272 | end |
|
266 | end | |
273 |
|
267 | |||
274 | def test_gantt_with_subprojects_should_not_show_private_subprojects |
|
268 | def test_gantt_with_subprojects_should_not_show_private_subprojects | |
275 | get :gantt, :id => 1, :with_subprojects => 1, :tracker_ids => [1, 2] |
|
269 | get :gantt, :id => 1, :with_subprojects => 1, :tracker_ids => [1, 2] | |
276 | assert_response :success |
|
270 | assert_response :success | |
277 | assert_template 'gantt.rhtml' |
|
271 | assert_template 'gantt.rhtml' | |
278 | assert_not_nil assigns(:events) |
|
272 | assert_not_nil assigns(:events) | |
279 | assert_no_tag :tag => 'a', :content => /#6/ |
|
273 | assert_no_tag :tag => 'a', :content => /#6/ | |
280 | end |
|
274 | end | |
281 |
|
275 | |||
282 | def test_gantt_with_subprojects_should_show_private_subprojects |
|
276 | def test_gantt_with_subprojects_should_show_private_subprojects | |
283 | @request.session[:user_id] = 2 |
|
277 | @request.session[:user_id] = 2 | |
284 | get :gantt, :id => 1, :with_subprojects => 1, :tracker_ids => [1, 2] |
|
278 | get :gantt, :id => 1, :with_subprojects => 1, :tracker_ids => [1, 2] | |
285 | assert_response :success |
|
279 | assert_response :success | |
286 | assert_template 'gantt.rhtml' |
|
280 | assert_template 'gantt.rhtml' | |
287 | assert_not_nil assigns(:events) |
|
281 | assert_not_nil assigns(:events) | |
288 | assert_tag :tag => 'a', :content => /#6/ |
|
282 | assert_tag :tag => 'a', :content => /#6/ | |
289 | end |
|
283 | end | |
290 |
|
284 | |||
291 | def test_gantt_export_to_pdf |
|
285 | def test_gantt_export_to_pdf | |
292 | get :gantt, :id => 1, :format => 'pdf' |
|
286 | get :gantt, :id => 1, :format => 'pdf' | |
293 | assert_response :success |
|
287 | assert_response :success | |
294 | assert_template 'gantt.rfpdf' |
|
288 | assert_template 'gantt.rfpdf' | |
295 | assert_equal 'application/pdf', @response.content_type |
|
289 | assert_equal 'application/pdf', @response.content_type | |
296 | assert_not_nil assigns(:events) |
|
290 | assert_not_nil assigns(:events) | |
297 | end |
|
291 | end | |
298 |
|
292 | |||
299 | def test_archive |
|
293 | def test_archive | |
300 | @request.session[:user_id] = 1 # admin |
|
294 | @request.session[:user_id] = 1 # admin | |
301 | post :archive, :id => 1 |
|
295 | post :archive, :id => 1 | |
302 | assert_redirected_to 'admin/projects' |
|
296 | assert_redirected_to 'admin/projects' | |
303 | assert !Project.find(1).active? |
|
297 | assert !Project.find(1).active? | |
304 | end |
|
298 | end | |
305 |
|
299 | |||
306 | def test_unarchive |
|
300 | def test_unarchive | |
307 | @request.session[:user_id] = 1 # admin |
|
301 | @request.session[:user_id] = 1 # admin | |
308 | Project.find(1).archive |
|
302 | Project.find(1).archive | |
309 | post :unarchive, :id => 1 |
|
303 | post :unarchive, :id => 1 | |
310 | assert_redirected_to 'admin/projects' |
|
304 | assert_redirected_to 'admin/projects' | |
311 | assert Project.find(1).active? |
|
305 | assert Project.find(1).active? | |
312 | end |
|
306 | end | |
313 | end |
|
307 | end |
General Comments 0
You need to be logged in to leave comments.
Login now