@@ -1,590 +1,592 | |||||
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 'csv' |
|
18 | require 'csv' | |
19 |
|
19 | |||
20 | class ProjectsController < ApplicationController |
|
20 | class ProjectsController < ApplicationController | |
21 | layout 'base' |
|
21 | layout 'base' | |
22 | before_filter :find_project, :authorize, :except => [ :index, :list, :add ] |
|
22 | before_filter :find_project, :authorize, :except => [ :index, :list, :add ] | |
23 | before_filter :require_admin, :only => [ :add, :destroy ] |
|
23 | before_filter :require_admin, :only => [ :add, :destroy ] | |
24 |
|
24 | |||
25 | helper :sort |
|
25 | helper :sort | |
26 | include SortHelper |
|
26 | include SortHelper | |
27 | helper :custom_fields |
|
27 | helper :custom_fields | |
28 | include CustomFieldsHelper |
|
28 | include CustomFieldsHelper | |
29 | helper :ifpdf |
|
29 | helper :ifpdf | |
30 | include IfpdfHelper |
|
30 | include IfpdfHelper | |
31 | helper IssuesHelper |
|
31 | helper IssuesHelper | |
32 | helper :queries |
|
32 | helper :queries | |
33 | include QueriesHelper |
|
33 | include QueriesHelper | |
34 |
|
34 | |||
35 | def index |
|
35 | def index | |
36 | list |
|
36 | list | |
37 | render :action => 'list' unless request.xhr? |
|
37 | render :action => 'list' unless request.xhr? | |
38 | end |
|
38 | end | |
39 |
|
39 | |||
40 | # Lists public projects |
|
40 | # Lists public projects | |
41 | def list |
|
41 | def list | |
42 | sort_init 'name', 'asc' |
|
42 | sort_init 'name', 'asc' | |
43 | sort_update |
|
43 | sort_update | |
44 | @project_count = Project.count(:all, :conditions => ["is_public=?", true]) |
|
44 | @project_count = Project.count(:all, :conditions => ["is_public=?", true]) | |
45 | @project_pages = Paginator.new self, @project_count, |
|
45 | @project_pages = Paginator.new self, @project_count, | |
46 | 15, |
|
46 | 15, | |
47 | params['page'] |
|
47 | params['page'] | |
48 | @projects = Project.find :all, :order => sort_clause, |
|
48 | @projects = Project.find :all, :order => sort_clause, | |
49 | :conditions => ["is_public=?", true], |
|
49 | :conditions => ["is_public=?", true], | |
50 | :limit => @project_pages.items_per_page, |
|
50 | :limit => @project_pages.items_per_page, | |
51 | :offset => @project_pages.current.offset |
|
51 | :offset => @project_pages.current.offset | |
52 |
|
52 | |||
53 | render :action => "list", :layout => false if request.xhr? |
|
53 | render :action => "list", :layout => false if request.xhr? | |
54 | end |
|
54 | end | |
55 |
|
55 | |||
56 | # Add a new project |
|
56 | # Add a new project | |
57 | def add |
|
57 | def add | |
58 | @custom_fields = IssueCustomField.find(:all) |
|
58 | @custom_fields = IssueCustomField.find(:all) | |
59 | @root_projects = Project.find(:all, :conditions => "parent_id is null") |
|
59 | @root_projects = Project.find(:all, :conditions => "parent_id is null") | |
60 | @project = Project.new(params[:project]) |
|
60 | @project = Project.new(params[:project]) | |
61 | if request.get? |
|
61 | if request.get? | |
62 | @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project) } |
|
62 | @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project) } | |
63 | else |
|
63 | else | |
64 | @project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids] |
|
64 | @project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids] | |
65 | @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) } |
|
65 | @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) } | |
66 | @project.custom_values = @custom_values |
|
66 | @project.custom_values = @custom_values | |
67 | if params[:repository_enabled] && params[:repository_enabled] == "1" |
|
67 | if params[:repository_enabled] && params[:repository_enabled] == "1" | |
68 | @project.repository = Repository.new |
|
68 | @project.repository = Repository.new | |
69 | @project.repository.attributes = params[:repository] |
|
69 | @project.repository.attributes = params[:repository] | |
70 | end |
|
70 | end | |
71 | if @project.save |
|
71 | if @project.save | |
72 | flash[:notice] = l(:notice_successful_create) |
|
72 | flash[:notice] = l(:notice_successful_create) | |
73 | redirect_to :controller => 'admin', :action => 'projects' |
|
73 | redirect_to :controller => 'admin', :action => 'projects' | |
74 | end |
|
74 | end | |
75 | end |
|
75 | end | |
76 | end |
|
76 | end | |
77 |
|
77 | |||
78 | # Show @project |
|
78 | # Show @project | |
79 | def show |
|
79 | def show | |
80 | @custom_values = @project.custom_values.find(:all, :include => :custom_field) |
|
80 | @custom_values = @project.custom_values.find(:all, :include => :custom_field) | |
81 | @members = @project.members.find(:all, :include => [:user, :role]) |
|
81 | @members = @project.members.find(:all, :include => [:user, :role]) | |
82 | @subprojects = @project.children if @project.children.size > 0 |
|
82 | @subprojects = @project.children if @project.children.size > 0 | |
83 | @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "news.created_on DESC") |
|
83 | @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "news.created_on DESC") | |
84 | @trackers = Tracker.find(:all, :order => 'position') |
|
84 | @trackers = Tracker.find(:all, :order => 'position') | |
85 | @open_issues_by_tracker = Issue.count(:group => :tracker, :joins => "INNER JOIN issue_statuses ON issue_statuses.id = issues.status_id", :conditions => ["project_id=? and issue_statuses.is_closed=?", @project.id, false]) |
|
85 | @open_issues_by_tracker = Issue.count(:group => :tracker, :joins => "INNER JOIN issue_statuses ON issue_statuses.id = issues.status_id", :conditions => ["project_id=? and issue_statuses.is_closed=?", @project.id, false]) | |
86 | @total_issues_by_tracker = Issue.count(:group => :tracker, :conditions => ["project_id=?", @project.id]) |
|
86 | @total_issues_by_tracker = Issue.count(:group => :tracker, :conditions => ["project_id=?", @project.id]) | |
87 | end |
|
87 | end | |
88 |
|
88 | |||
89 | def settings |
|
89 | def settings | |
90 | @root_projects = Project::find(:all, :conditions => ["parent_id is null and id <> ?", @project.id]) |
|
90 | @root_projects = Project::find(:all, :conditions => ["parent_id is null and id <> ?", @project.id]) | |
91 | @custom_fields = IssueCustomField.find(:all) |
|
91 | @custom_fields = IssueCustomField.find(:all) | |
92 | @issue_category ||= IssueCategory.new |
|
92 | @issue_category ||= IssueCategory.new | |
93 | @member ||= @project.members.new |
|
93 | @member ||= @project.members.new | |
94 | @roles = Role.find(:all, :order => 'position') |
|
94 | @roles = Role.find(:all, :order => 'position') | |
95 | @users = User.find_active(:all) - @project.users |
|
95 | @users = User.find_active(:all) - @project.users | |
96 | @custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) } |
|
96 | @custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) } | |
97 | end |
|
97 | end | |
98 |
|
98 | |||
99 | # Edit @project |
|
99 | # Edit @project | |
100 | def edit |
|
100 | def edit | |
101 | if request.post? |
|
101 | if request.post? | |
102 | @project.custom_fields = IssueCustomField.find(params[:custom_field_ids]) if params[:custom_field_ids] |
|
102 | @project.custom_fields = IssueCustomField.find(params[:custom_field_ids]) if params[:custom_field_ids] | |
103 | if params[:custom_fields] |
|
103 | if params[:custom_fields] | |
104 | @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) } |
|
104 | @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) } | |
105 | @project.custom_values = @custom_values |
|
105 | @project.custom_values = @custom_values | |
106 | end |
|
106 | end | |
107 | if params[:repository_enabled] |
|
107 | if params[:repository_enabled] | |
108 | case params[:repository_enabled] |
|
108 | case params[:repository_enabled] | |
109 | when "0" |
|
109 | when "0" | |
110 | @project.repository = nil |
|
110 | @project.repository = nil | |
111 | when "1" |
|
111 | when "1" | |
112 | @project.repository ||= Repository.new |
|
112 | @project.repository ||= Repository.new | |
113 | @project.repository.update_attributes params[:repository] |
|
113 | @project.repository.update_attributes params[:repository] | |
114 | end |
|
114 | end | |
115 | end |
|
115 | end | |
116 | @project.attributes = params[:project] |
|
116 | @project.attributes = params[:project] | |
117 | if @project.save |
|
117 | if @project.save | |
118 | flash[:notice] = l(:notice_successful_update) |
|
118 | flash[:notice] = l(:notice_successful_update) | |
119 | redirect_to :action => 'settings', :id => @project |
|
119 | redirect_to :action => 'settings', :id => @project | |
120 | else |
|
120 | else | |
121 | settings |
|
121 | settings | |
122 | render :action => 'settings' |
|
122 | render :action => 'settings' | |
123 | end |
|
123 | end | |
124 | end |
|
124 | end | |
125 | end |
|
125 | end | |
126 |
|
126 | |||
127 | # Delete @project |
|
127 | # Delete @project | |
128 | def destroy |
|
128 | def destroy | |
129 | if request.post? and params[:confirm] |
|
129 | if request.post? and params[:confirm] | |
130 | @project.destroy |
|
130 | @project.destroy | |
131 | redirect_to :controller => 'admin', :action => 'projects' |
|
131 | redirect_to :controller => 'admin', :action => 'projects' | |
132 | end |
|
132 | end | |
133 | end |
|
133 | end | |
134 |
|
134 | |||
135 | # Add a new issue category to @project |
|
135 | # Add a new issue category to @project | |
136 | def add_issue_category |
|
136 | def add_issue_category | |
137 | if request.post? |
|
137 | if request.post? | |
138 | @issue_category = @project.issue_categories.build(params[:issue_category]) |
|
138 | @issue_category = @project.issue_categories.build(params[:issue_category]) | |
139 | if @issue_category.save |
|
139 | if @issue_category.save | |
140 | flash[:notice] = l(:notice_successful_create) |
|
140 | flash[:notice] = l(:notice_successful_create) | |
141 | redirect_to :action => 'settings', :tab => 'categories', :id => @project |
|
141 | redirect_to :action => 'settings', :tab => 'categories', :id => @project | |
142 | else |
|
142 | else | |
143 | settings |
|
143 | settings | |
144 | render :action => 'settings' |
|
144 | render :action => 'settings' | |
145 | end |
|
145 | end | |
146 | end |
|
146 | end | |
147 | end |
|
147 | end | |
148 |
|
148 | |||
149 | # Add a new version to @project |
|
149 | # Add a new version to @project | |
150 | def add_version |
|
150 | def add_version | |
151 | @version = @project.versions.build(params[:version]) |
|
151 | @version = @project.versions.build(params[:version]) | |
152 | if request.post? and @version.save |
|
152 | if request.post? and @version.save | |
153 | flash[:notice] = l(:notice_successful_create) |
|
153 | flash[:notice] = l(:notice_successful_create) | |
154 | redirect_to :action => 'settings', :tab => 'versions', :id => @project |
|
154 | redirect_to :action => 'settings', :tab => 'versions', :id => @project | |
155 | end |
|
155 | end | |
156 | end |
|
156 | end | |
157 |
|
157 | |||
158 | # Add a new member to @project |
|
158 | # Add a new member to @project | |
159 | def add_member |
|
159 | def add_member | |
160 | @member = @project.members.build(params[:member]) |
|
160 | @member = @project.members.build(params[:member]) | |
161 | if request.post? |
|
161 | if request.post? | |
162 | if @member.save |
|
162 | if @member.save | |
163 | flash[:notice] = l(:notice_successful_create) |
|
163 | flash[:notice] = l(:notice_successful_create) | |
164 | redirect_to :action => 'settings', :tab => 'members', :id => @project |
|
164 | redirect_to :action => 'settings', :tab => 'members', :id => @project | |
165 | else |
|
165 | else | |
166 | settings |
|
166 | settings | |
167 | render :action => 'settings' |
|
167 | render :action => 'settings' | |
168 | end |
|
168 | end | |
169 | end |
|
169 | end | |
170 | end |
|
170 | end | |
171 |
|
171 | |||
172 | # Show members list of @project |
|
172 | # Show members list of @project | |
173 | def list_members |
|
173 | def list_members | |
174 | @members = @project.members.find(:all) |
|
174 | @members = @project.members.find(:all) | |
175 | end |
|
175 | end | |
176 |
|
176 | |||
177 | # Add a new document to @project |
|
177 | # Add a new document to @project | |
178 | def add_document |
|
178 | def add_document | |
179 | @categories = Enumeration::get_values('DCAT') |
|
179 | @categories = Enumeration::get_values('DCAT') | |
180 | @document = @project.documents.build(params[:document]) |
|
180 | @document = @project.documents.build(params[:document]) | |
181 | if request.post? and @document.save |
|
181 | if request.post? and @document.save | |
182 | # Save the attachments |
|
182 | # Save the attachments | |
183 | params[:attachments].each { |a| |
|
183 | params[:attachments].each { |a| | |
184 | Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0 |
|
184 | Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0 | |
185 | } if params[:attachments] and params[:attachments].is_a? Array |
|
185 | } if params[:attachments] and params[:attachments].is_a? Array | |
186 | flash[:notice] = l(:notice_successful_create) |
|
186 | flash[:notice] = l(:notice_successful_create) | |
187 | Mailer.deliver_document_add(@document) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? |
|
187 | Mailer.deliver_document_add(@document) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? | |
188 | redirect_to :action => 'list_documents', :id => @project |
|
188 | redirect_to :action => 'list_documents', :id => @project | |
189 | end |
|
189 | end | |
190 | end |
|
190 | end | |
191 |
|
191 | |||
192 | # Show documents list of @project |
|
192 | # Show documents list of @project | |
193 | def list_documents |
|
193 | def list_documents | |
194 | @documents = @project.documents.find :all, :include => :category |
|
194 | @documents = @project.documents.find :all, :include => :category | |
195 | end |
|
195 | end | |
196 |
|
196 | |||
197 | # Add a new issue to @project |
|
197 | # Add a new issue to @project | |
198 | def add_issue |
|
198 | def add_issue | |
199 | @tracker = Tracker.find(params[:tracker_id]) |
|
199 | @tracker = Tracker.find(params[:tracker_id]) | |
200 | @priorities = Enumeration::get_values('IPRI') |
|
200 | @priorities = Enumeration::get_values('IPRI') | |
201 | @issue = Issue.new(:project => @project, :tracker => @tracker) |
|
201 | @issue = Issue.new(:project => @project, :tracker => @tracker) | |
202 | if request.get? |
|
202 | if request.get? | |
203 | @issue.start_date = Date.today |
|
203 | @issue.start_date = Date.today | |
204 | @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) } |
|
204 | @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) } | |
205 | else |
|
205 | else | |
206 | @issue.attributes = params[:issue] |
|
206 | @issue.attributes = params[:issue] | |
207 | @issue.author_id = self.logged_in_user.id if self.logged_in_user |
|
207 | @issue.author_id = self.logged_in_user.id if self.logged_in_user | |
208 | # Multiple file upload |
|
208 | # Multiple file upload | |
209 | @attachments = [] |
|
209 | @attachments = [] | |
210 | params[:attachments].each { |a| |
|
210 | params[:attachments].each { |a| | |
211 | @attachments << Attachment.new(:container => @issue, :file => a, :author => logged_in_user) unless a.size == 0 |
|
211 | @attachments << Attachment.new(:container => @issue, :file => a, :author => logged_in_user) unless a.size == 0 | |
212 | } if params[:attachments] and params[:attachments].is_a? Array |
|
212 | } if params[:attachments] and params[:attachments].is_a? Array | |
213 | @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) } |
|
213 | @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) } | |
214 | @issue.custom_values = @custom_values |
|
214 | @issue.custom_values = @custom_values | |
215 | if @issue.save |
|
215 | if @issue.save | |
216 | @attachments.each(&:save) |
|
216 | @attachments.each(&:save) | |
217 | flash[:notice] = l(:notice_successful_create) |
|
217 | flash[:notice] = l(:notice_successful_create) | |
218 | Mailer.deliver_issue_add(@issue) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? |
|
218 | Mailer.deliver_issue_add(@issue) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? | |
219 | redirect_to :action => 'list_issues', :id => @project |
|
219 | redirect_to :action => 'list_issues', :id => @project | |
220 | end |
|
220 | end | |
221 | end |
|
221 | end | |
222 | end |
|
222 | end | |
223 |
|
223 | |||
224 | # Show filtered/sorted issues list of @project |
|
224 | # Show filtered/sorted issues list of @project | |
225 | def list_issues |
|
225 | def list_issues | |
226 | sort_init 'issues.id', 'desc' |
|
226 | sort_init 'issues.id', 'desc' | |
227 | sort_update |
|
227 | sort_update | |
228 |
|
228 | |||
229 | retrieve_query |
|
229 | retrieve_query | |
230 |
|
230 | |||
231 | @results_per_page_options = [ 15, 25, 50, 100 ] |
|
231 | @results_per_page_options = [ 15, 25, 50, 100 ] | |
232 | if params[:per_page] and @results_per_page_options.include? params[:per_page].to_i |
|
232 | if params[:per_page] and @results_per_page_options.include? params[:per_page].to_i | |
233 | @results_per_page = params[:per_page].to_i |
|
233 | @results_per_page = params[:per_page].to_i | |
234 | session[:results_per_page] = @results_per_page |
|
234 | session[:results_per_page] = @results_per_page | |
235 | else |
|
235 | else | |
236 | @results_per_page = session[:results_per_page] || 25 |
|
236 | @results_per_page = session[:results_per_page] || 25 | |
237 | end |
|
237 | end | |
238 |
|
238 | |||
239 | if @query.valid? |
|
239 | if @query.valid? | |
240 | @issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement) |
|
240 | @issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement) | |
241 | @issue_pages = Paginator.new self, @issue_count, @results_per_page, params['page'] |
|
241 | @issue_pages = Paginator.new self, @issue_count, @results_per_page, params['page'] | |
242 | @issues = Issue.find :all, :order => sort_clause, |
|
242 | @issues = Issue.find :all, :order => sort_clause, | |
243 | :include => [ :author, :status, :tracker, :project, :priority ], |
|
243 | :include => [ :author, :status, :tracker, :project, :priority ], | |
244 | :conditions => @query.statement, |
|
244 | :conditions => @query.statement, | |
245 | :limit => @issue_pages.items_per_page, |
|
245 | :limit => @issue_pages.items_per_page, | |
246 | :offset => @issue_pages.current.offset |
|
246 | :offset => @issue_pages.current.offset | |
247 | end |
|
247 | end | |
248 | @trackers = Tracker.find :all, :order => 'position' |
|
248 | @trackers = Tracker.find :all, :order => 'position' | |
249 | render :layout => false if request.xhr? |
|
249 | render :layout => false if request.xhr? | |
250 | end |
|
250 | end | |
251 |
|
251 | |||
252 | # Export filtered/sorted issues list to CSV |
|
252 | # Export filtered/sorted issues list to CSV | |
253 | def export_issues_csv |
|
253 | def export_issues_csv | |
254 | sort_init 'issues.id', 'desc' |
|
254 | sort_init 'issues.id', 'desc' | |
255 | sort_update |
|
255 | sort_update | |
256 |
|
256 | |||
257 | retrieve_query |
|
257 | retrieve_query | |
258 | render :action => 'list_issues' and return unless @query.valid? |
|
258 | render :action => 'list_issues' and return unless @query.valid? | |
259 |
|
259 | |||
260 | @issues = Issue.find :all, :order => sort_clause, |
|
260 | @issues = Issue.find :all, :order => sort_clause, | |
261 | :include => [ :author, :status, :tracker, :priority, {:custom_values => :custom_field} ], |
|
261 | :include => [ :author, :status, :tracker, :priority, {:custom_values => :custom_field} ], | |
262 | :conditions => @query.statement, |
|
262 | :conditions => @query.statement, | |
263 | :limit => Setting.issues_export_limit |
|
263 | :limit => Setting.issues_export_limit | |
264 |
|
264 | |||
265 | ic = Iconv.new('ISO-8859-1', 'UTF-8') |
|
265 | ic = Iconv.new('ISO-8859-1', 'UTF-8') | |
266 | export = StringIO.new |
|
266 | export = StringIO.new | |
267 | CSV::Writer.generate(export, l(:general_csv_separator)) do |csv| |
|
267 | CSV::Writer.generate(export, l(:general_csv_separator)) do |csv| | |
268 | # csv header fields |
|
268 | # csv header fields | |
269 | headers = [ "#", l(:field_status), |
|
269 | headers = [ "#", l(:field_status), | |
270 | l(:field_tracker), |
|
270 | l(:field_tracker), | |
271 | l(:field_priority), |
|
271 | l(:field_priority), | |
272 | l(:field_subject), |
|
272 | l(:field_subject), | |
273 | l(:field_author), |
|
273 | l(:field_author), | |
274 | l(:field_start_date), |
|
274 | l(:field_start_date), | |
275 | l(:field_due_date), |
|
275 | l(:field_due_date), | |
276 | l(:field_done_ratio), |
|
276 | l(:field_done_ratio), | |
277 | l(:field_created_on), |
|
277 | l(:field_created_on), | |
278 | l(:field_updated_on) |
|
278 | l(:field_updated_on) | |
279 | ] |
|
279 | ] | |
280 | for custom_field in @project.all_custom_fields |
|
280 | for custom_field in @project.all_custom_fields | |
281 | headers << custom_field.name |
|
281 | headers << custom_field.name | |
282 | end |
|
282 | end | |
283 | csv << headers.collect {|c| ic.iconv(c) } |
|
283 | csv << headers.collect {|c| ic.iconv(c) } | |
284 | # csv lines |
|
284 | # csv lines | |
285 | @issues.each do |issue| |
|
285 | @issues.each do |issue| | |
286 | fields = [issue.id, issue.status.name, |
|
286 | fields = [issue.id, issue.status.name, | |
287 | issue.tracker.name, |
|
287 | issue.tracker.name, | |
288 | issue.priority.name, |
|
288 | issue.priority.name, | |
289 | issue.subject, |
|
289 | issue.subject, | |
290 | issue.author.display_name, |
|
290 | issue.author.display_name, | |
291 | issue.start_date ? l_date(issue.start_date) : nil, |
|
291 | issue.start_date ? l_date(issue.start_date) : nil, | |
292 | issue.due_date ? l_date(issue.due_date) : nil, |
|
292 | issue.due_date ? l_date(issue.due_date) : nil, | |
293 | issue.done_ratio, |
|
293 | issue.done_ratio, | |
294 | l_datetime(issue.created_on), |
|
294 | l_datetime(issue.created_on), | |
295 | l_datetime(issue.updated_on) |
|
295 | l_datetime(issue.updated_on) | |
296 | ] |
|
296 | ] | |
297 | for custom_field in @project.all_custom_fields |
|
297 | for custom_field in @project.all_custom_fields | |
298 | fields << (show_value issue.custom_value_for(custom_field)) |
|
298 | fields << (show_value issue.custom_value_for(custom_field)) | |
299 | end |
|
299 | end | |
300 | csv << fields.collect {|c| ic.iconv(c.to_s) } |
|
300 | csv << fields.collect {|c| ic.iconv(c.to_s) } | |
301 | end |
|
301 | end | |
302 | end |
|
302 | end | |
303 | export.rewind |
|
303 | export.rewind | |
304 | send_data(export.read, :type => 'text/csv; header=present', :filename => 'export.csv') |
|
304 | send_data(export.read, :type => 'text/csv; header=present', :filename => 'export.csv') | |
305 | end |
|
305 | end | |
306 |
|
306 | |||
307 | # Export filtered/sorted issues to PDF |
|
307 | # Export filtered/sorted issues to PDF | |
308 | def export_issues_pdf |
|
308 | def export_issues_pdf | |
309 | sort_init 'issues.id', 'desc' |
|
309 | sort_init 'issues.id', 'desc' | |
310 | sort_update |
|
310 | sort_update | |
311 |
|
311 | |||
312 | retrieve_query |
|
312 | retrieve_query | |
313 | render :action => 'list_issues' and return unless @query.valid? |
|
313 | render :action => 'list_issues' and return unless @query.valid? | |
314 |
|
314 | |||
315 | @issues = Issue.find :all, :order => sort_clause, |
|
315 | @issues = Issue.find :all, :order => sort_clause, | |
316 | :include => [ :author, :status, :tracker, :priority ], |
|
316 | :include => [ :author, :status, :tracker, :priority ], | |
317 | :conditions => @query.statement, |
|
317 | :conditions => @query.statement, | |
318 | :limit => Setting.issues_export_limit |
|
318 | :limit => Setting.issues_export_limit | |
319 |
|
319 | |||
320 | @options_for_rfpdf ||= {} |
|
320 | @options_for_rfpdf ||= {} | |
321 | @options_for_rfpdf[:file_name] = "export.pdf" |
|
321 | @options_for_rfpdf[:file_name] = "export.pdf" | |
322 | render :layout => false |
|
322 | render :layout => false | |
323 | end |
|
323 | end | |
324 |
|
324 | |||
325 | def move_issues |
|
325 | def move_issues | |
326 | @issues = @project.issues.find(params[:issue_ids]) if params[:issue_ids] |
|
326 | @issues = @project.issues.find(params[:issue_ids]) if params[:issue_ids] | |
327 | redirect_to :action => 'list_issues', :id => @project and return unless @issues |
|
327 | redirect_to :action => 'list_issues', :id => @project and return unless @issues | |
328 | @projects = [] |
|
328 | @projects = [] | |
329 | # find projects to which the user is allowed to move the issue |
|
329 | # find projects to which the user is allowed to move the issue | |
330 | @logged_in_user.memberships.each {|m| @projects << m.project if Permission.allowed_to_role("projects/move_issues", m.role_id)} |
|
330 | @logged_in_user.memberships.each {|m| @projects << m.project if Permission.allowed_to_role("projects/move_issues", m.role_id)} | |
331 | # issue can be moved to any tracker |
|
331 | # issue can be moved to any tracker | |
332 | @trackers = Tracker.find(:all) |
|
332 | @trackers = Tracker.find(:all) | |
333 | if request.post? and params[:new_project_id] and params[:new_tracker_id] |
|
333 | if request.post? and params[:new_project_id] and params[:new_tracker_id] | |
334 | new_project = Project.find(params[:new_project_id]) |
|
334 | new_project = Project.find(params[:new_project_id]) | |
335 | new_tracker = Tracker.find(params[:new_tracker_id]) |
|
335 | new_tracker = Tracker.find(params[:new_tracker_id]) | |
336 | @issues.each { |i| |
|
336 | @issues.each { |i| | |
337 | # project dependent properties |
|
337 | # project dependent properties | |
338 | unless i.project_id == new_project.id |
|
338 | unless i.project_id == new_project.id | |
339 | i.category = nil |
|
339 | i.category = nil | |
340 | i.fixed_version = nil |
|
340 | i.fixed_version = nil | |
341 | end |
|
341 | end | |
342 | # move the issue |
|
342 | # move the issue | |
343 | i.project = new_project |
|
343 | i.project = new_project | |
344 | i.tracker = new_tracker |
|
344 | i.tracker = new_tracker | |
345 | i.save |
|
345 | i.save | |
346 | } |
|
346 | } | |
347 | flash[:notice] = l(:notice_successful_update) |
|
347 | flash[:notice] = l(:notice_successful_update) | |
348 | redirect_to :action => 'list_issues', :id => @project |
|
348 | redirect_to :action => 'list_issues', :id => @project | |
349 | end |
|
349 | end | |
350 | end |
|
350 | end | |
351 |
|
351 | |||
352 | def add_query |
|
352 | def add_query | |
353 | @query = Query.new(params[:query]) |
|
353 | @query = Query.new(params[:query]) | |
354 | @query.project = @project |
|
354 | @query.project = @project | |
355 | @query.user = logged_in_user |
|
355 | @query.user = logged_in_user | |
356 |
|
356 | |||
357 | params[:fields].each do |field| |
|
357 | params[:fields].each do |field| | |
358 | @query.add_filter(field, params[:operators][field], params[:values][field]) |
|
358 | @query.add_filter(field, params[:operators][field], params[:values][field]) | |
359 | end if params[:fields] |
|
359 | end if params[:fields] | |
360 |
|
360 | |||
361 | if request.post? and @query.save |
|
361 | if request.post? and @query.save | |
362 | flash[:notice] = l(:notice_successful_create) |
|
362 | flash[:notice] = l(:notice_successful_create) | |
363 | redirect_to :controller => 'reports', :action => 'issue_report', :id => @project |
|
363 | redirect_to :controller => 'reports', :action => 'issue_report', :id => @project | |
364 | end |
|
364 | end | |
365 | render :layout => false if request.xhr? |
|
365 | render :layout => false if request.xhr? | |
366 | end |
|
366 | end | |
367 |
|
367 | |||
368 | # Add a news to @project |
|
368 | # Add a news to @project | |
369 | def add_news |
|
369 | def add_news | |
370 | @news = News.new(:project => @project) |
|
370 | @news = News.new(:project => @project) | |
371 | if request.post? |
|
371 | if request.post? | |
372 | @news.attributes = params[:news] |
|
372 | @news.attributes = params[:news] | |
373 | @news.author_id = self.logged_in_user.id if self.logged_in_user |
|
373 | @news.author_id = self.logged_in_user.id if self.logged_in_user | |
374 | if @news.save |
|
374 | if @news.save | |
375 | flash[:notice] = l(:notice_successful_create) |
|
375 | flash[:notice] = l(:notice_successful_create) | |
376 | redirect_to :action => 'list_news', :id => @project |
|
376 | redirect_to :action => 'list_news', :id => @project | |
377 | end |
|
377 | end | |
378 | end |
|
378 | end | |
379 | end |
|
379 | end | |
380 |
|
380 | |||
381 | # Show news list of @project |
|
381 | # Show news list of @project | |
382 | def list_news |
|
382 | def list_news | |
383 | @news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "news.created_on DESC" |
|
383 | @news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "news.created_on DESC" | |
384 | render :action => "list_news", :layout => false if request.xhr? |
|
384 | render :action => "list_news", :layout => false if request.xhr? | |
385 | end |
|
385 | end | |
386 |
|
386 | |||
387 | def add_file |
|
387 | def add_file | |
388 | if request.post? |
|
388 | if request.post? | |
389 | @version = @project.versions.find_by_id(params[:version_id]) |
|
389 | @version = @project.versions.find_by_id(params[:version_id]) | |
390 | # Save the attachments |
|
390 | # Save the attachments | |
391 | @attachments = [] |
|
391 | @attachments = [] | |
392 | params[:attachments].each { |file| |
|
392 | params[:attachments].each { |file| | |
393 | next unless file.size > 0 |
|
393 | next unless file.size > 0 | |
394 | a = Attachment.create(:container => @version, :file => file, :author => logged_in_user) |
|
394 | a = Attachment.create(:container => @version, :file => file, :author => logged_in_user) | |
395 | @attachments << a unless a.new_record? |
|
395 | @attachments << a unless a.new_record? | |
396 | } if params[:attachments] and params[:attachments].is_a? Array |
|
396 | } if params[:attachments] and params[:attachments].is_a? Array | |
397 | Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? |
|
397 | Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? | |
398 | redirect_to :controller => 'projects', :action => 'list_files', :id => @project |
|
398 | redirect_to :controller => 'projects', :action => 'list_files', :id => @project | |
399 | end |
|
399 | end | |
400 | @versions = @project.versions |
|
400 | @versions = @project.versions | |
401 | end |
|
401 | end | |
402 |
|
402 | |||
403 | def list_files |
|
403 | def list_files | |
404 | @versions = @project.versions |
|
404 | @versions = @project.versions | |
405 | end |
|
405 | end | |
406 |
|
406 | |||
407 | # Show changelog for @project |
|
407 | # Show changelog for @project | |
408 | def changelog |
|
408 | def changelog | |
409 | @trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position') |
|
409 | @trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position') | |
410 | if request.get? |
|
410 | if request.get? | |
411 | @selected_tracker_ids = @trackers.collect {|t| t.id.to_s } |
|
411 | @selected_tracker_ids = @trackers.collect {|t| t.id.to_s } | |
412 | else |
|
412 | else | |
413 | @selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array |
|
413 | @selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array | |
414 | end |
|
414 | end | |
415 | @selected_tracker_ids ||= [] |
|
415 | @selected_tracker_ids ||= [] | |
416 | @fixed_issues = @project.issues.find(:all, |
|
416 | @fixed_issues = @project.issues.find(:all, | |
417 | :include => [ :fixed_version, :status, :tracker ], |
|
417 | :include => [ :fixed_version, :status, :tracker ], | |
418 | :conditions => [ "issue_statuses.is_closed=? and issues.tracker_id in (#{@selected_tracker_ids.join(',')}) and issues.fixed_version_id is not null", true], |
|
418 | :conditions => [ "issue_statuses.is_closed=? and issues.tracker_id in (#{@selected_tracker_ids.join(',')}) and issues.fixed_version_id is not null", true], | |
419 | :order => "versions.effective_date DESC, issues.id DESC" |
|
419 | :order => "versions.effective_date DESC, issues.id DESC" | |
420 | ) unless @selected_tracker_ids.empty? |
|
420 | ) unless @selected_tracker_ids.empty? | |
421 | @fixed_issues ||= [] |
|
421 | @fixed_issues ||= [] | |
422 | end |
|
422 | end | |
423 |
|
423 | |||
424 | def roadmap |
|
424 | def roadmap | |
425 | @trackers = Tracker.find(:all, :conditions => ["is_in_roadmap=?", true], :order => 'position') |
|
425 | @trackers = Tracker.find(:all, :conditions => ["is_in_roadmap=?", true], :order => 'position') | |
426 | if request.get? |
|
426 | if request.get? | |
427 | @selected_tracker_ids = @trackers.collect {|t| t.id.to_s } |
|
427 | @selected_tracker_ids = @trackers.collect {|t| t.id.to_s } | |
428 | else |
|
428 | else | |
429 | @selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array |
|
429 | @selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array | |
430 | end |
|
430 | end | |
431 | @selected_tracker_ids ||= [] |
|
431 | @selected_tracker_ids ||= [] | |
432 | @versions = @project.versions.find(:all, |
|
432 | @versions = @project.versions.find(:all, | |
433 | :conditions => [ "versions.effective_date>?", Date.today], |
|
433 | :conditions => [ "versions.effective_date>?", Date.today], | |
434 | :order => "versions.effective_date ASC" |
|
434 | :order => "versions.effective_date ASC" | |
435 | ) |
|
435 | ) | |
436 | end |
|
436 | end | |
437 |
|
437 | |||
438 | def activity |
|
438 | def activity | |
439 | if params[:year] and params[:year].to_i > 1900 |
|
439 | if params[:year] and params[:year].to_i > 1900 | |
440 | @year = params[:year].to_i |
|
440 | @year = params[:year].to_i | |
441 | if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13 |
|
441 | if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13 | |
442 | @month = params[:month].to_i |
|
442 | @month = params[:month].to_i | |
443 | end |
|
443 | end | |
444 | end |
|
444 | end | |
445 | @year ||= Date.today.year |
|
445 | @year ||= Date.today.year | |
446 | @month ||= Date.today.month |
|
446 | @month ||= Date.today.month | |
447 |
|
447 | |||
448 | @date_from = Date.civil(@year, @month, 1) |
|
448 | @date_from = Date.civil(@year, @month, 1) | |
449 | @date_to = (@date_from >> 1)-1 |
|
449 | @date_to = (@date_from >> 1)-1 | |
450 |
|
450 | |||
451 | @events_by_day = {} |
|
451 | @events_by_day = {} | |
452 |
|
452 | |||
453 | unless params[:show_issues] == "0" |
|
453 | unless params[:show_issues] == "0" | |
454 | @project.issues.find(:all, :include => [:author, :status], :conditions => ["issues.created_on>=? and issues.created_on<=?", @date_from, @date_to] ).each { |i| |
|
454 | @project.issues.find(:all, :include => [:author, :status], :conditions => ["issues.created_on>=? and issues.created_on<=?", @date_from, @date_to] ).each { |i| | |
455 | @events_by_day[i.created_on.to_date] ||= [] |
|
455 | @events_by_day[i.created_on.to_date] ||= [] | |
456 | @events_by_day[i.created_on.to_date] << i |
|
456 | @events_by_day[i.created_on.to_date] << i | |
457 | } |
|
457 | } | |
458 | @show_issues = 1 |
|
458 | @show_issues = 1 | |
459 | end |
|
459 | end | |
460 |
|
460 | |||
461 | unless params[:show_news] == "0" |
|
461 | unless params[:show_news] == "0" | |
462 | @project.news.find(:all, :conditions => ["news.created_on>=? and news.created_on<=?", @date_from, @date_to], :include => :author ).each { |i| |
|
462 | @project.news.find(:all, :conditions => ["news.created_on>=? and news.created_on<=?", @date_from, @date_to], :include => :author ).each { |i| | |
463 | @events_by_day[i.created_on.to_date] ||= [] |
|
463 | @events_by_day[i.created_on.to_date] ||= [] | |
464 | @events_by_day[i.created_on.to_date] << i |
|
464 | @events_by_day[i.created_on.to_date] << i | |
465 | } |
|
465 | } | |
466 | @show_news = 1 |
|
466 | @show_news = 1 | |
467 | end |
|
467 | end | |
468 |
|
468 | |||
469 | unless params[:show_files] == "0" |
|
469 | unless params[:show_files] == "0" | |
470 | Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN versions ON versions.id = attachments.container_id", :conditions => ["attachments.container_type='Version' and versions.project_id=? and attachments.created_on>=? and attachments.created_on<=?", @project.id, @date_from, @date_to], :include => :author ).each { |i| |
|
470 | Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN versions ON versions.id = attachments.container_id", :conditions => ["attachments.container_type='Version' and versions.project_id=? and attachments.created_on>=? and attachments.created_on<=?", @project.id, @date_from, @date_to], :include => :author ).each { |i| | |
471 | @events_by_day[i.created_on.to_date] ||= [] |
|
471 | @events_by_day[i.created_on.to_date] ||= [] | |
472 | @events_by_day[i.created_on.to_date] << i |
|
472 | @events_by_day[i.created_on.to_date] << i | |
473 | } |
|
473 | } | |
474 | @show_files = 1 |
|
474 | @show_files = 1 | |
475 | end |
|
475 | end | |
476 |
|
476 | |||
477 | unless params[:show_documents] == "0" |
|
477 | unless params[:show_documents] == "0" | |
478 | @project.documents.find(:all, :conditions => ["documents.created_on>=? and documents.created_on<=?", @date_from, @date_to] ).each { |i| |
|
478 | @project.documents.find(:all, :conditions => ["documents.created_on>=? and documents.created_on<=?", @date_from, @date_to] ).each { |i| | |
479 | @events_by_day[i.created_on.to_date] ||= [] |
|
479 | @events_by_day[i.created_on.to_date] ||= [] | |
480 | @events_by_day[i.created_on.to_date] << i |
|
480 | @events_by_day[i.created_on.to_date] << i | |
481 | } |
|
481 | } | |
482 | Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN documents ON documents.id = attachments.container_id", :conditions => ["attachments.container_type='Document' and documents.project_id=? and attachments.created_on>=? and attachments.created_on<=?", @project.id, @date_from, @date_to], :include => :author ).each { |i| |
|
482 | Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN documents ON documents.id = attachments.container_id", :conditions => ["attachments.container_type='Document' and documents.project_id=? and attachments.created_on>=? and attachments.created_on<=?", @project.id, @date_from, @date_to], :include => :author ).each { |i| | |
483 | @events_by_day[i.created_on.to_date] ||= [] |
|
483 | @events_by_day[i.created_on.to_date] ||= [] | |
484 | @events_by_day[i.created_on.to_date] << i |
|
484 | @events_by_day[i.created_on.to_date] << i | |
485 | } |
|
485 | } | |
486 | @show_documents = 1 |
|
486 | @show_documents = 1 | |
487 | end |
|
487 | end | |
488 |
|
488 | |||
489 | render :layout => false if request.xhr? |
|
489 | render :layout => false if request.xhr? | |
490 | end |
|
490 | end | |
491 |
|
491 | |||
492 | def calendar |
|
492 | def calendar | |
493 | if params[:year] and params[:year].to_i > 1900 |
|
493 | if params[:year] and params[:year].to_i > 1900 | |
494 | @year = params[:year].to_i |
|
494 | @year = params[:year].to_i | |
495 | if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13 |
|
495 | if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13 | |
496 | @month = params[:month].to_i |
|
496 | @month = params[:month].to_i | |
497 | end |
|
497 | end | |
498 | end |
|
498 | end | |
499 | @year ||= Date.today.year |
|
499 | @year ||= Date.today.year | |
500 | @month ||= Date.today.month |
|
500 | @month ||= Date.today.month | |
501 |
|
501 | |||
502 | @date_from = Date.civil(@year, @month, 1) |
|
502 | @date_from = Date.civil(@year, @month, 1) | |
503 | @date_to = (@date_from >> 1)-1 |
|
503 | @date_to = (@date_from >> 1)-1 | |
504 | # start on monday |
|
504 | # start on monday | |
505 | @date_from = @date_from - (@date_from.cwday-1) |
|
505 | @date_from = @date_from - (@date_from.cwday-1) | |
506 | # finish on sunday |
|
506 | # finish on sunday | |
507 | @date_to = @date_to + (7-@date_to.cwday) |
|
507 | @date_to = @date_to + (7-@date_to.cwday) | |
508 |
|
508 | |||
509 | @issues = @project.issues.find(:all, :include => [:tracker, :status, :assigned_to, :priority], :conditions => ["((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?))", @date_from, @date_to, @date_from, @date_to]) |
|
509 | @issues = @project.issues.find(:all, :include => [:tracker, :status, :assigned_to, :priority], :conditions => ["((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?))", @date_from, @date_to, @date_from, @date_to]) | |
510 | render :layout => false if request.xhr? |
|
510 | render :layout => false if request.xhr? | |
511 | end |
|
511 | end | |
512 |
|
512 | |||
513 | def gantt |
|
513 | def gantt | |
514 | if params[:year] and params[:year].to_i >0 |
|
514 | if params[:year] and params[:year].to_i >0 | |
515 | @year_from = params[:year].to_i |
|
515 | @year_from = params[:year].to_i | |
516 | if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12 |
|
516 | if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12 | |
517 | @month_from = params[:month].to_i |
|
517 | @month_from = params[:month].to_i | |
518 | else |
|
518 | else | |
519 | @month_from = 1 |
|
519 | @month_from = 1 | |
520 | end |
|
520 | end | |
521 | else |
|
521 | else | |
522 | @month_from ||= (Date.today << 1).month |
|
522 | @month_from ||= (Date.today << 1).month | |
523 | @year_from ||= (Date.today << 1).year |
|
523 | @year_from ||= (Date.today << 1).year | |
524 | end |
|
524 | end | |
525 |
|
525 | |||
526 | @zoom = (params[:zoom].to_i > 0 and params[:zoom].to_i < 5) ? params[:zoom].to_i : 2 |
|
526 | @zoom = (params[:zoom].to_i > 0 and params[:zoom].to_i < 5) ? params[:zoom].to_i : 2 | |
527 | @months = (params[:months].to_i > 0 and params[:months].to_i < 25) ? params[:months].to_i : 6 |
|
527 | @months = (params[:months].to_i > 0 and params[:months].to_i < 25) ? params[:months].to_i : 6 | |
528 |
|
528 | |||
529 | @date_from = Date.civil(@year_from, @month_from, 1) |
|
529 | @date_from = Date.civil(@year_from, @month_from, 1) | |
530 | @date_to = (@date_from >> @months) - 1 |
|
530 | @date_to = (@date_from >> @months) - 1 | |
531 | @issues = @project.issues.find(:all, :order => "start_date, due_date", :include => [:tracker, :status, :assigned_to, :priority], :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)", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to]) |
|
531 | @issues = @project.issues.find(:all, :order => "start_date, due_date", :include => [:tracker, :status, :assigned_to, :priority], :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)", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to]) | |
532 |
|
532 | |||
533 | if params[:output]=='pdf' |
|
533 | if params[:output]=='pdf' | |
534 | @options_for_rfpdf ||= {} |
|
534 | @options_for_rfpdf ||= {} | |
535 | @options_for_rfpdf[:file_name] = "gantt.pdf" |
|
535 | @options_for_rfpdf[:file_name] = "gantt.pdf" | |
536 | render :template => "projects/gantt.rfpdf", :layout => false |
|
536 | render :template => "projects/gantt.rfpdf", :layout => false | |
537 | else |
|
537 | else | |
538 | render :template => "projects/gantt.rhtml" |
|
538 | render :template => "projects/gantt.rhtml" | |
539 | end |
|
539 | end | |
540 | end |
|
540 | end | |
541 |
|
541 | |||
542 | def search |
|
542 | def search | |
543 | @token = params[:token] |
|
543 | @token = params[:token] | |
544 | @scope = params[:scope] || (params[:submit] ? [] : %w(issues news documents) ) |
|
544 | @scope = params[:scope] || (params[:submit] ? [] : %w(issues news documents) ) | |
545 |
|
545 | |||
546 | if @token and @token.length > 2 |
|
546 | if @token and @token.length > 2 | |
|
547 | @token.strip! | |||
|
548 | like_token = "%#{@token}%" | |||
547 | @results = [] |
|
549 | @results = [] | |
548 |
@results += @project.issues.find(:all, :include => :author, :conditions => ["issues.subject like ?", |
|
550 | @results += @project.issues.find(:all, :include => :author, :conditions => ["issues.subject like ? or issues.description like ?", like_token, like_token] ) if @scope.include? 'issues' | |
549 |
@results += @project.news.find(:all, :conditions => ["news.title like ?", |
|
551 | @results += @project.news.find(:all, :conditions => ["news.title like ? or news.description like ?", like_token, like_token], :include => :author ) if @scope.include? 'news' | |
550 |
@results += @project.documents.find(:all, :conditions => ["title like ?", |
|
552 | @results += @project.documents.find(:all, :conditions => ["title like ? or description like ?", like_token, like_token] ) if @scope.include? 'documents' | |
551 | end |
|
553 | end | |
552 | end |
|
554 | end | |
553 |
|
555 | |||
554 | private |
|
556 | private | |
555 | # Find project of id params[:id] |
|
557 | # Find project of id params[:id] | |
556 | # if not found, redirect to project list |
|
558 | # if not found, redirect to project list | |
557 | # Used as a before_filter |
|
559 | # Used as a before_filter | |
558 | def find_project |
|
560 | def find_project | |
559 | @project = Project.find(params[:id]) |
|
561 | @project = Project.find(params[:id]) | |
560 | @html_title = @project.name |
|
562 | @html_title = @project.name | |
561 | rescue ActiveRecord::RecordNotFound |
|
563 | rescue ActiveRecord::RecordNotFound | |
562 | render_404 |
|
564 | render_404 | |
563 | end |
|
565 | end | |
564 |
|
566 | |||
565 | # Retrieve query from session or build a new query |
|
567 | # Retrieve query from session or build a new query | |
566 | def retrieve_query |
|
568 | def retrieve_query | |
567 | if params[:query_id] |
|
569 | if params[:query_id] | |
568 | @query = @project.queries.find(params[:query_id]) |
|
570 | @query = @project.queries.find(params[:query_id]) | |
569 | session[:query] = @query |
|
571 | session[:query] = @query | |
570 | else |
|
572 | else | |
571 | if params[:set_filter] or !session[:query] or session[:query].project_id != @project.id |
|
573 | if params[:set_filter] or !session[:query] or session[:query].project_id != @project.id | |
572 | # Give it a name, required to be valid |
|
574 | # Give it a name, required to be valid | |
573 | @query = Query.new(:name => "_") |
|
575 | @query = Query.new(:name => "_") | |
574 | @query.project = @project |
|
576 | @query.project = @project | |
575 | if params[:fields] and params[:fields].is_a? Array |
|
577 | if params[:fields] and params[:fields].is_a? Array | |
576 | params[:fields].each do |field| |
|
578 | params[:fields].each do |field| | |
577 | @query.add_filter(field, params[:operators][field], params[:values][field]) |
|
579 | @query.add_filter(field, params[:operators][field], params[:values][field]) | |
578 | end |
|
580 | end | |
579 | else |
|
581 | else | |
580 | @query.available_filters.keys.each do |field| |
|
582 | @query.available_filters.keys.each do |field| | |
581 | @query.add_short_filter(field, params[field]) if params[field] |
|
583 | @query.add_short_filter(field, params[field]) if params[field] | |
582 | end |
|
584 | end | |
583 | end |
|
585 | end | |
584 | session[:query] = @query |
|
586 | session[:query] = @query | |
585 | else |
|
587 | else | |
586 | @query = session[:query] |
|
588 | @query = session[:query] | |
587 | end |
|
589 | end | |
588 | end |
|
590 | end | |
589 | end |
|
591 | end | |
590 | end |
|
592 | end |
@@ -1,19 +1,23 | |||||
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 | module ProjectsHelper |
|
18 | module ProjectsHelper | |
|
19 | def result_overview(text, token) | |||
|
20 | match = excerpt(text, token) | |||
|
21 | match ? highlight(match, token) : truncate(text, 150) | |||
|
22 | end | |||
19 | end |
|
23 | end |
@@ -1,32 +1,34 | |||||
1 | <h2><%= l(:label_search) %></h2> |
|
1 | <h2><%= l(:label_search) %></h2> | |
2 |
|
2 | |||
3 | <div class="box"> |
|
3 | <div class="box"> | |
4 | <% form_tag({:action => 'search', :id => @project}, :method => :get) do %> |
|
4 | <% form_tag({:action => 'search', :id => @project}, :method => :get) do %> | |
5 | <p><%= text_field_tag 'token', @token, :size => 30 %> |
|
5 | <p><%= text_field_tag 'token', @token, :size => 30 %> | |
6 | <%= check_box_tag 'scope[]', 'issues', (@scope.include? 'issues') %> <label><%= l(:label_issue_plural) %></label> |
|
6 | <%= check_box_tag 'scope[]', 'issues', (@scope.include? 'issues') %> <label><%= l(:label_issue_plural) %></label> | |
7 | <%= check_box_tag 'scope[]', 'news', (@scope.include? 'news') %> <label><%= l(:label_news_plural) %></label> |
|
7 | <%= check_box_tag 'scope[]', 'news', (@scope.include? 'news') %> <label><%= l(:label_news_plural) %></label> | |
8 | <%= check_box_tag 'scope[]', 'documents', (@scope.include? 'documents') %> <label><%= l(:label_document_plural) %></label></p> |
|
8 | <%= check_box_tag 'scope[]', 'documents', (@scope.include? 'documents') %> <label><%= l(:label_document_plural) %></label></p> | |
9 | <%= submit_tag l(:button_submit), :name => 'submit' %> |
|
9 | <%= submit_tag l(:button_submit), :name => 'submit' %> | |
10 | <% end %> |
|
10 | <% end %> | |
11 | </div> |
|
11 | </div> | |
12 |
|
12 | |||
13 | <% if @results %> |
|
13 | <% if @results %> | |
14 | <h3><%= lwr(:label_result, @results.length) %></h3> |
|
14 | <h3><%= lwr(:label_result, @results.length) %></h3> | |
15 | <ul> |
|
15 | <ul> | |
16 | <% @results.each do |e| %> |
|
16 | <% @results.each do |e| %> | |
17 | <li><p> |
|
17 | <li><p> | |
18 | <% if e.is_a? Issue %> |
|
18 | <% if e.is_a? Issue %> | |
19 | <%= link_to "#{e.tracker.name} ##{e.id}", :controller => 'issues', :action => 'show', :id => e %>: <%= highlight(h(e.subject), @token) %><br /> |
|
19 | <%= link_to "#{e.tracker.name} ##{e.id}", :controller => 'issues', :action => 'show', :id => e %>: <%= highlight(h(e.subject), @token) %><br /> | |
20 | <i><%= e.author.name %>, <%= format_time(e.created_on) %></i> |
|
20 | <%= result_overview(e.description, @token) %><br /> | |
|
21 | <i><%= e.author.name %>, <%= format_time(e.created_on) %></i> | |||
21 | <% elsif e.is_a? News %> |
|
22 | <% elsif e.is_a? News %> | |
22 | <%=l(:label_news)%>: <%= link_to highlight(h(e.title), @token), :controller => 'news', :action => 'show', :id => e %><br /> |
|
23 | <%=l(:label_news)%>: <%= link_to highlight(h(e.title), @token), :controller => 'news', :action => 'show', :id => e %><br /> | |
23 | <% unless e.summary.empty? %><%=h e.summary %><br /><% end %> |
|
24 | <%= result_overview(e.description, @token) %><br /> | |
24 |
|
|
25 | <i><%= e.author.name %>, <%= format_time(e.created_on) %></i> | |
25 | <% elsif e.is_a? Document %> |
|
26 | <% elsif e.is_a? Document %> | |
26 | <%=l(:label_document)%>: <%= link_to highlight(h(e.title), @token), :controller => 'documents', :action => 'show', :id => e %><br /> |
|
27 | <%=l(:label_document)%>: <%= link_to highlight(h(e.title), @token), :controller => 'documents', :action => 'show', :id => e %><br /> | |
27 |
|
|
28 | <%= result_overview(e.description, @token) %><br /> | |
|
29 | <i><%= format_time(e.created_on) %></i> | |||
28 | <% end %> |
|
30 | <% end %> | |
29 | </p></li> |
|
31 | </p></li> | |
30 | <% end %> |
|
32 | <% end %> | |
31 | </ul> |
|
33 | </ul> | |
32 | <% end %> No newline at end of file |
|
34 | <% end %> |
@@ -1,379 +1,541 | |||||
1 | --- |
|
1 | --- | |
|
2 | permissions_052: | |||
|
3 | action: destroy_comment | |||
|
4 | id: 52 | |||
|
5 | description: label_comment_delete | |||
|
6 | controller: news | |||
|
7 | mail_enabled: false | |||
|
8 | mail_option: false | |||
|
9 | sort: 1133 | |||
|
10 | is_public: false | |||
2 | permissions_041: |
|
11 | permissions_041: | |
3 | action: add_file |
|
12 | action: add_file | |
4 | id: 41 |
|
13 | id: 41 | |
5 | description: button_add |
|
14 | description: button_add | |
6 | controller: projects |
|
15 | controller: projects | |
7 | mail_enabled: false |
|
16 | mail_enabled: false | |
8 |
mail_option: |
|
17 | mail_option: true | |
9 | sort: 1320 |
|
18 | sort: 1320 | |
10 | is_public: false |
|
19 | is_public: false | |
11 | permissions_030: |
|
20 | permissions_030: | |
12 | action: destroy |
|
21 | action: destroy | |
13 | id: 30 |
|
22 | id: 30 | |
14 | description: button_delete |
|
23 | description: button_delete | |
15 | controller: news |
|
24 | controller: news | |
16 | mail_enabled: false |
|
25 | mail_enabled: false | |
17 | mail_option: false |
|
26 | mail_option: false | |
18 | sort: 1122 |
|
27 | sort: 1122 | |
19 | is_public: false |
|
28 | is_public: false | |
20 | permissions_019: |
|
29 | permissions_019: | |
21 | action: download |
|
30 | action: download | |
22 | id: 19 |
|
31 | id: 19 | |
23 | description: button_download |
|
32 | description: button_download | |
24 | controller: issues |
|
33 | controller: issues | |
25 | mail_enabled: false |
|
34 | mail_enabled: false | |
26 | mail_option: false |
|
35 | mail_option: false | |
27 | sort: 1010 |
|
36 | sort: 1010 | |
28 | is_public: true |
|
37 | is_public: true | |
29 | permissions_008: |
|
38 | permissions_008: | |
30 | action: edit |
|
39 | action: edit | |
31 | id: 8 |
|
40 | id: 8 | |
32 | description: button_edit |
|
41 | description: button_edit | |
33 | controller: members |
|
42 | controller: members | |
34 | mail_enabled: false |
|
43 | mail_enabled: false | |
35 | mail_option: false |
|
44 | mail_option: false | |
36 | sort: 221 |
|
45 | sort: 221 | |
37 | is_public: false |
|
46 | is_public: false | |
|
47 | permissions_053: | |||
|
48 | action: add_query | |||
|
49 | id: 53 | |||
|
50 | description: button_create | |||
|
51 | controller: projects | |||
|
52 | mail_enabled: false | |||
|
53 | mail_option: false | |||
|
54 | sort: 600 | |||
|
55 | is_public: false | |||
38 | permissions_042: |
|
56 | permissions_042: | |
39 | action: destroy_file |
|
57 | action: destroy_file | |
40 | id: 42 |
|
58 | id: 42 | |
41 | description: button_delete |
|
59 | description: button_delete | |
42 | controller: versions |
|
60 | controller: versions | |
43 | mail_enabled: false |
|
61 | mail_enabled: false | |
44 | mail_option: false |
|
62 | mail_option: false | |
45 | sort: 1322 |
|
63 | sort: 1322 | |
46 | is_public: false |
|
64 | is_public: false | |
47 | permissions_031: |
|
65 | permissions_031: | |
48 | action: list_documents |
|
66 | action: list_documents | |
49 | id: 31 |
|
67 | id: 31 | |
50 | description: button_list |
|
68 | description: button_list | |
51 | controller: projects |
|
69 | controller: projects | |
52 | mail_enabled: false |
|
70 | mail_enabled: false | |
53 | mail_option: false |
|
71 | mail_option: false | |
54 | sort: 1200 |
|
72 | sort: 1200 | |
55 | is_public: true |
|
73 | is_public: true | |
56 | permissions_020: |
|
74 | permissions_020: | |
57 | action: add_issue |
|
75 | action: add_issue | |
58 | id: 20 |
|
76 | id: 20 | |
59 | description: button_add |
|
77 | description: button_add | |
60 | controller: projects |
|
78 | controller: projects | |
61 | mail_enabled: true |
|
79 | mail_enabled: true | |
62 | mail_option: true |
|
80 | mail_option: true | |
63 | sort: 1050 |
|
81 | sort: 1050 | |
64 | is_public: false |
|
82 | is_public: false | |
65 | permissions_009: |
|
83 | permissions_009: | |
66 | action: destroy |
|
84 | action: destroy | |
67 | id: 9 |
|
85 | id: 9 | |
68 | description: button_delete |
|
86 | description: button_delete | |
69 | controller: members |
|
87 | controller: members | |
70 | mail_enabled: false |
|
88 | mail_enabled: false | |
71 | mail_option: false |
|
89 | mail_option: false | |
72 | sort: 222 |
|
90 | sort: 222 | |
73 | is_public: false |
|
91 | is_public: false | |
|
92 | permissions_054: | |||
|
93 | action: show | |||
|
94 | id: 54 | |||
|
95 | description: button_view | |||
|
96 | controller: repositories | |||
|
97 | mail_enabled: false | |||
|
98 | mail_option: false | |||
|
99 | sort: 1450 | |||
|
100 | is_public: true | |||
|
101 | permissions_043: | |||
|
102 | action: move_issues | |||
|
103 | id: 43 | |||
|
104 | description: button_move | |||
|
105 | controller: projects | |||
|
106 | mail_enabled: false | |||
|
107 | mail_option: false | |||
|
108 | sort: 1061 | |||
|
109 | is_public: false | |||
74 | permissions_032: |
|
110 | permissions_032: | |
75 | action: show |
|
111 | action: show | |
76 | id: 32 |
|
112 | id: 32 | |
77 | description: button_view |
|
113 | description: button_view | |
78 | controller: documents |
|
114 | controller: documents | |
79 | mail_enabled: false |
|
115 | mail_enabled: false | |
80 | mail_option: false |
|
116 | mail_option: false | |
81 | sort: 1201 |
|
117 | sort: 1201 | |
82 | is_public: true |
|
118 | is_public: true | |
83 | permissions_021: |
|
119 | permissions_021: | |
84 | action: edit |
|
120 | action: edit | |
85 | id: 21 |
|
121 | id: 21 | |
86 | description: button_edit |
|
122 | description: button_edit | |
87 | controller: issues |
|
123 | controller: issues | |
88 | mail_enabled: false |
|
124 | mail_enabled: false | |
89 | mail_option: false |
|
125 | mail_option: false | |
90 | sort: 1055 |
|
126 | sort: 1055 | |
91 | is_public: false |
|
127 | is_public: false | |
92 | permissions_010: |
|
128 | permissions_010: | |
93 | action: add_version |
|
129 | action: add_version | |
94 | id: 10 |
|
130 | id: 10 | |
95 | description: button_add |
|
131 | description: button_add | |
96 | controller: projects |
|
132 | controller: projects | |
97 | mail_enabled: false |
|
133 | mail_enabled: false | |
98 | mail_option: false |
|
134 | mail_option: false | |
99 | sort: 320 |
|
135 | sort: 320 | |
100 | is_public: false |
|
136 | is_public: false | |
|
137 | permissions_055: | |||
|
138 | action: browse | |||
|
139 | id: 55 | |||
|
140 | description: label_browse | |||
|
141 | controller: repositories | |||
|
142 | mail_enabled: false | |||
|
143 | mail_option: false | |||
|
144 | sort: 1460 | |||
|
145 | is_public: true | |||
|
146 | permissions_044: | |||
|
147 | action: add_note | |||
|
148 | id: 44 | |||
|
149 | description: label_add_note | |||
|
150 | controller: issues | |||
|
151 | mail_enabled: false | |||
|
152 | mail_option: true | |||
|
153 | sort: 1057 | |||
|
154 | is_public: false | |||
101 | permissions_033: |
|
155 | permissions_033: | |
102 | action: download |
|
156 | action: download | |
103 | id: 33 |
|
157 | id: 33 | |
104 | description: button_download |
|
158 | description: button_download | |
105 | controller: documents |
|
159 | controller: documents | |
106 | mail_enabled: false |
|
160 | mail_enabled: false | |
107 | mail_option: false |
|
161 | mail_option: false | |
108 | sort: 1202 |
|
162 | sort: 1202 | |
109 | is_public: true |
|
163 | is_public: true | |
110 | permissions_022: |
|
164 | permissions_022: | |
111 | action: change_status |
|
165 | action: change_status | |
112 | id: 22 |
|
166 | id: 22 | |
113 | description: label_change_status |
|
167 | description: label_change_status | |
114 | controller: issues |
|
168 | controller: issues | |
115 | mail_enabled: true |
|
169 | mail_enabled: true | |
116 | mail_option: true |
|
170 | mail_option: true | |
117 | sort: 1060 |
|
171 | sort: 1060 | |
118 | is_public: false |
|
172 | is_public: false | |
119 | permissions_011: |
|
173 | permissions_011: | |
120 | action: edit |
|
174 | action: edit | |
121 | id: 11 |
|
175 | id: 11 | |
122 | description: button_edit |
|
176 | description: button_edit | |
123 | controller: versions |
|
177 | controller: versions | |
124 | mail_enabled: false |
|
178 | mail_enabled: false | |
125 | mail_option: false |
|
179 | mail_option: false | |
126 | sort: 321 |
|
180 | sort: 321 | |
127 | is_public: false |
|
181 | is_public: false | |
|
182 | permissions_056: | |||
|
183 | action: entry | |||
|
184 | id: 56 | |||
|
185 | description: entry | |||
|
186 | controller: repositories | |||
|
187 | mail_enabled: false | |||
|
188 | mail_option: false | |||
|
189 | sort: 1462 | |||
|
190 | is_public: true | |||
|
191 | permissions_045: | |||
|
192 | action: export_issues_pdf | |||
|
193 | id: 45 | |||
|
194 | description: label_export_pdf | |||
|
195 | controller: projects | |||
|
196 | mail_enabled: false | |||
|
197 | mail_option: false | |||
|
198 | sort: 1002 | |||
|
199 | is_public: true | |||
128 | permissions_034: |
|
200 | permissions_034: | |
129 | action: add_document |
|
201 | action: add_document | |
130 | id: 34 |
|
202 | id: 34 | |
131 | description: button_add |
|
203 | description: button_add | |
132 | controller: projects |
|
204 | controller: projects | |
133 | mail_enabled: false |
|
205 | mail_enabled: false | |
134 |
mail_option: |
|
206 | mail_option: true | |
135 | sort: 1220 |
|
207 | sort: 1220 | |
136 | is_public: false |
|
208 | is_public: false | |
137 | permissions_023: |
|
209 | permissions_023: | |
138 | action: destroy |
|
210 | action: destroy | |
139 | id: 23 |
|
211 | id: 23 | |
140 | description: button_delete |
|
212 | description: button_delete | |
141 | controller: issues |
|
213 | controller: issues | |
142 | mail_enabled: false |
|
214 | mail_enabled: false | |
143 | mail_option: false |
|
215 | mail_option: false | |
144 | sort: 1065 |
|
216 | sort: 1065 | |
145 | is_public: false |
|
217 | is_public: false | |
146 | permissions_012: |
|
218 | permissions_012: | |
147 | action: destroy |
|
219 | action: destroy | |
148 | id: 12 |
|
220 | id: 12 | |
149 | description: button_delete |
|
221 | description: button_delete | |
150 | controller: versions |
|
222 | controller: versions | |
151 | mail_enabled: false |
|
223 | mail_enabled: false | |
152 | mail_option: false |
|
224 | mail_option: false | |
153 | sort: 322 |
|
225 | sort: 322 | |
154 | is_public: false |
|
226 | is_public: false | |
155 | permissions_001: |
|
227 | permissions_001: | |
156 | action: show |
|
228 | action: show | |
157 | id: 1 |
|
229 | id: 1 | |
158 | description: label_overview |
|
230 | description: label_overview | |
159 | controller: projects |
|
231 | controller: projects | |
160 | mail_enabled: false |
|
232 | mail_enabled: false | |
161 | mail_option: false |
|
233 | mail_option: false | |
162 | sort: 100 |
|
234 | sort: 100 | |
163 | is_public: true |
|
235 | is_public: true | |
|
236 | permissions_057: | |||
|
237 | action: revisions | |||
|
238 | id: 57 | |||
|
239 | description: label_view_revisions | |||
|
240 | controller: repositories | |||
|
241 | mail_enabled: false | |||
|
242 | mail_option: false | |||
|
243 | sort: 1470 | |||
|
244 | is_public: true | |||
|
245 | permissions_046: | |||
|
246 | action: export_pdf | |||
|
247 | id: 46 | |||
|
248 | description: label_export_pdf | |||
|
249 | controller: issues | |||
|
250 | mail_enabled: false | |||
|
251 | mail_option: false | |||
|
252 | sort: 1015 | |||
|
253 | is_public: true | |||
164 | permissions_035: |
|
254 | permissions_035: | |
165 | action: edit |
|
255 | action: edit | |
166 | id: 35 |
|
256 | id: 35 | |
167 | description: button_edit |
|
257 | description: button_edit | |
168 | controller: documents |
|
258 | controller: documents | |
169 | mail_enabled: false |
|
259 | mail_enabled: false | |
170 | mail_option: false |
|
260 | mail_option: false | |
171 | sort: 1221 |
|
261 | sort: 1221 | |
172 | is_public: false |
|
262 | is_public: false | |
173 | permissions_024: |
|
263 | permissions_024: | |
174 | action: add_attachment |
|
264 | action: add_attachment | |
175 | id: 24 |
|
265 | id: 24 | |
176 | description: label_attachment_new |
|
266 | description: label_attachment_new | |
177 | controller: issues |
|
267 | controller: issues | |
178 | mail_enabled: false |
|
268 | mail_enabled: false | |
179 |
mail_option: |
|
269 | mail_option: true | |
180 | sort: 1070 |
|
270 | sort: 1070 | |
181 | is_public: false |
|
271 | is_public: false | |
182 | permissions_013: |
|
272 | permissions_013: | |
183 | action: add_issue_category |
|
273 | action: add_issue_category | |
184 | id: 13 |
|
274 | id: 13 | |
185 | description: button_add |
|
275 | description: button_add | |
186 | controller: projects |
|
276 | controller: projects | |
187 | mail_enabled: false |
|
277 | mail_enabled: false | |
188 | mail_option: false |
|
278 | mail_option: false | |
189 | sort: 420 |
|
279 | sort: 420 | |
190 | is_public: false |
|
280 | is_public: false | |
191 | permissions_002: |
|
281 | permissions_002: | |
192 | action: changelog |
|
282 | action: changelog | |
193 | id: 2 |
|
283 | id: 2 | |
194 | description: label_change_log |
|
284 | description: label_change_log | |
195 | controller: projects |
|
285 | controller: projects | |
196 | mail_enabled: false |
|
286 | mail_enabled: false | |
197 | mail_option: false |
|
287 | mail_option: false | |
198 | sort: 105 |
|
288 | sort: 105 | |
199 | is_public: true |
|
289 | is_public: true | |
|
290 | permissions_058: | |||
|
291 | action: revision | |||
|
292 | id: 58 | |||
|
293 | description: label_view_revisions | |||
|
294 | controller: repositories | |||
|
295 | mail_enabled: false | |||
|
296 | mail_option: false | |||
|
297 | sort: 1472 | |||
|
298 | is_public: true | |||
|
299 | permissions_047: | |||
|
300 | action: activity | |||
|
301 | id: 47 | |||
|
302 | description: label_activity | |||
|
303 | controller: projects | |||
|
304 | mail_enabled: false | |||
|
305 | mail_option: false | |||
|
306 | sort: 160 | |||
|
307 | is_public: true | |||
200 | permissions_036: |
|
308 | permissions_036: | |
201 | action: destroy |
|
309 | action: destroy | |
202 | id: 36 |
|
310 | id: 36 | |
203 | description: button_delete |
|
311 | description: button_delete | |
204 | controller: documents |
|
312 | controller: documents | |
205 | mail_enabled: false |
|
313 | mail_enabled: false | |
206 | mail_option: false |
|
314 | mail_option: false | |
207 | sort: 1222 |
|
315 | sort: 1222 | |
208 | is_public: false |
|
316 | is_public: false | |
209 | permissions_025: |
|
317 | permissions_025: | |
210 | action: destroy_attachment |
|
318 | action: destroy_attachment | |
211 | id: 25 |
|
319 | id: 25 | |
212 | description: label_attachment_delete |
|
320 | description: label_attachment_delete | |
213 | controller: issues |
|
321 | controller: issues | |
214 | mail_enabled: false |
|
322 | mail_enabled: false | |
215 | mail_option: false |
|
323 | mail_option: false | |
216 | sort: 1075 |
|
324 | sort: 1075 | |
217 | is_public: false |
|
325 | is_public: false | |
218 | permissions_014: |
|
326 | permissions_014: | |
219 | action: edit |
|
327 | action: edit | |
220 | id: 14 |
|
328 | id: 14 | |
221 | description: button_edit |
|
329 | description: button_edit | |
222 | controller: issue_categories |
|
330 | controller: issue_categories | |
223 | mail_enabled: false |
|
331 | mail_enabled: false | |
224 | mail_option: false |
|
332 | mail_option: false | |
225 | sort: 421 |
|
333 | sort: 421 | |
226 | is_public: false |
|
334 | is_public: false | |
227 | permissions_003: |
|
335 | permissions_003: | |
228 | action: issue_report |
|
336 | action: issue_report | |
229 | id: 3 |
|
337 | id: 3 | |
230 | description: label_report_plural |
|
338 | description: label_report_plural | |
231 | controller: reports |
|
339 | controller: reports | |
232 | mail_enabled: false |
|
340 | mail_enabled: false | |
233 | mail_option: false |
|
341 | mail_option: false | |
234 | sort: 110 |
|
342 | sort: 110 | |
235 | is_public: true |
|
343 | is_public: true | |
|
344 | permissions_059: | |||
|
345 | action: diff | |||
|
346 | id: 59 | |||
|
347 | description: diff | |||
|
348 | controller: repositories | |||
|
349 | mail_enabled: false | |||
|
350 | mail_option: false | |||
|
351 | sort: 1480 | |||
|
352 | is_public: true | |||
|
353 | permissions_048: | |||
|
354 | action: calendar | |||
|
355 | id: 48 | |||
|
356 | description: label_calendar | |||
|
357 | controller: projects | |||
|
358 | mail_enabled: false | |||
|
359 | mail_option: false | |||
|
360 | sort: 165 | |||
|
361 | is_public: true | |||
236 | permissions_037: |
|
362 | permissions_037: | |
237 | action: add_attachment |
|
363 | action: add_attachment | |
238 | id: 37 |
|
364 | id: 37 | |
239 | description: label_attachment_new |
|
365 | description: label_attachment_new | |
240 | controller: documents |
|
366 | controller: documents | |
241 | mail_enabled: false |
|
367 | mail_enabled: false | |
242 |
mail_option: |
|
368 | mail_option: true | |
243 | sort: 1223 |
|
369 | sort: 1223 | |
244 | is_public: false |
|
370 | is_public: false | |
245 | permissions_026: |
|
371 | permissions_026: | |
246 | action: list_news |
|
372 | action: list_news | |
247 | id: 26 |
|
373 | id: 26 | |
248 | description: button_list |
|
374 | description: button_list | |
249 | controller: projects |
|
375 | controller: projects | |
250 | mail_enabled: false |
|
376 | mail_enabled: false | |
251 | mail_option: false |
|
377 | mail_option: false | |
252 | sort: 1100 |
|
378 | sort: 1100 | |
253 | is_public: true |
|
379 | is_public: true | |
254 | permissions_015: |
|
380 | permissions_015: | |
255 | action: destroy |
|
381 | action: destroy | |
256 | id: 15 |
|
382 | id: 15 | |
257 | description: button_delete |
|
383 | description: button_delete | |
258 | controller: issue_categories |
|
384 | controller: issue_categories | |
259 | mail_enabled: false |
|
385 | mail_enabled: false | |
260 | mail_option: false |
|
386 | mail_option: false | |
261 | sort: 422 |
|
387 | sort: 422 | |
262 | is_public: false |
|
388 | is_public: false | |
263 | permissions_004: |
|
389 | permissions_004: | |
264 | action: settings |
|
390 | action: settings | |
265 | id: 4 |
|
391 | id: 4 | |
266 | description: label_settings |
|
392 | description: label_settings | |
267 | controller: projects |
|
393 | controller: projects | |
268 | mail_enabled: false |
|
394 | mail_enabled: false | |
269 | mail_option: false |
|
395 | mail_option: false | |
270 | sort: 150 |
|
396 | sort: 150 | |
271 | is_public: false |
|
397 | is_public: false | |
|
398 | permissions_060: | |||
|
399 | action: search | |||
|
400 | id: 61 | |||
|
401 | description: label_search | |||
|
402 | controller: projects | |||
|
403 | mail_enabled: false | |||
|
404 | mail_option: false | |||
|
405 | sort: 130 | |||
|
406 | is_public: true | |||
|
407 | permissions_049: | |||
|
408 | action: gantt | |||
|
409 | id: 49 | |||
|
410 | description: label_gantt | |||
|
411 | controller: projects | |||
|
412 | mail_enabled: false | |||
|
413 | mail_option: false | |||
|
414 | sort: 166 | |||
|
415 | is_public: true | |||
272 | permissions_038: |
|
416 | permissions_038: | |
273 | action: destroy_attachment |
|
417 | action: destroy_attachment | |
274 | id: 38 |
|
418 | id: 38 | |
275 | description: label_attachment_delete |
|
419 | description: label_attachment_delete | |
276 | controller: documents |
|
420 | controller: documents | |
277 | mail_enabled: false |
|
421 | mail_enabled: false | |
278 | mail_option: false |
|
422 | mail_option: false | |
279 | sort: 1224 |
|
423 | sort: 1224 | |
280 | is_public: false |
|
424 | is_public: false | |
281 | permissions_027: |
|
425 | permissions_027: | |
282 | action: show |
|
426 | action: show | |
283 | id: 27 |
|
427 | id: 27 | |
284 | description: button_view |
|
428 | description: button_view | |
285 | controller: news |
|
429 | controller: news | |
286 | mail_enabled: false |
|
430 | mail_enabled: false | |
287 | mail_option: false |
|
431 | mail_option: false | |
288 | sort: 1101 |
|
432 | sort: 1101 | |
289 | is_public: true |
|
433 | is_public: true | |
290 | permissions_016: |
|
434 | permissions_016: | |
291 | action: list_issues |
|
435 | action: list_issues | |
292 | id: 16 |
|
436 | id: 16 | |
293 | description: button_list |
|
437 | description: button_list | |
294 | controller: projects |
|
438 | controller: projects | |
295 | mail_enabled: false |
|
439 | mail_enabled: false | |
296 | mail_option: false |
|
440 | mail_option: false | |
297 | sort: 1000 |
|
441 | sort: 1000 | |
298 | is_public: true |
|
442 | is_public: true | |
299 | permissions_005: |
|
443 | permissions_005: | |
300 | action: edit |
|
444 | action: edit | |
301 | id: 5 |
|
445 | id: 5 | |
302 | description: button_edit |
|
446 | description: button_edit | |
303 | controller: projects |
|
447 | controller: projects | |
304 | mail_enabled: false |
|
448 | mail_enabled: false | |
305 | mail_option: false |
|
449 | mail_option: false | |
306 | sort: 151 |
|
450 | sort: 151 | |
307 | is_public: false |
|
451 | is_public: false | |
|
452 | permissions_050: | |||
|
453 | action: history | |||
|
454 | id: 50 | |||
|
455 | description: label_history | |||
|
456 | controller: issues | |||
|
457 | mail_enabled: false | |||
|
458 | mail_option: false | |||
|
459 | sort: 1006 | |||
|
460 | is_public: true | |||
308 | permissions_039: |
|
461 | permissions_039: | |
309 | action: list_files |
|
462 | action: list_files | |
310 | id: 39 |
|
463 | id: 39 | |
311 | description: button_list |
|
464 | description: button_list | |
312 | controller: projects |
|
465 | controller: projects | |
313 | mail_enabled: false |
|
466 | mail_enabled: false | |
314 | mail_option: false |
|
467 | mail_option: false | |
315 | sort: 1300 |
|
468 | sort: 1300 | |
316 | is_public: true |
|
469 | is_public: true | |
317 | permissions_028: |
|
470 | permissions_028: | |
318 | action: add_news |
|
471 | action: add_news | |
319 | id: 28 |
|
472 | id: 28 | |
320 | description: button_add |
|
473 | description: button_add | |
321 | controller: projects |
|
474 | controller: projects | |
322 | mail_enabled: false |
|
475 | mail_enabled: false | |
323 | mail_option: false |
|
476 | mail_option: false | |
324 | sort: 1120 |
|
477 | sort: 1120 | |
325 | is_public: false |
|
478 | is_public: false | |
326 | permissions_017: |
|
479 | permissions_017: | |
327 | action: export_issues_csv |
|
480 | action: export_issues_csv | |
328 | id: 17 |
|
481 | id: 17 | |
329 | description: label_export_csv |
|
482 | description: label_export_csv | |
330 | controller: projects |
|
483 | controller: projects | |
331 | mail_enabled: false |
|
484 | mail_enabled: false | |
332 | mail_option: false |
|
485 | mail_option: false | |
333 | sort: 1001 |
|
486 | sort: 1001 | |
334 | is_public: true |
|
487 | is_public: true | |
335 | permissions_006: |
|
488 | permissions_006: | |
336 | action: list_members |
|
489 | action: list_members | |
337 | id: 6 |
|
490 | id: 6 | |
338 | description: button_list |
|
491 | description: button_list | |
339 | controller: projects |
|
492 | controller: projects | |
340 | mail_enabled: false |
|
493 | mail_enabled: false | |
341 | mail_option: false |
|
494 | mail_option: false | |
342 | sort: 200 |
|
495 | sort: 200 | |
343 | is_public: true |
|
496 | is_public: true | |
|
497 | permissions_051: | |||
|
498 | action: add_comment | |||
|
499 | id: 51 | |||
|
500 | description: label_comment_add | |||
|
501 | controller: news | |||
|
502 | mail_enabled: false | |||
|
503 | mail_option: false | |||
|
504 | sort: 1130 | |||
|
505 | is_public: false | |||
344 | permissions_040: |
|
506 | permissions_040: | |
345 | action: download |
|
507 | action: download | |
346 | id: 40 |
|
508 | id: 40 | |
347 | description: button_download |
|
509 | description: button_download | |
348 | controller: versions |
|
510 | controller: versions | |
349 | mail_enabled: false |
|
511 | mail_enabled: false | |
350 | mail_option: false |
|
512 | mail_option: false | |
351 | sort: 1301 |
|
513 | sort: 1301 | |
352 | is_public: true |
|
514 | is_public: true | |
353 | permissions_029: |
|
515 | permissions_029: | |
354 | action: edit |
|
516 | action: edit | |
355 | id: 29 |
|
517 | id: 29 | |
356 | description: button_edit |
|
518 | description: button_edit | |
357 | controller: news |
|
519 | controller: news | |
358 | mail_enabled: false |
|
520 | mail_enabled: false | |
359 | mail_option: false |
|
521 | mail_option: false | |
360 | sort: 1121 |
|
522 | sort: 1121 | |
361 | is_public: false |
|
523 | is_public: false | |
362 | permissions_018: |
|
524 | permissions_018: | |
363 | action: show |
|
525 | action: show | |
364 | id: 18 |
|
526 | id: 18 | |
365 | description: button_view |
|
527 | description: button_view | |
366 | controller: issues |
|
528 | controller: issues | |
367 | mail_enabled: false |
|
529 | mail_enabled: false | |
368 | mail_option: false |
|
530 | mail_option: false | |
369 | sort: 1005 |
|
531 | sort: 1005 | |
370 | is_public: true |
|
532 | is_public: true | |
371 | permissions_007: |
|
533 | permissions_007: | |
372 | action: add_member |
|
534 | action: add_member | |
373 | id: 7 |
|
535 | id: 7 | |
374 | description: button_add |
|
536 | description: button_add | |
375 | controller: projects |
|
537 | controller: projects | |
376 | mail_enabled: false |
|
538 | mail_enabled: false | |
377 | mail_option: false |
|
539 | mail_option: false | |
378 | sort: 220 |
|
540 | sort: 220 | |
379 | is_public: false |
|
541 | is_public: false |
@@ -1,114 +1,124 | |||||
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 | 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, :permissions |
|
25 | fixtures :projects, :permissions | |
26 |
|
26 | |||
27 | def setup |
|
27 | def setup | |
28 | @controller = ProjectsController.new |
|
28 | @controller = ProjectsController.new | |
29 | @request = ActionController::TestRequest.new |
|
29 | @request = ActionController::TestRequest.new | |
30 | @response = ActionController::TestResponse.new |
|
30 | @response = ActionController::TestResponse.new | |
31 | end |
|
31 | end | |
32 |
|
32 | |||
33 | def test_index |
|
33 | def test_index | |
34 | get :index |
|
34 | get :index | |
35 | assert_response :success |
|
35 | assert_response :success | |
36 | assert_template 'list' |
|
36 | assert_template 'list' | |
37 | end |
|
37 | end | |
38 |
|
38 | |||
39 | def test_list |
|
39 | def test_list | |
40 | get :list |
|
40 | get :list | |
41 | assert_response :success |
|
41 | assert_response :success | |
42 | assert_template 'list' |
|
42 | assert_template 'list' | |
43 | assert_not_nil assigns(:projects) |
|
43 | assert_not_nil assigns(:projects) | |
44 | end |
|
44 | end | |
45 |
|
45 | |||
46 | def test_show |
|
46 | def test_show | |
47 | get :show, :id => 1 |
|
47 | get :show, :id => 1 | |
48 | assert_response :success |
|
48 | assert_response :success | |
49 | assert_template 'show' |
|
49 | assert_template 'show' | |
50 | assert_not_nil assigns(:project) |
|
50 | assert_not_nil assigns(:project) | |
51 | end |
|
51 | end | |
52 |
|
52 | |||
53 | def test_list_members |
|
53 | def test_list_members | |
54 | get :list_members, :id => 1 |
|
54 | get :list_members, :id => 1 | |
55 | assert_response :success |
|
55 | assert_response :success | |
56 | assert_template 'list_members' |
|
56 | assert_template 'list_members' | |
57 | assert_not_nil assigns(:members) |
|
57 | assert_not_nil assigns(:members) | |
58 | end |
|
58 | end | |
59 |
|
59 | |||
60 | def test_list_documents |
|
60 | def test_list_documents | |
61 | get :list_documents, :id => 1 |
|
61 | get :list_documents, :id => 1 | |
62 | assert_response :success |
|
62 | assert_response :success | |
63 | assert_template 'list_documents' |
|
63 | assert_template 'list_documents' | |
64 | assert_not_nil assigns(:documents) |
|
64 | assert_not_nil assigns(:documents) | |
65 | end |
|
65 | end | |
66 |
|
66 | |||
67 | def test_list_issues |
|
67 | def test_list_issues | |
68 | get :list_issues, :id => 1 |
|
68 | get :list_issues, :id => 1 | |
69 | assert_response :success |
|
69 | assert_response :success | |
70 | assert_template 'list_issues' |
|
70 | assert_template 'list_issues' | |
71 | assert_not_nil assigns(:issues) |
|
71 | assert_not_nil assigns(:issues) | |
72 | end |
|
72 | end | |
73 |
|
73 | |||
74 | def test_list_issues_with_filter |
|
74 | def test_list_issues_with_filter | |
75 | get :list_issues, :id => 1, :set_filter => 1 |
|
75 | get :list_issues, :id => 1, :set_filter => 1 | |
76 | assert_response :success |
|
76 | assert_response :success | |
77 | assert_template 'list_issues' |
|
77 | assert_template 'list_issues' | |
78 | assert_not_nil assigns(:issues) |
|
78 | assert_not_nil assigns(:issues) | |
79 | end |
|
79 | end | |
80 |
|
80 | |||
81 | def test_list_issues_reset_filter |
|
81 | def test_list_issues_reset_filter | |
82 | post :list_issues, :id => 1 |
|
82 | post :list_issues, :id => 1 | |
83 | assert_response :success |
|
83 | assert_response :success | |
84 | assert_template 'list_issues' |
|
84 | assert_template 'list_issues' | |
85 | assert_not_nil assigns(:issues) |
|
85 | assert_not_nil assigns(:issues) | |
86 | end |
|
86 | end | |
87 |
|
87 | |||
88 | def test_export_issues_csv |
|
88 | def test_export_issues_csv | |
89 | get :export_issues_csv, :id => 1 |
|
89 | get :export_issues_csv, :id => 1 | |
90 | assert_response :success |
|
90 | assert_response :success | |
91 | assert_not_nil assigns(:issues) |
|
91 | assert_not_nil assigns(:issues) | |
92 | end |
|
92 | end | |
93 |
|
93 | |||
94 | def test_list_news |
|
94 | def test_list_news | |
95 | get :list_news, :id => 1 |
|
95 | get :list_news, :id => 1 | |
96 | assert_response :success |
|
96 | assert_response :success | |
97 | assert_template 'list_news' |
|
97 | assert_template 'list_news' | |
98 | assert_not_nil assigns(:news) |
|
98 | assert_not_nil assigns(:news) | |
99 | end |
|
99 | end | |
100 |
|
100 | |||
101 | def test_list_files |
|
101 | def test_list_files | |
102 | get :list_files, :id => 1 |
|
102 | get :list_files, :id => 1 | |
103 | assert_response :success |
|
103 | assert_response :success | |
104 | assert_template 'list_files' |
|
104 | assert_template 'list_files' | |
105 | assert_not_nil assigns(:versions) |
|
105 | assert_not_nil assigns(:versions) | |
106 | end |
|
106 | end | |
107 |
|
107 | |||
108 | def test_changelog |
|
108 | def test_changelog | |
109 | get :changelog, :id => 1 |
|
109 | get :changelog, :id => 1 | |
110 | assert_response :success |
|
110 | assert_response :success | |
111 | assert_template 'changelog' |
|
111 | assert_template 'changelog' | |
112 | assert_not_nil assigns(:fixed_issues) |
|
112 | assert_not_nil assigns(:fixed_issues) | |
113 | end |
|
113 | end | |
|
114 | ||||
|
115 | def test_search | |||
|
116 | get :search, :id => 1 | |||
|
117 | assert_response :success | |||
|
118 | assert_template 'search' | |||
|
119 | ||||
|
120 | get :search, :id => 1, :token => "can", :scope => ["issues", "news", "documents"] | |||
|
121 | assert_response :success | |||
|
122 | assert_template 'search' | |||
|
123 | end | |||
114 | end |
|
124 | end |
General Comments 0
You need to be logged in to leave comments.
Login now