##// END OF EJS Templates
Adds a "Copied from/to" relation when copying issue(s) (#6899)....
Jean-Philippe Lang -
r10282:cc4cff9f11b4
parent child
Show More
@@ -1,1283 +1,1292
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang
2 # Copyright (C) 2006-2012 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 Issue < ActiveRecord::Base
18 class Issue < ActiveRecord::Base
19 include Redmine::SafeAttributes
19 include Redmine::SafeAttributes
20
20
21 belongs_to :project
21 belongs_to :project
22 belongs_to :tracker
22 belongs_to :tracker
23 belongs_to :status, :class_name => 'IssueStatus', :foreign_key => 'status_id'
23 belongs_to :status, :class_name => 'IssueStatus', :foreign_key => 'status_id'
24 belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
24 belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
25 belongs_to :assigned_to, :class_name => 'Principal', :foreign_key => 'assigned_to_id'
25 belongs_to :assigned_to, :class_name => 'Principal', :foreign_key => 'assigned_to_id'
26 belongs_to :fixed_version, :class_name => 'Version', :foreign_key => 'fixed_version_id'
26 belongs_to :fixed_version, :class_name => 'Version', :foreign_key => 'fixed_version_id'
27 belongs_to :priority, :class_name => 'IssuePriority', :foreign_key => 'priority_id'
27 belongs_to :priority, :class_name => 'IssuePriority', :foreign_key => 'priority_id'
28 belongs_to :category, :class_name => 'IssueCategory', :foreign_key => 'category_id'
28 belongs_to :category, :class_name => 'IssueCategory', :foreign_key => 'category_id'
29
29
30 has_many :journals, :as => :journalized, :dependent => :destroy
30 has_many :journals, :as => :journalized, :dependent => :destroy
31 has_many :time_entries, :dependent => :delete_all
31 has_many :time_entries, :dependent => :delete_all
32 has_and_belongs_to_many :changesets, :order => "#{Changeset.table_name}.committed_on ASC, #{Changeset.table_name}.id ASC"
32 has_and_belongs_to_many :changesets, :order => "#{Changeset.table_name}.committed_on ASC, #{Changeset.table_name}.id ASC"
33
33
34 has_many :relations_from, :class_name => 'IssueRelation', :foreign_key => 'issue_from_id', :dependent => :delete_all
34 has_many :relations_from, :class_name => 'IssueRelation', :foreign_key => 'issue_from_id', :dependent => :delete_all
35 has_many :relations_to, :class_name => 'IssueRelation', :foreign_key => 'issue_to_id', :dependent => :delete_all
35 has_many :relations_to, :class_name => 'IssueRelation', :foreign_key => 'issue_to_id', :dependent => :delete_all
36
36
37 acts_as_nested_set :scope => 'root_id', :dependent => :destroy
37 acts_as_nested_set :scope => 'root_id', :dependent => :destroy
38 acts_as_attachable :after_add => :attachment_added, :after_remove => :attachment_removed
38 acts_as_attachable :after_add => :attachment_added, :after_remove => :attachment_removed
39 acts_as_customizable
39 acts_as_customizable
40 acts_as_watchable
40 acts_as_watchable
41 acts_as_searchable :columns => ['subject', "#{table_name}.description", "#{Journal.table_name}.notes"],
41 acts_as_searchable :columns => ['subject', "#{table_name}.description", "#{Journal.table_name}.notes"],
42 :include => [:project, :journals],
42 :include => [:project, :journals],
43 # sort by id so that limited eager loading doesn't break with postgresql
43 # sort by id so that limited eager loading doesn't break with postgresql
44 :order_column => "#{table_name}.id"
44 :order_column => "#{table_name}.id"
45 acts_as_event :title => Proc.new {|o| "#{o.tracker.name} ##{o.id} (#{o.status}): #{o.subject}"},
45 acts_as_event :title => Proc.new {|o| "#{o.tracker.name} ##{o.id} (#{o.status}): #{o.subject}"},
46 :url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.id}},
46 :url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.id}},
47 :type => Proc.new {|o| 'issue' + (o.closed? ? ' closed' : '') }
47 :type => Proc.new {|o| 'issue' + (o.closed? ? ' closed' : '') }
48
48
49 acts_as_activity_provider :find_options => {:include => [:project, :author, :tracker]},
49 acts_as_activity_provider :find_options => {:include => [:project, :author, :tracker]},
50 :author_key => :author_id
50 :author_key => :author_id
51
51
52 DONE_RATIO_OPTIONS = %w(issue_field issue_status)
52 DONE_RATIO_OPTIONS = %w(issue_field issue_status)
53
53
54 attr_reader :current_journal
54 attr_reader :current_journal
55
55
56 validates_presence_of :subject, :priority, :project, :tracker, :author, :status
56 validates_presence_of :subject, :priority, :project, :tracker, :author, :status
57
57
58 validates_length_of :subject, :maximum => 255
58 validates_length_of :subject, :maximum => 255
59 validates_inclusion_of :done_ratio, :in => 0..100
59 validates_inclusion_of :done_ratio, :in => 0..100
60 validates_numericality_of :estimated_hours, :allow_nil => true
60 validates_numericality_of :estimated_hours, :allow_nil => true
61 validate :validate_issue, :validate_required_fields
61 validate :validate_issue, :validate_required_fields
62
62
63 scope :visible,
63 scope :visible,
64 lambda {|*args| { :include => :project,
64 lambda {|*args| { :include => :project,
65 :conditions => Issue.visible_condition(args.shift || User.current, *args) } }
65 :conditions => Issue.visible_condition(args.shift || User.current, *args) } }
66
66
67 scope :open, lambda {|*args|
67 scope :open, lambda {|*args|
68 is_closed = args.size > 0 ? !args.first : false
68 is_closed = args.size > 0 ? !args.first : false
69 {:conditions => ["#{IssueStatus.table_name}.is_closed = ?", is_closed], :include => :status}
69 {:conditions => ["#{IssueStatus.table_name}.is_closed = ?", is_closed], :include => :status}
70 }
70 }
71
71
72 scope :recently_updated, :order => "#{Issue.table_name}.updated_on DESC"
72 scope :recently_updated, :order => "#{Issue.table_name}.updated_on DESC"
73 scope :on_active_project, :include => [:status, :project, :tracker],
73 scope :on_active_project, :include => [:status, :project, :tracker],
74 :conditions => ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"]
74 :conditions => ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"]
75
75
76 before_create :default_assign
76 before_create :default_assign
77 before_save :close_duplicates, :update_done_ratio_from_issue_status, :force_updated_on_change
77 before_save :close_duplicates, :update_done_ratio_from_issue_status, :force_updated_on_change
78 after_save {|issue| issue.send :after_project_change if !issue.id_changed? && issue.project_id_changed?}
78 after_save {|issue| issue.send :after_project_change if !issue.id_changed? && issue.project_id_changed?}
79 after_save :reschedule_following_issues, :update_nested_set_attributes, :update_parent_attributes, :create_journal
79 after_save :reschedule_following_issues, :update_nested_set_attributes, :update_parent_attributes, :create_journal
80 # Should be after_create but would be called before previous after_save callbacks
80 # Should be after_create but would be called before previous after_save callbacks
81 after_save :after_create_from_copy
81 after_save :after_create_from_copy
82 after_destroy :update_parent_attributes
82 after_destroy :update_parent_attributes
83
83
84 # Returns a SQL conditions string used to find all issues visible by the specified user
84 # Returns a SQL conditions string used to find all issues visible by the specified user
85 def self.visible_condition(user, options={})
85 def self.visible_condition(user, options={})
86 Project.allowed_to_condition(user, :view_issues, options) do |role, user|
86 Project.allowed_to_condition(user, :view_issues, options) do |role, user|
87 if user.logged?
87 if user.logged?
88 case role.issues_visibility
88 case role.issues_visibility
89 when 'all'
89 when 'all'
90 nil
90 nil
91 when 'default'
91 when 'default'
92 user_ids = [user.id] + user.groups.map(&:id)
92 user_ids = [user.id] + user.groups.map(&:id)
93 "(#{table_name}.is_private = #{connection.quoted_false} OR #{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
93 "(#{table_name}.is_private = #{connection.quoted_false} OR #{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
94 when 'own'
94 when 'own'
95 user_ids = [user.id] + user.groups.map(&:id)
95 user_ids = [user.id] + user.groups.map(&:id)
96 "(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
96 "(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
97 else
97 else
98 '1=0'
98 '1=0'
99 end
99 end
100 else
100 else
101 "(#{table_name}.is_private = #{connection.quoted_false})"
101 "(#{table_name}.is_private = #{connection.quoted_false})"
102 end
102 end
103 end
103 end
104 end
104 end
105
105
106 # Returns true if usr or current user is allowed to view the issue
106 # Returns true if usr or current user is allowed to view the issue
107 def visible?(usr=nil)
107 def visible?(usr=nil)
108 (usr || User.current).allowed_to?(:view_issues, self.project) do |role, user|
108 (usr || User.current).allowed_to?(:view_issues, self.project) do |role, user|
109 if user.logged?
109 if user.logged?
110 case role.issues_visibility
110 case role.issues_visibility
111 when 'all'
111 when 'all'
112 true
112 true
113 when 'default'
113 when 'default'
114 !self.is_private? || (self.author == user || user.is_or_belongs_to?(assigned_to))
114 !self.is_private? || (self.author == user || user.is_or_belongs_to?(assigned_to))
115 when 'own'
115 when 'own'
116 self.author == user || user.is_or_belongs_to?(assigned_to)
116 self.author == user || user.is_or_belongs_to?(assigned_to)
117 else
117 else
118 false
118 false
119 end
119 end
120 else
120 else
121 !self.is_private?
121 !self.is_private?
122 end
122 end
123 end
123 end
124 end
124 end
125
125
126 def initialize(attributes=nil, *args)
126 def initialize(attributes=nil, *args)
127 super
127 super
128 if new_record?
128 if new_record?
129 # set default values for new records only
129 # set default values for new records only
130 self.status ||= IssueStatus.default
130 self.status ||= IssueStatus.default
131 self.priority ||= IssuePriority.default
131 self.priority ||= IssuePriority.default
132 self.watcher_user_ids = []
132 self.watcher_user_ids = []
133 end
133 end
134 end
134 end
135
135
136 # AR#Persistence#destroy would raise and RecordNotFound exception
136 # AR#Persistence#destroy would raise and RecordNotFound exception
137 # if the issue was already deleted or updated (non matching lock_version).
137 # if the issue was already deleted or updated (non matching lock_version).
138 # This is a problem when bulk deleting issues or deleting a project
138 # This is a problem when bulk deleting issues or deleting a project
139 # (because an issue may already be deleted if its parent was deleted
139 # (because an issue may already be deleted if its parent was deleted
140 # first).
140 # first).
141 # The issue is reloaded by the nested_set before being deleted so
141 # The issue is reloaded by the nested_set before being deleted so
142 # the lock_version condition should not be an issue but we handle it.
142 # the lock_version condition should not be an issue but we handle it.
143 def destroy
143 def destroy
144 super
144 super
145 rescue ActiveRecord::RecordNotFound
145 rescue ActiveRecord::RecordNotFound
146 # Stale or already deleted
146 # Stale or already deleted
147 begin
147 begin
148 reload
148 reload
149 rescue ActiveRecord::RecordNotFound
149 rescue ActiveRecord::RecordNotFound
150 # The issue was actually already deleted
150 # The issue was actually already deleted
151 @destroyed = true
151 @destroyed = true
152 return freeze
152 return freeze
153 end
153 end
154 # The issue was stale, retry to destroy
154 # The issue was stale, retry to destroy
155 super
155 super
156 end
156 end
157
157
158 def reload(*args)
158 def reload(*args)
159 @workflow_rule_by_attribute = nil
159 @workflow_rule_by_attribute = nil
160 @assignable_versions = nil
160 @assignable_versions = nil
161 super
161 super
162 end
162 end
163
163
164 # Overrides Redmine::Acts::Customizable::InstanceMethods#available_custom_fields
164 # Overrides Redmine::Acts::Customizable::InstanceMethods#available_custom_fields
165 def available_custom_fields
165 def available_custom_fields
166 (project && tracker) ? (project.all_issue_custom_fields & tracker.custom_fields.all) : []
166 (project && tracker) ? (project.all_issue_custom_fields & tracker.custom_fields.all) : []
167 end
167 end
168
168
169 # Copies attributes from another issue, arg can be an id or an Issue
169 # Copies attributes from another issue, arg can be an id or an Issue
170 def copy_from(arg, options={})
170 def copy_from(arg, options={})
171 issue = arg.is_a?(Issue) ? arg : Issue.visible.find(arg)
171 issue = arg.is_a?(Issue) ? arg : Issue.visible.find(arg)
172 self.attributes = issue.attributes.dup.except("id", "root_id", "parent_id", "lft", "rgt", "created_on", "updated_on")
172 self.attributes = issue.attributes.dup.except("id", "root_id", "parent_id", "lft", "rgt", "created_on", "updated_on")
173 self.custom_field_values = issue.custom_field_values.inject({}) {|h,v| h[v.custom_field_id] = v.value; h}
173 self.custom_field_values = issue.custom_field_values.inject({}) {|h,v| h[v.custom_field_id] = v.value; h}
174 self.status = issue.status
174 self.status = issue.status
175 self.author = User.current
175 self.author = User.current
176 unless options[:attachments] == false
176 unless options[:attachments] == false
177 self.attachments = issue.attachments.map do |attachement|
177 self.attachments = issue.attachments.map do |attachement|
178 attachement.copy(:container => self)
178 attachement.copy(:container => self)
179 end
179 end
180 end
180 end
181 @copied_from = issue
181 @copied_from = issue
182 @copy_options = options
182 @copy_options = options
183 self
183 self
184 end
184 end
185
185
186 # Returns an unsaved copy of the issue
186 # Returns an unsaved copy of the issue
187 def copy(attributes=nil, copy_options={})
187 def copy(attributes=nil, copy_options={})
188 copy = self.class.new.copy_from(self, copy_options)
188 copy = self.class.new.copy_from(self, copy_options)
189 copy.attributes = attributes if attributes
189 copy.attributes = attributes if attributes
190 copy
190 copy
191 end
191 end
192
192
193 # Returns true if the issue is a copy
193 # Returns true if the issue is a copy
194 def copy?
194 def copy?
195 @copied_from.present?
195 @copied_from.present?
196 end
196 end
197
197
198 # Moves/copies an issue to a new project and tracker
198 # Moves/copies an issue to a new project and tracker
199 # Returns the moved/copied issue on success, false on failure
199 # Returns the moved/copied issue on success, false on failure
200 def move_to_project(new_project, new_tracker=nil, options={})
200 def move_to_project(new_project, new_tracker=nil, options={})
201 ActiveSupport::Deprecation.warn "Issue#move_to_project is deprecated, use #project= instead."
201 ActiveSupport::Deprecation.warn "Issue#move_to_project is deprecated, use #project= instead."
202
202
203 if options[:copy]
203 if options[:copy]
204 issue = self.copy
204 issue = self.copy
205 else
205 else
206 issue = self
206 issue = self
207 end
207 end
208
208
209 issue.init_journal(User.current, options[:notes])
209 issue.init_journal(User.current, options[:notes])
210
210
211 # Preserve previous behaviour
211 # Preserve previous behaviour
212 # #move_to_project doesn't change tracker automatically
212 # #move_to_project doesn't change tracker automatically
213 issue.send :project=, new_project, true
213 issue.send :project=, new_project, true
214 if new_tracker
214 if new_tracker
215 issue.tracker = new_tracker
215 issue.tracker = new_tracker
216 end
216 end
217 # Allow bulk setting of attributes on the issue
217 # Allow bulk setting of attributes on the issue
218 if options[:attributes]
218 if options[:attributes]
219 issue.attributes = options[:attributes]
219 issue.attributes = options[:attributes]
220 end
220 end
221
221
222 issue.save ? issue : false
222 issue.save ? issue : false
223 end
223 end
224
224
225 def status_id=(sid)
225 def status_id=(sid)
226 self.status = nil
226 self.status = nil
227 result = write_attribute(:status_id, sid)
227 result = write_attribute(:status_id, sid)
228 @workflow_rule_by_attribute = nil
228 @workflow_rule_by_attribute = nil
229 result
229 result
230 end
230 end
231
231
232 def priority_id=(pid)
232 def priority_id=(pid)
233 self.priority = nil
233 self.priority = nil
234 write_attribute(:priority_id, pid)
234 write_attribute(:priority_id, pid)
235 end
235 end
236
236
237 def category_id=(cid)
237 def category_id=(cid)
238 self.category = nil
238 self.category = nil
239 write_attribute(:category_id, cid)
239 write_attribute(:category_id, cid)
240 end
240 end
241
241
242 def fixed_version_id=(vid)
242 def fixed_version_id=(vid)
243 self.fixed_version = nil
243 self.fixed_version = nil
244 write_attribute(:fixed_version_id, vid)
244 write_attribute(:fixed_version_id, vid)
245 end
245 end
246
246
247 def tracker_id=(tid)
247 def tracker_id=(tid)
248 self.tracker = nil
248 self.tracker = nil
249 result = write_attribute(:tracker_id, tid)
249 result = write_attribute(:tracker_id, tid)
250 @custom_field_values = nil
250 @custom_field_values = nil
251 @workflow_rule_by_attribute = nil
251 @workflow_rule_by_attribute = nil
252 result
252 result
253 end
253 end
254
254
255 def project_id=(project_id)
255 def project_id=(project_id)
256 if project_id.to_s != self.project_id.to_s
256 if project_id.to_s != self.project_id.to_s
257 self.project = (project_id.present? ? Project.find_by_id(project_id) : nil)
257 self.project = (project_id.present? ? Project.find_by_id(project_id) : nil)
258 end
258 end
259 end
259 end
260
260
261 def project=(project, keep_tracker=false)
261 def project=(project, keep_tracker=false)
262 project_was = self.project
262 project_was = self.project
263 write_attribute(:project_id, project ? project.id : nil)
263 write_attribute(:project_id, project ? project.id : nil)
264 association_instance_set('project', project)
264 association_instance_set('project', project)
265 if project_was && project && project_was != project
265 if project_was && project && project_was != project
266 @assignable_versions = nil
266 @assignable_versions = nil
267
267
268 unless keep_tracker || project.trackers.include?(tracker)
268 unless keep_tracker || project.trackers.include?(tracker)
269 self.tracker = project.trackers.first
269 self.tracker = project.trackers.first
270 end
270 end
271 # Reassign to the category with same name if any
271 # Reassign to the category with same name if any
272 if category
272 if category
273 self.category = project.issue_categories.find_by_name(category.name)
273 self.category = project.issue_categories.find_by_name(category.name)
274 end
274 end
275 # Keep the fixed_version if it's still valid in the new_project
275 # Keep the fixed_version if it's still valid in the new_project
276 if fixed_version && fixed_version.project != project && !project.shared_versions.include?(fixed_version)
276 if fixed_version && fixed_version.project != project && !project.shared_versions.include?(fixed_version)
277 self.fixed_version = nil
277 self.fixed_version = nil
278 end
278 end
279 if parent && parent.project_id != project_id
279 if parent && parent.project_id != project_id
280 self.parent_issue_id = nil
280 self.parent_issue_id = nil
281 end
281 end
282 @custom_field_values = nil
282 @custom_field_values = nil
283 end
283 end
284 end
284 end
285
285
286 def description=(arg)
286 def description=(arg)
287 if arg.is_a?(String)
287 if arg.is_a?(String)
288 arg = arg.gsub(/(\r\n|\n|\r)/, "\r\n")
288 arg = arg.gsub(/(\r\n|\n|\r)/, "\r\n")
289 end
289 end
290 write_attribute(:description, arg)
290 write_attribute(:description, arg)
291 end
291 end
292
292
293 # Overrides assign_attributes so that project and tracker get assigned first
293 # Overrides assign_attributes so that project and tracker get assigned first
294 def assign_attributes_with_project_and_tracker_first(new_attributes, *args)
294 def assign_attributes_with_project_and_tracker_first(new_attributes, *args)
295 return if new_attributes.nil?
295 return if new_attributes.nil?
296 attrs = new_attributes.dup
296 attrs = new_attributes.dup
297 attrs.stringify_keys!
297 attrs.stringify_keys!
298
298
299 %w(project project_id tracker tracker_id).each do |attr|
299 %w(project project_id tracker tracker_id).each do |attr|
300 if attrs.has_key?(attr)
300 if attrs.has_key?(attr)
301 send "#{attr}=", attrs.delete(attr)
301 send "#{attr}=", attrs.delete(attr)
302 end
302 end
303 end
303 end
304 send :assign_attributes_without_project_and_tracker_first, attrs, *args
304 send :assign_attributes_without_project_and_tracker_first, attrs, *args
305 end
305 end
306 # Do not redefine alias chain on reload (see #4838)
306 # Do not redefine alias chain on reload (see #4838)
307 alias_method_chain(:assign_attributes, :project_and_tracker_first) unless method_defined?(:assign_attributes_without_project_and_tracker_first)
307 alias_method_chain(:assign_attributes, :project_and_tracker_first) unless method_defined?(:assign_attributes_without_project_and_tracker_first)
308
308
309 def estimated_hours=(h)
309 def estimated_hours=(h)
310 write_attribute :estimated_hours, (h.is_a?(String) ? h.to_hours : h)
310 write_attribute :estimated_hours, (h.is_a?(String) ? h.to_hours : h)
311 end
311 end
312
312
313 safe_attributes 'project_id',
313 safe_attributes 'project_id',
314 :if => lambda {|issue, user|
314 :if => lambda {|issue, user|
315 if issue.new_record?
315 if issue.new_record?
316 issue.copy?
316 issue.copy?
317 elsif user.allowed_to?(:move_issues, issue.project)
317 elsif user.allowed_to?(:move_issues, issue.project)
318 projects = Issue.allowed_target_projects_on_move(user)
318 projects = Issue.allowed_target_projects_on_move(user)
319 projects.include?(issue.project) && projects.size > 1
319 projects.include?(issue.project) && projects.size > 1
320 end
320 end
321 }
321 }
322
322
323 safe_attributes 'tracker_id',
323 safe_attributes 'tracker_id',
324 'status_id',
324 'status_id',
325 'category_id',
325 'category_id',
326 'assigned_to_id',
326 'assigned_to_id',
327 'priority_id',
327 'priority_id',
328 'fixed_version_id',
328 'fixed_version_id',
329 'subject',
329 'subject',
330 'description',
330 'description',
331 'start_date',
331 'start_date',
332 'due_date',
332 'due_date',
333 'done_ratio',
333 'done_ratio',
334 'estimated_hours',
334 'estimated_hours',
335 'custom_field_values',
335 'custom_field_values',
336 'custom_fields',
336 'custom_fields',
337 'lock_version',
337 'lock_version',
338 :if => lambda {|issue, user| issue.new_record? || user.allowed_to?(:edit_issues, issue.project) }
338 :if => lambda {|issue, user| issue.new_record? || user.allowed_to?(:edit_issues, issue.project) }
339
339
340 safe_attributes 'status_id',
340 safe_attributes 'status_id',
341 'assigned_to_id',
341 'assigned_to_id',
342 'fixed_version_id',
342 'fixed_version_id',
343 'done_ratio',
343 'done_ratio',
344 'lock_version',
344 'lock_version',
345 :if => lambda {|issue, user| issue.new_statuses_allowed_to(user).any? }
345 :if => lambda {|issue, user| issue.new_statuses_allowed_to(user).any? }
346
346
347 safe_attributes 'watcher_user_ids',
347 safe_attributes 'watcher_user_ids',
348 :if => lambda {|issue, user| issue.new_record? && user.allowed_to?(:add_issue_watchers, issue.project)}
348 :if => lambda {|issue, user| issue.new_record? && user.allowed_to?(:add_issue_watchers, issue.project)}
349
349
350 safe_attributes 'is_private',
350 safe_attributes 'is_private',
351 :if => lambda {|issue, user|
351 :if => lambda {|issue, user|
352 user.allowed_to?(:set_issues_private, issue.project) ||
352 user.allowed_to?(:set_issues_private, issue.project) ||
353 (issue.author == user && user.allowed_to?(:set_own_issues_private, issue.project))
353 (issue.author == user && user.allowed_to?(:set_own_issues_private, issue.project))
354 }
354 }
355
355
356 safe_attributes 'parent_issue_id',
356 safe_attributes 'parent_issue_id',
357 :if => lambda {|issue, user| (issue.new_record? || user.allowed_to?(:edit_issues, issue.project)) &&
357 :if => lambda {|issue, user| (issue.new_record? || user.allowed_to?(:edit_issues, issue.project)) &&
358 user.allowed_to?(:manage_subtasks, issue.project)}
358 user.allowed_to?(:manage_subtasks, issue.project)}
359
359
360 def safe_attribute_names(user=nil)
360 def safe_attribute_names(user=nil)
361 names = super
361 names = super
362 names -= disabled_core_fields
362 names -= disabled_core_fields
363 names -= read_only_attribute_names(user)
363 names -= read_only_attribute_names(user)
364 names
364 names
365 end
365 end
366
366
367 # Safely sets attributes
367 # Safely sets attributes
368 # Should be called from controllers instead of #attributes=
368 # Should be called from controllers instead of #attributes=
369 # attr_accessible is too rough because we still want things like
369 # attr_accessible is too rough because we still want things like
370 # Issue.new(:project => foo) to work
370 # Issue.new(:project => foo) to work
371 def safe_attributes=(attrs, user=User.current)
371 def safe_attributes=(attrs, user=User.current)
372 return unless attrs.is_a?(Hash)
372 return unless attrs.is_a?(Hash)
373
373
374 attrs = attrs.dup
374 attrs = attrs.dup
375
375
376 # Project and Tracker must be set before since new_statuses_allowed_to depends on it.
376 # Project and Tracker must be set before since new_statuses_allowed_to depends on it.
377 if (p = attrs.delete('project_id')) && safe_attribute?('project_id')
377 if (p = attrs.delete('project_id')) && safe_attribute?('project_id')
378 if allowed_target_projects(user).collect(&:id).include?(p.to_i)
378 if allowed_target_projects(user).collect(&:id).include?(p.to_i)
379 self.project_id = p
379 self.project_id = p
380 end
380 end
381 end
381 end
382
382
383 if (t = attrs.delete('tracker_id')) && safe_attribute?('tracker_id')
383 if (t = attrs.delete('tracker_id')) && safe_attribute?('tracker_id')
384 self.tracker_id = t
384 self.tracker_id = t
385 end
385 end
386
386
387 if (s = attrs.delete('status_id')) && safe_attribute?('status_id')
387 if (s = attrs.delete('status_id')) && safe_attribute?('status_id')
388 if new_statuses_allowed_to(user).collect(&:id).include?(s.to_i)
388 if new_statuses_allowed_to(user).collect(&:id).include?(s.to_i)
389 self.status_id = s
389 self.status_id = s
390 end
390 end
391 end
391 end
392
392
393 attrs = delete_unsafe_attributes(attrs, user)
393 attrs = delete_unsafe_attributes(attrs, user)
394 return if attrs.empty?
394 return if attrs.empty?
395
395
396 unless leaf?
396 unless leaf?
397 attrs.reject! {|k,v| %w(priority_id done_ratio start_date due_date estimated_hours).include?(k)}
397 attrs.reject! {|k,v| %w(priority_id done_ratio start_date due_date estimated_hours).include?(k)}
398 end
398 end
399
399
400 if attrs['parent_issue_id'].present?
400 if attrs['parent_issue_id'].present?
401 attrs.delete('parent_issue_id') unless Issue.visible(user).exists?(attrs['parent_issue_id'].to_i)
401 attrs.delete('parent_issue_id') unless Issue.visible(user).exists?(attrs['parent_issue_id'].to_i)
402 end
402 end
403
403
404 if attrs['custom_field_values'].present?
404 if attrs['custom_field_values'].present?
405 attrs['custom_field_values'] = attrs['custom_field_values'].reject {|k, v| read_only_attribute_names(user).include? k.to_s}
405 attrs['custom_field_values'] = attrs['custom_field_values'].reject {|k, v| read_only_attribute_names(user).include? k.to_s}
406 end
406 end
407
407
408 if attrs['custom_fields'].present?
408 if attrs['custom_fields'].present?
409 attrs['custom_fields'] = attrs['custom_fields'].reject {|c| read_only_attribute_names(user).include? c['id'].to_s}
409 attrs['custom_fields'] = attrs['custom_fields'].reject {|c| read_only_attribute_names(user).include? c['id'].to_s}
410 end
410 end
411
411
412 # mass-assignment security bypass
412 # mass-assignment security bypass
413 assign_attributes attrs, :without_protection => true
413 assign_attributes attrs, :without_protection => true
414 end
414 end
415
415
416 def disabled_core_fields
416 def disabled_core_fields
417 tracker ? tracker.disabled_core_fields : []
417 tracker ? tracker.disabled_core_fields : []
418 end
418 end
419
419
420 # Returns the custom_field_values that can be edited by the given user
420 # Returns the custom_field_values that can be edited by the given user
421 def editable_custom_field_values(user=nil)
421 def editable_custom_field_values(user=nil)
422 custom_field_values.reject do |value|
422 custom_field_values.reject do |value|
423 read_only_attribute_names(user).include?(value.custom_field_id.to_s)
423 read_only_attribute_names(user).include?(value.custom_field_id.to_s)
424 end
424 end
425 end
425 end
426
426
427 # Returns the names of attributes that are read-only for user or the current user
427 # Returns the names of attributes that are read-only for user or the current user
428 # For users with multiple roles, the read-only fields are the intersection of
428 # For users with multiple roles, the read-only fields are the intersection of
429 # read-only fields of each role
429 # read-only fields of each role
430 # The result is an array of strings where sustom fields are represented with their ids
430 # The result is an array of strings where sustom fields are represented with their ids
431 #
431 #
432 # Examples:
432 # Examples:
433 # issue.read_only_attribute_names # => ['due_date', '2']
433 # issue.read_only_attribute_names # => ['due_date', '2']
434 # issue.read_only_attribute_names(user) # => []
434 # issue.read_only_attribute_names(user) # => []
435 def read_only_attribute_names(user=nil)
435 def read_only_attribute_names(user=nil)
436 workflow_rule_by_attribute(user).reject {|attr, rule| rule != 'readonly'}.keys
436 workflow_rule_by_attribute(user).reject {|attr, rule| rule != 'readonly'}.keys
437 end
437 end
438
438
439 # Returns the names of required attributes for user or the current user
439 # Returns the names of required attributes for user or the current user
440 # For users with multiple roles, the required fields are the intersection of
440 # For users with multiple roles, the required fields are the intersection of
441 # required fields of each role
441 # required fields of each role
442 # The result is an array of strings where sustom fields are represented with their ids
442 # The result is an array of strings where sustom fields are represented with their ids
443 #
443 #
444 # Examples:
444 # Examples:
445 # issue.required_attribute_names # => ['due_date', '2']
445 # issue.required_attribute_names # => ['due_date', '2']
446 # issue.required_attribute_names(user) # => []
446 # issue.required_attribute_names(user) # => []
447 def required_attribute_names(user=nil)
447 def required_attribute_names(user=nil)
448 workflow_rule_by_attribute(user).reject {|attr, rule| rule != 'required'}.keys
448 workflow_rule_by_attribute(user).reject {|attr, rule| rule != 'required'}.keys
449 end
449 end
450
450
451 # Returns true if the attribute is required for user
451 # Returns true if the attribute is required for user
452 def required_attribute?(name, user=nil)
452 def required_attribute?(name, user=nil)
453 required_attribute_names(user).include?(name.to_s)
453 required_attribute_names(user).include?(name.to_s)
454 end
454 end
455
455
456 # Returns a hash of the workflow rule by attribute for the given user
456 # Returns a hash of the workflow rule by attribute for the given user
457 #
457 #
458 # Examples:
458 # Examples:
459 # issue.workflow_rule_by_attribute # => {'due_date' => 'required', 'start_date' => 'readonly'}
459 # issue.workflow_rule_by_attribute # => {'due_date' => 'required', 'start_date' => 'readonly'}
460 def workflow_rule_by_attribute(user=nil)
460 def workflow_rule_by_attribute(user=nil)
461 return @workflow_rule_by_attribute if @workflow_rule_by_attribute && user.nil?
461 return @workflow_rule_by_attribute if @workflow_rule_by_attribute && user.nil?
462
462
463 user_real = user || User.current
463 user_real = user || User.current
464 roles = user_real.admin ? Role.all : user_real.roles_for_project(project)
464 roles = user_real.admin ? Role.all : user_real.roles_for_project(project)
465 return {} if roles.empty?
465 return {} if roles.empty?
466
466
467 result = {}
467 result = {}
468 workflow_permissions = WorkflowPermission.where(:tracker_id => tracker_id, :old_status_id => status_id, :role_id => roles.map(&:id)).all
468 workflow_permissions = WorkflowPermission.where(:tracker_id => tracker_id, :old_status_id => status_id, :role_id => roles.map(&:id)).all
469 if workflow_permissions.any?
469 if workflow_permissions.any?
470 workflow_rules = workflow_permissions.inject({}) do |h, wp|
470 workflow_rules = workflow_permissions.inject({}) do |h, wp|
471 h[wp.field_name] ||= []
471 h[wp.field_name] ||= []
472 h[wp.field_name] << wp.rule
472 h[wp.field_name] << wp.rule
473 h
473 h
474 end
474 end
475 workflow_rules.each do |attr, rules|
475 workflow_rules.each do |attr, rules|
476 next if rules.size < roles.size
476 next if rules.size < roles.size
477 uniq_rules = rules.uniq
477 uniq_rules = rules.uniq
478 if uniq_rules.size == 1
478 if uniq_rules.size == 1
479 result[attr] = uniq_rules.first
479 result[attr] = uniq_rules.first
480 else
480 else
481 result[attr] = 'required'
481 result[attr] = 'required'
482 end
482 end
483 end
483 end
484 end
484 end
485 @workflow_rule_by_attribute = result if user.nil?
485 @workflow_rule_by_attribute = result if user.nil?
486 result
486 result
487 end
487 end
488 private :workflow_rule_by_attribute
488 private :workflow_rule_by_attribute
489
489
490 def done_ratio
490 def done_ratio
491 if Issue.use_status_for_done_ratio? && status && status.default_done_ratio
491 if Issue.use_status_for_done_ratio? && status && status.default_done_ratio
492 status.default_done_ratio
492 status.default_done_ratio
493 else
493 else
494 read_attribute(:done_ratio)
494 read_attribute(:done_ratio)
495 end
495 end
496 end
496 end
497
497
498 def self.use_status_for_done_ratio?
498 def self.use_status_for_done_ratio?
499 Setting.issue_done_ratio == 'issue_status'
499 Setting.issue_done_ratio == 'issue_status'
500 end
500 end
501
501
502 def self.use_field_for_done_ratio?
502 def self.use_field_for_done_ratio?
503 Setting.issue_done_ratio == 'issue_field'
503 Setting.issue_done_ratio == 'issue_field'
504 end
504 end
505
505
506 def validate_issue
506 def validate_issue
507 if self.due_date.nil? && @attributes['due_date'] && !@attributes['due_date'].empty?
507 if self.due_date.nil? && @attributes['due_date'] && !@attributes['due_date'].empty?
508 errors.add :due_date, :not_a_date
508 errors.add :due_date, :not_a_date
509 end
509 end
510
510
511 if self.due_date and self.start_date and self.due_date < self.start_date
511 if self.due_date and self.start_date and self.due_date < self.start_date
512 errors.add :due_date, :greater_than_start_date
512 errors.add :due_date, :greater_than_start_date
513 end
513 end
514
514
515 if start_date && soonest_start && start_date < soonest_start
515 if start_date && soonest_start && start_date < soonest_start
516 errors.add :start_date, :invalid
516 errors.add :start_date, :invalid
517 end
517 end
518
518
519 if fixed_version
519 if fixed_version
520 if !assignable_versions.include?(fixed_version)
520 if !assignable_versions.include?(fixed_version)
521 errors.add :fixed_version_id, :inclusion
521 errors.add :fixed_version_id, :inclusion
522 elsif reopened? && fixed_version.closed?
522 elsif reopened? && fixed_version.closed?
523 errors.add :base, I18n.t(:error_can_not_reopen_issue_on_closed_version)
523 errors.add :base, I18n.t(:error_can_not_reopen_issue_on_closed_version)
524 end
524 end
525 end
525 end
526
526
527 # Checks that the issue can not be added/moved to a disabled tracker
527 # Checks that the issue can not be added/moved to a disabled tracker
528 if project && (tracker_id_changed? || project_id_changed?)
528 if project && (tracker_id_changed? || project_id_changed?)
529 unless project.trackers.include?(tracker)
529 unless project.trackers.include?(tracker)
530 errors.add :tracker_id, :inclusion
530 errors.add :tracker_id, :inclusion
531 end
531 end
532 end
532 end
533
533
534 # Checks parent issue assignment
534 # Checks parent issue assignment
535 if @parent_issue
535 if @parent_issue
536 if @parent_issue.project_id != project_id
536 if @parent_issue.project_id != project_id
537 errors.add :parent_issue_id, :not_same_project
537 errors.add :parent_issue_id, :not_same_project
538 elsif !new_record?
538 elsif !new_record?
539 # moving an existing issue
539 # moving an existing issue
540 if @parent_issue.root_id != root_id
540 if @parent_issue.root_id != root_id
541 # we can always move to another tree
541 # we can always move to another tree
542 elsif move_possible?(@parent_issue)
542 elsif move_possible?(@parent_issue)
543 # move accepted inside tree
543 # move accepted inside tree
544 else
544 else
545 errors.add :parent_issue_id, :not_a_valid_parent
545 errors.add :parent_issue_id, :not_a_valid_parent
546 end
546 end
547 end
547 end
548 end
548 end
549 end
549 end
550
550
551 # Validates the issue against additional workflow requirements
551 # Validates the issue against additional workflow requirements
552 def validate_required_fields
552 def validate_required_fields
553 user = new_record? ? author : current_journal.try(:user)
553 user = new_record? ? author : current_journal.try(:user)
554
554
555 required_attribute_names(user).each do |attribute|
555 required_attribute_names(user).each do |attribute|
556 if attribute =~ /^\d+$/
556 if attribute =~ /^\d+$/
557 attribute = attribute.to_i
557 attribute = attribute.to_i
558 v = custom_field_values.detect {|v| v.custom_field_id == attribute }
558 v = custom_field_values.detect {|v| v.custom_field_id == attribute }
559 if v && v.value.blank?
559 if v && v.value.blank?
560 errors.add :base, v.custom_field.name + ' ' + l('activerecord.errors.messages.blank')
560 errors.add :base, v.custom_field.name + ' ' + l('activerecord.errors.messages.blank')
561 end
561 end
562 else
562 else
563 if respond_to?(attribute) && send(attribute).blank?
563 if respond_to?(attribute) && send(attribute).blank?
564 errors.add attribute, :blank
564 errors.add attribute, :blank
565 end
565 end
566 end
566 end
567 end
567 end
568 end
568 end
569
569
570 # Set the done_ratio using the status if that setting is set. This will keep the done_ratios
570 # Set the done_ratio using the status if that setting is set. This will keep the done_ratios
571 # even if the user turns off the setting later
571 # even if the user turns off the setting later
572 def update_done_ratio_from_issue_status
572 def update_done_ratio_from_issue_status
573 if Issue.use_status_for_done_ratio? && status && status.default_done_ratio
573 if Issue.use_status_for_done_ratio? && status && status.default_done_ratio
574 self.done_ratio = status.default_done_ratio
574 self.done_ratio = status.default_done_ratio
575 end
575 end
576 end
576 end
577
577
578 def init_journal(user, notes = "")
578 def init_journal(user, notes = "")
579 @current_journal ||= Journal.new(:journalized => self, :user => user, :notes => notes)
579 @current_journal ||= Journal.new(:journalized => self, :user => user, :notes => notes)
580 if new_record?
580 if new_record?
581 @current_journal.notify = false
581 @current_journal.notify = false
582 else
582 else
583 @attributes_before_change = attributes.dup
583 @attributes_before_change = attributes.dup
584 @custom_values_before_change = {}
584 @custom_values_before_change = {}
585 self.custom_field_values.each {|c| @custom_values_before_change.store c.custom_field_id, c.value }
585 self.custom_field_values.each {|c| @custom_values_before_change.store c.custom_field_id, c.value }
586 end
586 end
587 @current_journal
587 @current_journal
588 end
588 end
589
589
590 # Returns the id of the last journal or nil
590 # Returns the id of the last journal or nil
591 def last_journal_id
591 def last_journal_id
592 if new_record?
592 if new_record?
593 nil
593 nil
594 else
594 else
595 journals.maximum(:id)
595 journals.maximum(:id)
596 end
596 end
597 end
597 end
598
598
599 # Returns a scope for journals that have an id greater than journal_id
599 # Returns a scope for journals that have an id greater than journal_id
600 def journals_after(journal_id)
600 def journals_after(journal_id)
601 scope = journals.reorder("#{Journal.table_name}.id ASC")
601 scope = journals.reorder("#{Journal.table_name}.id ASC")
602 if journal_id.present?
602 if journal_id.present?
603 scope = scope.where("#{Journal.table_name}.id > ?", journal_id.to_i)
603 scope = scope.where("#{Journal.table_name}.id > ?", journal_id.to_i)
604 end
604 end
605 scope
605 scope
606 end
606 end
607
607
608 # Return true if the issue is closed, otherwise false
608 # Return true if the issue is closed, otherwise false
609 def closed?
609 def closed?
610 self.status.is_closed?
610 self.status.is_closed?
611 end
611 end
612
612
613 # Return true if the issue is being reopened
613 # Return true if the issue is being reopened
614 def reopened?
614 def reopened?
615 if !new_record? && status_id_changed?
615 if !new_record? && status_id_changed?
616 status_was = IssueStatus.find_by_id(status_id_was)
616 status_was = IssueStatus.find_by_id(status_id_was)
617 status_new = IssueStatus.find_by_id(status_id)
617 status_new = IssueStatus.find_by_id(status_id)
618 if status_was && status_new && status_was.is_closed? && !status_new.is_closed?
618 if status_was && status_new && status_was.is_closed? && !status_new.is_closed?
619 return true
619 return true
620 end
620 end
621 end
621 end
622 false
622 false
623 end
623 end
624
624
625 # Return true if the issue is being closed
625 # Return true if the issue is being closed
626 def closing?
626 def closing?
627 if !new_record? && status_id_changed?
627 if !new_record? && status_id_changed?
628 status_was = IssueStatus.find_by_id(status_id_was)
628 status_was = IssueStatus.find_by_id(status_id_was)
629 status_new = IssueStatus.find_by_id(status_id)
629 status_new = IssueStatus.find_by_id(status_id)
630 if status_was && status_new && !status_was.is_closed? && status_new.is_closed?
630 if status_was && status_new && !status_was.is_closed? && status_new.is_closed?
631 return true
631 return true
632 end
632 end
633 end
633 end
634 false
634 false
635 end
635 end
636
636
637 # Returns true if the issue is overdue
637 # Returns true if the issue is overdue
638 def overdue?
638 def overdue?
639 !due_date.nil? && (due_date < Date.today) && !status.is_closed?
639 !due_date.nil? && (due_date < Date.today) && !status.is_closed?
640 end
640 end
641
641
642 # Is the amount of work done less than it should for the due date
642 # Is the amount of work done less than it should for the due date
643 def behind_schedule?
643 def behind_schedule?
644 return false if start_date.nil? || due_date.nil?
644 return false if start_date.nil? || due_date.nil?
645 done_date = start_date + ((due_date - start_date+1)* done_ratio/100).floor
645 done_date = start_date + ((due_date - start_date+1)* done_ratio/100).floor
646 return done_date <= Date.today
646 return done_date <= Date.today
647 end
647 end
648
648
649 # Does this issue have children?
649 # Does this issue have children?
650 def children?
650 def children?
651 !leaf?
651 !leaf?
652 end
652 end
653
653
654 # Users the issue can be assigned to
654 # Users the issue can be assigned to
655 def assignable_users
655 def assignable_users
656 users = project.assignable_users
656 users = project.assignable_users
657 users << author if author
657 users << author if author
658 users << assigned_to if assigned_to
658 users << assigned_to if assigned_to
659 users.uniq.sort
659 users.uniq.sort
660 end
660 end
661
661
662 # Versions that the issue can be assigned to
662 # Versions that the issue can be assigned to
663 def assignable_versions
663 def assignable_versions
664 return @assignable_versions if @assignable_versions
664 return @assignable_versions if @assignable_versions
665
665
666 versions = project.shared_versions.open.all
666 versions = project.shared_versions.open.all
667 if fixed_version
667 if fixed_version
668 if fixed_version_id_changed?
668 if fixed_version_id_changed?
669 # nothing to do
669 # nothing to do
670 elsif project_id_changed?
670 elsif project_id_changed?
671 if project.shared_versions.include?(fixed_version)
671 if project.shared_versions.include?(fixed_version)
672 versions << fixed_version
672 versions << fixed_version
673 end
673 end
674 else
674 else
675 versions << fixed_version
675 versions << fixed_version
676 end
676 end
677 end
677 end
678 @assignable_versions = versions.uniq.sort
678 @assignable_versions = versions.uniq.sort
679 end
679 end
680
680
681 # Returns true if this issue is blocked by another issue that is still open
681 # Returns true if this issue is blocked by another issue that is still open
682 def blocked?
682 def blocked?
683 !relations_to.detect {|ir| ir.relation_type == 'blocks' && !ir.issue_from.closed?}.nil?
683 !relations_to.detect {|ir| ir.relation_type == 'blocks' && !ir.issue_from.closed?}.nil?
684 end
684 end
685
685
686 # Returns an array of statuses that user is able to apply
686 # Returns an array of statuses that user is able to apply
687 def new_statuses_allowed_to(user=User.current, include_default=false)
687 def new_statuses_allowed_to(user=User.current, include_default=false)
688 if new_record? && @copied_from
688 if new_record? && @copied_from
689 [IssueStatus.default, @copied_from.status].compact.uniq.sort
689 [IssueStatus.default, @copied_from.status].compact.uniq.sort
690 else
690 else
691 initial_status = nil
691 initial_status = nil
692 if new_record?
692 if new_record?
693 initial_status = IssueStatus.default
693 initial_status = IssueStatus.default
694 elsif status_id_was
694 elsif status_id_was
695 initial_status = IssueStatus.find_by_id(status_id_was)
695 initial_status = IssueStatus.find_by_id(status_id_was)
696 end
696 end
697 initial_status ||= status
697 initial_status ||= status
698
698
699 statuses = initial_status.find_new_statuses_allowed_to(
699 statuses = initial_status.find_new_statuses_allowed_to(
700 user.admin ? Role.all : user.roles_for_project(project),
700 user.admin ? Role.all : user.roles_for_project(project),
701 tracker,
701 tracker,
702 author == user,
702 author == user,
703 assigned_to_id_changed? ? assigned_to_id_was == user.id : assigned_to_id == user.id
703 assigned_to_id_changed? ? assigned_to_id_was == user.id : assigned_to_id == user.id
704 )
704 )
705 statuses << initial_status unless statuses.empty?
705 statuses << initial_status unless statuses.empty?
706 statuses << IssueStatus.default if include_default
706 statuses << IssueStatus.default if include_default
707 statuses = statuses.compact.uniq.sort
707 statuses = statuses.compact.uniq.sort
708 blocked? ? statuses.reject {|s| s.is_closed?} : statuses
708 blocked? ? statuses.reject {|s| s.is_closed?} : statuses
709 end
709 end
710 end
710 end
711
711
712 def assigned_to_was
712 def assigned_to_was
713 if assigned_to_id_changed? && assigned_to_id_was.present?
713 if assigned_to_id_changed? && assigned_to_id_was.present?
714 @assigned_to_was ||= User.find_by_id(assigned_to_id_was)
714 @assigned_to_was ||= User.find_by_id(assigned_to_id_was)
715 end
715 end
716 end
716 end
717
717
718 # Returns the mail adresses of users that should be notified
718 # Returns the mail adresses of users that should be notified
719 def recipients
719 def recipients
720 notified = []
720 notified = []
721 # Author and assignee are always notified unless they have been
721 # Author and assignee are always notified unless they have been
722 # locked or don't want to be notified
722 # locked or don't want to be notified
723 notified << author if author
723 notified << author if author
724 if assigned_to
724 if assigned_to
725 notified += (assigned_to.is_a?(Group) ? assigned_to.users : [assigned_to])
725 notified += (assigned_to.is_a?(Group) ? assigned_to.users : [assigned_to])
726 end
726 end
727 if assigned_to_was
727 if assigned_to_was
728 notified += (assigned_to_was.is_a?(Group) ? assigned_to_was.users : [assigned_to_was])
728 notified += (assigned_to_was.is_a?(Group) ? assigned_to_was.users : [assigned_to_was])
729 end
729 end
730 notified = notified.select {|u| u.active? && u.notify_about?(self)}
730 notified = notified.select {|u| u.active? && u.notify_about?(self)}
731
731
732 notified += project.notified_users
732 notified += project.notified_users
733 notified.uniq!
733 notified.uniq!
734 # Remove users that can not view the issue
734 # Remove users that can not view the issue
735 notified.reject! {|user| !visible?(user)}
735 notified.reject! {|user| !visible?(user)}
736 notified.collect(&:mail)
736 notified.collect(&:mail)
737 end
737 end
738
738
739 # Returns the number of hours spent on this issue
739 # Returns the number of hours spent on this issue
740 def spent_hours
740 def spent_hours
741 @spent_hours ||= time_entries.sum(:hours) || 0
741 @spent_hours ||= time_entries.sum(:hours) || 0
742 end
742 end
743
743
744 # Returns the total number of hours spent on this issue and its descendants
744 # Returns the total number of hours spent on this issue and its descendants
745 #
745 #
746 # Example:
746 # Example:
747 # spent_hours => 0.0
747 # spent_hours => 0.0
748 # spent_hours => 50.2
748 # spent_hours => 50.2
749 def total_spent_hours
749 def total_spent_hours
750 @total_spent_hours ||= self_and_descendants.sum("#{TimeEntry.table_name}.hours",
750 @total_spent_hours ||= self_and_descendants.sum("#{TimeEntry.table_name}.hours",
751 :joins => "LEFT JOIN #{TimeEntry.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id").to_f || 0.0
751 :joins => "LEFT JOIN #{TimeEntry.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id").to_f || 0.0
752 end
752 end
753
753
754 def relations
754 def relations
755 @relations ||= (relations_from + relations_to).sort
755 @relations ||= (relations_from + relations_to).sort
756 end
756 end
757
757
758 # Preloads relations for a collection of issues
758 # Preloads relations for a collection of issues
759 def self.load_relations(issues)
759 def self.load_relations(issues)
760 if issues.any?
760 if issues.any?
761 relations = IssueRelation.all(:conditions => ["issue_from_id IN (:ids) OR issue_to_id IN (:ids)", {:ids => issues.map(&:id)}])
761 relations = IssueRelation.all(:conditions => ["issue_from_id IN (:ids) OR issue_to_id IN (:ids)", {:ids => issues.map(&:id)}])
762 issues.each do |issue|
762 issues.each do |issue|
763 issue.instance_variable_set "@relations", relations.select {|r| r.issue_from_id == issue.id || r.issue_to_id == issue.id}
763 issue.instance_variable_set "@relations", relations.select {|r| r.issue_from_id == issue.id || r.issue_to_id == issue.id}
764 end
764 end
765 end
765 end
766 end
766 end
767
767
768 # Preloads visible spent time for a collection of issues
768 # Preloads visible spent time for a collection of issues
769 def self.load_visible_spent_hours(issues, user=User.current)
769 def self.load_visible_spent_hours(issues, user=User.current)
770 if issues.any?
770 if issues.any?
771 hours_by_issue_id = TimeEntry.visible(user).sum(:hours, :group => :issue_id)
771 hours_by_issue_id = TimeEntry.visible(user).sum(:hours, :group => :issue_id)
772 issues.each do |issue|
772 issues.each do |issue|
773 issue.instance_variable_set "@spent_hours", (hours_by_issue_id[issue.id] || 0)
773 issue.instance_variable_set "@spent_hours", (hours_by_issue_id[issue.id] || 0)
774 end
774 end
775 end
775 end
776 end
776 end
777
777
778 # Finds an issue relation given its id.
778 # Finds an issue relation given its id.
779 def find_relation(relation_id)
779 def find_relation(relation_id)
780 IssueRelation.find(relation_id, :conditions => ["issue_to_id = ? OR issue_from_id = ?", id, id])
780 IssueRelation.find(relation_id, :conditions => ["issue_to_id = ? OR issue_from_id = ?", id, id])
781 end
781 end
782
782
783 def all_dependent_issues(except=[])
783 def all_dependent_issues(except=[])
784 except << self
784 except << self
785 dependencies = []
785 dependencies = []
786 relations_from.each do |relation|
786 relations_from.each do |relation|
787 if relation.issue_to && !except.include?(relation.issue_to)
787 if relation.issue_to && !except.include?(relation.issue_to)
788 dependencies << relation.issue_to
788 dependencies << relation.issue_to
789 dependencies += relation.issue_to.all_dependent_issues(except)
789 dependencies += relation.issue_to.all_dependent_issues(except)
790 end
790 end
791 end
791 end
792 dependencies
792 dependencies
793 end
793 end
794
794
795 # Returns an array of issues that duplicate this one
795 # Returns an array of issues that duplicate this one
796 def duplicates
796 def duplicates
797 relations_to.select {|r| r.relation_type == IssueRelation::TYPE_DUPLICATES}.collect {|r| r.issue_from}
797 relations_to.select {|r| r.relation_type == IssueRelation::TYPE_DUPLICATES}.collect {|r| r.issue_from}
798 end
798 end
799
799
800 # Returns the due date or the target due date if any
800 # Returns the due date or the target due date if any
801 # Used on gantt chart
801 # Used on gantt chart
802 def due_before
802 def due_before
803 due_date || (fixed_version ? fixed_version.effective_date : nil)
803 due_date || (fixed_version ? fixed_version.effective_date : nil)
804 end
804 end
805
805
806 # Returns the time scheduled for this issue.
806 # Returns the time scheduled for this issue.
807 #
807 #
808 # Example:
808 # Example:
809 # Start Date: 2/26/09, End Date: 3/04/09
809 # Start Date: 2/26/09, End Date: 3/04/09
810 # duration => 6
810 # duration => 6
811 def duration
811 def duration
812 (start_date && due_date) ? due_date - start_date : 0
812 (start_date && due_date) ? due_date - start_date : 0
813 end
813 end
814
814
815 def soonest_start
815 def soonest_start
816 @soonest_start ||= (
816 @soonest_start ||= (
817 relations_to.collect{|relation| relation.successor_soonest_start} +
817 relations_to.collect{|relation| relation.successor_soonest_start} +
818 ancestors.collect(&:soonest_start)
818 ancestors.collect(&:soonest_start)
819 ).compact.max
819 ).compact.max
820 end
820 end
821
821
822 def reschedule_after(date)
822 def reschedule_after(date)
823 return if date.nil?
823 return if date.nil?
824 if leaf?
824 if leaf?
825 if start_date.nil? || start_date < date
825 if start_date.nil? || start_date < date
826 self.start_date, self.due_date = date, date + duration
826 self.start_date, self.due_date = date, date + duration
827 begin
827 begin
828 save
828 save
829 rescue ActiveRecord::StaleObjectError
829 rescue ActiveRecord::StaleObjectError
830 reload
830 reload
831 self.start_date, self.due_date = date, date + duration
831 self.start_date, self.due_date = date, date + duration
832 save
832 save
833 end
833 end
834 end
834 end
835 else
835 else
836 leaves.each do |leaf|
836 leaves.each do |leaf|
837 leaf.reschedule_after(date)
837 leaf.reschedule_after(date)
838 end
838 end
839 end
839 end
840 end
840 end
841
841
842 def <=>(issue)
842 def <=>(issue)
843 if issue.nil?
843 if issue.nil?
844 -1
844 -1
845 elsif root_id != issue.root_id
845 elsif root_id != issue.root_id
846 (root_id || 0) <=> (issue.root_id || 0)
846 (root_id || 0) <=> (issue.root_id || 0)
847 else
847 else
848 (lft || 0) <=> (issue.lft || 0)
848 (lft || 0) <=> (issue.lft || 0)
849 end
849 end
850 end
850 end
851
851
852 def to_s
852 def to_s
853 "#{tracker} ##{id}: #{subject}"
853 "#{tracker} ##{id}: #{subject}"
854 end
854 end
855
855
856 # Returns a string of css classes that apply to the issue
856 # Returns a string of css classes that apply to the issue
857 def css_classes
857 def css_classes
858 s = "issue status-#{status_id} priority-#{priority_id}"
858 s = "issue status-#{status_id} priority-#{priority_id}"
859 s << ' closed' if closed?
859 s << ' closed' if closed?
860 s << ' overdue' if overdue?
860 s << ' overdue' if overdue?
861 s << ' child' if child?
861 s << ' child' if child?
862 s << ' parent' unless leaf?
862 s << ' parent' unless leaf?
863 s << ' private' if is_private?
863 s << ' private' if is_private?
864 s << ' created-by-me' if User.current.logged? && author_id == User.current.id
864 s << ' created-by-me' if User.current.logged? && author_id == User.current.id
865 s << ' assigned-to-me' if User.current.logged? && assigned_to_id == User.current.id
865 s << ' assigned-to-me' if User.current.logged? && assigned_to_id == User.current.id
866 s
866 s
867 end
867 end
868
868
869 # Saves an issue and a time_entry from the parameters
869 # Saves an issue and a time_entry from the parameters
870 def save_issue_with_child_records(params, existing_time_entry=nil)
870 def save_issue_with_child_records(params, existing_time_entry=nil)
871 Issue.transaction do
871 Issue.transaction do
872 if params[:time_entry] && (params[:time_entry][:hours].present? || params[:time_entry][:comments].present?) && User.current.allowed_to?(:log_time, project)
872 if params[:time_entry] && (params[:time_entry][:hours].present? || params[:time_entry][:comments].present?) && User.current.allowed_to?(:log_time, project)
873 @time_entry = existing_time_entry || TimeEntry.new
873 @time_entry = existing_time_entry || TimeEntry.new
874 @time_entry.project = project
874 @time_entry.project = project
875 @time_entry.issue = self
875 @time_entry.issue = self
876 @time_entry.user = User.current
876 @time_entry.user = User.current
877 @time_entry.spent_on = User.current.today
877 @time_entry.spent_on = User.current.today
878 @time_entry.attributes = params[:time_entry]
878 @time_entry.attributes = params[:time_entry]
879 self.time_entries << @time_entry
879 self.time_entries << @time_entry
880 end
880 end
881
881
882 # TODO: Rename hook
882 # TODO: Rename hook
883 Redmine::Hook.call_hook(:controller_issues_edit_before_save, { :params => params, :issue => self, :time_entry => @time_entry, :journal => @current_journal})
883 Redmine::Hook.call_hook(:controller_issues_edit_before_save, { :params => params, :issue => self, :time_entry => @time_entry, :journal => @current_journal})
884 if save
884 if save
885 # TODO: Rename hook
885 # TODO: Rename hook
886 Redmine::Hook.call_hook(:controller_issues_edit_after_save, { :params => params, :issue => self, :time_entry => @time_entry, :journal => @current_journal})
886 Redmine::Hook.call_hook(:controller_issues_edit_after_save, { :params => params, :issue => self, :time_entry => @time_entry, :journal => @current_journal})
887 else
887 else
888 raise ActiveRecord::Rollback
888 raise ActiveRecord::Rollback
889 end
889 end
890 end
890 end
891 end
891 end
892
892
893 # Unassigns issues from +version+ if it's no longer shared with issue's project
893 # Unassigns issues from +version+ if it's no longer shared with issue's project
894 def self.update_versions_from_sharing_change(version)
894 def self.update_versions_from_sharing_change(version)
895 # Update issues assigned to the version
895 # Update issues assigned to the version
896 update_versions(["#{Issue.table_name}.fixed_version_id = ?", version.id])
896 update_versions(["#{Issue.table_name}.fixed_version_id = ?", version.id])
897 end
897 end
898
898
899 # Unassigns issues from versions that are no longer shared
899 # Unassigns issues from versions that are no longer shared
900 # after +project+ was moved
900 # after +project+ was moved
901 def self.update_versions_from_hierarchy_change(project)
901 def self.update_versions_from_hierarchy_change(project)
902 moved_project_ids = project.self_and_descendants.reload.collect(&:id)
902 moved_project_ids = project.self_and_descendants.reload.collect(&:id)
903 # Update issues of the moved projects and issues assigned to a version of a moved project
903 # Update issues of the moved projects and issues assigned to a version of a moved project
904 Issue.update_versions(["#{Version.table_name}.project_id IN (?) OR #{Issue.table_name}.project_id IN (?)", moved_project_ids, moved_project_ids])
904 Issue.update_versions(["#{Version.table_name}.project_id IN (?) OR #{Issue.table_name}.project_id IN (?)", moved_project_ids, moved_project_ids])
905 end
905 end
906
906
907 def parent_issue_id=(arg)
907 def parent_issue_id=(arg)
908 parent_issue_id = arg.blank? ? nil : arg.to_i
908 parent_issue_id = arg.blank? ? nil : arg.to_i
909 if parent_issue_id && @parent_issue = Issue.find_by_id(parent_issue_id)
909 if parent_issue_id && @parent_issue = Issue.find_by_id(parent_issue_id)
910 @parent_issue.id
910 @parent_issue.id
911 else
911 else
912 @parent_issue = nil
912 @parent_issue = nil
913 nil
913 nil
914 end
914 end
915 end
915 end
916
916
917 def parent_issue_id
917 def parent_issue_id
918 if instance_variable_defined? :@parent_issue
918 if instance_variable_defined? :@parent_issue
919 @parent_issue.nil? ? nil : @parent_issue.id
919 @parent_issue.nil? ? nil : @parent_issue.id
920 else
920 else
921 parent_id
921 parent_id
922 end
922 end
923 end
923 end
924
924
925 # Extracted from the ReportsController.
925 # Extracted from the ReportsController.
926 def self.by_tracker(project)
926 def self.by_tracker(project)
927 count_and_group_by(:project => project,
927 count_and_group_by(:project => project,
928 :field => 'tracker_id',
928 :field => 'tracker_id',
929 :joins => Tracker.table_name)
929 :joins => Tracker.table_name)
930 end
930 end
931
931
932 def self.by_version(project)
932 def self.by_version(project)
933 count_and_group_by(:project => project,
933 count_and_group_by(:project => project,
934 :field => 'fixed_version_id',
934 :field => 'fixed_version_id',
935 :joins => Version.table_name)
935 :joins => Version.table_name)
936 end
936 end
937
937
938 def self.by_priority(project)
938 def self.by_priority(project)
939 count_and_group_by(:project => project,
939 count_and_group_by(:project => project,
940 :field => 'priority_id',
940 :field => 'priority_id',
941 :joins => IssuePriority.table_name)
941 :joins => IssuePriority.table_name)
942 end
942 end
943
943
944 def self.by_category(project)
944 def self.by_category(project)
945 count_and_group_by(:project => project,
945 count_and_group_by(:project => project,
946 :field => 'category_id',
946 :field => 'category_id',
947 :joins => IssueCategory.table_name)
947 :joins => IssueCategory.table_name)
948 end
948 end
949
949
950 def self.by_assigned_to(project)
950 def self.by_assigned_to(project)
951 count_and_group_by(:project => project,
951 count_and_group_by(:project => project,
952 :field => 'assigned_to_id',
952 :field => 'assigned_to_id',
953 :joins => User.table_name)
953 :joins => User.table_name)
954 end
954 end
955
955
956 def self.by_author(project)
956 def self.by_author(project)
957 count_and_group_by(:project => project,
957 count_and_group_by(:project => project,
958 :field => 'author_id',
958 :field => 'author_id',
959 :joins => User.table_name)
959 :joins => User.table_name)
960 end
960 end
961
961
962 def self.by_subproject(project)
962 def self.by_subproject(project)
963 ActiveRecord::Base.connection.select_all("select s.id as status_id,
963 ActiveRecord::Base.connection.select_all("select s.id as status_id,
964 s.is_closed as closed,
964 s.is_closed as closed,
965 #{Issue.table_name}.project_id as project_id,
965 #{Issue.table_name}.project_id as project_id,
966 count(#{Issue.table_name}.id) as total
966 count(#{Issue.table_name}.id) as total
967 from
967 from
968 #{Issue.table_name}, #{Project.table_name}, #{IssueStatus.table_name} s
968 #{Issue.table_name}, #{Project.table_name}, #{IssueStatus.table_name} s
969 where
969 where
970 #{Issue.table_name}.status_id=s.id
970 #{Issue.table_name}.status_id=s.id
971 and #{Issue.table_name}.project_id = #{Project.table_name}.id
971 and #{Issue.table_name}.project_id = #{Project.table_name}.id
972 and #{visible_condition(User.current, :project => project, :with_subprojects => true)}
972 and #{visible_condition(User.current, :project => project, :with_subprojects => true)}
973 and #{Issue.table_name}.project_id <> #{project.id}
973 and #{Issue.table_name}.project_id <> #{project.id}
974 group by s.id, s.is_closed, #{Issue.table_name}.project_id") if project.descendants.active.any?
974 group by s.id, s.is_closed, #{Issue.table_name}.project_id") if project.descendants.active.any?
975 end
975 end
976 # End ReportsController extraction
976 # End ReportsController extraction
977
977
978 # Returns an array of projects that user can assign the issue to
978 # Returns an array of projects that user can assign the issue to
979 def allowed_target_projects(user=User.current)
979 def allowed_target_projects(user=User.current)
980 if new_record?
980 if new_record?
981 Project.all(:conditions => Project.allowed_to_condition(user, :add_issues))
981 Project.all(:conditions => Project.allowed_to_condition(user, :add_issues))
982 else
982 else
983 self.class.allowed_target_projects_on_move(user)
983 self.class.allowed_target_projects_on_move(user)
984 end
984 end
985 end
985 end
986
986
987 # Returns an array of projects that user can move issues to
987 # Returns an array of projects that user can move issues to
988 def self.allowed_target_projects_on_move(user=User.current)
988 def self.allowed_target_projects_on_move(user=User.current)
989 Project.all(:conditions => Project.allowed_to_condition(user, :move_issues))
989 Project.all(:conditions => Project.allowed_to_condition(user, :move_issues))
990 end
990 end
991
991
992 private
992 private
993
993
994 def after_project_change
994 def after_project_change
995 # Update project_id on related time entries
995 # Update project_id on related time entries
996 TimeEntry.update_all(["project_id = ?", project_id], {:issue_id => id})
996 TimeEntry.update_all(["project_id = ?", project_id], {:issue_id => id})
997
997
998 # Delete issue relations
998 # Delete issue relations
999 unless Setting.cross_project_issue_relations?
999 unless Setting.cross_project_issue_relations?
1000 relations_from.clear
1000 relations_from.clear
1001 relations_to.clear
1001 relations_to.clear
1002 end
1002 end
1003
1003
1004 # Move subtasks
1004 # Move subtasks
1005 children.each do |child|
1005 children.each do |child|
1006 # Change project and keep project
1006 # Change project and keep project
1007 child.send :project=, project, true
1007 child.send :project=, project, true
1008 unless child.save
1008 unless child.save
1009 raise ActiveRecord::Rollback
1009 raise ActiveRecord::Rollback
1010 end
1010 end
1011 end
1011 end
1012 end
1012 end
1013
1013
1014 # Copies subtasks from the copied issue
1014 # Callback for after the creation of an issue by copy
1015 # * adds a "copied to" relation with the copied issue
1016 # * copies subtasks from the copied issue
1015 def after_create_from_copy
1017 def after_create_from_copy
1016 return unless copy?
1018 return unless copy? && !@after_create_from_copy_handled
1017
1019
1018 unless @copied_from.leaf? || @copy_options[:subtasks] == false || @subtasks_copied
1020 if @copied_from.project_id == project_id || Setting.cross_project_issue_relations?
1021 relation = IssueRelation.new(:issue_from => @copied_from, :issue_to => self, :relation_type => IssueRelation::TYPE_COPIED_TO)
1022 unless relation.save
1023 logger.error "Could not create relation while copying ##{@copied_from.id} to ##{id} due to validation errors: #{relation.errors.full_messages.join(', ')}" if logger
1024 end
1025 end
1026
1027 unless @copied_from.leaf? || @copy_options[:subtasks] == false
1019 @copied_from.children.each do |child|
1028 @copied_from.children.each do |child|
1020 unless child.visible?
1029 unless child.visible?
1021 # Do not copy subtasks that are not visible to avoid potential disclosure of private data
1030 # Do not copy subtasks that are not visible to avoid potential disclosure of private data
1022 logger.error "Subtask ##{child.id} was not copied during ##{@copied_from.id} copy because it is not visible to the current user" if logger
1031 logger.error "Subtask ##{child.id} was not copied during ##{@copied_from.id} copy because it is not visible to the current user" if logger
1023 next
1032 next
1024 end
1033 end
1025 copy = Issue.new.copy_from(child, @copy_options)
1034 copy = Issue.new.copy_from(child, @copy_options)
1026 copy.author = author
1035 copy.author = author
1027 copy.project = project
1036 copy.project = project
1028 copy.parent_issue_id = id
1037 copy.parent_issue_id = id
1029 # Children subtasks are copied recursively
1038 # Children subtasks are copied recursively
1030 unless copy.save
1039 unless copy.save
1031 logger.error "Could not copy subtask ##{child.id} while copying ##{@copied_from.id} to ##{id} due to validation errors: #{copy.errors.full_messages.join(', ')}" if logger
1040 logger.error "Could not copy subtask ##{child.id} while copying ##{@copied_from.id} to ##{id} due to validation errors: #{copy.errors.full_messages.join(', ')}" if logger
1032 end
1041 end
1033 end
1042 end
1034 @subtasks_copied = true
1035 end
1043 end
1044 @after_create_from_copy_handled = true
1036 end
1045 end
1037
1046
1038 def update_nested_set_attributes
1047 def update_nested_set_attributes
1039 if root_id.nil?
1048 if root_id.nil?
1040 # issue was just created
1049 # issue was just created
1041 self.root_id = (@parent_issue.nil? ? id : @parent_issue.root_id)
1050 self.root_id = (@parent_issue.nil? ? id : @parent_issue.root_id)
1042 set_default_left_and_right
1051 set_default_left_and_right
1043 Issue.update_all("root_id = #{root_id}, lft = #{lft}, rgt = #{rgt}", ["id = ?", id])
1052 Issue.update_all("root_id = #{root_id}, lft = #{lft}, rgt = #{rgt}", ["id = ?", id])
1044 if @parent_issue
1053 if @parent_issue
1045 move_to_child_of(@parent_issue)
1054 move_to_child_of(@parent_issue)
1046 end
1055 end
1047 reload
1056 reload
1048 elsif parent_issue_id != parent_id
1057 elsif parent_issue_id != parent_id
1049 former_parent_id = parent_id
1058 former_parent_id = parent_id
1050 # moving an existing issue
1059 # moving an existing issue
1051 if @parent_issue && @parent_issue.root_id == root_id
1060 if @parent_issue && @parent_issue.root_id == root_id
1052 # inside the same tree
1061 # inside the same tree
1053 move_to_child_of(@parent_issue)
1062 move_to_child_of(@parent_issue)
1054 else
1063 else
1055 # to another tree
1064 # to another tree
1056 unless root?
1065 unless root?
1057 move_to_right_of(root)
1066 move_to_right_of(root)
1058 reload
1067 reload
1059 end
1068 end
1060 old_root_id = root_id
1069 old_root_id = root_id
1061 self.root_id = (@parent_issue.nil? ? id : @parent_issue.root_id )
1070 self.root_id = (@parent_issue.nil? ? id : @parent_issue.root_id )
1062 target_maxright = nested_set_scope.maximum(right_column_name) || 0
1071 target_maxright = nested_set_scope.maximum(right_column_name) || 0
1063 offset = target_maxright + 1 - lft
1072 offset = target_maxright + 1 - lft
1064 Issue.update_all("root_id = #{root_id}, lft = lft + #{offset}, rgt = rgt + #{offset}",
1073 Issue.update_all("root_id = #{root_id}, lft = lft + #{offset}, rgt = rgt + #{offset}",
1065 ["root_id = ? AND lft >= ? AND rgt <= ? ", old_root_id, lft, rgt])
1074 ["root_id = ? AND lft >= ? AND rgt <= ? ", old_root_id, lft, rgt])
1066 self[left_column_name] = lft + offset
1075 self[left_column_name] = lft + offset
1067 self[right_column_name] = rgt + offset
1076 self[right_column_name] = rgt + offset
1068 if @parent_issue
1077 if @parent_issue
1069 move_to_child_of(@parent_issue)
1078 move_to_child_of(@parent_issue)
1070 end
1079 end
1071 end
1080 end
1072 reload
1081 reload
1073 # delete invalid relations of all descendants
1082 # delete invalid relations of all descendants
1074 self_and_descendants.each do |issue|
1083 self_and_descendants.each do |issue|
1075 issue.relations.each do |relation|
1084 issue.relations.each do |relation|
1076 relation.destroy unless relation.valid?
1085 relation.destroy unless relation.valid?
1077 end
1086 end
1078 end
1087 end
1079 # update former parent
1088 # update former parent
1080 recalculate_attributes_for(former_parent_id) if former_parent_id
1089 recalculate_attributes_for(former_parent_id) if former_parent_id
1081 end
1090 end
1082 remove_instance_variable(:@parent_issue) if instance_variable_defined?(:@parent_issue)
1091 remove_instance_variable(:@parent_issue) if instance_variable_defined?(:@parent_issue)
1083 end
1092 end
1084
1093
1085 def update_parent_attributes
1094 def update_parent_attributes
1086 recalculate_attributes_for(parent_id) if parent_id
1095 recalculate_attributes_for(parent_id) if parent_id
1087 end
1096 end
1088
1097
1089 def recalculate_attributes_for(issue_id)
1098 def recalculate_attributes_for(issue_id)
1090 if issue_id && p = Issue.find_by_id(issue_id)
1099 if issue_id && p = Issue.find_by_id(issue_id)
1091 # priority = highest priority of children
1100 # priority = highest priority of children
1092 if priority_position = p.children.maximum("#{IssuePriority.table_name}.position", :joins => :priority)
1101 if priority_position = p.children.maximum("#{IssuePriority.table_name}.position", :joins => :priority)
1093 p.priority = IssuePriority.find_by_position(priority_position)
1102 p.priority = IssuePriority.find_by_position(priority_position)
1094 end
1103 end
1095
1104
1096 # start/due dates = lowest/highest dates of children
1105 # start/due dates = lowest/highest dates of children
1097 p.start_date = p.children.minimum(:start_date)
1106 p.start_date = p.children.minimum(:start_date)
1098 p.due_date = p.children.maximum(:due_date)
1107 p.due_date = p.children.maximum(:due_date)
1099 if p.start_date && p.due_date && p.due_date < p.start_date
1108 if p.start_date && p.due_date && p.due_date < p.start_date
1100 p.start_date, p.due_date = p.due_date, p.start_date
1109 p.start_date, p.due_date = p.due_date, p.start_date
1101 end
1110 end
1102
1111
1103 # done ratio = weighted average ratio of leaves
1112 # done ratio = weighted average ratio of leaves
1104 unless Issue.use_status_for_done_ratio? && p.status && p.status.default_done_ratio
1113 unless Issue.use_status_for_done_ratio? && p.status && p.status.default_done_ratio
1105 leaves_count = p.leaves.count
1114 leaves_count = p.leaves.count
1106 if leaves_count > 0
1115 if leaves_count > 0
1107 average = p.leaves.average(:estimated_hours).to_f
1116 average = p.leaves.average(:estimated_hours).to_f
1108 if average == 0
1117 if average == 0
1109 average = 1
1118 average = 1
1110 end
1119 end
1111 done = p.leaves.sum("COALESCE(estimated_hours, #{average}) * (CASE WHEN is_closed = #{connection.quoted_true} THEN 100 ELSE COALESCE(done_ratio, 0) END)", :joins => :status).to_f
1120 done = p.leaves.sum("COALESCE(estimated_hours, #{average}) * (CASE WHEN is_closed = #{connection.quoted_true} THEN 100 ELSE COALESCE(done_ratio, 0) END)", :joins => :status).to_f
1112 progress = done / (average * leaves_count)
1121 progress = done / (average * leaves_count)
1113 p.done_ratio = progress.round
1122 p.done_ratio = progress.round
1114 end
1123 end
1115 end
1124 end
1116
1125
1117 # estimate = sum of leaves estimates
1126 # estimate = sum of leaves estimates
1118 p.estimated_hours = p.leaves.sum(:estimated_hours).to_f
1127 p.estimated_hours = p.leaves.sum(:estimated_hours).to_f
1119 p.estimated_hours = nil if p.estimated_hours == 0.0
1128 p.estimated_hours = nil if p.estimated_hours == 0.0
1120
1129
1121 # ancestors will be recursively updated
1130 # ancestors will be recursively updated
1122 p.save(:validate => false)
1131 p.save(:validate => false)
1123 end
1132 end
1124 end
1133 end
1125
1134
1126 # Update issues so their versions are not pointing to a
1135 # Update issues so their versions are not pointing to a
1127 # fixed_version that is not shared with the issue's project
1136 # fixed_version that is not shared with the issue's project
1128 def self.update_versions(conditions=nil)
1137 def self.update_versions(conditions=nil)
1129 # Only need to update issues with a fixed_version from
1138 # Only need to update issues with a fixed_version from
1130 # a different project and that is not systemwide shared
1139 # a different project and that is not systemwide shared
1131 Issue.scoped(:conditions => conditions).all(
1140 Issue.scoped(:conditions => conditions).all(
1132 :conditions => "#{Issue.table_name}.fixed_version_id IS NOT NULL" +
1141 :conditions => "#{Issue.table_name}.fixed_version_id IS NOT NULL" +
1133 " AND #{Issue.table_name}.project_id <> #{Version.table_name}.project_id" +
1142 " AND #{Issue.table_name}.project_id <> #{Version.table_name}.project_id" +
1134 " AND #{Version.table_name}.sharing <> 'system'",
1143 " AND #{Version.table_name}.sharing <> 'system'",
1135 :include => [:project, :fixed_version]
1144 :include => [:project, :fixed_version]
1136 ).each do |issue|
1145 ).each do |issue|
1137 next if issue.project.nil? || issue.fixed_version.nil?
1146 next if issue.project.nil? || issue.fixed_version.nil?
1138 unless issue.project.shared_versions.include?(issue.fixed_version)
1147 unless issue.project.shared_versions.include?(issue.fixed_version)
1139 issue.init_journal(User.current)
1148 issue.init_journal(User.current)
1140 issue.fixed_version = nil
1149 issue.fixed_version = nil
1141 issue.save
1150 issue.save
1142 end
1151 end
1143 end
1152 end
1144 end
1153 end
1145
1154
1146 # Callback on file attachment
1155 # Callback on file attachment
1147 def attachment_added(obj)
1156 def attachment_added(obj)
1148 if @current_journal && !obj.new_record?
1157 if @current_journal && !obj.new_record?
1149 @current_journal.details << JournalDetail.new(:property => 'attachment', :prop_key => obj.id, :value => obj.filename)
1158 @current_journal.details << JournalDetail.new(:property => 'attachment', :prop_key => obj.id, :value => obj.filename)
1150 end
1159 end
1151 end
1160 end
1152
1161
1153 # Callback on attachment deletion
1162 # Callback on attachment deletion
1154 def attachment_removed(obj)
1163 def attachment_removed(obj)
1155 if @current_journal && !obj.new_record?
1164 if @current_journal && !obj.new_record?
1156 @current_journal.details << JournalDetail.new(:property => 'attachment', :prop_key => obj.id, :old_value => obj.filename)
1165 @current_journal.details << JournalDetail.new(:property => 'attachment', :prop_key => obj.id, :old_value => obj.filename)
1157 @current_journal.save
1166 @current_journal.save
1158 end
1167 end
1159 end
1168 end
1160
1169
1161 # Default assignment based on category
1170 # Default assignment based on category
1162 def default_assign
1171 def default_assign
1163 if assigned_to.nil? && category && category.assigned_to
1172 if assigned_to.nil? && category && category.assigned_to
1164 self.assigned_to = category.assigned_to
1173 self.assigned_to = category.assigned_to
1165 end
1174 end
1166 end
1175 end
1167
1176
1168 # Updates start/due dates of following issues
1177 # Updates start/due dates of following issues
1169 def reschedule_following_issues
1178 def reschedule_following_issues
1170 if start_date_changed? || due_date_changed?
1179 if start_date_changed? || due_date_changed?
1171 relations_from.each do |relation|
1180 relations_from.each do |relation|
1172 relation.set_issue_to_dates
1181 relation.set_issue_to_dates
1173 end
1182 end
1174 end
1183 end
1175 end
1184 end
1176
1185
1177 # Closes duplicates if the issue is being closed
1186 # Closes duplicates if the issue is being closed
1178 def close_duplicates
1187 def close_duplicates
1179 if closing?
1188 if closing?
1180 duplicates.each do |duplicate|
1189 duplicates.each do |duplicate|
1181 # Reload is need in case the duplicate was updated by a previous duplicate
1190 # Reload is need in case the duplicate was updated by a previous duplicate
1182 duplicate.reload
1191 duplicate.reload
1183 # Don't re-close it if it's already closed
1192 # Don't re-close it if it's already closed
1184 next if duplicate.closed?
1193 next if duplicate.closed?
1185 # Same user and notes
1194 # Same user and notes
1186 if @current_journal
1195 if @current_journal
1187 duplicate.init_journal(@current_journal.user, @current_journal.notes)
1196 duplicate.init_journal(@current_journal.user, @current_journal.notes)
1188 end
1197 end
1189 duplicate.update_attribute :status, self.status
1198 duplicate.update_attribute :status, self.status
1190 end
1199 end
1191 end
1200 end
1192 end
1201 end
1193
1202
1194 # Make sure updated_on is updated when adding a note
1203 # Make sure updated_on is updated when adding a note
1195 def force_updated_on_change
1204 def force_updated_on_change
1196 if @current_journal
1205 if @current_journal
1197 self.updated_on = current_time_from_proper_timezone
1206 self.updated_on = current_time_from_proper_timezone
1198 end
1207 end
1199 end
1208 end
1200
1209
1201 # Saves the changes in a Journal
1210 # Saves the changes in a Journal
1202 # Called after_save
1211 # Called after_save
1203 def create_journal
1212 def create_journal
1204 if @current_journal
1213 if @current_journal
1205 # attributes changes
1214 # attributes changes
1206 if @attributes_before_change
1215 if @attributes_before_change
1207 (Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on)).each {|c|
1216 (Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on)).each {|c|
1208 before = @attributes_before_change[c]
1217 before = @attributes_before_change[c]
1209 after = send(c)
1218 after = send(c)
1210 next if before == after || (before.blank? && after.blank?)
1219 next if before == after || (before.blank? && after.blank?)
1211 @current_journal.details << JournalDetail.new(:property => 'attr',
1220 @current_journal.details << JournalDetail.new(:property => 'attr',
1212 :prop_key => c,
1221 :prop_key => c,
1213 :old_value => before,
1222 :old_value => before,
1214 :value => after)
1223 :value => after)
1215 }
1224 }
1216 end
1225 end
1217 if @custom_values_before_change
1226 if @custom_values_before_change
1218 # custom fields changes
1227 # custom fields changes
1219 custom_field_values.each {|c|
1228 custom_field_values.each {|c|
1220 before = @custom_values_before_change[c.custom_field_id]
1229 before = @custom_values_before_change[c.custom_field_id]
1221 after = c.value
1230 after = c.value
1222 next if before == after || (before.blank? && after.blank?)
1231 next if before == after || (before.blank? && after.blank?)
1223
1232
1224 if before.is_a?(Array) || after.is_a?(Array)
1233 if before.is_a?(Array) || after.is_a?(Array)
1225 before = [before] unless before.is_a?(Array)
1234 before = [before] unless before.is_a?(Array)
1226 after = [after] unless after.is_a?(Array)
1235 after = [after] unless after.is_a?(Array)
1227
1236
1228 # values removed
1237 # values removed
1229 (before - after).reject(&:blank?).each do |value|
1238 (before - after).reject(&:blank?).each do |value|
1230 @current_journal.details << JournalDetail.new(:property => 'cf',
1239 @current_journal.details << JournalDetail.new(:property => 'cf',
1231 :prop_key => c.custom_field_id,
1240 :prop_key => c.custom_field_id,
1232 :old_value => value,
1241 :old_value => value,
1233 :value => nil)
1242 :value => nil)
1234 end
1243 end
1235 # values added
1244 # values added
1236 (after - before).reject(&:blank?).each do |value|
1245 (after - before).reject(&:blank?).each do |value|
1237 @current_journal.details << JournalDetail.new(:property => 'cf',
1246 @current_journal.details << JournalDetail.new(:property => 'cf',
1238 :prop_key => c.custom_field_id,
1247 :prop_key => c.custom_field_id,
1239 :old_value => nil,
1248 :old_value => nil,
1240 :value => value)
1249 :value => value)
1241 end
1250 end
1242 else
1251 else
1243 @current_journal.details << JournalDetail.new(:property => 'cf',
1252 @current_journal.details << JournalDetail.new(:property => 'cf',
1244 :prop_key => c.custom_field_id,
1253 :prop_key => c.custom_field_id,
1245 :old_value => before,
1254 :old_value => before,
1246 :value => after)
1255 :value => after)
1247 end
1256 end
1248 }
1257 }
1249 end
1258 end
1250 @current_journal.save
1259 @current_journal.save
1251 # reset current journal
1260 # reset current journal
1252 init_journal @current_journal.user, @current_journal.notes
1261 init_journal @current_journal.user, @current_journal.notes
1253 end
1262 end
1254 end
1263 end
1255
1264
1256 # Query generator for selecting groups of issue counts for a project
1265 # Query generator for selecting groups of issue counts for a project
1257 # based on specific criteria
1266 # based on specific criteria
1258 #
1267 #
1259 # Options
1268 # Options
1260 # * project - Project to search in.
1269 # * project - Project to search in.
1261 # * field - String. Issue field to key off of in the grouping.
1270 # * field - String. Issue field to key off of in the grouping.
1262 # * joins - String. The table name to join against.
1271 # * joins - String. The table name to join against.
1263 def self.count_and_group_by(options)
1272 def self.count_and_group_by(options)
1264 project = options.delete(:project)
1273 project = options.delete(:project)
1265 select_field = options.delete(:field)
1274 select_field = options.delete(:field)
1266 joins = options.delete(:joins)
1275 joins = options.delete(:joins)
1267
1276
1268 where = "#{Issue.table_name}.#{select_field}=j.id"
1277 where = "#{Issue.table_name}.#{select_field}=j.id"
1269
1278
1270 ActiveRecord::Base.connection.select_all("select s.id as status_id,
1279 ActiveRecord::Base.connection.select_all("select s.id as status_id,
1271 s.is_closed as closed,
1280 s.is_closed as closed,
1272 j.id as #{select_field},
1281 j.id as #{select_field},
1273 count(#{Issue.table_name}.id) as total
1282 count(#{Issue.table_name}.id) as total
1274 from
1283 from
1275 #{Issue.table_name}, #{Project.table_name}, #{IssueStatus.table_name} s, #{joins} j
1284 #{Issue.table_name}, #{Project.table_name}, #{IssueStatus.table_name} s, #{joins} j
1276 where
1285 where
1277 #{Issue.table_name}.status_id=s.id
1286 #{Issue.table_name}.status_id=s.id
1278 and #{where}
1287 and #{where}
1279 and #{Issue.table_name}.project_id=#{Project.table_name}.id
1288 and #{Issue.table_name}.project_id=#{Project.table_name}.id
1280 and #{visible_condition(User.current, :project => project)}
1289 and #{visible_condition(User.current, :project => project)}
1281 group by s.id, s.is_closed, j.id")
1290 group by s.id, s.is_closed, j.id")
1282 end
1291 end
1283 end
1292 end
@@ -1,143 +1,147
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang
2 # Copyright (C) 2006-2012 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 IssueRelation < ActiveRecord::Base
18 class IssueRelation < ActiveRecord::Base
19 belongs_to :issue_from, :class_name => 'Issue', :foreign_key => 'issue_from_id'
19 belongs_to :issue_from, :class_name => 'Issue', :foreign_key => 'issue_from_id'
20 belongs_to :issue_to, :class_name => 'Issue', :foreign_key => 'issue_to_id'
20 belongs_to :issue_to, :class_name => 'Issue', :foreign_key => 'issue_to_id'
21
21
22 TYPE_RELATES = "relates"
22 TYPE_RELATES = "relates"
23 TYPE_DUPLICATES = "duplicates"
23 TYPE_DUPLICATES = "duplicates"
24 TYPE_DUPLICATED = "duplicated"
24 TYPE_DUPLICATED = "duplicated"
25 TYPE_BLOCKS = "blocks"
25 TYPE_BLOCKS = "blocks"
26 TYPE_BLOCKED = "blocked"
26 TYPE_BLOCKED = "blocked"
27 TYPE_PRECEDES = "precedes"
27 TYPE_PRECEDES = "precedes"
28 TYPE_FOLLOWS = "follows"
28 TYPE_FOLLOWS = "follows"
29 TYPE_COPIED_TO = "copied_to"
30 TYPE_COPIED_FROM = "copied_from"
29
31
30 TYPES = { TYPE_RELATES => { :name => :label_relates_to, :sym_name => :label_relates_to, :order => 1, :sym => TYPE_RELATES },
32 TYPES = { TYPE_RELATES => { :name => :label_relates_to, :sym_name => :label_relates_to, :order => 1, :sym => TYPE_RELATES },
31 TYPE_DUPLICATES => { :name => :label_duplicates, :sym_name => :label_duplicated_by, :order => 2, :sym => TYPE_DUPLICATED },
33 TYPE_DUPLICATES => { :name => :label_duplicates, :sym_name => :label_duplicated_by, :order => 2, :sym => TYPE_DUPLICATED },
32 TYPE_DUPLICATED => { :name => :label_duplicated_by, :sym_name => :label_duplicates, :order => 3, :sym => TYPE_DUPLICATES, :reverse => TYPE_DUPLICATES },
34 TYPE_DUPLICATED => { :name => :label_duplicated_by, :sym_name => :label_duplicates, :order => 3, :sym => TYPE_DUPLICATES, :reverse => TYPE_DUPLICATES },
33 TYPE_BLOCKS => { :name => :label_blocks, :sym_name => :label_blocked_by, :order => 4, :sym => TYPE_BLOCKED },
35 TYPE_BLOCKS => { :name => :label_blocks, :sym_name => :label_blocked_by, :order => 4, :sym => TYPE_BLOCKED },
34 TYPE_BLOCKED => { :name => :label_blocked_by, :sym_name => :label_blocks, :order => 5, :sym => TYPE_BLOCKS, :reverse => TYPE_BLOCKS },
36 TYPE_BLOCKED => { :name => :label_blocked_by, :sym_name => :label_blocks, :order => 5, :sym => TYPE_BLOCKS, :reverse => TYPE_BLOCKS },
35 TYPE_PRECEDES => { :name => :label_precedes, :sym_name => :label_follows, :order => 6, :sym => TYPE_FOLLOWS },
37 TYPE_PRECEDES => { :name => :label_precedes, :sym_name => :label_follows, :order => 6, :sym => TYPE_FOLLOWS },
36 TYPE_FOLLOWS => { :name => :label_follows, :sym_name => :label_precedes, :order => 7, :sym => TYPE_PRECEDES, :reverse => TYPE_PRECEDES }
38 TYPE_FOLLOWS => { :name => :label_follows, :sym_name => :label_precedes, :order => 7, :sym => TYPE_PRECEDES, :reverse => TYPE_PRECEDES },
39 TYPE_COPIED_TO => { :name => :label_copied_to, :sym_name => :label_copied_from, :order => 8, :sym => TYPE_COPIED_FROM },
40 TYPE_COPIED_FROM => { :name => :label_copied_from, :sym_name => :label_copied_to, :order => 9, :sym => TYPE_COPIED_TO, :reverse => TYPE_COPIED_TO }
37 }.freeze
41 }.freeze
38
42
39 validates_presence_of :issue_from, :issue_to, :relation_type
43 validates_presence_of :issue_from, :issue_to, :relation_type
40 validates_inclusion_of :relation_type, :in => TYPES.keys
44 validates_inclusion_of :relation_type, :in => TYPES.keys
41 validates_numericality_of :delay, :allow_nil => true
45 validates_numericality_of :delay, :allow_nil => true
42 validates_uniqueness_of :issue_to_id, :scope => :issue_from_id
46 validates_uniqueness_of :issue_to_id, :scope => :issue_from_id
43
47
44 validate :validate_issue_relation
48 validate :validate_issue_relation
45
49
46 attr_protected :issue_from_id, :issue_to_id
50 attr_protected :issue_from_id, :issue_to_id
47
51
48 before_save :handle_issue_order
52 before_save :handle_issue_order
49
53
50 def visible?(user=User.current)
54 def visible?(user=User.current)
51 (issue_from.nil? || issue_from.visible?(user)) && (issue_to.nil? || issue_to.visible?(user))
55 (issue_from.nil? || issue_from.visible?(user)) && (issue_to.nil? || issue_to.visible?(user))
52 end
56 end
53
57
54 def deletable?(user=User.current)
58 def deletable?(user=User.current)
55 visible?(user) &&
59 visible?(user) &&
56 ((issue_from.nil? || user.allowed_to?(:manage_issue_relations, issue_from.project)) ||
60 ((issue_from.nil? || user.allowed_to?(:manage_issue_relations, issue_from.project)) ||
57 (issue_to.nil? || user.allowed_to?(:manage_issue_relations, issue_to.project)))
61 (issue_to.nil? || user.allowed_to?(:manage_issue_relations, issue_to.project)))
58 end
62 end
59
63
60 def initialize(attributes=nil, *args)
64 def initialize(attributes=nil, *args)
61 super
65 super
62 if new_record?
66 if new_record?
63 if relation_type.blank?
67 if relation_type.blank?
64 self.relation_type = IssueRelation::TYPE_RELATES
68 self.relation_type = IssueRelation::TYPE_RELATES
65 end
69 end
66 end
70 end
67 end
71 end
68
72
69 def validate_issue_relation
73 def validate_issue_relation
70 if issue_from && issue_to
74 if issue_from && issue_to
71 errors.add :issue_to_id, :invalid if issue_from_id == issue_to_id
75 errors.add :issue_to_id, :invalid if issue_from_id == issue_to_id
72 errors.add :issue_to_id, :not_same_project unless issue_from.project_id == issue_to.project_id || Setting.cross_project_issue_relations?
76 errors.add :issue_to_id, :not_same_project unless issue_from.project_id == issue_to.project_id || Setting.cross_project_issue_relations?
73 #detect circular dependencies depending wether the relation should be reversed
77 #detect circular dependencies depending wether the relation should be reversed
74 if TYPES.has_key?(relation_type) && TYPES[relation_type][:reverse]
78 if TYPES.has_key?(relation_type) && TYPES[relation_type][:reverse]
75 errors.add :base, :circular_dependency if issue_from.all_dependent_issues.include? issue_to
79 errors.add :base, :circular_dependency if issue_from.all_dependent_issues.include? issue_to
76 else
80 else
77 errors.add :base, :circular_dependency if issue_to.all_dependent_issues.include? issue_from
81 errors.add :base, :circular_dependency if issue_to.all_dependent_issues.include? issue_from
78 end
82 end
79 errors.add :base, :cant_link_an_issue_with_a_descendant if issue_from.is_descendant_of?(issue_to) || issue_from.is_ancestor_of?(issue_to)
83 errors.add :base, :cant_link_an_issue_with_a_descendant if issue_from.is_descendant_of?(issue_to) || issue_from.is_ancestor_of?(issue_to)
80 end
84 end
81 end
85 end
82
86
83 def other_issue(issue)
87 def other_issue(issue)
84 (self.issue_from_id == issue.id) ? issue_to : issue_from
88 (self.issue_from_id == issue.id) ? issue_to : issue_from
85 end
89 end
86
90
87 # Returns the relation type for +issue+
91 # Returns the relation type for +issue+
88 def relation_type_for(issue)
92 def relation_type_for(issue)
89 if TYPES[relation_type]
93 if TYPES[relation_type]
90 if self.issue_from_id == issue.id
94 if self.issue_from_id == issue.id
91 relation_type
95 relation_type
92 else
96 else
93 TYPES[relation_type][:sym]
97 TYPES[relation_type][:sym]
94 end
98 end
95 end
99 end
96 end
100 end
97
101
98 def label_for(issue)
102 def label_for(issue)
99 TYPES[relation_type] ? TYPES[relation_type][(self.issue_from_id == issue.id) ? :name : :sym_name] : :unknow
103 TYPES[relation_type] ? TYPES[relation_type][(self.issue_from_id == issue.id) ? :name : :sym_name] : :unknow
100 end
104 end
101
105
102 def handle_issue_order
106 def handle_issue_order
103 reverse_if_needed
107 reverse_if_needed
104
108
105 if TYPE_PRECEDES == relation_type
109 if TYPE_PRECEDES == relation_type
106 self.delay ||= 0
110 self.delay ||= 0
107 else
111 else
108 self.delay = nil
112 self.delay = nil
109 end
113 end
110 set_issue_to_dates
114 set_issue_to_dates
111 end
115 end
112
116
113 def set_issue_to_dates
117 def set_issue_to_dates
114 soonest_start = self.successor_soonest_start
118 soonest_start = self.successor_soonest_start
115 if soonest_start && issue_to
119 if soonest_start && issue_to
116 issue_to.reschedule_after(soonest_start)
120 issue_to.reschedule_after(soonest_start)
117 end
121 end
118 end
122 end
119
123
120 def successor_soonest_start
124 def successor_soonest_start
121 if (TYPE_PRECEDES == self.relation_type) && delay && issue_from && (issue_from.start_date || issue_from.due_date)
125 if (TYPE_PRECEDES == self.relation_type) && delay && issue_from && (issue_from.start_date || issue_from.due_date)
122 (issue_from.due_date || issue_from.start_date) + 1 + delay
126 (issue_from.due_date || issue_from.start_date) + 1 + delay
123 end
127 end
124 end
128 end
125
129
126 def <=>(relation)
130 def <=>(relation)
127 TYPES[self.relation_type][:order] <=> TYPES[relation.relation_type][:order]
131 TYPES[self.relation_type][:order] <=> TYPES[relation.relation_type][:order]
128 end
132 end
129
133
130 private
134 private
131
135
132 # Reverses the relation if needed so that it gets stored in the proper way
136 # Reverses the relation if needed so that it gets stored in the proper way
133 # Should not be reversed before validation so that it can be displayed back
137 # Should not be reversed before validation so that it can be displayed back
134 # as entered on new relation form
138 # as entered on new relation form
135 def reverse_if_needed
139 def reverse_if_needed
136 if TYPES.has_key?(relation_type) && TYPES[relation_type][:reverse]
140 if TYPES.has_key?(relation_type) && TYPES[relation_type][:reverse]
137 issue_tmp = issue_to
141 issue_tmp = issue_to
138 self.issue_to = issue_from
142 self.issue_to = issue_from
139 self.issue_from = issue_tmp
143 self.issue_from = issue_tmp
140 self.relation_type = TYPES[relation_type][:reverse]
144 self.relation_type = TYPES[relation_type][:reverse]
141 end
145 end
142 end
146 end
143 end
147 end
@@ -1,1062 +1,1064
1 en:
1 en:
2 # Text direction: Left-to-Right (ltr) or Right-to-Left (rtl)
2 # Text direction: Left-to-Right (ltr) or Right-to-Left (rtl)
3 direction: ltr
3 direction: ltr
4 date:
4 date:
5 formats:
5 formats:
6 # Use the strftime parameters for formats.
6 # Use the strftime parameters for formats.
7 # When no format has been given, it uses default.
7 # When no format has been given, it uses default.
8 # You can provide other formats here if you like!
8 # You can provide other formats here if you like!
9 default: "%m/%d/%Y"
9 default: "%m/%d/%Y"
10 short: "%b %d"
10 short: "%b %d"
11 long: "%B %d, %Y"
11 long: "%B %d, %Y"
12
12
13 day_names: [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday]
13 day_names: [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday]
14 abbr_day_names: [Sun, Mon, Tue, Wed, Thu, Fri, Sat]
14 abbr_day_names: [Sun, Mon, Tue, Wed, Thu, Fri, Sat]
15
15
16 # Don't forget the nil at the beginning; there's no such thing as a 0th month
16 # Don't forget the nil at the beginning; there's no such thing as a 0th month
17 month_names: [~, January, February, March, April, May, June, July, August, September, October, November, December]
17 month_names: [~, January, February, March, April, May, June, July, August, September, October, November, December]
18 abbr_month_names: [~, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec]
18 abbr_month_names: [~, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec]
19 # Used in date_select and datime_select.
19 # Used in date_select and datime_select.
20 order:
20 order:
21 - :year
21 - :year
22 - :month
22 - :month
23 - :day
23 - :day
24
24
25 time:
25 time:
26 formats:
26 formats:
27 default: "%m/%d/%Y %I:%M %p"
27 default: "%m/%d/%Y %I:%M %p"
28 time: "%I:%M %p"
28 time: "%I:%M %p"
29 short: "%d %b %H:%M"
29 short: "%d %b %H:%M"
30 long: "%B %d, %Y %H:%M"
30 long: "%B %d, %Y %H:%M"
31 am: "am"
31 am: "am"
32 pm: "pm"
32 pm: "pm"
33
33
34 datetime:
34 datetime:
35 distance_in_words:
35 distance_in_words:
36 half_a_minute: "half a minute"
36 half_a_minute: "half a minute"
37 less_than_x_seconds:
37 less_than_x_seconds:
38 one: "less than 1 second"
38 one: "less than 1 second"
39 other: "less than %{count} seconds"
39 other: "less than %{count} seconds"
40 x_seconds:
40 x_seconds:
41 one: "1 second"
41 one: "1 second"
42 other: "%{count} seconds"
42 other: "%{count} seconds"
43 less_than_x_minutes:
43 less_than_x_minutes:
44 one: "less than a minute"
44 one: "less than a minute"
45 other: "less than %{count} minutes"
45 other: "less than %{count} minutes"
46 x_minutes:
46 x_minutes:
47 one: "1 minute"
47 one: "1 minute"
48 other: "%{count} minutes"
48 other: "%{count} minutes"
49 about_x_hours:
49 about_x_hours:
50 one: "about 1 hour"
50 one: "about 1 hour"
51 other: "about %{count} hours"
51 other: "about %{count} hours"
52 x_hours:
52 x_hours:
53 one: "1 hour"
53 one: "1 hour"
54 other: "%{count} hours"
54 other: "%{count} hours"
55 x_days:
55 x_days:
56 one: "1 day"
56 one: "1 day"
57 other: "%{count} days"
57 other: "%{count} days"
58 about_x_months:
58 about_x_months:
59 one: "about 1 month"
59 one: "about 1 month"
60 other: "about %{count} months"
60 other: "about %{count} months"
61 x_months:
61 x_months:
62 one: "1 month"
62 one: "1 month"
63 other: "%{count} months"
63 other: "%{count} months"
64 about_x_years:
64 about_x_years:
65 one: "about 1 year"
65 one: "about 1 year"
66 other: "about %{count} years"
66 other: "about %{count} years"
67 over_x_years:
67 over_x_years:
68 one: "over 1 year"
68 one: "over 1 year"
69 other: "over %{count} years"
69 other: "over %{count} years"
70 almost_x_years:
70 almost_x_years:
71 one: "almost 1 year"
71 one: "almost 1 year"
72 other: "almost %{count} years"
72 other: "almost %{count} years"
73
73
74 number:
74 number:
75 format:
75 format:
76 separator: "."
76 separator: "."
77 delimiter: ""
77 delimiter: ""
78 precision: 3
78 precision: 3
79
79
80 human:
80 human:
81 format:
81 format:
82 delimiter: ""
82 delimiter: ""
83 precision: 3
83 precision: 3
84 storage_units:
84 storage_units:
85 format: "%n %u"
85 format: "%n %u"
86 units:
86 units:
87 byte:
87 byte:
88 one: "Byte"
88 one: "Byte"
89 other: "Bytes"
89 other: "Bytes"
90 kb: "KB"
90 kb: "KB"
91 mb: "MB"
91 mb: "MB"
92 gb: "GB"
92 gb: "GB"
93 tb: "TB"
93 tb: "TB"
94
94
95 # Used in array.to_sentence.
95 # Used in array.to_sentence.
96 support:
96 support:
97 array:
97 array:
98 sentence_connector: "and"
98 sentence_connector: "and"
99 skip_last_comma: false
99 skip_last_comma: false
100
100
101 activerecord:
101 activerecord:
102 errors:
102 errors:
103 template:
103 template:
104 header:
104 header:
105 one: "1 error prohibited this %{model} from being saved"
105 one: "1 error prohibited this %{model} from being saved"
106 other: "%{count} errors prohibited this %{model} from being saved"
106 other: "%{count} errors prohibited this %{model} from being saved"
107 messages:
107 messages:
108 inclusion: "is not included in the list"
108 inclusion: "is not included in the list"
109 exclusion: "is reserved"
109 exclusion: "is reserved"
110 invalid: "is invalid"
110 invalid: "is invalid"
111 confirmation: "doesn't match confirmation"
111 confirmation: "doesn't match confirmation"
112 accepted: "must be accepted"
112 accepted: "must be accepted"
113 empty: "can't be empty"
113 empty: "can't be empty"
114 blank: "can't be blank"
114 blank: "can't be blank"
115 too_long: "is too long (maximum is %{count} characters)"
115 too_long: "is too long (maximum is %{count} characters)"
116 too_short: "is too short (minimum is %{count} characters)"
116 too_short: "is too short (minimum is %{count} characters)"
117 wrong_length: "is the wrong length (should be %{count} characters)"
117 wrong_length: "is the wrong length (should be %{count} characters)"
118 taken: "has already been taken"
118 taken: "has already been taken"
119 not_a_number: "is not a number"
119 not_a_number: "is not a number"
120 not_a_date: "is not a valid date"
120 not_a_date: "is not a valid date"
121 greater_than: "must be greater than %{count}"
121 greater_than: "must be greater than %{count}"
122 greater_than_or_equal_to: "must be greater than or equal to %{count}"
122 greater_than_or_equal_to: "must be greater than or equal to %{count}"
123 equal_to: "must be equal to %{count}"
123 equal_to: "must be equal to %{count}"
124 less_than: "must be less than %{count}"
124 less_than: "must be less than %{count}"
125 less_than_or_equal_to: "must be less than or equal to %{count}"
125 less_than_or_equal_to: "must be less than or equal to %{count}"
126 odd: "must be odd"
126 odd: "must be odd"
127 even: "must be even"
127 even: "must be even"
128 greater_than_start_date: "must be greater than start date"
128 greater_than_start_date: "must be greater than start date"
129 not_same_project: "doesn't belong to the same project"
129 not_same_project: "doesn't belong to the same project"
130 circular_dependency: "This relation would create a circular dependency"
130 circular_dependency: "This relation would create a circular dependency"
131 cant_link_an_issue_with_a_descendant: "An issue cannot be linked to one of its subtasks"
131 cant_link_an_issue_with_a_descendant: "An issue cannot be linked to one of its subtasks"
132
132
133 actionview_instancetag_blank_option: Please select
133 actionview_instancetag_blank_option: Please select
134
134
135 general_text_No: 'No'
135 general_text_No: 'No'
136 general_text_Yes: 'Yes'
136 general_text_Yes: 'Yes'
137 general_text_no: 'no'
137 general_text_no: 'no'
138 general_text_yes: 'yes'
138 general_text_yes: 'yes'
139 general_lang_name: 'English'
139 general_lang_name: 'English'
140 general_csv_separator: ','
140 general_csv_separator: ','
141 general_csv_decimal_separator: '.'
141 general_csv_decimal_separator: '.'
142 general_csv_encoding: ISO-8859-1
142 general_csv_encoding: ISO-8859-1
143 general_pdf_encoding: UTF-8
143 general_pdf_encoding: UTF-8
144 general_first_day_of_week: '7'
144 general_first_day_of_week: '7'
145
145
146 notice_account_updated: Account was successfully updated.
146 notice_account_updated: Account was successfully updated.
147 notice_account_invalid_creditentials: Invalid user or password
147 notice_account_invalid_creditentials: Invalid user or password
148 notice_account_password_updated: Password was successfully updated.
148 notice_account_password_updated: Password was successfully updated.
149 notice_account_wrong_password: Wrong password
149 notice_account_wrong_password: Wrong password
150 notice_account_register_done: Account was successfully created. To activate your account, click on the link that was emailed to you.
150 notice_account_register_done: Account was successfully created. To activate your account, click on the link that was emailed to you.
151 notice_account_unknown_email: Unknown user.
151 notice_account_unknown_email: Unknown user.
152 notice_can_t_change_password: This account uses an external authentication source. Impossible to change the password.
152 notice_can_t_change_password: This account uses an external authentication source. Impossible to change the password.
153 notice_account_lost_email_sent: An email with instructions to choose a new password has been sent to you.
153 notice_account_lost_email_sent: An email with instructions to choose a new password has been sent to you.
154 notice_account_activated: Your account has been activated. You can now log in.
154 notice_account_activated: Your account has been activated. You can now log in.
155 notice_successful_create: Successful creation.
155 notice_successful_create: Successful creation.
156 notice_successful_update: Successful update.
156 notice_successful_update: Successful update.
157 notice_successful_delete: Successful deletion.
157 notice_successful_delete: Successful deletion.
158 notice_successful_connection: Successful connection.
158 notice_successful_connection: Successful connection.
159 notice_file_not_found: The page you were trying to access doesn't exist or has been removed.
159 notice_file_not_found: The page you were trying to access doesn't exist or has been removed.
160 notice_locking_conflict: Data has been updated by another user.
160 notice_locking_conflict: Data has been updated by another user.
161 notice_not_authorized: You are not authorized to access this page.
161 notice_not_authorized: You are not authorized to access this page.
162 notice_not_authorized_archived_project: The project you're trying to access has been archived.
162 notice_not_authorized_archived_project: The project you're trying to access has been archived.
163 notice_email_sent: "An email was sent to %{value}"
163 notice_email_sent: "An email was sent to %{value}"
164 notice_email_error: "An error occurred while sending mail (%{value})"
164 notice_email_error: "An error occurred while sending mail (%{value})"
165 notice_feeds_access_key_reseted: Your RSS access key was reset.
165 notice_feeds_access_key_reseted: Your RSS access key was reset.
166 notice_api_access_key_reseted: Your API access key was reset.
166 notice_api_access_key_reseted: Your API access key was reset.
167 notice_failed_to_save_issues: "Failed to save %{count} issue(s) on %{total} selected: %{ids}."
167 notice_failed_to_save_issues: "Failed to save %{count} issue(s) on %{total} selected: %{ids}."
168 notice_failed_to_save_time_entries: "Failed to save %{count} time entrie(s) on %{total} selected: %{ids}."
168 notice_failed_to_save_time_entries: "Failed to save %{count} time entrie(s) on %{total} selected: %{ids}."
169 notice_failed_to_save_members: "Failed to save member(s): %{errors}."
169 notice_failed_to_save_members: "Failed to save member(s): %{errors}."
170 notice_no_issue_selected: "No issue is selected! Please, check the issues you want to edit."
170 notice_no_issue_selected: "No issue is selected! Please, check the issues you want to edit."
171 notice_account_pending: "Your account was created and is now pending administrator approval."
171 notice_account_pending: "Your account was created and is now pending administrator approval."
172 notice_default_data_loaded: Default configuration successfully loaded.
172 notice_default_data_loaded: Default configuration successfully loaded.
173 notice_unable_delete_version: Unable to delete version.
173 notice_unable_delete_version: Unable to delete version.
174 notice_unable_delete_time_entry: Unable to delete time log entry.
174 notice_unable_delete_time_entry: Unable to delete time log entry.
175 notice_issue_done_ratios_updated: Issue done ratios updated.
175 notice_issue_done_ratios_updated: Issue done ratios updated.
176 notice_gantt_chart_truncated: "The chart was truncated because it exceeds the maximum number of items that can be displayed (%{max})"
176 notice_gantt_chart_truncated: "The chart was truncated because it exceeds the maximum number of items that can be displayed (%{max})"
177 notice_issue_successful_create: "Issue %{id} created."
177 notice_issue_successful_create: "Issue %{id} created."
178 notice_issue_update_conflict: "The issue has been updated by an other user while you were editing it."
178 notice_issue_update_conflict: "The issue has been updated by an other user while you were editing it."
179 notice_account_deleted: "Your account has been permanently deleted."
179 notice_account_deleted: "Your account has been permanently deleted."
180 notice_user_successful_create: "User %{id} created."
180 notice_user_successful_create: "User %{id} created."
181
181
182 error_can_t_load_default_data: "Default configuration could not be loaded: %{value}"
182 error_can_t_load_default_data: "Default configuration could not be loaded: %{value}"
183 error_scm_not_found: "The entry or revision was not found in the repository."
183 error_scm_not_found: "The entry or revision was not found in the repository."
184 error_scm_command_failed: "An error occurred when trying to access the repository: %{value}"
184 error_scm_command_failed: "An error occurred when trying to access the repository: %{value}"
185 error_scm_annotate: "The entry does not exist or cannot be annotated."
185 error_scm_annotate: "The entry does not exist or cannot be annotated."
186 error_scm_annotate_big_text_file: "The entry cannot be annotated, as it exceeds the maximum text file size."
186 error_scm_annotate_big_text_file: "The entry cannot be annotated, as it exceeds the maximum text file size."
187 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
187 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
188 error_no_tracker_in_project: 'No tracker is associated to this project. Please check the Project settings.'
188 error_no_tracker_in_project: 'No tracker is associated to this project. Please check the Project settings.'
189 error_no_default_issue_status: 'No default issue status is defined. Please check your configuration (Go to "Administration -> Issue statuses").'
189 error_no_default_issue_status: 'No default issue status is defined. Please check your configuration (Go to "Administration -> Issue statuses").'
190 error_can_not_delete_custom_field: Unable to delete custom field
190 error_can_not_delete_custom_field: Unable to delete custom field
191 error_can_not_delete_tracker: "This tracker contains issues and cannot be deleted."
191 error_can_not_delete_tracker: "This tracker contains issues and cannot be deleted."
192 error_can_not_remove_role: "This role is in use and cannot be deleted."
192 error_can_not_remove_role: "This role is in use and cannot be deleted."
193 error_can_not_reopen_issue_on_closed_version: 'An issue assigned to a closed version cannot be reopened'
193 error_can_not_reopen_issue_on_closed_version: 'An issue assigned to a closed version cannot be reopened'
194 error_can_not_archive_project: This project cannot be archived
194 error_can_not_archive_project: This project cannot be archived
195 error_issue_done_ratios_not_updated: "Issue done ratios not updated."
195 error_issue_done_ratios_not_updated: "Issue done ratios not updated."
196 error_workflow_copy_source: 'Please select a source tracker or role'
196 error_workflow_copy_source: 'Please select a source tracker or role'
197 error_workflow_copy_target: 'Please select target tracker(s) and role(s)'
197 error_workflow_copy_target: 'Please select target tracker(s) and role(s)'
198 error_unable_delete_issue_status: 'Unable to delete issue status'
198 error_unable_delete_issue_status: 'Unable to delete issue status'
199 error_unable_to_connect: "Unable to connect (%{value})"
199 error_unable_to_connect: "Unable to connect (%{value})"
200 error_attachment_too_big: "This file cannot be uploaded because it exceeds the maximum allowed file size (%{max_size})"
200 error_attachment_too_big: "This file cannot be uploaded because it exceeds the maximum allowed file size (%{max_size})"
201 error_session_expired: "Your session has expired. Please login again."
201 error_session_expired: "Your session has expired. Please login again."
202 warning_attachments_not_saved: "%{count} file(s) could not be saved."
202 warning_attachments_not_saved: "%{count} file(s) could not be saved."
203
203
204 mail_subject_lost_password: "Your %{value} password"
204 mail_subject_lost_password: "Your %{value} password"
205 mail_body_lost_password: 'To change your password, click on the following link:'
205 mail_body_lost_password: 'To change your password, click on the following link:'
206 mail_subject_register: "Your %{value} account activation"
206 mail_subject_register: "Your %{value} account activation"
207 mail_body_register: 'To activate your account, click on the following link:'
207 mail_body_register: 'To activate your account, click on the following link:'
208 mail_body_account_information_external: "You can use your %{value} account to log in."
208 mail_body_account_information_external: "You can use your %{value} account to log in."
209 mail_body_account_information: Your account information
209 mail_body_account_information: Your account information
210 mail_subject_account_activation_request: "%{value} account activation request"
210 mail_subject_account_activation_request: "%{value} account activation request"
211 mail_body_account_activation_request: "A new user (%{value}) has registered. The account is pending your approval:"
211 mail_body_account_activation_request: "A new user (%{value}) has registered. The account is pending your approval:"
212 mail_subject_reminder: "%{count} issue(s) due in the next %{days} days"
212 mail_subject_reminder: "%{count} issue(s) due in the next %{days} days"
213 mail_body_reminder: "%{count} issue(s) that are assigned to you are due in the next %{days} days:"
213 mail_body_reminder: "%{count} issue(s) that are assigned to you are due in the next %{days} days:"
214 mail_subject_wiki_content_added: "'%{id}' wiki page has been added"
214 mail_subject_wiki_content_added: "'%{id}' wiki page has been added"
215 mail_body_wiki_content_added: "The '%{id}' wiki page has been added by %{author}."
215 mail_body_wiki_content_added: "The '%{id}' wiki page has been added by %{author}."
216 mail_subject_wiki_content_updated: "'%{id}' wiki page has been updated"
216 mail_subject_wiki_content_updated: "'%{id}' wiki page has been updated"
217 mail_body_wiki_content_updated: "The '%{id}' wiki page has been updated by %{author}."
217 mail_body_wiki_content_updated: "The '%{id}' wiki page has been updated by %{author}."
218
218
219 gui_validation_error: 1 error
219 gui_validation_error: 1 error
220 gui_validation_error_plural: "%{count} errors"
220 gui_validation_error_plural: "%{count} errors"
221
221
222 field_name: Name
222 field_name: Name
223 field_description: Description
223 field_description: Description
224 field_summary: Summary
224 field_summary: Summary
225 field_is_required: Required
225 field_is_required: Required
226 field_firstname: First name
226 field_firstname: First name
227 field_lastname: Last name
227 field_lastname: Last name
228 field_mail: Email
228 field_mail: Email
229 field_filename: File
229 field_filename: File
230 field_filesize: Size
230 field_filesize: Size
231 field_downloads: Downloads
231 field_downloads: Downloads
232 field_author: Author
232 field_author: Author
233 field_created_on: Created
233 field_created_on: Created
234 field_updated_on: Updated
234 field_updated_on: Updated
235 field_field_format: Format
235 field_field_format: Format
236 field_is_for_all: For all projects
236 field_is_for_all: For all projects
237 field_possible_values: Possible values
237 field_possible_values: Possible values
238 field_regexp: Regular expression
238 field_regexp: Regular expression
239 field_min_length: Minimum length
239 field_min_length: Minimum length
240 field_max_length: Maximum length
240 field_max_length: Maximum length
241 field_value: Value
241 field_value: Value
242 field_category: Category
242 field_category: Category
243 field_title: Title
243 field_title: Title
244 field_project: Project
244 field_project: Project
245 field_issue: Issue
245 field_issue: Issue
246 field_status: Status
246 field_status: Status
247 field_notes: Notes
247 field_notes: Notes
248 field_is_closed: Issue closed
248 field_is_closed: Issue closed
249 field_is_default: Default value
249 field_is_default: Default value
250 field_tracker: Tracker
250 field_tracker: Tracker
251 field_subject: Subject
251 field_subject: Subject
252 field_due_date: Due date
252 field_due_date: Due date
253 field_assigned_to: Assignee
253 field_assigned_to: Assignee
254 field_priority: Priority
254 field_priority: Priority
255 field_fixed_version: Target version
255 field_fixed_version: Target version
256 field_user: User
256 field_user: User
257 field_principal: Principal
257 field_principal: Principal
258 field_role: Role
258 field_role: Role
259 field_homepage: Homepage
259 field_homepage: Homepage
260 field_is_public: Public
260 field_is_public: Public
261 field_parent: Subproject of
261 field_parent: Subproject of
262 field_is_in_roadmap: Issues displayed in roadmap
262 field_is_in_roadmap: Issues displayed in roadmap
263 field_login: Login
263 field_login: Login
264 field_mail_notification: Email notifications
264 field_mail_notification: Email notifications
265 field_admin: Administrator
265 field_admin: Administrator
266 field_last_login_on: Last connection
266 field_last_login_on: Last connection
267 field_language: Language
267 field_language: Language
268 field_effective_date: Date
268 field_effective_date: Date
269 field_password: Password
269 field_password: Password
270 field_new_password: New password
270 field_new_password: New password
271 field_password_confirmation: Confirmation
271 field_password_confirmation: Confirmation
272 field_version: Version
272 field_version: Version
273 field_type: Type
273 field_type: Type
274 field_host: Host
274 field_host: Host
275 field_port: Port
275 field_port: Port
276 field_account: Account
276 field_account: Account
277 field_base_dn: Base DN
277 field_base_dn: Base DN
278 field_attr_login: Login attribute
278 field_attr_login: Login attribute
279 field_attr_firstname: Firstname attribute
279 field_attr_firstname: Firstname attribute
280 field_attr_lastname: Lastname attribute
280 field_attr_lastname: Lastname attribute
281 field_attr_mail: Email attribute
281 field_attr_mail: Email attribute
282 field_onthefly: On-the-fly user creation
282 field_onthefly: On-the-fly user creation
283 field_start_date: Start date
283 field_start_date: Start date
284 field_done_ratio: "% Done"
284 field_done_ratio: "% Done"
285 field_auth_source: Authentication mode
285 field_auth_source: Authentication mode
286 field_hide_mail: Hide my email address
286 field_hide_mail: Hide my email address
287 field_comments: Comment
287 field_comments: Comment
288 field_url: URL
288 field_url: URL
289 field_start_page: Start page
289 field_start_page: Start page
290 field_subproject: Subproject
290 field_subproject: Subproject
291 field_hours: Hours
291 field_hours: Hours
292 field_activity: Activity
292 field_activity: Activity
293 field_spent_on: Date
293 field_spent_on: Date
294 field_identifier: Identifier
294 field_identifier: Identifier
295 field_is_filter: Used as a filter
295 field_is_filter: Used as a filter
296 field_issue_to: Related issue
296 field_issue_to: Related issue
297 field_delay: Delay
297 field_delay: Delay
298 field_assignable: Issues can be assigned to this role
298 field_assignable: Issues can be assigned to this role
299 field_redirect_existing_links: Redirect existing links
299 field_redirect_existing_links: Redirect existing links
300 field_estimated_hours: Estimated time
300 field_estimated_hours: Estimated time
301 field_column_names: Columns
301 field_column_names: Columns
302 field_time_entries: Log time
302 field_time_entries: Log time
303 field_time_zone: Time zone
303 field_time_zone: Time zone
304 field_searchable: Searchable
304 field_searchable: Searchable
305 field_default_value: Default value
305 field_default_value: Default value
306 field_comments_sorting: Display comments
306 field_comments_sorting: Display comments
307 field_parent_title: Parent page
307 field_parent_title: Parent page
308 field_editable: Editable
308 field_editable: Editable
309 field_watcher: Watcher
309 field_watcher: Watcher
310 field_identity_url: OpenID URL
310 field_identity_url: OpenID URL
311 field_content: Content
311 field_content: Content
312 field_group_by: Group results by
312 field_group_by: Group results by
313 field_sharing: Sharing
313 field_sharing: Sharing
314 field_parent_issue: Parent task
314 field_parent_issue: Parent task
315 field_member_of_group: "Assignee's group"
315 field_member_of_group: "Assignee's group"
316 field_assigned_to_role: "Assignee's role"
316 field_assigned_to_role: "Assignee's role"
317 field_text: Text field
317 field_text: Text field
318 field_visible: Visible
318 field_visible: Visible
319 field_warn_on_leaving_unsaved: "Warn me when leaving a page with unsaved text"
319 field_warn_on_leaving_unsaved: "Warn me when leaving a page with unsaved text"
320 field_issues_visibility: Issues visibility
320 field_issues_visibility: Issues visibility
321 field_is_private: Private
321 field_is_private: Private
322 field_commit_logs_encoding: Commit messages encoding
322 field_commit_logs_encoding: Commit messages encoding
323 field_scm_path_encoding: Path encoding
323 field_scm_path_encoding: Path encoding
324 field_path_to_repository: Path to repository
324 field_path_to_repository: Path to repository
325 field_root_directory: Root directory
325 field_root_directory: Root directory
326 field_cvsroot: CVSROOT
326 field_cvsroot: CVSROOT
327 field_cvs_module: Module
327 field_cvs_module: Module
328 field_repository_is_default: Main repository
328 field_repository_is_default: Main repository
329 field_multiple: Multiple values
329 field_multiple: Multiple values
330 field_auth_source_ldap_filter: LDAP filter
330 field_auth_source_ldap_filter: LDAP filter
331 field_core_fields: Standard fields
331 field_core_fields: Standard fields
332 field_timeout: "Timeout (in seconds)"
332 field_timeout: "Timeout (in seconds)"
333 field_board_parent: Parent forum
333 field_board_parent: Parent forum
334
334
335 setting_app_title: Application title
335 setting_app_title: Application title
336 setting_app_subtitle: Application subtitle
336 setting_app_subtitle: Application subtitle
337 setting_welcome_text: Welcome text
337 setting_welcome_text: Welcome text
338 setting_default_language: Default language
338 setting_default_language: Default language
339 setting_login_required: Authentication required
339 setting_login_required: Authentication required
340 setting_self_registration: Self-registration
340 setting_self_registration: Self-registration
341 setting_attachment_max_size: Maximum attachment size
341 setting_attachment_max_size: Maximum attachment size
342 setting_issues_export_limit: Issues export limit
342 setting_issues_export_limit: Issues export limit
343 setting_mail_from: Emission email address
343 setting_mail_from: Emission email address
344 setting_bcc_recipients: Blind carbon copy recipients (bcc)
344 setting_bcc_recipients: Blind carbon copy recipients (bcc)
345 setting_plain_text_mail: Plain text mail (no HTML)
345 setting_plain_text_mail: Plain text mail (no HTML)
346 setting_host_name: Host name and path
346 setting_host_name: Host name and path
347 setting_text_formatting: Text formatting
347 setting_text_formatting: Text formatting
348 setting_wiki_compression: Wiki history compression
348 setting_wiki_compression: Wiki history compression
349 setting_feeds_limit: Maximum number of items in Atom feeds
349 setting_feeds_limit: Maximum number of items in Atom feeds
350 setting_default_projects_public: New projects are public by default
350 setting_default_projects_public: New projects are public by default
351 setting_autofetch_changesets: Fetch commits automatically
351 setting_autofetch_changesets: Fetch commits automatically
352 setting_sys_api_enabled: Enable WS for repository management
352 setting_sys_api_enabled: Enable WS for repository management
353 setting_commit_ref_keywords: Referencing keywords
353 setting_commit_ref_keywords: Referencing keywords
354 setting_commit_fix_keywords: Fixing keywords
354 setting_commit_fix_keywords: Fixing keywords
355 setting_autologin: Autologin
355 setting_autologin: Autologin
356 setting_date_format: Date format
356 setting_date_format: Date format
357 setting_time_format: Time format
357 setting_time_format: Time format
358 setting_cross_project_issue_relations: Allow cross-project issue relations
358 setting_cross_project_issue_relations: Allow cross-project issue relations
359 setting_issue_list_default_columns: Default columns displayed on the issue list
359 setting_issue_list_default_columns: Default columns displayed on the issue list
360 setting_repositories_encodings: Attachments and repositories encodings
360 setting_repositories_encodings: Attachments and repositories encodings
361 setting_emails_header: Emails header
361 setting_emails_header: Emails header
362 setting_emails_footer: Emails footer
362 setting_emails_footer: Emails footer
363 setting_protocol: Protocol
363 setting_protocol: Protocol
364 setting_per_page_options: Objects per page options
364 setting_per_page_options: Objects per page options
365 setting_user_format: Users display format
365 setting_user_format: Users display format
366 setting_activity_days_default: Days displayed on project activity
366 setting_activity_days_default: Days displayed on project activity
367 setting_display_subprojects_issues: Display subprojects issues on main projects by default
367 setting_display_subprojects_issues: Display subprojects issues on main projects by default
368 setting_enabled_scm: Enabled SCM
368 setting_enabled_scm: Enabled SCM
369 setting_mail_handler_body_delimiters: "Truncate emails after one of these lines"
369 setting_mail_handler_body_delimiters: "Truncate emails after one of these lines"
370 setting_mail_handler_api_enabled: Enable WS for incoming emails
370 setting_mail_handler_api_enabled: Enable WS for incoming emails
371 setting_mail_handler_api_key: API key
371 setting_mail_handler_api_key: API key
372 setting_sequential_project_identifiers: Generate sequential project identifiers
372 setting_sequential_project_identifiers: Generate sequential project identifiers
373 setting_gravatar_enabled: Use Gravatar user icons
373 setting_gravatar_enabled: Use Gravatar user icons
374 setting_gravatar_default: Default Gravatar image
374 setting_gravatar_default: Default Gravatar image
375 setting_diff_max_lines_displayed: Maximum number of diff lines displayed
375 setting_diff_max_lines_displayed: Maximum number of diff lines displayed
376 setting_file_max_size_displayed: Maximum size of text files displayed inline
376 setting_file_max_size_displayed: Maximum size of text files displayed inline
377 setting_repository_log_display_limit: Maximum number of revisions displayed on file log
377 setting_repository_log_display_limit: Maximum number of revisions displayed on file log
378 setting_openid: Allow OpenID login and registration
378 setting_openid: Allow OpenID login and registration
379 setting_password_min_length: Minimum password length
379 setting_password_min_length: Minimum password length
380 setting_new_project_user_role_id: Role given to a non-admin user who creates a project
380 setting_new_project_user_role_id: Role given to a non-admin user who creates a project
381 setting_default_projects_modules: Default enabled modules for new projects
381 setting_default_projects_modules: Default enabled modules for new projects
382 setting_issue_done_ratio: Calculate the issue done ratio with
382 setting_issue_done_ratio: Calculate the issue done ratio with
383 setting_issue_done_ratio_issue_field: Use the issue field
383 setting_issue_done_ratio_issue_field: Use the issue field
384 setting_issue_done_ratio_issue_status: Use the issue status
384 setting_issue_done_ratio_issue_status: Use the issue status
385 setting_start_of_week: Start calendars on
385 setting_start_of_week: Start calendars on
386 setting_rest_api_enabled: Enable REST web service
386 setting_rest_api_enabled: Enable REST web service
387 setting_cache_formatted_text: Cache formatted text
387 setting_cache_formatted_text: Cache formatted text
388 setting_default_notification_option: Default notification option
388 setting_default_notification_option: Default notification option
389 setting_commit_logtime_enabled: Enable time logging
389 setting_commit_logtime_enabled: Enable time logging
390 setting_commit_logtime_activity_id: Activity for logged time
390 setting_commit_logtime_activity_id: Activity for logged time
391 setting_gantt_items_limit: Maximum number of items displayed on the gantt chart
391 setting_gantt_items_limit: Maximum number of items displayed on the gantt chart
392 setting_issue_group_assignment: Allow issue assignment to groups
392 setting_issue_group_assignment: Allow issue assignment to groups
393 setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
393 setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
394 setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed
394 setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed
395 setting_unsubscribe: Allow users to delete their own account
395 setting_unsubscribe: Allow users to delete their own account
396 setting_session_lifetime: Session maximum lifetime
396 setting_session_lifetime: Session maximum lifetime
397 setting_session_timeout: Session inactivity timeout
397 setting_session_timeout: Session inactivity timeout
398 setting_thumbnails_enabled: Display attachment thumbnails
398 setting_thumbnails_enabled: Display attachment thumbnails
399 setting_thumbnails_size: Thumbnails size (in pixels)
399 setting_thumbnails_size: Thumbnails size (in pixels)
400
400
401 permission_add_project: Create project
401 permission_add_project: Create project
402 permission_add_subprojects: Create subprojects
402 permission_add_subprojects: Create subprojects
403 permission_edit_project: Edit project
403 permission_edit_project: Edit project
404 permission_close_project: Close / reopen the project
404 permission_close_project: Close / reopen the project
405 permission_select_project_modules: Select project modules
405 permission_select_project_modules: Select project modules
406 permission_manage_members: Manage members
406 permission_manage_members: Manage members
407 permission_manage_project_activities: Manage project activities
407 permission_manage_project_activities: Manage project activities
408 permission_manage_versions: Manage versions
408 permission_manage_versions: Manage versions
409 permission_manage_categories: Manage issue categories
409 permission_manage_categories: Manage issue categories
410 permission_view_issues: View Issues
410 permission_view_issues: View Issues
411 permission_add_issues: Add issues
411 permission_add_issues: Add issues
412 permission_edit_issues: Edit issues
412 permission_edit_issues: Edit issues
413 permission_manage_issue_relations: Manage issue relations
413 permission_manage_issue_relations: Manage issue relations
414 permission_set_issues_private: Set issues public or private
414 permission_set_issues_private: Set issues public or private
415 permission_set_own_issues_private: Set own issues public or private
415 permission_set_own_issues_private: Set own issues public or private
416 permission_add_issue_notes: Add notes
416 permission_add_issue_notes: Add notes
417 permission_edit_issue_notes: Edit notes
417 permission_edit_issue_notes: Edit notes
418 permission_edit_own_issue_notes: Edit own notes
418 permission_edit_own_issue_notes: Edit own notes
419 permission_move_issues: Move issues
419 permission_move_issues: Move issues
420 permission_delete_issues: Delete issues
420 permission_delete_issues: Delete issues
421 permission_manage_public_queries: Manage public queries
421 permission_manage_public_queries: Manage public queries
422 permission_save_queries: Save queries
422 permission_save_queries: Save queries
423 permission_view_gantt: View gantt chart
423 permission_view_gantt: View gantt chart
424 permission_view_calendar: View calendar
424 permission_view_calendar: View calendar
425 permission_view_issue_watchers: View watchers list
425 permission_view_issue_watchers: View watchers list
426 permission_add_issue_watchers: Add watchers
426 permission_add_issue_watchers: Add watchers
427 permission_delete_issue_watchers: Delete watchers
427 permission_delete_issue_watchers: Delete watchers
428 permission_log_time: Log spent time
428 permission_log_time: Log spent time
429 permission_view_time_entries: View spent time
429 permission_view_time_entries: View spent time
430 permission_edit_time_entries: Edit time logs
430 permission_edit_time_entries: Edit time logs
431 permission_edit_own_time_entries: Edit own time logs
431 permission_edit_own_time_entries: Edit own time logs
432 permission_manage_news: Manage news
432 permission_manage_news: Manage news
433 permission_comment_news: Comment news
433 permission_comment_news: Comment news
434 permission_manage_documents: Manage documents
434 permission_manage_documents: Manage documents
435 permission_view_documents: View documents
435 permission_view_documents: View documents
436 permission_manage_files: Manage files
436 permission_manage_files: Manage files
437 permission_view_files: View files
437 permission_view_files: View files
438 permission_manage_wiki: Manage wiki
438 permission_manage_wiki: Manage wiki
439 permission_rename_wiki_pages: Rename wiki pages
439 permission_rename_wiki_pages: Rename wiki pages
440 permission_delete_wiki_pages: Delete wiki pages
440 permission_delete_wiki_pages: Delete wiki pages
441 permission_view_wiki_pages: View wiki
441 permission_view_wiki_pages: View wiki
442 permission_view_wiki_edits: View wiki history
442 permission_view_wiki_edits: View wiki history
443 permission_edit_wiki_pages: Edit wiki pages
443 permission_edit_wiki_pages: Edit wiki pages
444 permission_delete_wiki_pages_attachments: Delete attachments
444 permission_delete_wiki_pages_attachments: Delete attachments
445 permission_protect_wiki_pages: Protect wiki pages
445 permission_protect_wiki_pages: Protect wiki pages
446 permission_manage_repository: Manage repository
446 permission_manage_repository: Manage repository
447 permission_browse_repository: Browse repository
447 permission_browse_repository: Browse repository
448 permission_view_changesets: View changesets
448 permission_view_changesets: View changesets
449 permission_commit_access: Commit access
449 permission_commit_access: Commit access
450 permission_manage_boards: Manage forums
450 permission_manage_boards: Manage forums
451 permission_view_messages: View messages
451 permission_view_messages: View messages
452 permission_add_messages: Post messages
452 permission_add_messages: Post messages
453 permission_edit_messages: Edit messages
453 permission_edit_messages: Edit messages
454 permission_edit_own_messages: Edit own messages
454 permission_edit_own_messages: Edit own messages
455 permission_delete_messages: Delete messages
455 permission_delete_messages: Delete messages
456 permission_delete_own_messages: Delete own messages
456 permission_delete_own_messages: Delete own messages
457 permission_export_wiki_pages: Export wiki pages
457 permission_export_wiki_pages: Export wiki pages
458 permission_manage_subtasks: Manage subtasks
458 permission_manage_subtasks: Manage subtasks
459 permission_manage_related_issues: Manage related issues
459 permission_manage_related_issues: Manage related issues
460
460
461 project_module_issue_tracking: Issue tracking
461 project_module_issue_tracking: Issue tracking
462 project_module_time_tracking: Time tracking
462 project_module_time_tracking: Time tracking
463 project_module_news: News
463 project_module_news: News
464 project_module_documents: Documents
464 project_module_documents: Documents
465 project_module_files: Files
465 project_module_files: Files
466 project_module_wiki: Wiki
466 project_module_wiki: Wiki
467 project_module_repository: Repository
467 project_module_repository: Repository
468 project_module_boards: Forums
468 project_module_boards: Forums
469 project_module_calendar: Calendar
469 project_module_calendar: Calendar
470 project_module_gantt: Gantt
470 project_module_gantt: Gantt
471
471
472 label_user: User
472 label_user: User
473 label_user_plural: Users
473 label_user_plural: Users
474 label_user_new: New user
474 label_user_new: New user
475 label_user_anonymous: Anonymous
475 label_user_anonymous: Anonymous
476 label_project: Project
476 label_project: Project
477 label_project_new: New project
477 label_project_new: New project
478 label_project_plural: Projects
478 label_project_plural: Projects
479 label_x_projects:
479 label_x_projects:
480 zero: no projects
480 zero: no projects
481 one: 1 project
481 one: 1 project
482 other: "%{count} projects"
482 other: "%{count} projects"
483 label_project_all: All Projects
483 label_project_all: All Projects
484 label_project_latest: Latest projects
484 label_project_latest: Latest projects
485 label_issue: Issue
485 label_issue: Issue
486 label_issue_new: New issue
486 label_issue_new: New issue
487 label_issue_plural: Issues
487 label_issue_plural: Issues
488 label_issue_view_all: View all issues
488 label_issue_view_all: View all issues
489 label_issues_by: "Issues by %{value}"
489 label_issues_by: "Issues by %{value}"
490 label_issue_added: Issue added
490 label_issue_added: Issue added
491 label_issue_updated: Issue updated
491 label_issue_updated: Issue updated
492 label_issue_note_added: Note added
492 label_issue_note_added: Note added
493 label_issue_status_updated: Status updated
493 label_issue_status_updated: Status updated
494 label_issue_priority_updated: Priority updated
494 label_issue_priority_updated: Priority updated
495 label_document: Document
495 label_document: Document
496 label_document_new: New document
496 label_document_new: New document
497 label_document_plural: Documents
497 label_document_plural: Documents
498 label_document_added: Document added
498 label_document_added: Document added
499 label_role: Role
499 label_role: Role
500 label_role_plural: Roles
500 label_role_plural: Roles
501 label_role_new: New role
501 label_role_new: New role
502 label_role_and_permissions: Roles and permissions
502 label_role_and_permissions: Roles and permissions
503 label_role_anonymous: Anonymous
503 label_role_anonymous: Anonymous
504 label_role_non_member: Non member
504 label_role_non_member: Non member
505 label_member: Member
505 label_member: Member
506 label_member_new: New member
506 label_member_new: New member
507 label_member_plural: Members
507 label_member_plural: Members
508 label_tracker: Tracker
508 label_tracker: Tracker
509 label_tracker_plural: Trackers
509 label_tracker_plural: Trackers
510 label_tracker_new: New tracker
510 label_tracker_new: New tracker
511 label_workflow: Workflow
511 label_workflow: Workflow
512 label_issue_status: Issue status
512 label_issue_status: Issue status
513 label_issue_status_plural: Issue statuses
513 label_issue_status_plural: Issue statuses
514 label_issue_status_new: New status
514 label_issue_status_new: New status
515 label_issue_category: Issue category
515 label_issue_category: Issue category
516 label_issue_category_plural: Issue categories
516 label_issue_category_plural: Issue categories
517 label_issue_category_new: New category
517 label_issue_category_new: New category
518 label_custom_field: Custom field
518 label_custom_field: Custom field
519 label_custom_field_plural: Custom fields
519 label_custom_field_plural: Custom fields
520 label_custom_field_new: New custom field
520 label_custom_field_new: New custom field
521 label_enumerations: Enumerations
521 label_enumerations: Enumerations
522 label_enumeration_new: New value
522 label_enumeration_new: New value
523 label_information: Information
523 label_information: Information
524 label_information_plural: Information
524 label_information_plural: Information
525 label_please_login: Please log in
525 label_please_login: Please log in
526 label_register: Register
526 label_register: Register
527 label_login_with_open_id_option: or login with OpenID
527 label_login_with_open_id_option: or login with OpenID
528 label_password_lost: Lost password
528 label_password_lost: Lost password
529 label_home: Home
529 label_home: Home
530 label_my_page: My page
530 label_my_page: My page
531 label_my_account: My account
531 label_my_account: My account
532 label_my_projects: My projects
532 label_my_projects: My projects
533 label_my_page_block: My page block
533 label_my_page_block: My page block
534 label_administration: Administration
534 label_administration: Administration
535 label_login: Sign in
535 label_login: Sign in
536 label_logout: Sign out
536 label_logout: Sign out
537 label_help: Help
537 label_help: Help
538 label_reported_issues: Reported issues
538 label_reported_issues: Reported issues
539 label_assigned_to_me_issues: Issues assigned to me
539 label_assigned_to_me_issues: Issues assigned to me
540 label_last_login: Last connection
540 label_last_login: Last connection
541 label_registered_on: Registered on
541 label_registered_on: Registered on
542 label_activity: Activity
542 label_activity: Activity
543 label_overall_activity: Overall activity
543 label_overall_activity: Overall activity
544 label_user_activity: "%{value}'s activity"
544 label_user_activity: "%{value}'s activity"
545 label_new: New
545 label_new: New
546 label_logged_as: Logged in as
546 label_logged_as: Logged in as
547 label_environment: Environment
547 label_environment: Environment
548 label_authentication: Authentication
548 label_authentication: Authentication
549 label_auth_source: Authentication mode
549 label_auth_source: Authentication mode
550 label_auth_source_new: New authentication mode
550 label_auth_source_new: New authentication mode
551 label_auth_source_plural: Authentication modes
551 label_auth_source_plural: Authentication modes
552 label_subproject_plural: Subprojects
552 label_subproject_plural: Subprojects
553 label_subproject_new: New subproject
553 label_subproject_new: New subproject
554 label_and_its_subprojects: "%{value} and its subprojects"
554 label_and_its_subprojects: "%{value} and its subprojects"
555 label_min_max_length: Min - Max length
555 label_min_max_length: Min - Max length
556 label_list: List
556 label_list: List
557 label_date: Date
557 label_date: Date
558 label_integer: Integer
558 label_integer: Integer
559 label_float: Float
559 label_float: Float
560 label_boolean: Boolean
560 label_boolean: Boolean
561 label_string: Text
561 label_string: Text
562 label_text: Long text
562 label_text: Long text
563 label_attribute: Attribute
563 label_attribute: Attribute
564 label_attribute_plural: Attributes
564 label_attribute_plural: Attributes
565 label_download: "%{count} Download"
565 label_download: "%{count} Download"
566 label_download_plural: "%{count} Downloads"
566 label_download_plural: "%{count} Downloads"
567 label_no_data: No data to display
567 label_no_data: No data to display
568 label_change_status: Change status
568 label_change_status: Change status
569 label_history: History
569 label_history: History
570 label_attachment: File
570 label_attachment: File
571 label_attachment_new: New file
571 label_attachment_new: New file
572 label_attachment_delete: Delete file
572 label_attachment_delete: Delete file
573 label_attachment_plural: Files
573 label_attachment_plural: Files
574 label_file_added: File added
574 label_file_added: File added
575 label_report: Report
575 label_report: Report
576 label_report_plural: Reports
576 label_report_plural: Reports
577 label_news: News
577 label_news: News
578 label_news_new: Add news
578 label_news_new: Add news
579 label_news_plural: News
579 label_news_plural: News
580 label_news_latest: Latest news
580 label_news_latest: Latest news
581 label_news_view_all: View all news
581 label_news_view_all: View all news
582 label_news_added: News added
582 label_news_added: News added
583 label_news_comment_added: Comment added to a news
583 label_news_comment_added: Comment added to a news
584 label_settings: Settings
584 label_settings: Settings
585 label_overview: Overview
585 label_overview: Overview
586 label_version: Version
586 label_version: Version
587 label_version_new: New version
587 label_version_new: New version
588 label_version_plural: Versions
588 label_version_plural: Versions
589 label_close_versions: Close completed versions
589 label_close_versions: Close completed versions
590 label_confirmation: Confirmation
590 label_confirmation: Confirmation
591 label_export_to: 'Also available in:'
591 label_export_to: 'Also available in:'
592 label_read: Read...
592 label_read: Read...
593 label_public_projects: Public projects
593 label_public_projects: Public projects
594 label_open_issues: open
594 label_open_issues: open
595 label_open_issues_plural: open
595 label_open_issues_plural: open
596 label_closed_issues: closed
596 label_closed_issues: closed
597 label_closed_issues_plural: closed
597 label_closed_issues_plural: closed
598 label_x_open_issues_abbr_on_total:
598 label_x_open_issues_abbr_on_total:
599 zero: 0 open / %{total}
599 zero: 0 open / %{total}
600 one: 1 open / %{total}
600 one: 1 open / %{total}
601 other: "%{count} open / %{total}"
601 other: "%{count} open / %{total}"
602 label_x_open_issues_abbr:
602 label_x_open_issues_abbr:
603 zero: 0 open
603 zero: 0 open
604 one: 1 open
604 one: 1 open
605 other: "%{count} open"
605 other: "%{count} open"
606 label_x_closed_issues_abbr:
606 label_x_closed_issues_abbr:
607 zero: 0 closed
607 zero: 0 closed
608 one: 1 closed
608 one: 1 closed
609 other: "%{count} closed"
609 other: "%{count} closed"
610 label_x_issues:
610 label_x_issues:
611 zero: 0 issues
611 zero: 0 issues
612 one: 1 issue
612 one: 1 issue
613 other: "%{count} issues"
613 other: "%{count} issues"
614 label_total: Total
614 label_total: Total
615 label_permissions: Permissions
615 label_permissions: Permissions
616 label_current_status: Current status
616 label_current_status: Current status
617 label_new_statuses_allowed: New statuses allowed
617 label_new_statuses_allowed: New statuses allowed
618 label_all: all
618 label_all: all
619 label_none: none
619 label_none: none
620 label_nobody: nobody
620 label_nobody: nobody
621 label_next: Next
621 label_next: Next
622 label_previous: Previous
622 label_previous: Previous
623 label_used_by: Used by
623 label_used_by: Used by
624 label_details: Details
624 label_details: Details
625 label_add_note: Add a note
625 label_add_note: Add a note
626 label_per_page: Per page
626 label_per_page: Per page
627 label_calendar: Calendar
627 label_calendar: Calendar
628 label_months_from: months from
628 label_months_from: months from
629 label_gantt: Gantt
629 label_gantt: Gantt
630 label_internal: Internal
630 label_internal: Internal
631 label_last_changes: "last %{count} changes"
631 label_last_changes: "last %{count} changes"
632 label_change_view_all: View all changes
632 label_change_view_all: View all changes
633 label_personalize_page: Personalize this page
633 label_personalize_page: Personalize this page
634 label_comment: Comment
634 label_comment: Comment
635 label_comment_plural: Comments
635 label_comment_plural: Comments
636 label_x_comments:
636 label_x_comments:
637 zero: no comments
637 zero: no comments
638 one: 1 comment
638 one: 1 comment
639 other: "%{count} comments"
639 other: "%{count} comments"
640 label_comment_add: Add a comment
640 label_comment_add: Add a comment
641 label_comment_added: Comment added
641 label_comment_added: Comment added
642 label_comment_delete: Delete comments
642 label_comment_delete: Delete comments
643 label_query: Custom query
643 label_query: Custom query
644 label_query_plural: Custom queries
644 label_query_plural: Custom queries
645 label_query_new: New query
645 label_query_new: New query
646 label_my_queries: My custom queries
646 label_my_queries: My custom queries
647 label_filter_add: Add filter
647 label_filter_add: Add filter
648 label_filter_plural: Filters
648 label_filter_plural: Filters
649 label_equals: is
649 label_equals: is
650 label_not_equals: is not
650 label_not_equals: is not
651 label_in_less_than: in less than
651 label_in_less_than: in less than
652 label_in_more_than: in more than
652 label_in_more_than: in more than
653 label_greater_or_equal: '>='
653 label_greater_or_equal: '>='
654 label_less_or_equal: '<='
654 label_less_or_equal: '<='
655 label_between: between
655 label_between: between
656 label_in: in
656 label_in: in
657 label_today: today
657 label_today: today
658 label_all_time: all time
658 label_all_time: all time
659 label_yesterday: yesterday
659 label_yesterday: yesterday
660 label_this_week: this week
660 label_this_week: this week
661 label_last_week: last week
661 label_last_week: last week
662 label_last_n_days: "last %{count} days"
662 label_last_n_days: "last %{count} days"
663 label_this_month: this month
663 label_this_month: this month
664 label_last_month: last month
664 label_last_month: last month
665 label_this_year: this year
665 label_this_year: this year
666 label_date_range: Date range
666 label_date_range: Date range
667 label_less_than_ago: less than days ago
667 label_less_than_ago: less than days ago
668 label_more_than_ago: more than days ago
668 label_more_than_ago: more than days ago
669 label_ago: days ago
669 label_ago: days ago
670 label_contains: contains
670 label_contains: contains
671 label_not_contains: doesn't contain
671 label_not_contains: doesn't contain
672 label_day_plural: days
672 label_day_plural: days
673 label_repository: Repository
673 label_repository: Repository
674 label_repository_new: New repository
674 label_repository_new: New repository
675 label_repository_plural: Repositories
675 label_repository_plural: Repositories
676 label_browse: Browse
676 label_browse: Browse
677 label_modification: "%{count} change"
677 label_modification: "%{count} change"
678 label_modification_plural: "%{count} changes"
678 label_modification_plural: "%{count} changes"
679 label_branch: Branch
679 label_branch: Branch
680 label_tag: Tag
680 label_tag: Tag
681 label_revision: Revision
681 label_revision: Revision
682 label_revision_plural: Revisions
682 label_revision_plural: Revisions
683 label_revision_id: "Revision %{value}"
683 label_revision_id: "Revision %{value}"
684 label_associated_revisions: Associated revisions
684 label_associated_revisions: Associated revisions
685 label_added: added
685 label_added: added
686 label_modified: modified
686 label_modified: modified
687 label_copied: copied
687 label_copied: copied
688 label_renamed: renamed
688 label_renamed: renamed
689 label_deleted: deleted
689 label_deleted: deleted
690 label_latest_revision: Latest revision
690 label_latest_revision: Latest revision
691 label_latest_revision_plural: Latest revisions
691 label_latest_revision_plural: Latest revisions
692 label_view_revisions: View revisions
692 label_view_revisions: View revisions
693 label_view_all_revisions: View all revisions
693 label_view_all_revisions: View all revisions
694 label_max_size: Maximum size
694 label_max_size: Maximum size
695 label_sort_highest: Move to top
695 label_sort_highest: Move to top
696 label_sort_higher: Move up
696 label_sort_higher: Move up
697 label_sort_lower: Move down
697 label_sort_lower: Move down
698 label_sort_lowest: Move to bottom
698 label_sort_lowest: Move to bottom
699 label_roadmap: Roadmap
699 label_roadmap: Roadmap
700 label_roadmap_due_in: "Due in %{value}"
700 label_roadmap_due_in: "Due in %{value}"
701 label_roadmap_overdue: "%{value} late"
701 label_roadmap_overdue: "%{value} late"
702 label_roadmap_no_issues: No issues for this version
702 label_roadmap_no_issues: No issues for this version
703 label_search: Search
703 label_search: Search
704 label_result_plural: Results
704 label_result_plural: Results
705 label_all_words: All words
705 label_all_words: All words
706 label_wiki: Wiki
706 label_wiki: Wiki
707 label_wiki_edit: Wiki edit
707 label_wiki_edit: Wiki edit
708 label_wiki_edit_plural: Wiki edits
708 label_wiki_edit_plural: Wiki edits
709 label_wiki_page: Wiki page
709 label_wiki_page: Wiki page
710 label_wiki_page_plural: Wiki pages
710 label_wiki_page_plural: Wiki pages
711 label_index_by_title: Index by title
711 label_index_by_title: Index by title
712 label_index_by_date: Index by date
712 label_index_by_date: Index by date
713 label_current_version: Current version
713 label_current_version: Current version
714 label_preview: Preview
714 label_preview: Preview
715 label_feed_plural: Feeds
715 label_feed_plural: Feeds
716 label_changes_details: Details of all changes
716 label_changes_details: Details of all changes
717 label_issue_tracking: Issue tracking
717 label_issue_tracking: Issue tracking
718 label_spent_time: Spent time
718 label_spent_time: Spent time
719 label_overall_spent_time: Overall spent time
719 label_overall_spent_time: Overall spent time
720 label_f_hour: "%{value} hour"
720 label_f_hour: "%{value} hour"
721 label_f_hour_plural: "%{value} hours"
721 label_f_hour_plural: "%{value} hours"
722 label_time_tracking: Time tracking
722 label_time_tracking: Time tracking
723 label_change_plural: Changes
723 label_change_plural: Changes
724 label_statistics: Statistics
724 label_statistics: Statistics
725 label_commits_per_month: Commits per month
725 label_commits_per_month: Commits per month
726 label_commits_per_author: Commits per author
726 label_commits_per_author: Commits per author
727 label_diff: diff
727 label_diff: diff
728 label_view_diff: View differences
728 label_view_diff: View differences
729 label_diff_inline: inline
729 label_diff_inline: inline
730 label_diff_side_by_side: side by side
730 label_diff_side_by_side: side by side
731 label_options: Options
731 label_options: Options
732 label_copy_workflow_from: Copy workflow from
732 label_copy_workflow_from: Copy workflow from
733 label_permissions_report: Permissions report
733 label_permissions_report: Permissions report
734 label_watched_issues: Watched issues
734 label_watched_issues: Watched issues
735 label_related_issues: Related issues
735 label_related_issues: Related issues
736 label_applied_status: Applied status
736 label_applied_status: Applied status
737 label_loading: Loading...
737 label_loading: Loading...
738 label_relation_new: New relation
738 label_relation_new: New relation
739 label_relation_delete: Delete relation
739 label_relation_delete: Delete relation
740 label_relates_to: related to
740 label_relates_to: related to
741 label_duplicates: duplicates
741 label_duplicates: duplicates
742 label_duplicated_by: duplicated by
742 label_duplicated_by: duplicated by
743 label_blocks: blocks
743 label_blocks: blocks
744 label_blocked_by: blocked by
744 label_blocked_by: blocked by
745 label_precedes: precedes
745 label_precedes: precedes
746 label_follows: follows
746 label_follows: follows
747 label_copied_to: copied to
748 label_copied_from: copied from
747 label_end_to_start: end to start
749 label_end_to_start: end to start
748 label_end_to_end: end to end
750 label_end_to_end: end to end
749 label_start_to_start: start to start
751 label_start_to_start: start to start
750 label_start_to_end: start to end
752 label_start_to_end: start to end
751 label_stay_logged_in: Stay logged in
753 label_stay_logged_in: Stay logged in
752 label_disabled: disabled
754 label_disabled: disabled
753 label_show_completed_versions: Show completed versions
755 label_show_completed_versions: Show completed versions
754 label_me: me
756 label_me: me
755 label_board: Forum
757 label_board: Forum
756 label_board_new: New forum
758 label_board_new: New forum
757 label_board_plural: Forums
759 label_board_plural: Forums
758 label_board_locked: Locked
760 label_board_locked: Locked
759 label_board_sticky: Sticky
761 label_board_sticky: Sticky
760 label_topic_plural: Topics
762 label_topic_plural: Topics
761 label_message_plural: Messages
763 label_message_plural: Messages
762 label_message_last: Last message
764 label_message_last: Last message
763 label_message_new: New message
765 label_message_new: New message
764 label_message_posted: Message added
766 label_message_posted: Message added
765 label_reply_plural: Replies
767 label_reply_plural: Replies
766 label_send_information: Send account information to the user
768 label_send_information: Send account information to the user
767 label_year: Year
769 label_year: Year
768 label_month: Month
770 label_month: Month
769 label_week: Week
771 label_week: Week
770 label_date_from: From
772 label_date_from: From
771 label_date_to: To
773 label_date_to: To
772 label_language_based: Based on user's language
774 label_language_based: Based on user's language
773 label_sort_by: "Sort by %{value}"
775 label_sort_by: "Sort by %{value}"
774 label_send_test_email: Send a test email
776 label_send_test_email: Send a test email
775 label_feeds_access_key: RSS access key
777 label_feeds_access_key: RSS access key
776 label_missing_feeds_access_key: Missing a RSS access key
778 label_missing_feeds_access_key: Missing a RSS access key
777 label_feeds_access_key_created_on: "RSS access key created %{value} ago"
779 label_feeds_access_key_created_on: "RSS access key created %{value} ago"
778 label_module_plural: Modules
780 label_module_plural: Modules
779 label_added_time_by: "Added by %{author} %{age} ago"
781 label_added_time_by: "Added by %{author} %{age} ago"
780 label_updated_time_by: "Updated by %{author} %{age} ago"
782 label_updated_time_by: "Updated by %{author} %{age} ago"
781 label_updated_time: "Updated %{value} ago"
783 label_updated_time: "Updated %{value} ago"
782 label_jump_to_a_project: Jump to a project...
784 label_jump_to_a_project: Jump to a project...
783 label_file_plural: Files
785 label_file_plural: Files
784 label_changeset_plural: Changesets
786 label_changeset_plural: Changesets
785 label_default_columns: Default columns
787 label_default_columns: Default columns
786 label_no_change_option: (No change)
788 label_no_change_option: (No change)
787 label_bulk_edit_selected_issues: Bulk edit selected issues
789 label_bulk_edit_selected_issues: Bulk edit selected issues
788 label_bulk_edit_selected_time_entries: Bulk edit selected time entries
790 label_bulk_edit_selected_time_entries: Bulk edit selected time entries
789 label_theme: Theme
791 label_theme: Theme
790 label_default: Default
792 label_default: Default
791 label_search_titles_only: Search titles only
793 label_search_titles_only: Search titles only
792 label_user_mail_option_all: "For any event on all my projects"
794 label_user_mail_option_all: "For any event on all my projects"
793 label_user_mail_option_selected: "For any event on the selected projects only..."
795 label_user_mail_option_selected: "For any event on the selected projects only..."
794 label_user_mail_option_none: "No events"
796 label_user_mail_option_none: "No events"
795 label_user_mail_option_only_my_events: "Only for things I watch or I'm involved in"
797 label_user_mail_option_only_my_events: "Only for things I watch or I'm involved in"
796 label_user_mail_option_only_assigned: "Only for things I am assigned to"
798 label_user_mail_option_only_assigned: "Only for things I am assigned to"
797 label_user_mail_option_only_owner: "Only for things I am the owner of"
799 label_user_mail_option_only_owner: "Only for things I am the owner of"
798 label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
800 label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
799 label_registration_activation_by_email: account activation by email
801 label_registration_activation_by_email: account activation by email
800 label_registration_manual_activation: manual account activation
802 label_registration_manual_activation: manual account activation
801 label_registration_automatic_activation: automatic account activation
803 label_registration_automatic_activation: automatic account activation
802 label_display_per_page: "Per page: %{value}"
804 label_display_per_page: "Per page: %{value}"
803 label_age: Age
805 label_age: Age
804 label_change_properties: Change properties
806 label_change_properties: Change properties
805 label_general: General
807 label_general: General
806 label_more: More
808 label_more: More
807 label_scm: SCM
809 label_scm: SCM
808 label_plugins: Plugins
810 label_plugins: Plugins
809 label_ldap_authentication: LDAP authentication
811 label_ldap_authentication: LDAP authentication
810 label_downloads_abbr: D/L
812 label_downloads_abbr: D/L
811 label_optional_description: Optional description
813 label_optional_description: Optional description
812 label_add_another_file: Add another file
814 label_add_another_file: Add another file
813 label_preferences: Preferences
815 label_preferences: Preferences
814 label_chronological_order: In chronological order
816 label_chronological_order: In chronological order
815 label_reverse_chronological_order: In reverse chronological order
817 label_reverse_chronological_order: In reverse chronological order
816 label_planning: Planning
818 label_planning: Planning
817 label_incoming_emails: Incoming emails
819 label_incoming_emails: Incoming emails
818 label_generate_key: Generate a key
820 label_generate_key: Generate a key
819 label_issue_watchers: Watchers
821 label_issue_watchers: Watchers
820 label_example: Example
822 label_example: Example
821 label_display: Display
823 label_display: Display
822 label_sort: Sort
824 label_sort: Sort
823 label_ascending: Ascending
825 label_ascending: Ascending
824 label_descending: Descending
826 label_descending: Descending
825 label_date_from_to: From %{start} to %{end}
827 label_date_from_to: From %{start} to %{end}
826 label_wiki_content_added: Wiki page added
828 label_wiki_content_added: Wiki page added
827 label_wiki_content_updated: Wiki page updated
829 label_wiki_content_updated: Wiki page updated
828 label_group: Group
830 label_group: Group
829 label_group_plural: Groups
831 label_group_plural: Groups
830 label_group_new: New group
832 label_group_new: New group
831 label_time_entry_plural: Spent time
833 label_time_entry_plural: Spent time
832 label_version_sharing_none: Not shared
834 label_version_sharing_none: Not shared
833 label_version_sharing_descendants: With subprojects
835 label_version_sharing_descendants: With subprojects
834 label_version_sharing_hierarchy: With project hierarchy
836 label_version_sharing_hierarchy: With project hierarchy
835 label_version_sharing_tree: With project tree
837 label_version_sharing_tree: With project tree
836 label_version_sharing_system: With all projects
838 label_version_sharing_system: With all projects
837 label_update_issue_done_ratios: Update issue done ratios
839 label_update_issue_done_ratios: Update issue done ratios
838 label_copy_source: Source
840 label_copy_source: Source
839 label_copy_target: Target
841 label_copy_target: Target
840 label_copy_same_as_target: Same as target
842 label_copy_same_as_target: Same as target
841 label_display_used_statuses_only: Only display statuses that are used by this tracker
843 label_display_used_statuses_only: Only display statuses that are used by this tracker
842 label_api_access_key: API access key
844 label_api_access_key: API access key
843 label_missing_api_access_key: Missing an API access key
845 label_missing_api_access_key: Missing an API access key
844 label_api_access_key_created_on: "API access key created %{value} ago"
846 label_api_access_key_created_on: "API access key created %{value} ago"
845 label_profile: Profile
847 label_profile: Profile
846 label_subtask_plural: Subtasks
848 label_subtask_plural: Subtasks
847 label_project_copy_notifications: Send email notifications during the project copy
849 label_project_copy_notifications: Send email notifications during the project copy
848 label_principal_search: "Search for user or group:"
850 label_principal_search: "Search for user or group:"
849 label_user_search: "Search for user:"
851 label_user_search: "Search for user:"
850 label_additional_workflow_transitions_for_author: Additional transitions allowed when the user is the author
852 label_additional_workflow_transitions_for_author: Additional transitions allowed when the user is the author
851 label_additional_workflow_transitions_for_assignee: Additional transitions allowed when the user is the assignee
853 label_additional_workflow_transitions_for_assignee: Additional transitions allowed when the user is the assignee
852 label_issues_visibility_all: All issues
854 label_issues_visibility_all: All issues
853 label_issues_visibility_public: All non private issues
855 label_issues_visibility_public: All non private issues
854 label_issues_visibility_own: Issues created by or assigned to the user
856 label_issues_visibility_own: Issues created by or assigned to the user
855 label_git_report_last_commit: Report last commit for files and directories
857 label_git_report_last_commit: Report last commit for files and directories
856 label_parent_revision: Parent
858 label_parent_revision: Parent
857 label_child_revision: Child
859 label_child_revision: Child
858 label_export_options: "%{export_format} export options"
860 label_export_options: "%{export_format} export options"
859 label_copy_attachments: Copy attachments
861 label_copy_attachments: Copy attachments
860 label_copy_subtasks: Copy subtasks
862 label_copy_subtasks: Copy subtasks
861 label_item_position: "%{position} of %{count}"
863 label_item_position: "%{position} of %{count}"
862 label_completed_versions: Completed versions
864 label_completed_versions: Completed versions
863 label_search_for_watchers: Search for watchers to add
865 label_search_for_watchers: Search for watchers to add
864 label_session_expiration: Session expiration
866 label_session_expiration: Session expiration
865 label_show_closed_projects: View closed projects
867 label_show_closed_projects: View closed projects
866 label_status_transitions: Status transitions
868 label_status_transitions: Status transitions
867 label_fields_permissions: Fields permissions
869 label_fields_permissions: Fields permissions
868 label_readonly: Read-only
870 label_readonly: Read-only
869 label_required: Required
871 label_required: Required
870 label_attribute_of_project: "Project's %{name}"
872 label_attribute_of_project: "Project's %{name}"
871 label_attribute_of_author: "Author's %{name}"
873 label_attribute_of_author: "Author's %{name}"
872 label_attribute_of_assigned_to: "Assignee's %{name}"
874 label_attribute_of_assigned_to: "Assignee's %{name}"
873 label_attribute_of_fixed_version: "Target version's %{name}"
875 label_attribute_of_fixed_version: "Target version's %{name}"
874
876
875 button_login: Login
877 button_login: Login
876 button_submit: Submit
878 button_submit: Submit
877 button_save: Save
879 button_save: Save
878 button_check_all: Check all
880 button_check_all: Check all
879 button_uncheck_all: Uncheck all
881 button_uncheck_all: Uncheck all
880 button_collapse_all: Collapse all
882 button_collapse_all: Collapse all
881 button_expand_all: Expand all
883 button_expand_all: Expand all
882 button_delete: Delete
884 button_delete: Delete
883 button_create: Create
885 button_create: Create
884 button_create_and_continue: Create and continue
886 button_create_and_continue: Create and continue
885 button_test: Test
887 button_test: Test
886 button_edit: Edit
888 button_edit: Edit
887 button_edit_associated_wikipage: "Edit associated Wiki page: %{page_title}"
889 button_edit_associated_wikipage: "Edit associated Wiki page: %{page_title}"
888 button_add: Add
890 button_add: Add
889 button_change: Change
891 button_change: Change
890 button_apply: Apply
892 button_apply: Apply
891 button_clear: Clear
893 button_clear: Clear
892 button_lock: Lock
894 button_lock: Lock
893 button_unlock: Unlock
895 button_unlock: Unlock
894 button_download: Download
896 button_download: Download
895 button_list: List
897 button_list: List
896 button_view: View
898 button_view: View
897 button_move: Move
899 button_move: Move
898 button_move_and_follow: Move and follow
900 button_move_and_follow: Move and follow
899 button_back: Back
901 button_back: Back
900 button_cancel: Cancel
902 button_cancel: Cancel
901 button_activate: Activate
903 button_activate: Activate
902 button_sort: Sort
904 button_sort: Sort
903 button_log_time: Log time
905 button_log_time: Log time
904 button_rollback: Rollback to this version
906 button_rollback: Rollback to this version
905 button_watch: Watch
907 button_watch: Watch
906 button_unwatch: Unwatch
908 button_unwatch: Unwatch
907 button_reply: Reply
909 button_reply: Reply
908 button_archive: Archive
910 button_archive: Archive
909 button_unarchive: Unarchive
911 button_unarchive: Unarchive
910 button_reset: Reset
912 button_reset: Reset
911 button_rename: Rename
913 button_rename: Rename
912 button_change_password: Change password
914 button_change_password: Change password
913 button_copy: Copy
915 button_copy: Copy
914 button_copy_and_follow: Copy and follow
916 button_copy_and_follow: Copy and follow
915 button_annotate: Annotate
917 button_annotate: Annotate
916 button_update: Update
918 button_update: Update
917 button_configure: Configure
919 button_configure: Configure
918 button_quote: Quote
920 button_quote: Quote
919 button_duplicate: Duplicate
921 button_duplicate: Duplicate
920 button_show: Show
922 button_show: Show
921 button_edit_section: Edit this section
923 button_edit_section: Edit this section
922 button_export: Export
924 button_export: Export
923 button_delete_my_account: Delete my account
925 button_delete_my_account: Delete my account
924 button_close: Close
926 button_close: Close
925 button_reopen: Reopen
927 button_reopen: Reopen
926
928
927 status_active: active
929 status_active: active
928 status_registered: registered
930 status_registered: registered
929 status_locked: locked
931 status_locked: locked
930
932
931 project_status_active: active
933 project_status_active: active
932 project_status_closed: closed
934 project_status_closed: closed
933 project_status_archived: archived
935 project_status_archived: archived
934
936
935 version_status_open: open
937 version_status_open: open
936 version_status_locked: locked
938 version_status_locked: locked
937 version_status_closed: closed
939 version_status_closed: closed
938
940
939 field_active: Active
941 field_active: Active
940
942
941 text_select_mail_notifications: Select actions for which email notifications should be sent.
943 text_select_mail_notifications: Select actions for which email notifications should be sent.
942 text_regexp_info: eg. ^[A-Z0-9]+$
944 text_regexp_info: eg. ^[A-Z0-9]+$
943 text_min_max_length_info: 0 means no restriction
945 text_min_max_length_info: 0 means no restriction
944 text_project_destroy_confirmation: Are you sure you want to delete this project and related data?
946 text_project_destroy_confirmation: Are you sure you want to delete this project and related data?
945 text_subprojects_destroy_warning: "Its subproject(s): %{value} will be also deleted."
947 text_subprojects_destroy_warning: "Its subproject(s): %{value} will be also deleted."
946 text_workflow_edit: Select a role and a tracker to edit the workflow
948 text_workflow_edit: Select a role and a tracker to edit the workflow
947 text_are_you_sure: Are you sure?
949 text_are_you_sure: Are you sure?
948 text_are_you_sure_with_children: "Delete issue and all child issues?"
950 text_are_you_sure_with_children: "Delete issue and all child issues?"
949 text_journal_changed: "%{label} changed from %{old} to %{new}"
951 text_journal_changed: "%{label} changed from %{old} to %{new}"
950 text_journal_changed_no_detail: "%{label} updated"
952 text_journal_changed_no_detail: "%{label} updated"
951 text_journal_set_to: "%{label} set to %{value}"
953 text_journal_set_to: "%{label} set to %{value}"
952 text_journal_deleted: "%{label} deleted (%{old})"
954 text_journal_deleted: "%{label} deleted (%{old})"
953 text_journal_added: "%{label} %{value} added"
955 text_journal_added: "%{label} %{value} added"
954 text_tip_issue_begin_day: issue beginning this day
956 text_tip_issue_begin_day: issue beginning this day
955 text_tip_issue_end_day: issue ending this day
957 text_tip_issue_end_day: issue ending this day
956 text_tip_issue_begin_end_day: issue beginning and ending this day
958 text_tip_issue_begin_end_day: issue beginning and ending this day
957 text_project_identifier_info: 'Only lower case letters (a-z), numbers, dashes and underscores are allowed.<br />Once saved, the identifier cannot be changed.'
959 text_project_identifier_info: 'Only lower case letters (a-z), numbers, dashes and underscores are allowed.<br />Once saved, the identifier cannot be changed.'
958 text_caracters_maximum: "%{count} characters maximum."
960 text_caracters_maximum: "%{count} characters maximum."
959 text_caracters_minimum: "Must be at least %{count} characters long."
961 text_caracters_minimum: "Must be at least %{count} characters long."
960 text_length_between: "Length between %{min} and %{max} characters."
962 text_length_between: "Length between %{min} and %{max} characters."
961 text_tracker_no_workflow: No workflow defined for this tracker
963 text_tracker_no_workflow: No workflow defined for this tracker
962 text_unallowed_characters: Unallowed characters
964 text_unallowed_characters: Unallowed characters
963 text_comma_separated: Multiple values allowed (comma separated).
965 text_comma_separated: Multiple values allowed (comma separated).
964 text_line_separated: Multiple values allowed (one line for each value).
966 text_line_separated: Multiple values allowed (one line for each value).
965 text_issues_ref_in_commit_messages: Referencing and fixing issues in commit messages
967 text_issues_ref_in_commit_messages: Referencing and fixing issues in commit messages
966 text_issue_added: "Issue %{id} has been reported by %{author}."
968 text_issue_added: "Issue %{id} has been reported by %{author}."
967 text_issue_updated: "Issue %{id} has been updated by %{author}."
969 text_issue_updated: "Issue %{id} has been updated by %{author}."
968 text_wiki_destroy_confirmation: Are you sure you want to delete this wiki and all its content?
970 text_wiki_destroy_confirmation: Are you sure you want to delete this wiki and all its content?
969 text_issue_category_destroy_question: "Some issues (%{count}) are assigned to this category. What do you want to do?"
971 text_issue_category_destroy_question: "Some issues (%{count}) are assigned to this category. What do you want to do?"
970 text_issue_category_destroy_assignments: Remove category assignments
972 text_issue_category_destroy_assignments: Remove category assignments
971 text_issue_category_reassign_to: Reassign issues to this category
973 text_issue_category_reassign_to: Reassign issues to this category
972 text_user_mail_option: "For unselected projects, you will only receive notifications about things you watch or you're involved in (eg. issues you're the author or assignee)."
974 text_user_mail_option: "For unselected projects, you will only receive notifications about things you watch or you're involved in (eg. issues you're the author or assignee)."
973 text_no_configuration_data: "Roles, trackers, issue statuses and workflow have not been configured yet.\nIt is highly recommended to load the default configuration. You will be able to modify it once loaded."
975 text_no_configuration_data: "Roles, trackers, issue statuses and workflow have not been configured yet.\nIt is highly recommended to load the default configuration. You will be able to modify it once loaded."
974 text_load_default_configuration: Load the default configuration
976 text_load_default_configuration: Load the default configuration
975 text_status_changed_by_changeset: "Applied in changeset %{value}."
977 text_status_changed_by_changeset: "Applied in changeset %{value}."
976 text_time_logged_by_changeset: "Applied in changeset %{value}."
978 text_time_logged_by_changeset: "Applied in changeset %{value}."
977 text_issues_destroy_confirmation: 'Are you sure you want to delete the selected issue(s)?'
979 text_issues_destroy_confirmation: 'Are you sure you want to delete the selected issue(s)?'
978 text_issues_destroy_descendants_confirmation: "This will also delete %{count} subtask(s)."
980 text_issues_destroy_descendants_confirmation: "This will also delete %{count} subtask(s)."
979 text_time_entries_destroy_confirmation: 'Are you sure you want to delete the selected time entr(y/ies)?'
981 text_time_entries_destroy_confirmation: 'Are you sure you want to delete the selected time entr(y/ies)?'
980 text_select_project_modules: 'Select modules to enable for this project:'
982 text_select_project_modules: 'Select modules to enable for this project:'
981 text_default_administrator_account_changed: Default administrator account changed
983 text_default_administrator_account_changed: Default administrator account changed
982 text_file_repository_writable: Attachments directory writable
984 text_file_repository_writable: Attachments directory writable
983 text_plugin_assets_writable: Plugin assets directory writable
985 text_plugin_assets_writable: Plugin assets directory writable
984 text_rmagick_available: RMagick available (optional)
986 text_rmagick_available: RMagick available (optional)
985 text_destroy_time_entries_question: "%{hours} hours were reported on the issues you are about to delete. What do you want to do?"
987 text_destroy_time_entries_question: "%{hours} hours were reported on the issues you are about to delete. What do you want to do?"
986 text_destroy_time_entries: Delete reported hours
988 text_destroy_time_entries: Delete reported hours
987 text_assign_time_entries_to_project: Assign reported hours to the project
989 text_assign_time_entries_to_project: Assign reported hours to the project
988 text_reassign_time_entries: 'Reassign reported hours to this issue:'
990 text_reassign_time_entries: 'Reassign reported hours to this issue:'
989 text_user_wrote: "%{value} wrote:"
991 text_user_wrote: "%{value} wrote:"
990 text_enumeration_destroy_question: "%{count} objects are assigned to this value."
992 text_enumeration_destroy_question: "%{count} objects are assigned to this value."
991 text_enumeration_category_reassign_to: 'Reassign them to this value:'
993 text_enumeration_category_reassign_to: 'Reassign them to this value:'
992 text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/configuration.yml and restart the application to enable them."
994 text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/configuration.yml and restart the application to enable them."
993 text_repository_usernames_mapping: "Select or update the Redmine user mapped to each username found in the repository log.\nUsers with the same Redmine and repository username or email are automatically mapped."
995 text_repository_usernames_mapping: "Select or update the Redmine user mapped to each username found in the repository log.\nUsers with the same Redmine and repository username or email are automatically mapped."
994 text_diff_truncated: '... This diff was truncated because it exceeds the maximum size that can be displayed.'
996 text_diff_truncated: '... This diff was truncated because it exceeds the maximum size that can be displayed.'
995 text_custom_field_possible_values_info: 'One line for each value'
997 text_custom_field_possible_values_info: 'One line for each value'
996 text_wiki_page_destroy_question: "This page has %{descendants} child page(s) and descendant(s). What do you want to do?"
998 text_wiki_page_destroy_question: "This page has %{descendants} child page(s) and descendant(s). What do you want to do?"
997 text_wiki_page_nullify_children: "Keep child pages as root pages"
999 text_wiki_page_nullify_children: "Keep child pages as root pages"
998 text_wiki_page_destroy_children: "Delete child pages and all their descendants"
1000 text_wiki_page_destroy_children: "Delete child pages and all their descendants"
999 text_wiki_page_reassign_children: "Reassign child pages to this parent page"
1001 text_wiki_page_reassign_children: "Reassign child pages to this parent page"
1000 text_own_membership_delete_confirmation: "You are about to remove some or all of your permissions and may no longer be able to edit this project after that.\nAre you sure you want to continue?"
1002 text_own_membership_delete_confirmation: "You are about to remove some or all of your permissions and may no longer be able to edit this project after that.\nAre you sure you want to continue?"
1001 text_zoom_in: Zoom in
1003 text_zoom_in: Zoom in
1002 text_zoom_out: Zoom out
1004 text_zoom_out: Zoom out
1003 text_warn_on_leaving_unsaved: "The current page contains unsaved text that will be lost if you leave this page."
1005 text_warn_on_leaving_unsaved: "The current page contains unsaved text that will be lost if you leave this page."
1004 text_scm_path_encoding_note: "Default: UTF-8"
1006 text_scm_path_encoding_note: "Default: UTF-8"
1005 text_git_repository_note: Repository is bare and local (e.g. /gitrepo, c:\gitrepo)
1007 text_git_repository_note: Repository is bare and local (e.g. /gitrepo, c:\gitrepo)
1006 text_mercurial_repository_note: Local repository (e.g. /hgrepo, c:\hgrepo)
1008 text_mercurial_repository_note: Local repository (e.g. /hgrepo, c:\hgrepo)
1007 text_scm_command: Command
1009 text_scm_command: Command
1008 text_scm_command_version: Version
1010 text_scm_command_version: Version
1009 text_scm_config: You can configure your scm commands in config/configuration.yml. Please restart the application after editing it.
1011 text_scm_config: You can configure your scm commands in config/configuration.yml. Please restart the application after editing it.
1010 text_scm_command_not_available: Scm command is not available. Please check settings on the administration panel.
1012 text_scm_command_not_available: Scm command is not available. Please check settings on the administration panel.
1011 text_issue_conflict_resolution_overwrite: "Apply my changes anyway (previous notes will be kept but some changes may be overwritten)"
1013 text_issue_conflict_resolution_overwrite: "Apply my changes anyway (previous notes will be kept but some changes may be overwritten)"
1012 text_issue_conflict_resolution_add_notes: "Add my notes and discard my other changes"
1014 text_issue_conflict_resolution_add_notes: "Add my notes and discard my other changes"
1013 text_issue_conflict_resolution_cancel: "Discard all my changes and redisplay %{link}"
1015 text_issue_conflict_resolution_cancel: "Discard all my changes and redisplay %{link}"
1014 text_account_destroy_confirmation: "Are you sure you want to proceed?\nYour account will be permanently deleted, with no way to reactivate it."
1016 text_account_destroy_confirmation: "Are you sure you want to proceed?\nYour account will be permanently deleted, with no way to reactivate it."
1015 text_session_expiration_settings: "Warning: changing these settings may expire the current sessions including yours."
1017 text_session_expiration_settings: "Warning: changing these settings may expire the current sessions including yours."
1016 text_project_closed: This project is closed and read-only.
1018 text_project_closed: This project is closed and read-only.
1017
1019
1018 default_role_manager: Manager
1020 default_role_manager: Manager
1019 default_role_developer: Developer
1021 default_role_developer: Developer
1020 default_role_reporter: Reporter
1022 default_role_reporter: Reporter
1021 default_tracker_bug: Bug
1023 default_tracker_bug: Bug
1022 default_tracker_feature: Feature
1024 default_tracker_feature: Feature
1023 default_tracker_support: Support
1025 default_tracker_support: Support
1024 default_issue_status_new: New
1026 default_issue_status_new: New
1025 default_issue_status_in_progress: In Progress
1027 default_issue_status_in_progress: In Progress
1026 default_issue_status_resolved: Resolved
1028 default_issue_status_resolved: Resolved
1027 default_issue_status_feedback: Feedback
1029 default_issue_status_feedback: Feedback
1028 default_issue_status_closed: Closed
1030 default_issue_status_closed: Closed
1029 default_issue_status_rejected: Rejected
1031 default_issue_status_rejected: Rejected
1030 default_doc_category_user: User documentation
1032 default_doc_category_user: User documentation
1031 default_doc_category_tech: Technical documentation
1033 default_doc_category_tech: Technical documentation
1032 default_priority_low: Low
1034 default_priority_low: Low
1033 default_priority_normal: Normal
1035 default_priority_normal: Normal
1034 default_priority_high: High
1036 default_priority_high: High
1035 default_priority_urgent: Urgent
1037 default_priority_urgent: Urgent
1036 default_priority_immediate: Immediate
1038 default_priority_immediate: Immediate
1037 default_activity_design: Design
1039 default_activity_design: Design
1038 default_activity_development: Development
1040 default_activity_development: Development
1039
1041
1040 enumeration_issue_priorities: Issue priorities
1042 enumeration_issue_priorities: Issue priorities
1041 enumeration_doc_categories: Document categories
1043 enumeration_doc_categories: Document categories
1042 enumeration_activities: Activities (time tracking)
1044 enumeration_activities: Activities (time tracking)
1043 enumeration_system_activity: System Activity
1045 enumeration_system_activity: System Activity
1044 description_filter: Filter
1046 description_filter: Filter
1045 description_search: Searchfield
1047 description_search: Searchfield
1046 description_choose_project: Projects
1048 description_choose_project: Projects
1047 description_project_scope: Search scope
1049 description_project_scope: Search scope
1048 description_notes: Notes
1050 description_notes: Notes
1049 description_message_content: Message content
1051 description_message_content: Message content
1050 description_query_sort_criteria_attribute: Sort attribute
1052 description_query_sort_criteria_attribute: Sort attribute
1051 description_query_sort_criteria_direction: Sort direction
1053 description_query_sort_criteria_direction: Sort direction
1052 description_user_mail_notification: Mail notification settings
1054 description_user_mail_notification: Mail notification settings
1053 description_available_columns: Available Columns
1055 description_available_columns: Available Columns
1054 description_selected_columns: Selected Columns
1056 description_selected_columns: Selected Columns
1055 description_all_columns: All Columns
1057 description_all_columns: All Columns
1056 description_issue_category_reassign: Choose issue category
1058 description_issue_category_reassign: Choose issue category
1057 description_wiki_subpages_reassign: Choose new parent page
1059 description_wiki_subpages_reassign: Choose new parent page
1058 description_date_range_list: Choose range from list
1060 description_date_range_list: Choose range from list
1059 description_date_range_interval: Choose range by selecting start and end date
1061 description_date_range_interval: Choose range by selecting start and end date
1060 description_date_from: Enter start date
1062 description_date_from: Enter start date
1061 description_date_to: Enter end date
1063 description_date_to: Enter end date
1062 text_repository_identifier_info: 'Only lower case letters (a-z), numbers, dashes and underscores are allowed.<br />Once saved, the identifier cannot be changed.'
1064 text_repository_identifier_info: 'Only lower case letters (a-z), numbers, dashes and underscores are allowed.<br />Once saved, the identifier cannot be changed.'
@@ -1,1079 +1,1081
1 # French translations for Ruby on Rails
1 # French translations for Ruby on Rails
2 # by Christian Lescuyer (christian@flyingcoders.com)
2 # by Christian Lescuyer (christian@flyingcoders.com)
3 # contributor: Sebastien Grosjean - ZenCocoon.com
3 # contributor: Sebastien Grosjean - ZenCocoon.com
4 # contributor: Thibaut Cuvelier - Developpez.com
4 # contributor: Thibaut Cuvelier - Developpez.com
5
5
6 fr:
6 fr:
7 direction: ltr
7 direction: ltr
8 date:
8 date:
9 formats:
9 formats:
10 default: "%d/%m/%Y"
10 default: "%d/%m/%Y"
11 short: "%e %b"
11 short: "%e %b"
12 long: "%e %B %Y"
12 long: "%e %B %Y"
13 long_ordinal: "%e %B %Y"
13 long_ordinal: "%e %B %Y"
14 only_day: "%e"
14 only_day: "%e"
15
15
16 day_names: [dimanche, lundi, mardi, mercredi, jeudi, vendredi, samedi]
16 day_names: [dimanche, lundi, mardi, mercredi, jeudi, vendredi, samedi]
17 abbr_day_names: [dim, lun, mar, mer, jeu, ven, sam]
17 abbr_day_names: [dim, lun, mar, mer, jeu, ven, sam]
18 month_names: [~, janvier, fΓ©vrier, mars, avril, mai, juin, juillet, aoΓ»t, septembre, octobre, novembre, dΓ©cembre]
18 month_names: [~, janvier, fΓ©vrier, mars, avril, mai, juin, juillet, aoΓ»t, septembre, octobre, novembre, dΓ©cembre]
19 abbr_month_names: [~, jan., fΓ©v., mar., avr., mai, juin, juil., aoΓ»t, sept., oct., nov., dΓ©c.]
19 abbr_month_names: [~, jan., fΓ©v., mar., avr., mai, juin, juil., aoΓ»t, sept., oct., nov., dΓ©c.]
20 order:
20 order:
21 - :day
21 - :day
22 - :month
22 - :month
23 - :year
23 - :year
24
24
25 time:
25 time:
26 formats:
26 formats:
27 default: "%d/%m/%Y %H:%M"
27 default: "%d/%m/%Y %H:%M"
28 time: "%H:%M"
28 time: "%H:%M"
29 short: "%d %b %H:%M"
29 short: "%d %b %H:%M"
30 long: "%A %d %B %Y %H:%M:%S %Z"
30 long: "%A %d %B %Y %H:%M:%S %Z"
31 long_ordinal: "%A %d %B %Y %H:%M:%S %Z"
31 long_ordinal: "%A %d %B %Y %H:%M:%S %Z"
32 only_second: "%S"
32 only_second: "%S"
33 am: 'am'
33 am: 'am'
34 pm: 'pm'
34 pm: 'pm'
35
35
36 datetime:
36 datetime:
37 distance_in_words:
37 distance_in_words:
38 half_a_minute: "30 secondes"
38 half_a_minute: "30 secondes"
39 less_than_x_seconds:
39 less_than_x_seconds:
40 zero: "moins d'une seconde"
40 zero: "moins d'une seconde"
41 one: "moins d'uneΒ seconde"
41 one: "moins d'uneΒ seconde"
42 other: "moins de %{count}Β secondes"
42 other: "moins de %{count}Β secondes"
43 x_seconds:
43 x_seconds:
44 one: "1Β seconde"
44 one: "1Β seconde"
45 other: "%{count}Β secondes"
45 other: "%{count}Β secondes"
46 less_than_x_minutes:
46 less_than_x_minutes:
47 zero: "moins d'une minute"
47 zero: "moins d'une minute"
48 one: "moins d'uneΒ minute"
48 one: "moins d'uneΒ minute"
49 other: "moins de %{count}Β minutes"
49 other: "moins de %{count}Β minutes"
50 x_minutes:
50 x_minutes:
51 one: "1Β minute"
51 one: "1Β minute"
52 other: "%{count}Β minutes"
52 other: "%{count}Β minutes"
53 about_x_hours:
53 about_x_hours:
54 one: "environ une heure"
54 one: "environ une heure"
55 other: "environ %{count}Β heures"
55 other: "environ %{count}Β heures"
56 x_hours:
56 x_hours:
57 one: "une heure"
57 one: "une heure"
58 other: "%{count}Β heures"
58 other: "%{count}Β heures"
59 x_days:
59 x_days:
60 one: "unΒ jour"
60 one: "unΒ jour"
61 other: "%{count}Β jours"
61 other: "%{count}Β jours"
62 about_x_months:
62 about_x_months:
63 one: "environ un mois"
63 one: "environ un mois"
64 other: "environ %{count}Β mois"
64 other: "environ %{count}Β mois"
65 x_months:
65 x_months:
66 one: "unΒ mois"
66 one: "unΒ mois"
67 other: "%{count}Β mois"
67 other: "%{count}Β mois"
68 about_x_years:
68 about_x_years:
69 one: "environ un an"
69 one: "environ un an"
70 other: "environ %{count}Β ans"
70 other: "environ %{count}Β ans"
71 over_x_years:
71 over_x_years:
72 one: "plus d'un an"
72 one: "plus d'un an"
73 other: "plus de %{count}Β ans"
73 other: "plus de %{count}Β ans"
74 almost_x_years:
74 almost_x_years:
75 one: "presqu'un an"
75 one: "presqu'un an"
76 other: "presque %{count} ans"
76 other: "presque %{count} ans"
77 prompts:
77 prompts:
78 year: "AnnΓ©e"
78 year: "AnnΓ©e"
79 month: "Mois"
79 month: "Mois"
80 day: "Jour"
80 day: "Jour"
81 hour: "Heure"
81 hour: "Heure"
82 minute: "Minute"
82 minute: "Minute"
83 second: "Seconde"
83 second: "Seconde"
84
84
85 number:
85 number:
86 format:
86 format:
87 precision: 3
87 precision: 3
88 separator: ','
88 separator: ','
89 delimiter: 'Β '
89 delimiter: 'Β '
90 currency:
90 currency:
91 format:
91 format:
92 unit: '€'
92 unit: '€'
93 precision: 2
93 precision: 2
94 format: '%nΒ %u'
94 format: '%nΒ %u'
95 human:
95 human:
96 format:
96 format:
97 precision: 3
97 precision: 3
98 storage_units:
98 storage_units:
99 format: "%n %u"
99 format: "%n %u"
100 units:
100 units:
101 byte:
101 byte:
102 one: "octet"
102 one: "octet"
103 other: "octet"
103 other: "octet"
104 kb: "ko"
104 kb: "ko"
105 mb: "Mo"
105 mb: "Mo"
106 gb: "Go"
106 gb: "Go"
107 tb: "To"
107 tb: "To"
108
108
109 support:
109 support:
110 array:
110 array:
111 sentence_connector: 'et'
111 sentence_connector: 'et'
112 skip_last_comma: true
112 skip_last_comma: true
113 word_connector: ", "
113 word_connector: ", "
114 two_words_connector: " et "
114 two_words_connector: " et "
115 last_word_connector: " et "
115 last_word_connector: " et "
116
116
117 activerecord:
117 activerecord:
118 errors:
118 errors:
119 template:
119 template:
120 header:
120 header:
121 one: "Impossible d'enregistrer %{model} : une erreur"
121 one: "Impossible d'enregistrer %{model} : une erreur"
122 other: "Impossible d'enregistrer %{model} : %{count} erreurs."
122 other: "Impossible d'enregistrer %{model} : %{count} erreurs."
123 body: "Veuillez vΓ©rifier les champs suivantsΒ :"
123 body: "Veuillez vΓ©rifier les champs suivantsΒ :"
124 messages:
124 messages:
125 inclusion: "n'est pas inclus(e) dans la liste"
125 inclusion: "n'est pas inclus(e) dans la liste"
126 exclusion: "n'est pas disponible"
126 exclusion: "n'est pas disponible"
127 invalid: "n'est pas valide"
127 invalid: "n'est pas valide"
128 confirmation: "ne concorde pas avec la confirmation"
128 confirmation: "ne concorde pas avec la confirmation"
129 accepted: "doit Γͺtre acceptΓ©(e)"
129 accepted: "doit Γͺtre acceptΓ©(e)"
130 empty: "doit Γͺtre renseignΓ©(e)"
130 empty: "doit Γͺtre renseignΓ©(e)"
131 blank: "doit Γͺtre renseignΓ©(e)"
131 blank: "doit Γͺtre renseignΓ©(e)"
132 too_long: "est trop long (pas plus de %{count} caractères)"
132 too_long: "est trop long (pas plus de %{count} caractères)"
133 too_short: "est trop court (au moins %{count} caractères)"
133 too_short: "est trop court (au moins %{count} caractères)"
134 wrong_length: "ne fait pas la bonne longueur (doit comporter %{count} caractères)"
134 wrong_length: "ne fait pas la bonne longueur (doit comporter %{count} caractères)"
135 taken: "est dΓ©jΓ  utilisΓ©"
135 taken: "est dΓ©jΓ  utilisΓ©"
136 not_a_number: "n'est pas un nombre"
136 not_a_number: "n'est pas un nombre"
137 not_a_date: "n'est pas une date valide"
137 not_a_date: "n'est pas une date valide"
138 greater_than: "doit Γͺtre supΓ©rieur Γ  %{count}"
138 greater_than: "doit Γͺtre supΓ©rieur Γ  %{count}"
139 greater_than_or_equal_to: "doit Γͺtre supΓ©rieur ou Γ©gal Γ  %{count}"
139 greater_than_or_equal_to: "doit Γͺtre supΓ©rieur ou Γ©gal Γ  %{count}"
140 equal_to: "doit Γͺtre Γ©gal Γ  %{count}"
140 equal_to: "doit Γͺtre Γ©gal Γ  %{count}"
141 less_than: "doit Γͺtre infΓ©rieur Γ  %{count}"
141 less_than: "doit Γͺtre infΓ©rieur Γ  %{count}"
142 less_than_or_equal_to: "doit Γͺtre infΓ©rieur ou Γ©gal Γ  %{count}"
142 less_than_or_equal_to: "doit Γͺtre infΓ©rieur ou Γ©gal Γ  %{count}"
143 odd: "doit Γͺtre impair"
143 odd: "doit Γͺtre impair"
144 even: "doit Γͺtre pair"
144 even: "doit Γͺtre pair"
145 greater_than_start_date: "doit Γͺtre postΓ©rieure Γ  la date de dΓ©but"
145 greater_than_start_date: "doit Γͺtre postΓ©rieure Γ  la date de dΓ©but"
146 not_same_project: "n'appartient pas au mΓͺme projet"
146 not_same_project: "n'appartient pas au mΓͺme projet"
147 circular_dependency: "Cette relation crΓ©erait une dΓ©pendance circulaire"
147 circular_dependency: "Cette relation crΓ©erait une dΓ©pendance circulaire"
148 cant_link_an_issue_with_a_descendant: "Une demande ne peut pas Γͺtre liΓ©e Γ  l'une de ses sous-tΓ’ches"
148 cant_link_an_issue_with_a_descendant: "Une demande ne peut pas Γͺtre liΓ©e Γ  l'une de ses sous-tΓ’ches"
149
149
150 actionview_instancetag_blank_option: Choisir
150 actionview_instancetag_blank_option: Choisir
151
151
152 general_text_No: 'Non'
152 general_text_No: 'Non'
153 general_text_Yes: 'Oui'
153 general_text_Yes: 'Oui'
154 general_text_no: 'non'
154 general_text_no: 'non'
155 general_text_yes: 'oui'
155 general_text_yes: 'oui'
156 general_lang_name: 'FranΓ§ais'
156 general_lang_name: 'FranΓ§ais'
157 general_csv_separator: ';'
157 general_csv_separator: ';'
158 general_csv_decimal_separator: ','
158 general_csv_decimal_separator: ','
159 general_csv_encoding: ISO-8859-1
159 general_csv_encoding: ISO-8859-1
160 general_pdf_encoding: UTF-8
160 general_pdf_encoding: UTF-8
161 general_first_day_of_week: '1'
161 general_first_day_of_week: '1'
162
162
163 notice_account_updated: Le compte a été mis à jour avec succès.
163 notice_account_updated: Le compte a été mis à jour avec succès.
164 notice_account_invalid_creditentials: Identifiant ou mot de passe invalide.
164 notice_account_invalid_creditentials: Identifiant ou mot de passe invalide.
165 notice_account_password_updated: Mot de passe mis à jour avec succès.
165 notice_account_password_updated: Mot de passe mis à jour avec succès.
166 notice_account_wrong_password: Mot de passe incorrect
166 notice_account_wrong_password: Mot de passe incorrect
167 notice_account_register_done: Un message contenant les instructions pour activer votre compte vous a Γ©tΓ© envoyΓ©.
167 notice_account_register_done: Un message contenant les instructions pour activer votre compte vous a Γ©tΓ© envoyΓ©.
168 notice_account_unknown_email: Aucun compte ne correspond Γ  cette adresse.
168 notice_account_unknown_email: Aucun compte ne correspond Γ  cette adresse.
169 notice_can_t_change_password: Ce compte utilise une authentification externe. Impossible de changer le mot de passe.
169 notice_can_t_change_password: Ce compte utilise une authentification externe. Impossible de changer le mot de passe.
170 notice_account_lost_email_sent: Un message contenant les instructions pour choisir un nouveau mot de passe vous a Γ©tΓ© envoyΓ©.
170 notice_account_lost_email_sent: Un message contenant les instructions pour choisir un nouveau mot de passe vous a Γ©tΓ© envoyΓ©.
171 notice_account_activated: Votre compte a Γ©tΓ© activΓ©. Vous pouvez Γ  prΓ©sent vous connecter.
171 notice_account_activated: Votre compte a Γ©tΓ© activΓ©. Vous pouvez Γ  prΓ©sent vous connecter.
172 notice_successful_create: Création effectuée avec succès.
172 notice_successful_create: Création effectuée avec succès.
173 notice_successful_update: Mise à jour effectuée avec succès.
173 notice_successful_update: Mise à jour effectuée avec succès.
174 notice_successful_delete: Suppression effectuée avec succès.
174 notice_successful_delete: Suppression effectuée avec succès.
175 notice_successful_connection: Connexion rΓ©ussie.
175 notice_successful_connection: Connexion rΓ©ussie.
176 notice_file_not_found: "La page Γ  laquelle vous souhaitez accΓ©der n'existe pas ou a Γ©tΓ© supprimΓ©e."
176 notice_file_not_found: "La page Γ  laquelle vous souhaitez accΓ©der n'existe pas ou a Γ©tΓ© supprimΓ©e."
177 notice_locking_conflict: Les donnΓ©es ont Γ©tΓ© mises Γ  jour par un autre utilisateur. Mise Γ  jour impossible.
177 notice_locking_conflict: Les donnΓ©es ont Γ©tΓ© mises Γ  jour par un autre utilisateur. Mise Γ  jour impossible.
178 notice_not_authorized: "Vous n'Γͺtes pas autorisΓ© Γ  accΓ©der Γ  cette page."
178 notice_not_authorized: "Vous n'Γͺtes pas autorisΓ© Γ  accΓ©der Γ  cette page."
179 notice_not_authorized_archived_project: Le projet auquel vous tentez d'accΓ©der a Γ©tΓ© archivΓ©.
179 notice_not_authorized_archived_project: Le projet auquel vous tentez d'accΓ©der a Γ©tΓ© archivΓ©.
180 notice_email_sent: "Un email a Γ©tΓ© envoyΓ© Γ  %{value}"
180 notice_email_sent: "Un email a Γ©tΓ© envoyΓ© Γ  %{value}"
181 notice_email_error: "Erreur lors de l'envoi de l'email (%{value})"
181 notice_email_error: "Erreur lors de l'envoi de l'email (%{value})"
182 notice_feeds_access_key_reseted: "Votre clé d'accès aux flux RSS a été réinitialisée."
182 notice_feeds_access_key_reseted: "Votre clé d'accès aux flux RSS a été réinitialisée."
183 notice_failed_to_save_issues: "%{count} demande(s) sur les %{total} sΓ©lectionnΓ©es n'ont pas pu Γͺtre mise(s) Γ  jour : %{ids}."
183 notice_failed_to_save_issues: "%{count} demande(s) sur les %{total} sΓ©lectionnΓ©es n'ont pas pu Γͺtre mise(s) Γ  jour : %{ids}."
184 notice_failed_to_save_time_entries: "%{count} temps passΓ©(s) sur les %{total} sΓ©lectionnΓ©s n'ont pas pu Γͺtre mis Γ  jour: %{ids}."
184 notice_failed_to_save_time_entries: "%{count} temps passΓ©(s) sur les %{total} sΓ©lectionnΓ©s n'ont pas pu Γͺtre mis Γ  jour: %{ids}."
185 notice_no_issue_selected: "Aucune demande sΓ©lectionnΓ©e ! Cochez les demandes que vous voulez mettre Γ  jour."
185 notice_no_issue_selected: "Aucune demande sΓ©lectionnΓ©e ! Cochez les demandes que vous voulez mettre Γ  jour."
186 notice_account_pending: "Votre compte a été créé et attend l'approbation de l'administrateur."
186 notice_account_pending: "Votre compte a été créé et attend l'approbation de l'administrateur."
187 notice_default_data_loaded: Paramétrage par défaut chargé avec succès.
187 notice_default_data_loaded: Paramétrage par défaut chargé avec succès.
188 notice_unable_delete_version: Impossible de supprimer cette version.
188 notice_unable_delete_version: Impossible de supprimer cette version.
189 notice_issue_done_ratios_updated: L'avancement des demandes a Γ©tΓ© mis Γ  jour.
189 notice_issue_done_ratios_updated: L'avancement des demandes a Γ©tΓ© mis Γ  jour.
190 notice_api_access_key_reseted: Votre clé d'accès API a été réinitialisée.
190 notice_api_access_key_reseted: Votre clé d'accès API a été réinitialisée.
191 notice_gantt_chart_truncated: "Le diagramme a Γ©tΓ© tronquΓ© car il excΓ¨de le nombre maximal d'Γ©lΓ©ments pouvant Γͺtre affichΓ©s (%{max})"
191 notice_gantt_chart_truncated: "Le diagramme a Γ©tΓ© tronquΓ© car il excΓ¨de le nombre maximal d'Γ©lΓ©ments pouvant Γͺtre affichΓ©s (%{max})"
192 notice_issue_successful_create: "Demande %{id} créée."
192 notice_issue_successful_create: "Demande %{id} créée."
193 notice_issue_update_conflict: "La demande a Γ©tΓ© mise Γ  jour par un autre utilisateur pendant que vous la modifiez."
193 notice_issue_update_conflict: "La demande a Γ©tΓ© mise Γ  jour par un autre utilisateur pendant que vous la modifiez."
194 notice_account_deleted: "Votre compte a Γ©tΓ© dΓ©finitivement supprimΓ©."
194 notice_account_deleted: "Votre compte a Γ©tΓ© dΓ©finitivement supprimΓ©."
195 notice_user_successful_create: "Utilisateur %{id} créé."
195 notice_user_successful_create: "Utilisateur %{id} créé."
196
196
197 error_can_t_load_default_data: "Une erreur s'est produite lors du chargement du paramΓ©trage : %{value}"
197 error_can_t_load_default_data: "Une erreur s'est produite lors du chargement du paramΓ©trage : %{value}"
198 error_scm_not_found: "L'entrΓ©e et/ou la rΓ©vision demandΓ©e n'existe pas dans le dΓ©pΓ΄t."
198 error_scm_not_found: "L'entrΓ©e et/ou la rΓ©vision demandΓ©e n'existe pas dans le dΓ©pΓ΄t."
199 error_scm_command_failed: "Une erreur s'est produite lors de l'accès au dépôt : %{value}"
199 error_scm_command_failed: "Une erreur s'est produite lors de l'accès au dépôt : %{value}"
200 error_scm_annotate: "L'entrΓ©e n'existe pas ou ne peut pas Γͺtre annotΓ©e."
200 error_scm_annotate: "L'entrΓ©e n'existe pas ou ne peut pas Γͺtre annotΓ©e."
201 error_issue_not_found_in_project: "La demande n'existe pas ou n'appartient pas Γ  ce projet"
201 error_issue_not_found_in_project: "La demande n'existe pas ou n'appartient pas Γ  ce projet"
202 error_can_not_reopen_issue_on_closed_version: 'Une demande assignΓ©e Γ  une version fermΓ©e ne peut pas Γͺtre rΓ©ouverte'
202 error_can_not_reopen_issue_on_closed_version: 'Une demande assignΓ©e Γ  une version fermΓ©e ne peut pas Γͺtre rΓ©ouverte'
203 error_can_not_archive_project: "Ce projet ne peut pas Γͺtre archivΓ©"
203 error_can_not_archive_project: "Ce projet ne peut pas Γͺtre archivΓ©"
204 error_workflow_copy_source: 'Veuillez sΓ©lectionner un tracker et/ou un rΓ΄le source'
204 error_workflow_copy_source: 'Veuillez sΓ©lectionner un tracker et/ou un rΓ΄le source'
205 error_workflow_copy_target: 'Veuillez sΓ©lectionner les trackers et rΓ΄les cibles'
205 error_workflow_copy_target: 'Veuillez sΓ©lectionner les trackers et rΓ΄les cibles'
206 error_issue_done_ratios_not_updated: L'avancement des demandes n'a pas pu Γͺtre mis Γ  jour.
206 error_issue_done_ratios_not_updated: L'avancement des demandes n'a pas pu Γͺtre mis Γ  jour.
207 error_attachment_too_big: Ce fichier ne peut pas Γͺtre attachΓ© car il excΓ¨de la taille maximale autorisΓ©e (%{max_size})
207 error_attachment_too_big: Ce fichier ne peut pas Γͺtre attachΓ© car il excΓ¨de la taille maximale autorisΓ©e (%{max_size})
208 error_session_expired: "Votre session a expirΓ©. Veuillez vous reconnecter."
208 error_session_expired: "Votre session a expirΓ©. Veuillez vous reconnecter."
209
209
210 warning_attachments_not_saved: "%{count} fichier(s) n'ont pas pu Γͺtre sauvegardΓ©s."
210 warning_attachments_not_saved: "%{count} fichier(s) n'ont pas pu Γͺtre sauvegardΓ©s."
211
211
212 mail_subject_lost_password: "Votre mot de passe %{value}"
212 mail_subject_lost_password: "Votre mot de passe %{value}"
213 mail_body_lost_password: 'Pour changer votre mot de passe, cliquez sur le lien suivant :'
213 mail_body_lost_password: 'Pour changer votre mot de passe, cliquez sur le lien suivant :'
214 mail_subject_register: "Activation de votre compte %{value}"
214 mail_subject_register: "Activation de votre compte %{value}"
215 mail_body_register: 'Pour activer votre compte, cliquez sur le lien suivant :'
215 mail_body_register: 'Pour activer votre compte, cliquez sur le lien suivant :'
216 mail_body_account_information_external: "Vous pouvez utiliser votre compte %{value} pour vous connecter."
216 mail_body_account_information_external: "Vous pouvez utiliser votre compte %{value} pour vous connecter."
217 mail_body_account_information: Paramètres de connexion de votre compte
217 mail_body_account_information: Paramètres de connexion de votre compte
218 mail_subject_account_activation_request: "Demande d'activation d'un compte %{value}"
218 mail_subject_account_activation_request: "Demande d'activation d'un compte %{value}"
219 mail_body_account_activation_request: "Un nouvel utilisateur (%{value}) s'est inscrit. Son compte nΓ©cessite votre approbation :"
219 mail_body_account_activation_request: "Un nouvel utilisateur (%{value}) s'est inscrit. Son compte nΓ©cessite votre approbation :"
220 mail_subject_reminder: "%{count} demande(s) arrivent Γ  Γ©chΓ©ance (%{days})"
220 mail_subject_reminder: "%{count} demande(s) arrivent Γ  Γ©chΓ©ance (%{days})"
221 mail_body_reminder: "%{count} demande(s) qui vous sont assignΓ©es arrivent Γ  Γ©chΓ©ance dans les %{days} prochains jours :"
221 mail_body_reminder: "%{count} demande(s) qui vous sont assignΓ©es arrivent Γ  Γ©chΓ©ance dans les %{days} prochains jours :"
222 mail_subject_wiki_content_added: "Page wiki '%{id}' ajoutΓ©e"
222 mail_subject_wiki_content_added: "Page wiki '%{id}' ajoutΓ©e"
223 mail_body_wiki_content_added: "La page wiki '%{id}' a Γ©tΓ© ajoutΓ©e par %{author}."
223 mail_body_wiki_content_added: "La page wiki '%{id}' a Γ©tΓ© ajoutΓ©e par %{author}."
224 mail_subject_wiki_content_updated: "Page wiki '%{id}' mise Γ  jour"
224 mail_subject_wiki_content_updated: "Page wiki '%{id}' mise Γ  jour"
225 mail_body_wiki_content_updated: "La page wiki '%{id}' a Γ©tΓ© mise Γ  jour par %{author}."
225 mail_body_wiki_content_updated: "La page wiki '%{id}' a Γ©tΓ© mise Γ  jour par %{author}."
226
226
227 gui_validation_error: 1 erreur
227 gui_validation_error: 1 erreur
228 gui_validation_error_plural: "%{count} erreurs"
228 gui_validation_error_plural: "%{count} erreurs"
229
229
230 field_name: Nom
230 field_name: Nom
231 field_description: Description
231 field_description: Description
232 field_summary: RΓ©sumΓ©
232 field_summary: RΓ©sumΓ©
233 field_is_required: Obligatoire
233 field_is_required: Obligatoire
234 field_firstname: PrΓ©nom
234 field_firstname: PrΓ©nom
235 field_lastname: Nom
235 field_lastname: Nom
236 field_mail: "Email "
236 field_mail: "Email "
237 field_filename: Fichier
237 field_filename: Fichier
238 field_filesize: Taille
238 field_filesize: Taille
239 field_downloads: TΓ©lΓ©chargements
239 field_downloads: TΓ©lΓ©chargements
240 field_author: Auteur
240 field_author: Auteur
241 field_created_on: "Créé "
241 field_created_on: "Créé "
242 field_updated_on: "Mis-Γ -jour "
242 field_updated_on: "Mis-Γ -jour "
243 field_field_format: Format
243 field_field_format: Format
244 field_is_for_all: Pour tous les projets
244 field_is_for_all: Pour tous les projets
245 field_possible_values: Valeurs possibles
245 field_possible_values: Valeurs possibles
246 field_regexp: Expression régulière
246 field_regexp: Expression régulière
247 field_min_length: Longueur minimum
247 field_min_length: Longueur minimum
248 field_max_length: Longueur maximum
248 field_max_length: Longueur maximum
249 field_value: Valeur
249 field_value: Valeur
250 field_category: CatΓ©gorie
250 field_category: CatΓ©gorie
251 field_title: Titre
251 field_title: Titre
252 field_project: Projet
252 field_project: Projet
253 field_issue: Demande
253 field_issue: Demande
254 field_status: Statut
254 field_status: Statut
255 field_notes: Notes
255 field_notes: Notes
256 field_is_closed: Demande fermΓ©e
256 field_is_closed: Demande fermΓ©e
257 field_is_default: Valeur par dΓ©faut
257 field_is_default: Valeur par dΓ©faut
258 field_tracker: Tracker
258 field_tracker: Tracker
259 field_subject: Sujet
259 field_subject: Sujet
260 field_due_date: EchΓ©ance
260 field_due_date: EchΓ©ance
261 field_assigned_to: AssignΓ© Γ 
261 field_assigned_to: AssignΓ© Γ 
262 field_priority: PrioritΓ©
262 field_priority: PrioritΓ©
263 field_fixed_version: Version cible
263 field_fixed_version: Version cible
264 field_user: Utilisateur
264 field_user: Utilisateur
265 field_role: RΓ΄le
265 field_role: RΓ΄le
266 field_homepage: "Site web "
266 field_homepage: "Site web "
267 field_is_public: Public
267 field_is_public: Public
268 field_parent: Sous-projet de
268 field_parent: Sous-projet de
269 field_is_in_roadmap: Demandes affichΓ©es dans la roadmap
269 field_is_in_roadmap: Demandes affichΓ©es dans la roadmap
270 field_login: "Identifiant "
270 field_login: "Identifiant "
271 field_mail_notification: Notifications par mail
271 field_mail_notification: Notifications par mail
272 field_admin: Administrateur
272 field_admin: Administrateur
273 field_last_login_on: "Dernière connexion "
273 field_last_login_on: "Dernière connexion "
274 field_language: Langue
274 field_language: Langue
275 field_effective_date: Date
275 field_effective_date: Date
276 field_password: Mot de passe
276 field_password: Mot de passe
277 field_new_password: Nouveau mot de passe
277 field_new_password: Nouveau mot de passe
278 field_password_confirmation: Confirmation
278 field_password_confirmation: Confirmation
279 field_version: Version
279 field_version: Version
280 field_type: Type
280 field_type: Type
281 field_host: HΓ΄te
281 field_host: HΓ΄te
282 field_port: Port
282 field_port: Port
283 field_account: Compte
283 field_account: Compte
284 field_base_dn: Base DN
284 field_base_dn: Base DN
285 field_attr_login: Attribut Identifiant
285 field_attr_login: Attribut Identifiant
286 field_attr_firstname: Attribut PrΓ©nom
286 field_attr_firstname: Attribut PrΓ©nom
287 field_attr_lastname: Attribut Nom
287 field_attr_lastname: Attribut Nom
288 field_attr_mail: Attribut Email
288 field_attr_mail: Attribut Email
289 field_onthefly: CrΓ©ation des utilisateurs Γ  la volΓ©e
289 field_onthefly: CrΓ©ation des utilisateurs Γ  la volΓ©e
290 field_start_date: DΓ©but
290 field_start_date: DΓ©but
291 field_done_ratio: "% rΓ©alisΓ©"
291 field_done_ratio: "% rΓ©alisΓ©"
292 field_auth_source: Mode d'authentification
292 field_auth_source: Mode d'authentification
293 field_hide_mail: Cacher mon adresse mail
293 field_hide_mail: Cacher mon adresse mail
294 field_comments: Commentaire
294 field_comments: Commentaire
295 field_url: URL
295 field_url: URL
296 field_start_page: Page de dΓ©marrage
296 field_start_page: Page de dΓ©marrage
297 field_subproject: Sous-projet
297 field_subproject: Sous-projet
298 field_hours: Heures
298 field_hours: Heures
299 field_activity: ActivitΓ©
299 field_activity: ActivitΓ©
300 field_spent_on: Date
300 field_spent_on: Date
301 field_identifier: Identifiant
301 field_identifier: Identifiant
302 field_is_filter: UtilisΓ© comme filtre
302 field_is_filter: UtilisΓ© comme filtre
303 field_issue_to: Demande liΓ©e
303 field_issue_to: Demande liΓ©e
304 field_delay: Retard
304 field_delay: Retard
305 field_assignable: Demandes assignables Γ  ce rΓ΄le
305 field_assignable: Demandes assignables Γ  ce rΓ΄le
306 field_redirect_existing_links: Rediriger les liens existants
306 field_redirect_existing_links: Rediriger les liens existants
307 field_estimated_hours: Temps estimΓ©
307 field_estimated_hours: Temps estimΓ©
308 field_column_names: Colonnes
308 field_column_names: Colonnes
309 field_time_zone: Fuseau horaire
309 field_time_zone: Fuseau horaire
310 field_searchable: UtilisΓ© pour les recherches
310 field_searchable: UtilisΓ© pour les recherches
311 field_default_value: Valeur par dΓ©faut
311 field_default_value: Valeur par dΓ©faut
312 field_comments_sorting: Afficher les commentaires
312 field_comments_sorting: Afficher les commentaires
313 field_parent_title: Page parent
313 field_parent_title: Page parent
314 field_editable: Modifiable
314 field_editable: Modifiable
315 field_watcher: Observateur
315 field_watcher: Observateur
316 field_identity_url: URL OpenID
316 field_identity_url: URL OpenID
317 field_content: Contenu
317 field_content: Contenu
318 field_group_by: Grouper par
318 field_group_by: Grouper par
319 field_sharing: Partage
319 field_sharing: Partage
320 field_active: Actif
320 field_active: Actif
321 field_parent_issue: TΓ’che parente
321 field_parent_issue: TΓ’che parente
322 field_visible: Visible
322 field_visible: Visible
323 field_warn_on_leaving_unsaved: "M'avertir lorsque je quitte une page contenant du texte non sauvegardΓ©"
323 field_warn_on_leaving_unsaved: "M'avertir lorsque je quitte une page contenant du texte non sauvegardΓ©"
324 field_issues_visibility: VisibilitΓ© des demandes
324 field_issues_visibility: VisibilitΓ© des demandes
325 field_is_private: PrivΓ©e
325 field_is_private: PrivΓ©e
326 field_commit_logs_encoding: Encodage des messages de commit
326 field_commit_logs_encoding: Encodage des messages de commit
327 field_repository_is_default: DΓ©pΓ΄t principal
327 field_repository_is_default: DΓ©pΓ΄t principal
328 field_multiple: Valeurs multiples
328 field_multiple: Valeurs multiples
329 field_auth_source_ldap_filter: Filtre LDAP
329 field_auth_source_ldap_filter: Filtre LDAP
330 field_core_fields: Champs standards
330 field_core_fields: Champs standards
331 field_timeout: "Timeout (en secondes)"
331 field_timeout: "Timeout (en secondes)"
332 field_board_parent: Forum parent
332 field_board_parent: Forum parent
333
333
334 setting_app_title: Titre de l'application
334 setting_app_title: Titre de l'application
335 setting_app_subtitle: Sous-titre de l'application
335 setting_app_subtitle: Sous-titre de l'application
336 setting_welcome_text: Texte d'accueil
336 setting_welcome_text: Texte d'accueil
337 setting_default_language: Langue par dΓ©faut
337 setting_default_language: Langue par dΓ©faut
338 setting_login_required: Authentification obligatoire
338 setting_login_required: Authentification obligatoire
339 setting_self_registration: Inscription des nouveaux utilisateurs
339 setting_self_registration: Inscription des nouveaux utilisateurs
340 setting_attachment_max_size: Taille maximale des fichiers
340 setting_attachment_max_size: Taille maximale des fichiers
341 setting_issues_export_limit: Limite d'exportation des demandes
341 setting_issues_export_limit: Limite d'exportation des demandes
342 setting_mail_from: Adresse d'Γ©mission
342 setting_mail_from: Adresse d'Γ©mission
343 setting_bcc_recipients: Destinataires en copie cachΓ©e (cci)
343 setting_bcc_recipients: Destinataires en copie cachΓ©e (cci)
344 setting_plain_text_mail: Mail en texte brut (non HTML)
344 setting_plain_text_mail: Mail en texte brut (non HTML)
345 setting_host_name: Nom d'hΓ΄te et chemin
345 setting_host_name: Nom d'hΓ΄te et chemin
346 setting_text_formatting: Formatage du texte
346 setting_text_formatting: Formatage du texte
347 setting_wiki_compression: Compression de l'historique des pages wiki
347 setting_wiki_compression: Compression de l'historique des pages wiki
348 setting_feeds_limit: Nombre maximal d'Γ©lΓ©ments dans les flux Atom
348 setting_feeds_limit: Nombre maximal d'Γ©lΓ©ments dans les flux Atom
349 setting_default_projects_public: DΓ©finir les nouveaux projets comme publics par dΓ©faut
349 setting_default_projects_public: DΓ©finir les nouveaux projets comme publics par dΓ©faut
350 setting_autofetch_changesets: RΓ©cupΓ©ration automatique des commits
350 setting_autofetch_changesets: RΓ©cupΓ©ration automatique des commits
351 setting_sys_api_enabled: Activer les WS pour la gestion des dΓ©pΓ΄ts
351 setting_sys_api_enabled: Activer les WS pour la gestion des dΓ©pΓ΄ts
352 setting_commit_ref_keywords: Mots-clΓ©s de rΓ©fΓ©rencement
352 setting_commit_ref_keywords: Mots-clΓ©s de rΓ©fΓ©rencement
353 setting_commit_fix_keywords: Mots-clΓ©s de rΓ©solution
353 setting_commit_fix_keywords: Mots-clΓ©s de rΓ©solution
354 setting_autologin: DurΓ©e maximale de connexion automatique
354 setting_autologin: DurΓ©e maximale de connexion automatique
355 setting_date_format: Format de date
355 setting_date_format: Format de date
356 setting_time_format: Format d'heure
356 setting_time_format: Format d'heure
357 setting_cross_project_issue_relations: Autoriser les relations entre demandes de diffΓ©rents projets
357 setting_cross_project_issue_relations: Autoriser les relations entre demandes de diffΓ©rents projets
358 setting_issue_list_default_columns: Colonnes affichΓ©es par dΓ©faut sur la liste des demandes
358 setting_issue_list_default_columns: Colonnes affichΓ©es par dΓ©faut sur la liste des demandes
359 setting_emails_footer: Pied-de-page des emails
359 setting_emails_footer: Pied-de-page des emails
360 setting_protocol: Protocole
360 setting_protocol: Protocole
361 setting_per_page_options: Options d'objets affichΓ©s par page
361 setting_per_page_options: Options d'objets affichΓ©s par page
362 setting_user_format: Format d'affichage des utilisateurs
362 setting_user_format: Format d'affichage des utilisateurs
363 setting_activity_days_default: Nombre de jours affichΓ©s sur l'activitΓ© des projets
363 setting_activity_days_default: Nombre de jours affichΓ©s sur l'activitΓ© des projets
364 setting_display_subprojects_issues: Afficher par dΓ©faut les demandes des sous-projets sur les projets principaux
364 setting_display_subprojects_issues: Afficher par dΓ©faut les demandes des sous-projets sur les projets principaux
365 setting_enabled_scm: SCM activΓ©s
365 setting_enabled_scm: SCM activΓ©s
366 setting_mail_handler_body_delimiters: "Tronquer les emails après l'une de ces lignes"
366 setting_mail_handler_body_delimiters: "Tronquer les emails après l'une de ces lignes"
367 setting_mail_handler_api_enabled: "Activer le WS pour la rΓ©ception d'emails"
367 setting_mail_handler_api_enabled: "Activer le WS pour la rΓ©ception d'emails"
368 setting_mail_handler_api_key: ClΓ© de protection de l'API
368 setting_mail_handler_api_key: ClΓ© de protection de l'API
369 setting_sequential_project_identifiers: GΓ©nΓ©rer des identifiants de projet sΓ©quentiels
369 setting_sequential_project_identifiers: GΓ©nΓ©rer des identifiants de projet sΓ©quentiels
370 setting_gravatar_enabled: Afficher les Gravatar des utilisateurs
370 setting_gravatar_enabled: Afficher les Gravatar des utilisateurs
371 setting_diff_max_lines_displayed: Nombre maximum de lignes de diff affichΓ©es
371 setting_diff_max_lines_displayed: Nombre maximum de lignes de diff affichΓ©es
372 setting_file_max_size_displayed: Taille maximum des fichiers texte affichΓ©s en ligne
372 setting_file_max_size_displayed: Taille maximum des fichiers texte affichΓ©s en ligne
373 setting_repository_log_display_limit: "Nombre maximum de rΓ©visions affichΓ©es sur l'historique d'un fichier"
373 setting_repository_log_display_limit: "Nombre maximum de rΓ©visions affichΓ©es sur l'historique d'un fichier"
374 setting_openid: "Autoriser l'authentification et l'enregistrement OpenID"
374 setting_openid: "Autoriser l'authentification et l'enregistrement OpenID"
375 setting_password_min_length: Longueur minimum des mots de passe
375 setting_password_min_length: Longueur minimum des mots de passe
376 setting_new_project_user_role_id: RΓ΄le donnΓ© Γ  un utilisateur non-administrateur qui crΓ©e un projet
376 setting_new_project_user_role_id: RΓ΄le donnΓ© Γ  un utilisateur non-administrateur qui crΓ©e un projet
377 setting_default_projects_modules: Modules activΓ©s par dΓ©faut pour les nouveaux projets
377 setting_default_projects_modules: Modules activΓ©s par dΓ©faut pour les nouveaux projets
378 setting_issue_done_ratio: Calcul de l'avancement des demandes
378 setting_issue_done_ratio: Calcul de l'avancement des demandes
379 setting_issue_done_ratio_issue_status: Utiliser le statut
379 setting_issue_done_ratio_issue_status: Utiliser le statut
380 setting_issue_done_ratio_issue_field: 'Utiliser le champ % effectuΓ©'
380 setting_issue_done_ratio_issue_field: 'Utiliser le champ % effectuΓ©'
381 setting_rest_api_enabled: Activer l'API REST
381 setting_rest_api_enabled: Activer l'API REST
382 setting_gravatar_default: Image Gravatar par dΓ©faut
382 setting_gravatar_default: Image Gravatar par dΓ©faut
383 setting_start_of_week: Jour de dΓ©but des calendriers
383 setting_start_of_week: Jour de dΓ©but des calendriers
384 setting_cache_formatted_text: Mettre en cache le texte formatΓ©
384 setting_cache_formatted_text: Mettre en cache le texte formatΓ©
385 setting_commit_logtime_enabled: Permettre la saisie de temps
385 setting_commit_logtime_enabled: Permettre la saisie de temps
386 setting_commit_logtime_activity_id: ActivitΓ© pour le temps saisi
386 setting_commit_logtime_activity_id: ActivitΓ© pour le temps saisi
387 setting_gantt_items_limit: Nombre maximum d'Γ©lΓ©ments affichΓ©s sur le gantt
387 setting_gantt_items_limit: Nombre maximum d'Γ©lΓ©ments affichΓ©s sur le gantt
388 setting_issue_group_assignment: Permettre l'assignement des demandes aux groupes
388 setting_issue_group_assignment: Permettre l'assignement des demandes aux groupes
389 setting_default_issue_start_date_to_creation_date: Donner Γ  la date de dΓ©but d'une nouvelle demande la valeur de la date du jour
389 setting_default_issue_start_date_to_creation_date: Donner Γ  la date de dΓ©but d'une nouvelle demande la valeur de la date du jour
390 setting_commit_cross_project_ref: Permettre le rΓ©fΓ©rencement et la rΓ©solution des demandes de tous les autres projets
390 setting_commit_cross_project_ref: Permettre le rΓ©fΓ©rencement et la rΓ©solution des demandes de tous les autres projets
391 setting_unsubscribe: Permettre aux utilisateurs de supprimer leur propre compte
391 setting_unsubscribe: Permettre aux utilisateurs de supprimer leur propre compte
392 setting_session_lifetime: DurΓ©e de vie maximale des sessions
392 setting_session_lifetime: DurΓ©e de vie maximale des sessions
393 setting_session_timeout: DurΓ©e maximale d'inactivitΓ©
393 setting_session_timeout: DurΓ©e maximale d'inactivitΓ©
394 setting_thumbnails_enabled: Afficher les vignettes des images
394 setting_thumbnails_enabled: Afficher les vignettes des images
395 setting_thumbnails_size: Taille des vignettes (en pixels)
395 setting_thumbnails_size: Taille des vignettes (en pixels)
396
396
397 permission_add_project: CrΓ©er un projet
397 permission_add_project: CrΓ©er un projet
398 permission_add_subprojects: CrΓ©er des sous-projets
398 permission_add_subprojects: CrΓ©er des sous-projets
399 permission_edit_project: Modifier le projet
399 permission_edit_project: Modifier le projet
400 permission_close_project: Fermer / rΓ©ouvrir le projet
400 permission_close_project: Fermer / rΓ©ouvrir le projet
401 permission_select_project_modules: Choisir les modules
401 permission_select_project_modules: Choisir les modules
402 permission_manage_members: GΓ©rer les membres
402 permission_manage_members: GΓ©rer les membres
403 permission_manage_versions: GΓ©rer les versions
403 permission_manage_versions: GΓ©rer les versions
404 permission_manage_categories: GΓ©rer les catΓ©gories de demandes
404 permission_manage_categories: GΓ©rer les catΓ©gories de demandes
405 permission_view_issues: Voir les demandes
405 permission_view_issues: Voir les demandes
406 permission_add_issues: CrΓ©er des demandes
406 permission_add_issues: CrΓ©er des demandes
407 permission_edit_issues: Modifier les demandes
407 permission_edit_issues: Modifier les demandes
408 permission_manage_issue_relations: GΓ©rer les relations
408 permission_manage_issue_relations: GΓ©rer les relations
409 permission_set_issues_private: Rendre les demandes publiques ou privΓ©es
409 permission_set_issues_private: Rendre les demandes publiques ou privΓ©es
410 permission_set_own_issues_private: Rendre ses propres demandes publiques ou privΓ©es
410 permission_set_own_issues_private: Rendre ses propres demandes publiques ou privΓ©es
411 permission_add_issue_notes: Ajouter des notes
411 permission_add_issue_notes: Ajouter des notes
412 permission_edit_issue_notes: Modifier les notes
412 permission_edit_issue_notes: Modifier les notes
413 permission_edit_own_issue_notes: Modifier ses propres notes
413 permission_edit_own_issue_notes: Modifier ses propres notes
414 permission_move_issues: DΓ©placer les demandes
414 permission_move_issues: DΓ©placer les demandes
415 permission_delete_issues: Supprimer les demandes
415 permission_delete_issues: Supprimer les demandes
416 permission_manage_public_queries: GΓ©rer les requΓͺtes publiques
416 permission_manage_public_queries: GΓ©rer les requΓͺtes publiques
417 permission_save_queries: Sauvegarder les requΓͺtes
417 permission_save_queries: Sauvegarder les requΓͺtes
418 permission_view_gantt: Voir le gantt
418 permission_view_gantt: Voir le gantt
419 permission_view_calendar: Voir le calendrier
419 permission_view_calendar: Voir le calendrier
420 permission_view_issue_watchers: Voir la liste des observateurs
420 permission_view_issue_watchers: Voir la liste des observateurs
421 permission_add_issue_watchers: Ajouter des observateurs
421 permission_add_issue_watchers: Ajouter des observateurs
422 permission_delete_issue_watchers: Supprimer des observateurs
422 permission_delete_issue_watchers: Supprimer des observateurs
423 permission_log_time: Saisir le temps passΓ©
423 permission_log_time: Saisir le temps passΓ©
424 permission_view_time_entries: Voir le temps passΓ©
424 permission_view_time_entries: Voir le temps passΓ©
425 permission_edit_time_entries: Modifier les temps passΓ©s
425 permission_edit_time_entries: Modifier les temps passΓ©s
426 permission_edit_own_time_entries: Modifier son propre temps passΓ©
426 permission_edit_own_time_entries: Modifier son propre temps passΓ©
427 permission_manage_news: GΓ©rer les annonces
427 permission_manage_news: GΓ©rer les annonces
428 permission_comment_news: Commenter les annonces
428 permission_comment_news: Commenter les annonces
429 permission_manage_documents: GΓ©rer les documents
429 permission_manage_documents: GΓ©rer les documents
430 permission_view_documents: Voir les documents
430 permission_view_documents: Voir les documents
431 permission_manage_files: GΓ©rer les fichiers
431 permission_manage_files: GΓ©rer les fichiers
432 permission_view_files: Voir les fichiers
432 permission_view_files: Voir les fichiers
433 permission_manage_wiki: GΓ©rer le wiki
433 permission_manage_wiki: GΓ©rer le wiki
434 permission_rename_wiki_pages: Renommer les pages
434 permission_rename_wiki_pages: Renommer les pages
435 permission_delete_wiki_pages: Supprimer les pages
435 permission_delete_wiki_pages: Supprimer les pages
436 permission_view_wiki_pages: Voir le wiki
436 permission_view_wiki_pages: Voir le wiki
437 permission_view_wiki_edits: "Voir l'historique des modifications"
437 permission_view_wiki_edits: "Voir l'historique des modifications"
438 permission_edit_wiki_pages: Modifier les pages
438 permission_edit_wiki_pages: Modifier les pages
439 permission_delete_wiki_pages_attachments: Supprimer les fichiers joints
439 permission_delete_wiki_pages_attachments: Supprimer les fichiers joints
440 permission_protect_wiki_pages: ProtΓ©ger les pages
440 permission_protect_wiki_pages: ProtΓ©ger les pages
441 permission_manage_repository: GΓ©rer le dΓ©pΓ΄t de sources
441 permission_manage_repository: GΓ©rer le dΓ©pΓ΄t de sources
442 permission_browse_repository: Parcourir les sources
442 permission_browse_repository: Parcourir les sources
443 permission_view_changesets: Voir les rΓ©visions
443 permission_view_changesets: Voir les rΓ©visions
444 permission_commit_access: Droit de commit
444 permission_commit_access: Droit de commit
445 permission_manage_boards: GΓ©rer les forums
445 permission_manage_boards: GΓ©rer les forums
446 permission_view_messages: Voir les messages
446 permission_view_messages: Voir les messages
447 permission_add_messages: Poster un message
447 permission_add_messages: Poster un message
448 permission_edit_messages: Modifier les messages
448 permission_edit_messages: Modifier les messages
449 permission_edit_own_messages: Modifier ses propres messages
449 permission_edit_own_messages: Modifier ses propres messages
450 permission_delete_messages: Supprimer les messages
450 permission_delete_messages: Supprimer les messages
451 permission_delete_own_messages: Supprimer ses propres messages
451 permission_delete_own_messages: Supprimer ses propres messages
452 permission_export_wiki_pages: Exporter les pages
452 permission_export_wiki_pages: Exporter les pages
453 permission_manage_project_activities: GΓ©rer les activitΓ©s
453 permission_manage_project_activities: GΓ©rer les activitΓ©s
454 permission_manage_subtasks: GΓ©rer les sous-tΓ’ches
454 permission_manage_subtasks: GΓ©rer les sous-tΓ’ches
455 permission_manage_related_issues: GΓ©rer les demandes associΓ©es
455 permission_manage_related_issues: GΓ©rer les demandes associΓ©es
456
456
457 project_module_issue_tracking: Suivi des demandes
457 project_module_issue_tracking: Suivi des demandes
458 project_module_time_tracking: Suivi du temps passΓ©
458 project_module_time_tracking: Suivi du temps passΓ©
459 project_module_news: Publication d'annonces
459 project_module_news: Publication d'annonces
460 project_module_documents: Publication de documents
460 project_module_documents: Publication de documents
461 project_module_files: Publication de fichiers
461 project_module_files: Publication de fichiers
462 project_module_wiki: Wiki
462 project_module_wiki: Wiki
463 project_module_repository: DΓ©pΓ΄t de sources
463 project_module_repository: DΓ©pΓ΄t de sources
464 project_module_boards: Forums de discussion
464 project_module_boards: Forums de discussion
465
465
466 label_user: Utilisateur
466 label_user: Utilisateur
467 label_user_plural: Utilisateurs
467 label_user_plural: Utilisateurs
468 label_user_new: Nouvel utilisateur
468 label_user_new: Nouvel utilisateur
469 label_user_anonymous: Anonyme
469 label_user_anonymous: Anonyme
470 label_project: Projet
470 label_project: Projet
471 label_project_new: Nouveau projet
471 label_project_new: Nouveau projet
472 label_project_plural: Projets
472 label_project_plural: Projets
473 label_x_projects:
473 label_x_projects:
474 zero: aucun projet
474 zero: aucun projet
475 one: un projet
475 one: un projet
476 other: "%{count} projets"
476 other: "%{count} projets"
477 label_project_all: Tous les projets
477 label_project_all: Tous les projets
478 label_project_latest: Derniers projets
478 label_project_latest: Derniers projets
479 label_issue: Demande
479 label_issue: Demande
480 label_issue_new: Nouvelle demande
480 label_issue_new: Nouvelle demande
481 label_issue_plural: Demandes
481 label_issue_plural: Demandes
482 label_issue_view_all: Voir toutes les demandes
482 label_issue_view_all: Voir toutes les demandes
483 label_issue_added: Demande ajoutΓ©e
483 label_issue_added: Demande ajoutΓ©e
484 label_issue_updated: Demande mise Γ  jour
484 label_issue_updated: Demande mise Γ  jour
485 label_issue_note_added: Note ajoutΓ©e
485 label_issue_note_added: Note ajoutΓ©e
486 label_issue_status_updated: Statut changΓ©
486 label_issue_status_updated: Statut changΓ©
487 label_issue_priority_updated: PrioritΓ© changΓ©e
487 label_issue_priority_updated: PrioritΓ© changΓ©e
488 label_issues_by: "Demandes par %{value}"
488 label_issues_by: "Demandes par %{value}"
489 label_document: Document
489 label_document: Document
490 label_document_new: Nouveau document
490 label_document_new: Nouveau document
491 label_document_plural: Documents
491 label_document_plural: Documents
492 label_document_added: Document ajoutΓ©
492 label_document_added: Document ajoutΓ©
493 label_role: RΓ΄le
493 label_role: RΓ΄le
494 label_role_plural: RΓ΄les
494 label_role_plural: RΓ΄les
495 label_role_new: Nouveau rΓ΄le
495 label_role_new: Nouveau rΓ΄le
496 label_role_and_permissions: RΓ΄les et permissions
496 label_role_and_permissions: RΓ΄les et permissions
497 label_role_anonymous: Anonyme
497 label_role_anonymous: Anonyme
498 label_role_non_member: Non membre
498 label_role_non_member: Non membre
499 label_member: Membre
499 label_member: Membre
500 label_member_new: Nouveau membre
500 label_member_new: Nouveau membre
501 label_member_plural: Membres
501 label_member_plural: Membres
502 label_tracker: Tracker
502 label_tracker: Tracker
503 label_tracker_plural: Trackers
503 label_tracker_plural: Trackers
504 label_tracker_new: Nouveau tracker
504 label_tracker_new: Nouveau tracker
505 label_workflow: Workflow
505 label_workflow: Workflow
506 label_issue_status: Statut de demandes
506 label_issue_status: Statut de demandes
507 label_issue_status_plural: Statuts de demandes
507 label_issue_status_plural: Statuts de demandes
508 label_issue_status_new: Nouveau statut
508 label_issue_status_new: Nouveau statut
509 label_issue_category: CatΓ©gorie de demandes
509 label_issue_category: CatΓ©gorie de demandes
510 label_issue_category_plural: CatΓ©gories de demandes
510 label_issue_category_plural: CatΓ©gories de demandes
511 label_issue_category_new: Nouvelle catΓ©gorie
511 label_issue_category_new: Nouvelle catΓ©gorie
512 label_custom_field: Champ personnalisΓ©
512 label_custom_field: Champ personnalisΓ©
513 label_custom_field_plural: Champs personnalisΓ©s
513 label_custom_field_plural: Champs personnalisΓ©s
514 label_custom_field_new: Nouveau champ personnalisΓ©
514 label_custom_field_new: Nouveau champ personnalisΓ©
515 label_enumerations: Listes de valeurs
515 label_enumerations: Listes de valeurs
516 label_enumeration_new: Nouvelle valeur
516 label_enumeration_new: Nouvelle valeur
517 label_information: Information
517 label_information: Information
518 label_information_plural: Informations
518 label_information_plural: Informations
519 label_please_login: Identification
519 label_please_login: Identification
520 label_register: S'enregistrer
520 label_register: S'enregistrer
521 label_login_with_open_id_option: S'authentifier avec OpenID
521 label_login_with_open_id_option: S'authentifier avec OpenID
522 label_password_lost: Mot de passe perdu
522 label_password_lost: Mot de passe perdu
523 label_home: Accueil
523 label_home: Accueil
524 label_my_page: Ma page
524 label_my_page: Ma page
525 label_my_account: Mon compte
525 label_my_account: Mon compte
526 label_my_projects: Mes projets
526 label_my_projects: Mes projets
527 label_my_page_block: Blocs disponibles
527 label_my_page_block: Blocs disponibles
528 label_administration: Administration
528 label_administration: Administration
529 label_login: Connexion
529 label_login: Connexion
530 label_logout: DΓ©connexion
530 label_logout: DΓ©connexion
531 label_help: Aide
531 label_help: Aide
532 label_reported_issues: "Demandes soumises "
532 label_reported_issues: "Demandes soumises "
533 label_assigned_to_me_issues: Demandes qui me sont assignΓ©es
533 label_assigned_to_me_issues: Demandes qui me sont assignΓ©es
534 label_last_login: "Dernière connexion "
534 label_last_login: "Dernière connexion "
535 label_registered_on: "Inscrit le "
535 label_registered_on: "Inscrit le "
536 label_activity: ActivitΓ©
536 label_activity: ActivitΓ©
537 label_overall_activity: ActivitΓ© globale
537 label_overall_activity: ActivitΓ© globale
538 label_user_activity: "ActivitΓ© de %{value}"
538 label_user_activity: "ActivitΓ© de %{value}"
539 label_new: Nouveau
539 label_new: Nouveau
540 label_logged_as: ConnectΓ© en tant que
540 label_logged_as: ConnectΓ© en tant que
541 label_environment: Environnement
541 label_environment: Environnement
542 label_authentication: Authentification
542 label_authentication: Authentification
543 label_auth_source: Mode d'authentification
543 label_auth_source: Mode d'authentification
544 label_auth_source_new: Nouveau mode d'authentification
544 label_auth_source_new: Nouveau mode d'authentification
545 label_auth_source_plural: Modes d'authentification
545 label_auth_source_plural: Modes d'authentification
546 label_subproject_plural: Sous-projets
546 label_subproject_plural: Sous-projets
547 label_subproject_new: Nouveau sous-projet
547 label_subproject_new: Nouveau sous-projet
548 label_and_its_subprojects: "%{value} et ses sous-projets"
548 label_and_its_subprojects: "%{value} et ses sous-projets"
549 label_min_max_length: Longueurs mini - maxi
549 label_min_max_length: Longueurs mini - maxi
550 label_list: Liste
550 label_list: Liste
551 label_date: Date
551 label_date: Date
552 label_integer: Entier
552 label_integer: Entier
553 label_float: Nombre dΓ©cimal
553 label_float: Nombre dΓ©cimal
554 label_boolean: BoolΓ©en
554 label_boolean: BoolΓ©en
555 label_string: Texte
555 label_string: Texte
556 label_text: Texte long
556 label_text: Texte long
557 label_attribute: Attribut
557 label_attribute: Attribut
558 label_attribute_plural: Attributs
558 label_attribute_plural: Attributs
559 label_download: "%{count} tΓ©lΓ©chargement"
559 label_download: "%{count} tΓ©lΓ©chargement"
560 label_download_plural: "%{count} tΓ©lΓ©chargements"
560 label_download_plural: "%{count} tΓ©lΓ©chargements"
561 label_no_data: Aucune donnΓ©e Γ  afficher
561 label_no_data: Aucune donnΓ©e Γ  afficher
562 label_change_status: Changer le statut
562 label_change_status: Changer le statut
563 label_history: Historique
563 label_history: Historique
564 label_attachment: Fichier
564 label_attachment: Fichier
565 label_attachment_new: Nouveau fichier
565 label_attachment_new: Nouveau fichier
566 label_attachment_delete: Supprimer le fichier
566 label_attachment_delete: Supprimer le fichier
567 label_attachment_plural: Fichiers
567 label_attachment_plural: Fichiers
568 label_file_added: Fichier ajoutΓ©
568 label_file_added: Fichier ajoutΓ©
569 label_report: Rapport
569 label_report: Rapport
570 label_report_plural: Rapports
570 label_report_plural: Rapports
571 label_news: Annonce
571 label_news: Annonce
572 label_news_new: Nouvelle annonce
572 label_news_new: Nouvelle annonce
573 label_news_plural: Annonces
573 label_news_plural: Annonces
574 label_news_latest: Dernières annonces
574 label_news_latest: Dernières annonces
575 label_news_view_all: Voir toutes les annonces
575 label_news_view_all: Voir toutes les annonces
576 label_news_added: Annonce ajoutΓ©e
576 label_news_added: Annonce ajoutΓ©e
577 label_news_comment_added: Commentaire ajoutΓ© Γ  une annonce
577 label_news_comment_added: Commentaire ajoutΓ© Γ  une annonce
578 label_settings: Configuration
578 label_settings: Configuration
579 label_overview: AperΓ§u
579 label_overview: AperΓ§u
580 label_version: Version
580 label_version: Version
581 label_version_new: Nouvelle version
581 label_version_new: Nouvelle version
582 label_version_plural: Versions
582 label_version_plural: Versions
583 label_confirmation: Confirmation
583 label_confirmation: Confirmation
584 label_export_to: 'Formats disponibles :'
584 label_export_to: 'Formats disponibles :'
585 label_read: Lire...
585 label_read: Lire...
586 label_public_projects: Projets publics
586 label_public_projects: Projets publics
587 label_open_issues: ouvert
587 label_open_issues: ouvert
588 label_open_issues_plural: ouverts
588 label_open_issues_plural: ouverts
589 label_closed_issues: fermΓ©
589 label_closed_issues: fermΓ©
590 label_closed_issues_plural: fermΓ©s
590 label_closed_issues_plural: fermΓ©s
591 label_x_open_issues_abbr_on_total:
591 label_x_open_issues_abbr_on_total:
592 zero: 0 ouverte sur %{total}
592 zero: 0 ouverte sur %{total}
593 one: 1 ouverte sur %{total}
593 one: 1 ouverte sur %{total}
594 other: "%{count} ouvertes sur %{total}"
594 other: "%{count} ouvertes sur %{total}"
595 label_x_open_issues_abbr:
595 label_x_open_issues_abbr:
596 zero: 0 ouverte
596 zero: 0 ouverte
597 one: 1 ouverte
597 one: 1 ouverte
598 other: "%{count} ouvertes"
598 other: "%{count} ouvertes"
599 label_x_closed_issues_abbr:
599 label_x_closed_issues_abbr:
600 zero: 0 fermΓ©e
600 zero: 0 fermΓ©e
601 one: 1 fermΓ©e
601 one: 1 fermΓ©e
602 other: "%{count} fermΓ©es"
602 other: "%{count} fermΓ©es"
603 label_x_issues:
603 label_x_issues:
604 zero: 0 demande
604 zero: 0 demande
605 one: 1 demande
605 one: 1 demande
606 other: "%{count} demandes"
606 other: "%{count} demandes"
607 label_total: Total
607 label_total: Total
608 label_permissions: Permissions
608 label_permissions: Permissions
609 label_current_status: Statut actuel
609 label_current_status: Statut actuel
610 label_new_statuses_allowed: Nouveaux statuts autorisΓ©s
610 label_new_statuses_allowed: Nouveaux statuts autorisΓ©s
611 label_all: tous
611 label_all: tous
612 label_none: aucun
612 label_none: aucun
613 label_nobody: personne
613 label_nobody: personne
614 label_next: Suivant
614 label_next: Suivant
615 label_previous: PrΓ©cΓ©dent
615 label_previous: PrΓ©cΓ©dent
616 label_used_by: UtilisΓ© par
616 label_used_by: UtilisΓ© par
617 label_details: DΓ©tails
617 label_details: DΓ©tails
618 label_add_note: Ajouter une note
618 label_add_note: Ajouter une note
619 label_per_page: Par page
619 label_per_page: Par page
620 label_calendar: Calendrier
620 label_calendar: Calendrier
621 label_months_from: mois depuis
621 label_months_from: mois depuis
622 label_gantt: Gantt
622 label_gantt: Gantt
623 label_internal: Interne
623 label_internal: Interne
624 label_last_changes: "%{count} derniers changements"
624 label_last_changes: "%{count} derniers changements"
625 label_change_view_all: Voir tous les changements
625 label_change_view_all: Voir tous les changements
626 label_personalize_page: Personnaliser cette page
626 label_personalize_page: Personnaliser cette page
627 label_comment: Commentaire
627 label_comment: Commentaire
628 label_comment_plural: Commentaires
628 label_comment_plural: Commentaires
629 label_x_comments:
629 label_x_comments:
630 zero: aucun commentaire
630 zero: aucun commentaire
631 one: un commentaire
631 one: un commentaire
632 other: "%{count} commentaires"
632 other: "%{count} commentaires"
633 label_comment_add: Ajouter un commentaire
633 label_comment_add: Ajouter un commentaire
634 label_comment_added: Commentaire ajoutΓ©
634 label_comment_added: Commentaire ajoutΓ©
635 label_comment_delete: Supprimer les commentaires
635 label_comment_delete: Supprimer les commentaires
636 label_query: Rapport personnalisΓ©
636 label_query: Rapport personnalisΓ©
637 label_query_plural: Rapports personnalisΓ©s
637 label_query_plural: Rapports personnalisΓ©s
638 label_query_new: Nouveau rapport
638 label_query_new: Nouveau rapport
639 label_my_queries: Mes rapports personnalisΓ©s
639 label_my_queries: Mes rapports personnalisΓ©s
640 label_filter_add: "Ajouter le filtre "
640 label_filter_add: "Ajouter le filtre "
641 label_filter_plural: Filtres
641 label_filter_plural: Filtres
642 label_equals: Γ©gal
642 label_equals: Γ©gal
643 label_not_equals: diffΓ©rent
643 label_not_equals: diffΓ©rent
644 label_in_less_than: dans moins de
644 label_in_less_than: dans moins de
645 label_in_more_than: dans plus de
645 label_in_more_than: dans plus de
646 label_in: dans
646 label_in: dans
647 label_today: aujourd'hui
647 label_today: aujourd'hui
648 label_all_time: toute la pΓ©riode
648 label_all_time: toute la pΓ©riode
649 label_yesterday: hier
649 label_yesterday: hier
650 label_this_week: cette semaine
650 label_this_week: cette semaine
651 label_last_week: la semaine dernière
651 label_last_week: la semaine dernière
652 label_last_n_days: "les %{count} derniers jours"
652 label_last_n_days: "les %{count} derniers jours"
653 label_this_month: ce mois-ci
653 label_this_month: ce mois-ci
654 label_last_month: le mois dernier
654 label_last_month: le mois dernier
655 label_this_year: cette annΓ©e
655 label_this_year: cette annΓ©e
656 label_date_range: PΓ©riode
656 label_date_range: PΓ©riode
657 label_less_than_ago: il y a moins de
657 label_less_than_ago: il y a moins de
658 label_more_than_ago: il y a plus de
658 label_more_than_ago: il y a plus de
659 label_ago: il y a
659 label_ago: il y a
660 label_contains: contient
660 label_contains: contient
661 label_not_contains: ne contient pas
661 label_not_contains: ne contient pas
662 label_day_plural: jours
662 label_day_plural: jours
663 label_repository: DΓ©pΓ΄t
663 label_repository: DΓ©pΓ΄t
664 label_repository_new: Nouveau dΓ©pΓ΄t
664 label_repository_new: Nouveau dΓ©pΓ΄t
665 label_repository_plural: DΓ©pΓ΄ts
665 label_repository_plural: DΓ©pΓ΄ts
666 label_browse: Parcourir
666 label_browse: Parcourir
667 label_modification: "%{count} modification"
667 label_modification: "%{count} modification"
668 label_modification_plural: "%{count} modifications"
668 label_modification_plural: "%{count} modifications"
669 label_revision: "RΓ©vision "
669 label_revision: "RΓ©vision "
670 label_revision_plural: RΓ©visions
670 label_revision_plural: RΓ©visions
671 label_associated_revisions: RΓ©visions associΓ©es
671 label_associated_revisions: RΓ©visions associΓ©es
672 label_added: ajoutΓ©
672 label_added: ajoutΓ©
673 label_modified: modifiΓ©
673 label_modified: modifiΓ©
674 label_copied: copiΓ©
674 label_copied: copiΓ©
675 label_renamed: renommΓ©
675 label_renamed: renommΓ©
676 label_deleted: supprimΓ©
676 label_deleted: supprimΓ©
677 label_latest_revision: Dernière révision
677 label_latest_revision: Dernière révision
678 label_latest_revision_plural: Dernières révisions
678 label_latest_revision_plural: Dernières révisions
679 label_view_revisions: Voir les rΓ©visions
679 label_view_revisions: Voir les rΓ©visions
680 label_max_size: Taille maximale
680 label_max_size: Taille maximale
681 label_sort_highest: Remonter en premier
681 label_sort_highest: Remonter en premier
682 label_sort_higher: Remonter
682 label_sort_higher: Remonter
683 label_sort_lower: Descendre
683 label_sort_lower: Descendre
684 label_sort_lowest: Descendre en dernier
684 label_sort_lowest: Descendre en dernier
685 label_roadmap: Roadmap
685 label_roadmap: Roadmap
686 label_roadmap_due_in: "Γ‰chΓ©ance dans %{value}"
686 label_roadmap_due_in: "Γ‰chΓ©ance dans %{value}"
687 label_roadmap_overdue: "En retard de %{value}"
687 label_roadmap_overdue: "En retard de %{value}"
688 label_roadmap_no_issues: Aucune demande pour cette version
688 label_roadmap_no_issues: Aucune demande pour cette version
689 label_search: "Recherche "
689 label_search: "Recherche "
690 label_result_plural: RΓ©sultats
690 label_result_plural: RΓ©sultats
691 label_all_words: Tous les mots
691 label_all_words: Tous les mots
692 label_wiki: Wiki
692 label_wiki: Wiki
693 label_wiki_edit: RΓ©vision wiki
693 label_wiki_edit: RΓ©vision wiki
694 label_wiki_edit_plural: RΓ©visions wiki
694 label_wiki_edit_plural: RΓ©visions wiki
695 label_wiki_page: Page wiki
695 label_wiki_page: Page wiki
696 label_wiki_page_plural: Pages wiki
696 label_wiki_page_plural: Pages wiki
697 label_index_by_title: Index par titre
697 label_index_by_title: Index par titre
698 label_index_by_date: Index par date
698 label_index_by_date: Index par date
699 label_current_version: Version actuelle
699 label_current_version: Version actuelle
700 label_preview: PrΓ©visualisation
700 label_preview: PrΓ©visualisation
701 label_feed_plural: Flux RSS
701 label_feed_plural: Flux RSS
702 label_changes_details: DΓ©tails de tous les changements
702 label_changes_details: DΓ©tails de tous les changements
703 label_issue_tracking: Suivi des demandes
703 label_issue_tracking: Suivi des demandes
704 label_spent_time: Temps passΓ©
704 label_spent_time: Temps passΓ©
705 label_f_hour: "%{value} heure"
705 label_f_hour: "%{value} heure"
706 label_f_hour_plural: "%{value} heures"
706 label_f_hour_plural: "%{value} heures"
707 label_time_tracking: Suivi du temps
707 label_time_tracking: Suivi du temps
708 label_change_plural: Changements
708 label_change_plural: Changements
709 label_statistics: Statistiques
709 label_statistics: Statistiques
710 label_commits_per_month: Commits par mois
710 label_commits_per_month: Commits par mois
711 label_commits_per_author: Commits par auteur
711 label_commits_per_author: Commits par auteur
712 label_view_diff: Voir les diffΓ©rences
712 label_view_diff: Voir les diffΓ©rences
713 label_diff_inline: en ligne
713 label_diff_inline: en ligne
714 label_diff_side_by_side: cΓ΄te Γ  cΓ΄te
714 label_diff_side_by_side: cΓ΄te Γ  cΓ΄te
715 label_options: Options
715 label_options: Options
716 label_copy_workflow_from: Copier le workflow de
716 label_copy_workflow_from: Copier le workflow de
717 label_permissions_report: Synthèse des permissions
717 label_permissions_report: Synthèse des permissions
718 label_watched_issues: Demandes surveillΓ©es
718 label_watched_issues: Demandes surveillΓ©es
719 label_related_issues: Demandes liΓ©es
719 label_related_issues: Demandes liΓ©es
720 label_applied_status: Statut appliquΓ©
720 label_applied_status: Statut appliquΓ©
721 label_loading: Chargement...
721 label_loading: Chargement...
722 label_relation_new: Nouvelle relation
722 label_relation_new: Nouvelle relation
723 label_relation_delete: Supprimer la relation
723 label_relation_delete: Supprimer la relation
724 label_relates_to: liΓ© Γ 
724 label_relates_to: liΓ© Γ 
725 label_duplicates: duplique
725 label_duplicates: duplique
726 label_duplicated_by: dupliquΓ© par
726 label_duplicated_by: dupliquΓ© par
727 label_blocks: bloque
727 label_blocks: bloque
728 label_blocked_by: bloquΓ© par
728 label_blocked_by: bloquΓ© par
729 label_precedes: précède
729 label_precedes: précède
730 label_follows: suit
730 label_follows: suit
731 label_copied_to: copiΓ© vers
732 label_copied_from: copiΓ© depuis
731 label_end_to_start: fin Γ  dΓ©but
733 label_end_to_start: fin Γ  dΓ©but
732 label_end_to_end: fin Γ  fin
734 label_end_to_end: fin Γ  fin
733 label_start_to_start: dΓ©but Γ  dΓ©but
735 label_start_to_start: dΓ©but Γ  dΓ©but
734 label_start_to_end: dΓ©but Γ  fin
736 label_start_to_end: dΓ©but Γ  fin
735 label_stay_logged_in: Rester connectΓ©
737 label_stay_logged_in: Rester connectΓ©
736 label_disabled: dΓ©sactivΓ©
738 label_disabled: dΓ©sactivΓ©
737 label_show_completed_versions: Voir les versions passΓ©es
739 label_show_completed_versions: Voir les versions passΓ©es
738 label_me: moi
740 label_me: moi
739 label_board: Forum
741 label_board: Forum
740 label_board_new: Nouveau forum
742 label_board_new: Nouveau forum
741 label_board_plural: Forums
743 label_board_plural: Forums
742 label_topic_plural: Discussions
744 label_topic_plural: Discussions
743 label_message_plural: Messages
745 label_message_plural: Messages
744 label_message_last: Dernier message
746 label_message_last: Dernier message
745 label_message_new: Nouveau message
747 label_message_new: Nouveau message
746 label_message_posted: Message ajoutΓ©
748 label_message_posted: Message ajoutΓ©
747 label_reply_plural: RΓ©ponses
749 label_reply_plural: RΓ©ponses
748 label_send_information: Envoyer les informations Γ  l'utilisateur
750 label_send_information: Envoyer les informations Γ  l'utilisateur
749 label_year: AnnΓ©e
751 label_year: AnnΓ©e
750 label_month: Mois
752 label_month: Mois
751 label_week: Semaine
753 label_week: Semaine
752 label_date_from: Du
754 label_date_from: Du
753 label_date_to: Au
755 label_date_to: Au
754 label_language_based: BasΓ© sur la langue de l'utilisateur
756 label_language_based: BasΓ© sur la langue de l'utilisateur
755 label_sort_by: "Trier par %{value}"
757 label_sort_by: "Trier par %{value}"
756 label_send_test_email: Envoyer un email de test
758 label_send_test_email: Envoyer un email de test
757 label_feeds_access_key_created_on: "Clé d'accès RSS créée il y a %{value}"
759 label_feeds_access_key_created_on: "Clé d'accès RSS créée il y a %{value}"
758 label_module_plural: Modules
760 label_module_plural: Modules
759 label_added_time_by: "AjoutΓ© par %{author} il y a %{age}"
761 label_added_time_by: "AjoutΓ© par %{author} il y a %{age}"
760 label_updated_time_by: "Mis Γ  jour par %{author} il y a %{age}"
762 label_updated_time_by: "Mis Γ  jour par %{author} il y a %{age}"
761 label_updated_time: "Mis Γ  jour il y a %{value}"
763 label_updated_time: "Mis Γ  jour il y a %{value}"
762 label_jump_to_a_project: Aller Γ  un projet...
764 label_jump_to_a_project: Aller Γ  un projet...
763 label_file_plural: Fichiers
765 label_file_plural: Fichiers
764 label_changeset_plural: RΓ©visions
766 label_changeset_plural: RΓ©visions
765 label_default_columns: Colonnes par dΓ©faut
767 label_default_columns: Colonnes par dΓ©faut
766 label_no_change_option: (Pas de changement)
768 label_no_change_option: (Pas de changement)
767 label_bulk_edit_selected_issues: Modifier les demandes sΓ©lectionnΓ©es
769 label_bulk_edit_selected_issues: Modifier les demandes sΓ©lectionnΓ©es
768 label_theme: Thème
770 label_theme: Thème
769 label_default: DΓ©faut
771 label_default: DΓ©faut
770 label_search_titles_only: Uniquement dans les titres
772 label_search_titles_only: Uniquement dans les titres
771 label_user_mail_option_all: "Pour tous les Γ©vΓ©nements de tous mes projets"
773 label_user_mail_option_all: "Pour tous les Γ©vΓ©nements de tous mes projets"
772 label_user_mail_option_selected: "Pour tous les Γ©vΓ©nements des projets sΓ©lectionnΓ©s..."
774 label_user_mail_option_selected: "Pour tous les Γ©vΓ©nements des projets sΓ©lectionnΓ©s..."
773 label_user_mail_no_self_notified: "Je ne veux pas Γͺtre notifiΓ© des changements que j'effectue"
775 label_user_mail_no_self_notified: "Je ne veux pas Γͺtre notifiΓ© des changements que j'effectue"
774 label_registration_activation_by_email: activation du compte par email
776 label_registration_activation_by_email: activation du compte par email
775 label_registration_manual_activation: activation manuelle du compte
777 label_registration_manual_activation: activation manuelle du compte
776 label_registration_automatic_activation: activation automatique du compte
778 label_registration_automatic_activation: activation automatique du compte
777 label_display_per_page: "Par page : %{value}"
779 label_display_per_page: "Par page : %{value}"
778 label_age: Γ‚ge
780 label_age: Γ‚ge
779 label_change_properties: Changer les propriΓ©tΓ©s
781 label_change_properties: Changer les propriΓ©tΓ©s
780 label_general: GΓ©nΓ©ral
782 label_general: GΓ©nΓ©ral
781 label_more: Plus
783 label_more: Plus
782 label_scm: SCM
784 label_scm: SCM
783 label_plugins: Plugins
785 label_plugins: Plugins
784 label_ldap_authentication: Authentification LDAP
786 label_ldap_authentication: Authentification LDAP
785 label_downloads_abbr: D/L
787 label_downloads_abbr: D/L
786 label_optional_description: Description facultative
788 label_optional_description: Description facultative
787 label_add_another_file: Ajouter un autre fichier
789 label_add_another_file: Ajouter un autre fichier
788 label_preferences: PrΓ©fΓ©rences
790 label_preferences: PrΓ©fΓ©rences
789 label_chronological_order: Dans l'ordre chronologique
791 label_chronological_order: Dans l'ordre chronologique
790 label_reverse_chronological_order: Dans l'ordre chronologique inverse
792 label_reverse_chronological_order: Dans l'ordre chronologique inverse
791 label_planning: Planning
793 label_planning: Planning
792 label_incoming_emails: Emails entrants
794 label_incoming_emails: Emails entrants
793 label_generate_key: GΓ©nΓ©rer une clΓ©
795 label_generate_key: GΓ©nΓ©rer une clΓ©
794 label_issue_watchers: Observateurs
796 label_issue_watchers: Observateurs
795 label_example: Exemple
797 label_example: Exemple
796 label_display: Affichage
798 label_display: Affichage
797 label_sort: Tri
799 label_sort: Tri
798 label_ascending: Croissant
800 label_ascending: Croissant
799 label_descending: DΓ©croissant
801 label_descending: DΓ©croissant
800 label_date_from_to: Du %{start} au %{end}
802 label_date_from_to: Du %{start} au %{end}
801 label_wiki_content_added: Page wiki ajoutΓ©e
803 label_wiki_content_added: Page wiki ajoutΓ©e
802 label_wiki_content_updated: Page wiki mise Γ  jour
804 label_wiki_content_updated: Page wiki mise Γ  jour
803 label_group_plural: Groupes
805 label_group_plural: Groupes
804 label_group: Groupe
806 label_group: Groupe
805 label_group_new: Nouveau groupe
807 label_group_new: Nouveau groupe
806 label_time_entry_plural: Temps passΓ©
808 label_time_entry_plural: Temps passΓ©
807 label_version_sharing_none: Non partagΓ©
809 label_version_sharing_none: Non partagΓ©
808 label_version_sharing_descendants: Avec les sous-projets
810 label_version_sharing_descendants: Avec les sous-projets
809 label_version_sharing_hierarchy: Avec toute la hiΓ©rarchie
811 label_version_sharing_hierarchy: Avec toute la hiΓ©rarchie
810 label_version_sharing_tree: Avec tout l'arbre
812 label_version_sharing_tree: Avec tout l'arbre
811 label_version_sharing_system: Avec tous les projets
813 label_version_sharing_system: Avec tous les projets
812 label_copy_source: Source
814 label_copy_source: Source
813 label_copy_target: Cible
815 label_copy_target: Cible
814 label_copy_same_as_target: Comme la cible
816 label_copy_same_as_target: Comme la cible
815 label_update_issue_done_ratios: Mettre Γ  jour l'avancement des demandes
817 label_update_issue_done_ratios: Mettre Γ  jour l'avancement des demandes
816 label_display_used_statuses_only: N'afficher que les statuts utilisΓ©s dans ce tracker
818 label_display_used_statuses_only: N'afficher que les statuts utilisΓ©s dans ce tracker
817 label_api_access_key: Clé d'accès API
819 label_api_access_key: Clé d'accès API
818 label_api_access_key_created_on: Clé d'accès API créée il y a %{value}
820 label_api_access_key_created_on: Clé d'accès API créée il y a %{value}
819 label_feeds_access_key: Clé d'accès RSS
821 label_feeds_access_key: Clé d'accès RSS
820 label_missing_api_access_key: Clé d'accès API manquante
822 label_missing_api_access_key: Clé d'accès API manquante
821 label_missing_feeds_access_key: Clé d'accès RSS manquante
823 label_missing_feeds_access_key: Clé d'accès RSS manquante
822 label_close_versions: Fermer les versions terminΓ©es
824 label_close_versions: Fermer les versions terminΓ©es
823 label_revision_id: RΓ©vision %{value}
825 label_revision_id: RΓ©vision %{value}
824 label_profile: Profil
826 label_profile: Profil
825 label_subtask_plural: Sous-tΓ’ches
827 label_subtask_plural: Sous-tΓ’ches
826 label_project_copy_notifications: Envoyer les notifications durant la copie du projet
828 label_project_copy_notifications: Envoyer les notifications durant la copie du projet
827 label_principal_search: "Rechercher un utilisateur ou un groupe :"
829 label_principal_search: "Rechercher un utilisateur ou un groupe :"
828 label_user_search: "Rechercher un utilisateur :"
830 label_user_search: "Rechercher un utilisateur :"
829 label_additional_workflow_transitions_for_author: Autorisations supplémentaires lorsque l'utilisateur a créé la demande
831 label_additional_workflow_transitions_for_author: Autorisations supplémentaires lorsque l'utilisateur a créé la demande
830 label_additional_workflow_transitions_for_assignee: Autorisations supplΓ©mentaires lorsque la demande est assignΓ©e Γ  l'utilisateur
832 label_additional_workflow_transitions_for_assignee: Autorisations supplΓ©mentaires lorsque la demande est assignΓ©e Γ  l'utilisateur
831 label_issues_visibility_all: Toutes les demandes
833 label_issues_visibility_all: Toutes les demandes
832 label_issues_visibility_public: Toutes les demandes non privΓ©es
834 label_issues_visibility_public: Toutes les demandes non privΓ©es
833 label_issues_visibility_own: Demandes créées par ou assignées à l'utilisateur
835 label_issues_visibility_own: Demandes créées par ou assignées à l'utilisateur
834 label_export_options: Options d'exportation %{export_format}
836 label_export_options: Options d'exportation %{export_format}
835 label_copy_attachments: Copier les fichiers
837 label_copy_attachments: Copier les fichiers
836 label_copy_subtasks: Copier les sous-tΓ’ches
838 label_copy_subtasks: Copier les sous-tΓ’ches
837 label_item_position: "%{position} sur %{count}"
839 label_item_position: "%{position} sur %{count}"
838 label_completed_versions: Versions passΓ©es
840 label_completed_versions: Versions passΓ©es
839 label_session_expiration: Expiration des sessions
841 label_session_expiration: Expiration des sessions
840 label_show_closed_projects: Voir les projets fermΓ©s
842 label_show_closed_projects: Voir les projets fermΓ©s
841 label_status_transitions: Changements de statut
843 label_status_transitions: Changements de statut
842 label_fields_permissions: Permissions sur les champs
844 label_fields_permissions: Permissions sur les champs
843 label_readonly: Lecture
845 label_readonly: Lecture
844 label_required: Obligatoire
846 label_required: Obligatoire
845 label_attribute_of_project: "%{name} du projet"
847 label_attribute_of_project: "%{name} du projet"
846 label_attribute_of_author: "%{name} de l'auteur"
848 label_attribute_of_author: "%{name} de l'auteur"
847 label_attribute_of_assigned_to: "%{name} de l'assignΓ©"
849 label_attribute_of_assigned_to: "%{name} de l'assignΓ©"
848 label_attribute_of_fixed_version: "%{name} de la version cible"
850 label_attribute_of_fixed_version: "%{name} de la version cible"
849
851
850 button_login: Connexion
852 button_login: Connexion
851 button_submit: Soumettre
853 button_submit: Soumettre
852 button_save: Sauvegarder
854 button_save: Sauvegarder
853 button_check_all: Tout cocher
855 button_check_all: Tout cocher
854 button_uncheck_all: Tout dΓ©cocher
856 button_uncheck_all: Tout dΓ©cocher
855 button_collapse_all: Plier tout
857 button_collapse_all: Plier tout
856 button_expand_all: DΓ©plier tout
858 button_expand_all: DΓ©plier tout
857 button_delete: Supprimer
859 button_delete: Supprimer
858 button_create: CrΓ©er
860 button_create: CrΓ©er
859 button_create_and_continue: CrΓ©er et continuer
861 button_create_and_continue: CrΓ©er et continuer
860 button_test: Tester
862 button_test: Tester
861 button_edit: Modifier
863 button_edit: Modifier
862 button_add: Ajouter
864 button_add: Ajouter
863 button_change: Changer
865 button_change: Changer
864 button_apply: Appliquer
866 button_apply: Appliquer
865 button_clear: Effacer
867 button_clear: Effacer
866 button_lock: Verrouiller
868 button_lock: Verrouiller
867 button_unlock: DΓ©verrouiller
869 button_unlock: DΓ©verrouiller
868 button_download: TΓ©lΓ©charger
870 button_download: TΓ©lΓ©charger
869 button_list: Lister
871 button_list: Lister
870 button_view: Voir
872 button_view: Voir
871 button_move: DΓ©placer
873 button_move: DΓ©placer
872 button_move_and_follow: DΓ©placer et suivre
874 button_move_and_follow: DΓ©placer et suivre
873 button_back: Retour
875 button_back: Retour
874 button_cancel: Annuler
876 button_cancel: Annuler
875 button_activate: Activer
877 button_activate: Activer
876 button_sort: Trier
878 button_sort: Trier
877 button_log_time: Saisir temps
879 button_log_time: Saisir temps
878 button_rollback: Revenir Γ  cette version
880 button_rollback: Revenir Γ  cette version
879 button_watch: Surveiller
881 button_watch: Surveiller
880 button_unwatch: Ne plus surveiller
882 button_unwatch: Ne plus surveiller
881 button_reply: RΓ©pondre
883 button_reply: RΓ©pondre
882 button_archive: Archiver
884 button_archive: Archiver
883 button_unarchive: DΓ©sarchiver
885 button_unarchive: DΓ©sarchiver
884 button_reset: RΓ©initialiser
886 button_reset: RΓ©initialiser
885 button_rename: Renommer
887 button_rename: Renommer
886 button_change_password: Changer de mot de passe
888 button_change_password: Changer de mot de passe
887 button_copy: Copier
889 button_copy: Copier
888 button_copy_and_follow: Copier et suivre
890 button_copy_and_follow: Copier et suivre
889 button_annotate: Annoter
891 button_annotate: Annoter
890 button_update: Mettre Γ  jour
892 button_update: Mettre Γ  jour
891 button_configure: Configurer
893 button_configure: Configurer
892 button_quote: Citer
894 button_quote: Citer
893 button_duplicate: Dupliquer
895 button_duplicate: Dupliquer
894 button_show: Afficher
896 button_show: Afficher
895 button_edit_section: Modifier cette section
897 button_edit_section: Modifier cette section
896 button_export: Exporter
898 button_export: Exporter
897 button_delete_my_account: Supprimer mon compte
899 button_delete_my_account: Supprimer mon compte
898 button_close: Fermer
900 button_close: Fermer
899 button_reopen: RΓ©ouvrir
901 button_reopen: RΓ©ouvrir
900
902
901 status_active: actif
903 status_active: actif
902 status_registered: enregistrΓ©
904 status_registered: enregistrΓ©
903 status_locked: verrouillΓ©
905 status_locked: verrouillΓ©
904
906
905 project_status_active: actif
907 project_status_active: actif
906 project_status_closed: fermΓ©
908 project_status_closed: fermΓ©
907 project_status_archived: archivΓ©
909 project_status_archived: archivΓ©
908
910
909 version_status_open: ouvert
911 version_status_open: ouvert
910 version_status_locked: verrouillΓ©
912 version_status_locked: verrouillΓ©
911 version_status_closed: fermΓ©
913 version_status_closed: fermΓ©
912
914
913 text_select_mail_notifications: Actions pour lesquelles une notification par e-mail est envoyΓ©e
915 text_select_mail_notifications: Actions pour lesquelles une notification par e-mail est envoyΓ©e
914 text_regexp_info: ex. ^[A-Z0-9]+$
916 text_regexp_info: ex. ^[A-Z0-9]+$
915 text_min_max_length_info: 0 pour aucune restriction
917 text_min_max_length_info: 0 pour aucune restriction
916 text_project_destroy_confirmation: Êtes-vous sûr de vouloir supprimer ce projet et toutes ses données ?
918 text_project_destroy_confirmation: Êtes-vous sûr de vouloir supprimer ce projet et toutes ses données ?
917 text_subprojects_destroy_warning: "Ses sous-projets : %{value} seront Γ©galement supprimΓ©s."
919 text_subprojects_destroy_warning: "Ses sous-projets : %{value} seront Γ©galement supprimΓ©s."
918 text_workflow_edit: SΓ©lectionner un tracker et un rΓ΄le pour Γ©diter le workflow
920 text_workflow_edit: SΓ©lectionner un tracker et un rΓ΄le pour Γ©diter le workflow
919 text_are_you_sure: Êtes-vous sûr ?
921 text_are_you_sure: Êtes-vous sûr ?
920 text_tip_issue_begin_day: tΓ’che commenΓ§ant ce jour
922 text_tip_issue_begin_day: tΓ’che commenΓ§ant ce jour
921 text_tip_issue_end_day: tΓ’che finissant ce jour
923 text_tip_issue_end_day: tΓ’che finissant ce jour
922 text_tip_issue_begin_end_day: tΓ’che commenΓ§ant et finissant ce jour
924 text_tip_issue_begin_end_day: tΓ’che commenΓ§ant et finissant ce jour
923 text_project_identifier_info: 'Seuls les lettres minuscules (a-z), chiffres, tirets et underscore sont autorisΓ©s.<br />Un fois sauvegardΓ©, l''identifiant ne pourra plus Γͺtre modifiΓ©.'
925 text_project_identifier_info: 'Seuls les lettres minuscules (a-z), chiffres, tirets et underscore sont autorisΓ©s.<br />Un fois sauvegardΓ©, l''identifiant ne pourra plus Γͺtre modifiΓ©.'
924 text_caracters_maximum: "%{count} caractères maximum."
926 text_caracters_maximum: "%{count} caractères maximum."
925 text_caracters_minimum: "%{count} caractères minimum."
927 text_caracters_minimum: "%{count} caractères minimum."
926 text_length_between: "Longueur comprise entre %{min} et %{max} caractères."
928 text_length_between: "Longueur comprise entre %{min} et %{max} caractères."
927 text_tracker_no_workflow: Aucun worflow n'est dΓ©fini pour ce tracker
929 text_tracker_no_workflow: Aucun worflow n'est dΓ©fini pour ce tracker
928 text_unallowed_characters: Caractères non autorisés
930 text_unallowed_characters: Caractères non autorisés
929 text_comma_separated: Plusieurs valeurs possibles (sΓ©parΓ©es par des virgules).
931 text_comma_separated: Plusieurs valeurs possibles (sΓ©parΓ©es par des virgules).
930 text_line_separated: Plusieurs valeurs possibles (une valeur par ligne).
932 text_line_separated: Plusieurs valeurs possibles (une valeur par ligne).
931 text_issues_ref_in_commit_messages: RΓ©fΓ©rencement et rΓ©solution des demandes dans les commentaires de commits
933 text_issues_ref_in_commit_messages: RΓ©fΓ©rencement et rΓ©solution des demandes dans les commentaires de commits
932 text_issue_added: "La demande %{id} a Γ©tΓ© soumise par %{author}."
934 text_issue_added: "La demande %{id} a Γ©tΓ© soumise par %{author}."
933 text_issue_updated: "La demande %{id} a Γ©tΓ© mise Γ  jour par %{author}."
935 text_issue_updated: "La demande %{id} a Γ©tΓ© mise Γ  jour par %{author}."
934 text_wiki_destroy_confirmation: Etes-vous sΓ»r de vouloir supprimer ce wiki et tout son contenu ?
936 text_wiki_destroy_confirmation: Etes-vous sΓ»r de vouloir supprimer ce wiki et tout son contenu ?
935 text_issue_category_destroy_question: "%{count} demandes sont affectΓ©es Γ  cette catΓ©gorie. Que voulez-vous faire ?"
937 text_issue_category_destroy_question: "%{count} demandes sont affectΓ©es Γ  cette catΓ©gorie. Que voulez-vous faire ?"
936 text_issue_category_destroy_assignments: N'affecter les demandes Γ  aucune autre catΓ©gorie
938 text_issue_category_destroy_assignments: N'affecter les demandes Γ  aucune autre catΓ©gorie
937 text_issue_category_reassign_to: RΓ©affecter les demandes Γ  cette catΓ©gorie
939 text_issue_category_reassign_to: RΓ©affecter les demandes Γ  cette catΓ©gorie
938 text_user_mail_option: "Pour les projets non sΓ©lectionnΓ©s, vous recevrez seulement des notifications pour ce que vous surveillez ou Γ  quoi vous participez (exemple: demandes dont vous Γͺtes l'auteur ou la personne assignΓ©e)."
940 text_user_mail_option: "Pour les projets non sΓ©lectionnΓ©s, vous recevrez seulement des notifications pour ce que vous surveillez ou Γ  quoi vous participez (exemple: demandes dont vous Γͺtes l'auteur ou la personne assignΓ©e)."
939 text_no_configuration_data: "Les rΓ΄les, trackers, statuts et le workflow ne sont pas encore paramΓ©trΓ©s.\nIl est vivement recommandΓ© de charger le paramΓ©trage par defaut. Vous pourrez le modifier une fois chargΓ©."
941 text_no_configuration_data: "Les rΓ΄les, trackers, statuts et le workflow ne sont pas encore paramΓ©trΓ©s.\nIl est vivement recommandΓ© de charger le paramΓ©trage par defaut. Vous pourrez le modifier une fois chargΓ©."
940 text_load_default_configuration: Charger le paramΓ©trage par dΓ©faut
942 text_load_default_configuration: Charger le paramΓ©trage par dΓ©faut
941 text_status_changed_by_changeset: "AppliquΓ© par commit %{value}."
943 text_status_changed_by_changeset: "AppliquΓ© par commit %{value}."
942 text_time_logged_by_changeset: "AppliquΓ© par commit %{value}"
944 text_time_logged_by_changeset: "AppliquΓ© par commit %{value}"
943 text_issues_destroy_confirmation: 'Êtes-vous sûr de vouloir supprimer la ou les demandes(s) selectionnée(s) ?'
945 text_issues_destroy_confirmation: 'Êtes-vous sûr de vouloir supprimer la ou les demandes(s) selectionnée(s) ?'
944 text_issues_destroy_descendants_confirmation: "Cela entrainera Γ©galement la suppression de %{count} sous-tΓ’che(s)."
946 text_issues_destroy_descendants_confirmation: "Cela entrainera Γ©galement la suppression de %{count} sous-tΓ’che(s)."
945 text_select_project_modules: 'SΓ©lectionner les modules Γ  activer pour ce projet :'
947 text_select_project_modules: 'SΓ©lectionner les modules Γ  activer pour ce projet :'
946 text_default_administrator_account_changed: Compte administrateur par dΓ©faut changΓ©
948 text_default_administrator_account_changed: Compte administrateur par dΓ©faut changΓ©
947 text_file_repository_writable: RΓ©pertoire de stockage des fichiers accessible en Γ©criture
949 text_file_repository_writable: RΓ©pertoire de stockage des fichiers accessible en Γ©criture
948 text_plugin_assets_writable: RΓ©pertoire public des plugins accessible en Γ©criture
950 text_plugin_assets_writable: RΓ©pertoire public des plugins accessible en Γ©criture
949 text_rmagick_available: Bibliothèque RMagick présente (optionnelle)
951 text_rmagick_available: Bibliothèque RMagick présente (optionnelle)
950 text_destroy_time_entries_question: "%{hours} heures ont Γ©tΓ© enregistrΓ©es sur les demandes Γ  supprimer. Que voulez-vous faire ?"
952 text_destroy_time_entries_question: "%{hours} heures ont Γ©tΓ© enregistrΓ©es sur les demandes Γ  supprimer. Que voulez-vous faire ?"
951 text_destroy_time_entries: Supprimer les heures
953 text_destroy_time_entries: Supprimer les heures
952 text_assign_time_entries_to_project: Reporter les heures sur le projet
954 text_assign_time_entries_to_project: Reporter les heures sur le projet
953 text_reassign_time_entries: 'Reporter les heures sur cette demande:'
955 text_reassign_time_entries: 'Reporter les heures sur cette demande:'
954 text_user_wrote: "%{value} a Γ©crit :"
956 text_user_wrote: "%{value} a Γ©crit :"
955 text_enumeration_destroy_question: "Cette valeur est affectΓ©e Γ  %{count} objets."
957 text_enumeration_destroy_question: "Cette valeur est affectΓ©e Γ  %{count} objets."
956 text_enumeration_category_reassign_to: 'RΓ©affecter les objets Γ  cette valeur:'
958 text_enumeration_category_reassign_to: 'RΓ©affecter les objets Γ  cette valeur:'
957 text_email_delivery_not_configured: "L'envoi de mail n'est pas configurΓ©, les notifications sont dΓ©sactivΓ©es.\nConfigurez votre serveur SMTP dans config/configuration.yml et redΓ©marrez l'application pour les activer."
959 text_email_delivery_not_configured: "L'envoi de mail n'est pas configurΓ©, les notifications sont dΓ©sactivΓ©es.\nConfigurez votre serveur SMTP dans config/configuration.yml et redΓ©marrez l'application pour les activer."
958 text_repository_usernames_mapping: "Vous pouvez sΓ©lectionner ou modifier l'utilisateur Redmine associΓ© Γ  chaque nom d'utilisateur figurant dans l'historique du dΓ©pΓ΄t.\nLes utilisateurs avec le mΓͺme identifiant ou la mΓͺme adresse mail seront automatiquement associΓ©s."
960 text_repository_usernames_mapping: "Vous pouvez sΓ©lectionner ou modifier l'utilisateur Redmine associΓ© Γ  chaque nom d'utilisateur figurant dans l'historique du dΓ©pΓ΄t.\nLes utilisateurs avec le mΓͺme identifiant ou la mΓͺme adresse mail seront automatiquement associΓ©s."
959 text_diff_truncated: '... Ce diffΓ©rentiel a Γ©tΓ© tronquΓ© car il excΓ¨de la taille maximale pouvant Γͺtre affichΓ©e.'
961 text_diff_truncated: '... Ce diffΓ©rentiel a Γ©tΓ© tronquΓ© car il excΓ¨de la taille maximale pouvant Γͺtre affichΓ©e.'
960 text_custom_field_possible_values_info: 'Une ligne par valeur'
962 text_custom_field_possible_values_info: 'Une ligne par valeur'
961 text_wiki_page_destroy_question: "Cette page possède %{descendants} sous-page(s) et descendante(s). Que voulez-vous faire ?"
963 text_wiki_page_destroy_question: "Cette page possède %{descendants} sous-page(s) et descendante(s). Que voulez-vous faire ?"
962 text_wiki_page_nullify_children: "Conserver les sous-pages en tant que pages racines"
964 text_wiki_page_nullify_children: "Conserver les sous-pages en tant que pages racines"
963 text_wiki_page_destroy_children: "Supprimer les sous-pages et toutes leurs descedantes"
965 text_wiki_page_destroy_children: "Supprimer les sous-pages et toutes leurs descedantes"
964 text_wiki_page_reassign_children: "RΓ©affecter les sous-pages Γ  cette page"
966 text_wiki_page_reassign_children: "RΓ©affecter les sous-pages Γ  cette page"
965 text_own_membership_delete_confirmation: "Vous allez supprimer tout ou partie de vos permissions sur ce projet et ne serez peut-Γͺtre plus autorisΓ© Γ  modifier ce projet.\nEtes-vous sΓ»r de vouloir continuer ?"
967 text_own_membership_delete_confirmation: "Vous allez supprimer tout ou partie de vos permissions sur ce projet et ne serez peut-Γͺtre plus autorisΓ© Γ  modifier ce projet.\nEtes-vous sΓ»r de vouloir continuer ?"
966 text_warn_on_leaving_unsaved: "Cette page contient du texte non sauvegardΓ© qui sera perdu si vous quittez la page."
968 text_warn_on_leaving_unsaved: "Cette page contient du texte non sauvegardΓ© qui sera perdu si vous quittez la page."
967 text_issue_conflict_resolution_overwrite: "Appliquer quand mΓͺme ma mise Γ  jour (les notes prΓ©cΓ©dentes seront conservΓ©es mais des changements pourront Γͺtre Γ©crasΓ©s)"
969 text_issue_conflict_resolution_overwrite: "Appliquer quand mΓͺme ma mise Γ  jour (les notes prΓ©cΓ©dentes seront conservΓ©es mais des changements pourront Γͺtre Γ©crasΓ©s)"
968 text_issue_conflict_resolution_add_notes: "Ajouter mes notes et ignorer mes autres changements"
970 text_issue_conflict_resolution_add_notes: "Ajouter mes notes et ignorer mes autres changements"
969 text_issue_conflict_resolution_cancel: "Annuler ma mise Γ  jour et rΓ©afficher %{link}"
971 text_issue_conflict_resolution_cancel: "Annuler ma mise Γ  jour et rΓ©afficher %{link}"
970 text_account_destroy_confirmation: "Êtes-vous sûr de vouloir continuer ?\nVotre compte sera définitivement supprimé, sans aucune possibilité de le réactiver."
972 text_account_destroy_confirmation: "Êtes-vous sûr de vouloir continuer ?\nVotre compte sera définitivement supprimé, sans aucune possibilité de le réactiver."
971 text_session_expiration_settings: "Attention : le changement de ces paramètres peut entrainer l'expiration des sessions utilisateurs en cours, y compris la vôtre."
973 text_session_expiration_settings: "Attention : le changement de ces paramètres peut entrainer l'expiration des sessions utilisateurs en cours, y compris la vôtre."
972 text_project_closed: Ce projet est fermΓ© et accessible en lecture seule.
974 text_project_closed: Ce projet est fermΓ© et accessible en lecture seule.
973
975
974 default_role_manager: "Manager "
976 default_role_manager: "Manager "
975 default_role_developer: "DΓ©veloppeur "
977 default_role_developer: "DΓ©veloppeur "
976 default_role_reporter: "Rapporteur "
978 default_role_reporter: "Rapporteur "
977 default_tracker_bug: Anomalie
979 default_tracker_bug: Anomalie
978 default_tracker_feature: Evolution
980 default_tracker_feature: Evolution
979 default_tracker_support: Assistance
981 default_tracker_support: Assistance
980 default_issue_status_new: Nouveau
982 default_issue_status_new: Nouveau
981 default_issue_status_in_progress: En cours
983 default_issue_status_in_progress: En cours
982 default_issue_status_resolved: RΓ©solu
984 default_issue_status_resolved: RΓ©solu
983 default_issue_status_feedback: Commentaire
985 default_issue_status_feedback: Commentaire
984 default_issue_status_closed: FermΓ©
986 default_issue_status_closed: FermΓ©
985 default_issue_status_rejected: RejetΓ©
987 default_issue_status_rejected: RejetΓ©
986 default_doc_category_user: Documentation utilisateur
988 default_doc_category_user: Documentation utilisateur
987 default_doc_category_tech: Documentation technique
989 default_doc_category_tech: Documentation technique
988 default_priority_low: Bas
990 default_priority_low: Bas
989 default_priority_normal: Normal
991 default_priority_normal: Normal
990 default_priority_high: Haut
992 default_priority_high: Haut
991 default_priority_urgent: Urgent
993 default_priority_urgent: Urgent
992 default_priority_immediate: ImmΓ©diat
994 default_priority_immediate: ImmΓ©diat
993 default_activity_design: Conception
995 default_activity_design: Conception
994 default_activity_development: DΓ©veloppement
996 default_activity_development: DΓ©veloppement
995
997
996 enumeration_issue_priorities: PrioritΓ©s des demandes
998 enumeration_issue_priorities: PrioritΓ©s des demandes
997 enumeration_doc_categories: CatΓ©gories des documents
999 enumeration_doc_categories: CatΓ©gories des documents
998 enumeration_activities: ActivitΓ©s (suivi du temps)
1000 enumeration_activities: ActivitΓ©s (suivi du temps)
999 label_greater_or_equal: ">="
1001 label_greater_or_equal: ">="
1000 label_less_or_equal: "<="
1002 label_less_or_equal: "<="
1001 label_between: entre
1003 label_between: entre
1002 label_view_all_revisions: Voir toutes les rΓ©visions
1004 label_view_all_revisions: Voir toutes les rΓ©visions
1003 label_tag: Tag
1005 label_tag: Tag
1004 label_branch: Branche
1006 label_branch: Branche
1005 error_no_tracker_in_project: "Aucun tracker n'est associΓ© Γ  ce projet. VΓ©rifier la configuration du projet."
1007 error_no_tracker_in_project: "Aucun tracker n'est associΓ© Γ  ce projet. VΓ©rifier la configuration du projet."
1006 error_no_default_issue_status: "Aucun statut de demande n'est dΓ©fini par dΓ©faut. VΓ©rifier votre configuration (Administration -> Statuts de demandes)."
1008 error_no_default_issue_status: "Aucun statut de demande n'est dΓ©fini par dΓ©faut. VΓ©rifier votre configuration (Administration -> Statuts de demandes)."
1007 text_journal_changed: "%{label} changΓ© de %{old} Γ  %{new}"
1009 text_journal_changed: "%{label} changΓ© de %{old} Γ  %{new}"
1008 text_journal_changed_no_detail: "%{label} mis Γ  jour"
1010 text_journal_changed_no_detail: "%{label} mis Γ  jour"
1009 text_journal_set_to: "%{label} mis Γ  %{value}"
1011 text_journal_set_to: "%{label} mis Γ  %{value}"
1010 text_journal_deleted: "%{label} %{old} supprimΓ©"
1012 text_journal_deleted: "%{label} %{old} supprimΓ©"
1011 text_journal_added: "%{label} %{value} ajoutΓ©"
1013 text_journal_added: "%{label} %{value} ajoutΓ©"
1012 enumeration_system_activity: Activité système
1014 enumeration_system_activity: Activité système
1013 label_board_sticky: Sticky
1015 label_board_sticky: Sticky
1014 label_board_locked: VerrouillΓ©
1016 label_board_locked: VerrouillΓ©
1015 error_unable_delete_issue_status: Impossible de supprimer le statut de demande
1017 error_unable_delete_issue_status: Impossible de supprimer le statut de demande
1016 error_can_not_delete_custom_field: Impossible de supprimer le champ personnalisΓ©
1018 error_can_not_delete_custom_field: Impossible de supprimer le champ personnalisΓ©
1017 error_unable_to_connect: Connexion impossible (%{value})
1019 error_unable_to_connect: Connexion impossible (%{value})
1018 error_can_not_remove_role: Ce rΓ΄le est utilisΓ© et ne peut pas Γͺtre supprimΓ©.
1020 error_can_not_remove_role: Ce rΓ΄le est utilisΓ© et ne peut pas Γͺtre supprimΓ©.
1019 error_can_not_delete_tracker: Ce tracker contient des demandes et ne peut pas Γͺtre supprimΓ©.
1021 error_can_not_delete_tracker: Ce tracker contient des demandes et ne peut pas Γͺtre supprimΓ©.
1020 field_principal: Principal
1022 field_principal: Principal
1021 notice_failed_to_save_members: "Erreur lors de la sauvegarde des membres: %{errors}."
1023 notice_failed_to_save_members: "Erreur lors de la sauvegarde des membres: %{errors}."
1022 text_zoom_out: Zoom arrière
1024 text_zoom_out: Zoom arrière
1023 text_zoom_in: Zoom avant
1025 text_zoom_in: Zoom avant
1024 notice_unable_delete_time_entry: Impossible de supprimer le temps passΓ©.
1026 notice_unable_delete_time_entry: Impossible de supprimer le temps passΓ©.
1025 label_overall_spent_time: Temps passΓ© global
1027 label_overall_spent_time: Temps passΓ© global
1026 field_time_entries: Temps passΓ©
1028 field_time_entries: Temps passΓ©
1027 project_module_gantt: Gantt
1029 project_module_gantt: Gantt
1028 project_module_calendar: Calendrier
1030 project_module_calendar: Calendrier
1029 button_edit_associated_wikipage: "Modifier la page wiki associΓ©e: %{page_title}"
1031 button_edit_associated_wikipage: "Modifier la page wiki associΓ©e: %{page_title}"
1030 text_are_you_sure_with_children: Supprimer la demande et toutes ses sous-demandes ?
1032 text_are_you_sure_with_children: Supprimer la demande et toutes ses sous-demandes ?
1031 field_text: Champ texte
1033 field_text: Champ texte
1032 label_user_mail_option_only_owner: Seulement pour ce que j'ai créé
1034 label_user_mail_option_only_owner: Seulement pour ce que j'ai créé
1033 setting_default_notification_option: Option de notification par dΓ©faut
1035 setting_default_notification_option: Option de notification par dΓ©faut
1034 label_user_mail_option_only_my_events: Seulement pour ce que je surveille
1036 label_user_mail_option_only_my_events: Seulement pour ce que je surveille
1035 label_user_mail_option_only_assigned: Seulement pour ce qui m'est assignΓ©
1037 label_user_mail_option_only_assigned: Seulement pour ce qui m'est assignΓ©
1036 label_user_mail_option_none: Aucune notification
1038 label_user_mail_option_none: Aucune notification
1037 field_member_of_group: Groupe de l'assignΓ©
1039 field_member_of_group: Groupe de l'assignΓ©
1038 field_assigned_to_role: RΓ΄le de l'assignΓ©
1040 field_assigned_to_role: RΓ΄le de l'assignΓ©
1039 setting_emails_header: En-tΓͺte des emails
1041 setting_emails_header: En-tΓͺte des emails
1040 label_bulk_edit_selected_time_entries: Modifier les temps passΓ©s sΓ©lectionnΓ©s
1042 label_bulk_edit_selected_time_entries: Modifier les temps passΓ©s sΓ©lectionnΓ©s
1041 text_time_entries_destroy_confirmation: "Etes-vous sΓ»r de vouloir supprimer les temps passΓ©s sΓ©lectionnΓ©s ?"
1043 text_time_entries_destroy_confirmation: "Etes-vous sΓ»r de vouloir supprimer les temps passΓ©s sΓ©lectionnΓ©s ?"
1042 field_scm_path_encoding: Encodage des chemins
1044 field_scm_path_encoding: Encodage des chemins
1043 text_scm_path_encoding_note: "DΓ©faut : UTF-8"
1045 text_scm_path_encoding_note: "DΓ©faut : UTF-8"
1044 field_path_to_repository: Chemin du dΓ©pΓ΄t
1046 field_path_to_repository: Chemin du dΓ©pΓ΄t
1045 field_root_directory: RΓ©pertoire racine
1047 field_root_directory: RΓ©pertoire racine
1046 field_cvs_module: Module
1048 field_cvs_module: Module
1047 field_cvsroot: CVSROOT
1049 field_cvsroot: CVSROOT
1048 text_mercurial_repository_note: "DΓ©pΓ΄t local (exemples : /hgrepo, c:\\hgrepo)"
1050 text_mercurial_repository_note: "DΓ©pΓ΄t local (exemples : /hgrepo, c:\\hgrepo)"
1049 text_scm_command: Commande
1051 text_scm_command: Commande
1050 text_scm_command_version: Version
1052 text_scm_command_version: Version
1051 label_git_report_last_commit: Afficher le dernier commit des fichiers et rΓ©pertoires
1053 label_git_report_last_commit: Afficher le dernier commit des fichiers et rΓ©pertoires
1052 text_scm_config: Vous pouvez configurer les commandes des SCM dans config/configuration.yml. Redémarrer l'application après modification.
1054 text_scm_config: Vous pouvez configurer les commandes des SCM dans config/configuration.yml. Redémarrer l'application après modification.
1053 text_scm_command_not_available: Ce SCM n'est pas disponible. Vérifier les paramètres dans la section administration.
1055 text_scm_command_not_available: Ce SCM n'est pas disponible. Vérifier les paramètres dans la section administration.
1054 label_diff: diff
1056 label_diff: diff
1055 text_git_repository_note: Repository is bare and local (e.g. /gitrepo, c:\gitrepo)
1057 text_git_repository_note: Repository is bare and local (e.g. /gitrepo, c:\gitrepo)
1056 description_query_sort_criteria_direction: Ordre de tri
1058 description_query_sort_criteria_direction: Ordre de tri
1057 description_project_scope: Périmètre de recherche
1059 description_project_scope: Périmètre de recherche
1058 description_filter: Filtre
1060 description_filter: Filtre
1059 description_user_mail_notification: Option de notification
1061 description_user_mail_notification: Option de notification
1060 description_date_from: Date de dΓ©but
1062 description_date_from: Date de dΓ©but
1061 description_message_content: Contenu du message
1063 description_message_content: Contenu du message
1062 description_available_columns: Colonnes disponibles
1064 description_available_columns: Colonnes disponibles
1063 description_all_columns: Toutes les colonnes
1065 description_all_columns: Toutes les colonnes
1064 description_date_range_interval: Choisir une pΓ©riode
1066 description_date_range_interval: Choisir une pΓ©riode
1065 description_issue_category_reassign: Choisir une catΓ©gorie
1067 description_issue_category_reassign: Choisir une catΓ©gorie
1066 description_search: Champ de recherche
1068 description_search: Champ de recherche
1067 description_notes: Notes
1069 description_notes: Notes
1068 description_date_range_list: Choisir une pΓ©riode prΓ©dΓ©finie
1070 description_date_range_list: Choisir une pΓ©riode prΓ©dΓ©finie
1069 description_choose_project: Projets
1071 description_choose_project: Projets
1070 description_date_to: Date de fin
1072 description_date_to: Date de fin
1071 description_query_sort_criteria_attribute: Critère de tri
1073 description_query_sort_criteria_attribute: Critère de tri
1072 description_wiki_subpages_reassign: Choisir une nouvelle page parent
1074 description_wiki_subpages_reassign: Choisir une nouvelle page parent
1073 description_selected_columns: Colonnes sΓ©lectionnΓ©es
1075 description_selected_columns: Colonnes sΓ©lectionnΓ©es
1074 label_parent_revision: Parent
1076 label_parent_revision: Parent
1075 label_child_revision: Enfant
1077 label_child_revision: Enfant
1076 error_scm_annotate_big_text_file: Cette entrΓ©e ne peut pas Γͺtre annotΓ©e car elle excΓ¨de la taille maximale.
1078 error_scm_annotate_big_text_file: Cette entrΓ©e ne peut pas Γͺtre annotΓ©e car elle excΓ¨de la taille maximale.
1077 setting_repositories_encodings: Encodages des fichiers et des dΓ©pΓ΄ts
1079 setting_repositories_encodings: Encodages des fichiers et des dΓ©pΓ΄ts
1078 label_search_for_watchers: Rechercher des observateurs
1080 label_search_for_watchers: Rechercher des observateurs
1079 text_repository_identifier_info: 'Seuls les lettres minuscules (a-z), chiffres, tirets et underscore sont autorisΓ©s.<br />Un fois sauvegardΓ©, l''identifiant ne pourra plus Γͺtre modifiΓ©.'
1081 text_repository_identifier_info: 'Seuls les lettres minuscules (a-z), chiffres, tirets et underscore sont autorisΓ©s.<br />Un fois sauvegardΓ©, l''identifiant ne pourra plus Γͺtre modifiΓ©.'
@@ -1,3658 +1,3684
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang
2 # Copyright (C) 2006-2012 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.expand_path('../../test_helper', __FILE__)
18 require File.expand_path('../../test_helper', __FILE__)
19 require 'issues_controller'
19 require 'issues_controller'
20
20
21 class IssuesControllerTest < ActionController::TestCase
21 class IssuesControllerTest < ActionController::TestCase
22 fixtures :projects,
22 fixtures :projects,
23 :users,
23 :users,
24 :roles,
24 :roles,
25 :members,
25 :members,
26 :member_roles,
26 :member_roles,
27 :issues,
27 :issues,
28 :issue_statuses,
28 :issue_statuses,
29 :versions,
29 :versions,
30 :trackers,
30 :trackers,
31 :projects_trackers,
31 :projects_trackers,
32 :issue_categories,
32 :issue_categories,
33 :enabled_modules,
33 :enabled_modules,
34 :enumerations,
34 :enumerations,
35 :attachments,
35 :attachments,
36 :workflows,
36 :workflows,
37 :custom_fields,
37 :custom_fields,
38 :custom_values,
38 :custom_values,
39 :custom_fields_projects,
39 :custom_fields_projects,
40 :custom_fields_trackers,
40 :custom_fields_trackers,
41 :time_entries,
41 :time_entries,
42 :journals,
42 :journals,
43 :journal_details,
43 :journal_details,
44 :queries,
44 :queries,
45 :repositories,
45 :repositories,
46 :changesets
46 :changesets
47
47
48 include Redmine::I18n
48 include Redmine::I18n
49
49
50 def setup
50 def setup
51 @controller = IssuesController.new
51 @controller = IssuesController.new
52 @request = ActionController::TestRequest.new
52 @request = ActionController::TestRequest.new
53 @response = ActionController::TestResponse.new
53 @response = ActionController::TestResponse.new
54 User.current = nil
54 User.current = nil
55 end
55 end
56
56
57 def test_index
57 def test_index
58 with_settings :default_language => "en" do
58 with_settings :default_language => "en" do
59 get :index
59 get :index
60 assert_response :success
60 assert_response :success
61 assert_template 'index'
61 assert_template 'index'
62 assert_not_nil assigns(:issues)
62 assert_not_nil assigns(:issues)
63 assert_nil assigns(:project)
63 assert_nil assigns(:project)
64 assert_tag :tag => 'a', :content => /Can&#x27;t print recipes/
64 assert_tag :tag => 'a', :content => /Can&#x27;t print recipes/
65 assert_tag :tag => 'a', :content => /Subproject issue/
65 assert_tag :tag => 'a', :content => /Subproject issue/
66 # private projects hidden
66 # private projects hidden
67 assert_no_tag :tag => 'a', :content => /Issue of a private subproject/
67 assert_no_tag :tag => 'a', :content => /Issue of a private subproject/
68 assert_no_tag :tag => 'a', :content => /Issue on project 2/
68 assert_no_tag :tag => 'a', :content => /Issue on project 2/
69 # project column
69 # project column
70 assert_tag :tag => 'th', :content => /Project/
70 assert_tag :tag => 'th', :content => /Project/
71 end
71 end
72 end
72 end
73
73
74 def test_index_should_not_list_issues_when_module_disabled
74 def test_index_should_not_list_issues_when_module_disabled
75 EnabledModule.delete_all("name = 'issue_tracking' AND project_id = 1")
75 EnabledModule.delete_all("name = 'issue_tracking' AND project_id = 1")
76 get :index
76 get :index
77 assert_response :success
77 assert_response :success
78 assert_template 'index'
78 assert_template 'index'
79 assert_not_nil assigns(:issues)
79 assert_not_nil assigns(:issues)
80 assert_nil assigns(:project)
80 assert_nil assigns(:project)
81 assert_no_tag :tag => 'a', :content => /Can&#x27;t print recipes/
81 assert_no_tag :tag => 'a', :content => /Can&#x27;t print recipes/
82 assert_tag :tag => 'a', :content => /Subproject issue/
82 assert_tag :tag => 'a', :content => /Subproject issue/
83 end
83 end
84
84
85 def test_index_should_list_visible_issues_only
85 def test_index_should_list_visible_issues_only
86 get :index, :per_page => 100
86 get :index, :per_page => 100
87 assert_response :success
87 assert_response :success
88 assert_not_nil assigns(:issues)
88 assert_not_nil assigns(:issues)
89 assert_nil assigns(:issues).detect {|issue| !issue.visible?}
89 assert_nil assigns(:issues).detect {|issue| !issue.visible?}
90 end
90 end
91
91
92 def test_index_with_project
92 def test_index_with_project
93 Setting.display_subprojects_issues = 0
93 Setting.display_subprojects_issues = 0
94 get :index, :project_id => 1
94 get :index, :project_id => 1
95 assert_response :success
95 assert_response :success
96 assert_template 'index'
96 assert_template 'index'
97 assert_not_nil assigns(:issues)
97 assert_not_nil assigns(:issues)
98 assert_tag :tag => 'a', :content => /Can&#x27;t print recipes/
98 assert_tag :tag => 'a', :content => /Can&#x27;t print recipes/
99 assert_no_tag :tag => 'a', :content => /Subproject issue/
99 assert_no_tag :tag => 'a', :content => /Subproject issue/
100 end
100 end
101
101
102 def test_index_with_project_and_subprojects
102 def test_index_with_project_and_subprojects
103 Setting.display_subprojects_issues = 1
103 Setting.display_subprojects_issues = 1
104 get :index, :project_id => 1
104 get :index, :project_id => 1
105 assert_response :success
105 assert_response :success
106 assert_template 'index'
106 assert_template 'index'
107 assert_not_nil assigns(:issues)
107 assert_not_nil assigns(:issues)
108 assert_tag :tag => 'a', :content => /Can&#x27;t print recipes/
108 assert_tag :tag => 'a', :content => /Can&#x27;t print recipes/
109 assert_tag :tag => 'a', :content => /Subproject issue/
109 assert_tag :tag => 'a', :content => /Subproject issue/
110 assert_no_tag :tag => 'a', :content => /Issue of a private subproject/
110 assert_no_tag :tag => 'a', :content => /Issue of a private subproject/
111 end
111 end
112
112
113 def test_index_with_project_and_subprojects_should_show_private_subprojects
113 def test_index_with_project_and_subprojects_should_show_private_subprojects
114 @request.session[:user_id] = 2
114 @request.session[:user_id] = 2
115 Setting.display_subprojects_issues = 1
115 Setting.display_subprojects_issues = 1
116 get :index, :project_id => 1
116 get :index, :project_id => 1
117 assert_response :success
117 assert_response :success
118 assert_template 'index'
118 assert_template 'index'
119 assert_not_nil assigns(:issues)
119 assert_not_nil assigns(:issues)
120 assert_tag :tag => 'a', :content => /Can&#x27;t print recipes/
120 assert_tag :tag => 'a', :content => /Can&#x27;t print recipes/
121 assert_tag :tag => 'a', :content => /Subproject issue/
121 assert_tag :tag => 'a', :content => /Subproject issue/
122 assert_tag :tag => 'a', :content => /Issue of a private subproject/
122 assert_tag :tag => 'a', :content => /Issue of a private subproject/
123 end
123 end
124
124
125 def test_index_with_project_and_default_filter
125 def test_index_with_project_and_default_filter
126 get :index, :project_id => 1, :set_filter => 1
126 get :index, :project_id => 1, :set_filter => 1
127 assert_response :success
127 assert_response :success
128 assert_template 'index'
128 assert_template 'index'
129 assert_not_nil assigns(:issues)
129 assert_not_nil assigns(:issues)
130
130
131 query = assigns(:query)
131 query = assigns(:query)
132 assert_not_nil query
132 assert_not_nil query
133 # default filter
133 # default filter
134 assert_equal({'status_id' => {:operator => 'o', :values => ['']}}, query.filters)
134 assert_equal({'status_id' => {:operator => 'o', :values => ['']}}, query.filters)
135 end
135 end
136
136
137 def test_index_with_project_and_filter
137 def test_index_with_project_and_filter
138 get :index, :project_id => 1, :set_filter => 1,
138 get :index, :project_id => 1, :set_filter => 1,
139 :f => ['tracker_id'],
139 :f => ['tracker_id'],
140 :op => {'tracker_id' => '='},
140 :op => {'tracker_id' => '='},
141 :v => {'tracker_id' => ['1']}
141 :v => {'tracker_id' => ['1']}
142 assert_response :success
142 assert_response :success
143 assert_template 'index'
143 assert_template 'index'
144 assert_not_nil assigns(:issues)
144 assert_not_nil assigns(:issues)
145
145
146 query = assigns(:query)
146 query = assigns(:query)
147 assert_not_nil query
147 assert_not_nil query
148 assert_equal({'tracker_id' => {:operator => '=', :values => ['1']}}, query.filters)
148 assert_equal({'tracker_id' => {:operator => '=', :values => ['1']}}, query.filters)
149 end
149 end
150
150
151 def test_index_with_short_filters
151 def test_index_with_short_filters
152 to_test = {
152 to_test = {
153 'status_id' => {
153 'status_id' => {
154 'o' => { :op => 'o', :values => [''] },
154 'o' => { :op => 'o', :values => [''] },
155 'c' => { :op => 'c', :values => [''] },
155 'c' => { :op => 'c', :values => [''] },
156 '7' => { :op => '=', :values => ['7'] },
156 '7' => { :op => '=', :values => ['7'] },
157 '7|3|4' => { :op => '=', :values => ['7', '3', '4'] },
157 '7|3|4' => { :op => '=', :values => ['7', '3', '4'] },
158 '=7' => { :op => '=', :values => ['7'] },
158 '=7' => { :op => '=', :values => ['7'] },
159 '!3' => { :op => '!', :values => ['3'] },
159 '!3' => { :op => '!', :values => ['3'] },
160 '!7|3|4' => { :op => '!', :values => ['7', '3', '4'] }},
160 '!7|3|4' => { :op => '!', :values => ['7', '3', '4'] }},
161 'subject' => {
161 'subject' => {
162 'This is a subject' => { :op => '=', :values => ['This is a subject'] },
162 'This is a subject' => { :op => '=', :values => ['This is a subject'] },
163 'o' => { :op => '=', :values => ['o'] },
163 'o' => { :op => '=', :values => ['o'] },
164 '~This is part of a subject' => { :op => '~', :values => ['This is part of a subject'] },
164 '~This is part of a subject' => { :op => '~', :values => ['This is part of a subject'] },
165 '!~This is part of a subject' => { :op => '!~', :values => ['This is part of a subject'] }},
165 '!~This is part of a subject' => { :op => '!~', :values => ['This is part of a subject'] }},
166 'tracker_id' => {
166 'tracker_id' => {
167 '3' => { :op => '=', :values => ['3'] },
167 '3' => { :op => '=', :values => ['3'] },
168 '=3' => { :op => '=', :values => ['3'] }},
168 '=3' => { :op => '=', :values => ['3'] }},
169 'start_date' => {
169 'start_date' => {
170 '2011-10-12' => { :op => '=', :values => ['2011-10-12'] },
170 '2011-10-12' => { :op => '=', :values => ['2011-10-12'] },
171 '=2011-10-12' => { :op => '=', :values => ['2011-10-12'] },
171 '=2011-10-12' => { :op => '=', :values => ['2011-10-12'] },
172 '>=2011-10-12' => { :op => '>=', :values => ['2011-10-12'] },
172 '>=2011-10-12' => { :op => '>=', :values => ['2011-10-12'] },
173 '<=2011-10-12' => { :op => '<=', :values => ['2011-10-12'] },
173 '<=2011-10-12' => { :op => '<=', :values => ['2011-10-12'] },
174 '><2011-10-01|2011-10-30' => { :op => '><', :values => ['2011-10-01', '2011-10-30'] },
174 '><2011-10-01|2011-10-30' => { :op => '><', :values => ['2011-10-01', '2011-10-30'] },
175 '<t+2' => { :op => '<t+', :values => ['2'] },
175 '<t+2' => { :op => '<t+', :values => ['2'] },
176 '>t+2' => { :op => '>t+', :values => ['2'] },
176 '>t+2' => { :op => '>t+', :values => ['2'] },
177 't+2' => { :op => 't+', :values => ['2'] },
177 't+2' => { :op => 't+', :values => ['2'] },
178 't' => { :op => 't', :values => [''] },
178 't' => { :op => 't', :values => [''] },
179 'w' => { :op => 'w', :values => [''] },
179 'w' => { :op => 'w', :values => [''] },
180 '>t-2' => { :op => '>t-', :values => ['2'] },
180 '>t-2' => { :op => '>t-', :values => ['2'] },
181 '<t-2' => { :op => '<t-', :values => ['2'] },
181 '<t-2' => { :op => '<t-', :values => ['2'] },
182 't-2' => { :op => 't-', :values => ['2'] }},
182 't-2' => { :op => 't-', :values => ['2'] }},
183 'created_on' => {
183 'created_on' => {
184 '>=2011-10-12' => { :op => '>=', :values => ['2011-10-12'] },
184 '>=2011-10-12' => { :op => '>=', :values => ['2011-10-12'] },
185 '<t-2' => { :op => '<t-', :values => ['2'] },
185 '<t-2' => { :op => '<t-', :values => ['2'] },
186 '>t-2' => { :op => '>t-', :values => ['2'] },
186 '>t-2' => { :op => '>t-', :values => ['2'] },
187 't-2' => { :op => 't-', :values => ['2'] }},
187 't-2' => { :op => 't-', :values => ['2'] }},
188 'cf_1' => {
188 'cf_1' => {
189 'c' => { :op => '=', :values => ['c'] },
189 'c' => { :op => '=', :values => ['c'] },
190 '!c' => { :op => '!', :values => ['c'] },
190 '!c' => { :op => '!', :values => ['c'] },
191 '!*' => { :op => '!*', :values => [''] },
191 '!*' => { :op => '!*', :values => [''] },
192 '*' => { :op => '*', :values => [''] }},
192 '*' => { :op => '*', :values => [''] }},
193 'estimated_hours' => {
193 'estimated_hours' => {
194 '=13.4' => { :op => '=', :values => ['13.4'] },
194 '=13.4' => { :op => '=', :values => ['13.4'] },
195 '>=45' => { :op => '>=', :values => ['45'] },
195 '>=45' => { :op => '>=', :values => ['45'] },
196 '<=125' => { :op => '<=', :values => ['125'] },
196 '<=125' => { :op => '<=', :values => ['125'] },
197 '><10.5|20.5' => { :op => '><', :values => ['10.5', '20.5'] },
197 '><10.5|20.5' => { :op => '><', :values => ['10.5', '20.5'] },
198 '!*' => { :op => '!*', :values => [''] },
198 '!*' => { :op => '!*', :values => [''] },
199 '*' => { :op => '*', :values => [''] }}
199 '*' => { :op => '*', :values => [''] }}
200 }
200 }
201
201
202 default_filter = { 'status_id' => {:operator => 'o', :values => [''] }}
202 default_filter = { 'status_id' => {:operator => 'o', :values => [''] }}
203
203
204 to_test.each do |field, expression_and_expected|
204 to_test.each do |field, expression_and_expected|
205 expression_and_expected.each do |filter_expression, expected|
205 expression_and_expected.each do |filter_expression, expected|
206
206
207 get :index, :set_filter => 1, field => filter_expression
207 get :index, :set_filter => 1, field => filter_expression
208
208
209 assert_response :success
209 assert_response :success
210 assert_template 'index'
210 assert_template 'index'
211 assert_not_nil assigns(:issues)
211 assert_not_nil assigns(:issues)
212
212
213 query = assigns(:query)
213 query = assigns(:query)
214 assert_not_nil query
214 assert_not_nil query
215 assert query.has_filter?(field)
215 assert query.has_filter?(field)
216 assert_equal(default_filter.merge({field => {:operator => expected[:op], :values => expected[:values]}}), query.filters)
216 assert_equal(default_filter.merge({field => {:operator => expected[:op], :values => expected[:values]}}), query.filters)
217 end
217 end
218 end
218 end
219 end
219 end
220
220
221 def test_index_with_project_and_empty_filters
221 def test_index_with_project_and_empty_filters
222 get :index, :project_id => 1, :set_filter => 1, :fields => ['']
222 get :index, :project_id => 1, :set_filter => 1, :fields => ['']
223 assert_response :success
223 assert_response :success
224 assert_template 'index'
224 assert_template 'index'
225 assert_not_nil assigns(:issues)
225 assert_not_nil assigns(:issues)
226
226
227 query = assigns(:query)
227 query = assigns(:query)
228 assert_not_nil query
228 assert_not_nil query
229 # no filter
229 # no filter
230 assert_equal({}, query.filters)
230 assert_equal({}, query.filters)
231 end
231 end
232
232
233 def test_index_with_project_custom_field_filter
233 def test_index_with_project_custom_field_filter
234 field = ProjectCustomField.create!(:name => 'Client', :is_filter => true, :field_format => 'string')
234 field = ProjectCustomField.create!(:name => 'Client', :is_filter => true, :field_format => 'string')
235 CustomValue.create!(:custom_field => field, :customized => Project.find(3), :value => 'Foo')
235 CustomValue.create!(:custom_field => field, :customized => Project.find(3), :value => 'Foo')
236 CustomValue.create!(:custom_field => field, :customized => Project.find(5), :value => 'Foo')
236 CustomValue.create!(:custom_field => field, :customized => Project.find(5), :value => 'Foo')
237 filter_name = "project.cf_#{field.id}"
237 filter_name = "project.cf_#{field.id}"
238 @request.session[:user_id] = 1
238 @request.session[:user_id] = 1
239
239
240 get :index, :set_filter => 1,
240 get :index, :set_filter => 1,
241 :f => [filter_name],
241 :f => [filter_name],
242 :op => {filter_name => '='},
242 :op => {filter_name => '='},
243 :v => {filter_name => ['Foo']}
243 :v => {filter_name => ['Foo']}
244 assert_response :success
244 assert_response :success
245 assert_template 'index'
245 assert_template 'index'
246 assert_equal [3, 5], assigns(:issues).map(&:project_id).uniq.sort
246 assert_equal [3, 5], assigns(:issues).map(&:project_id).uniq.sort
247 end
247 end
248
248
249 def test_index_with_query
249 def test_index_with_query
250 get :index, :project_id => 1, :query_id => 5
250 get :index, :project_id => 1, :query_id => 5
251 assert_response :success
251 assert_response :success
252 assert_template 'index'
252 assert_template 'index'
253 assert_not_nil assigns(:issues)
253 assert_not_nil assigns(:issues)
254 assert_nil assigns(:issue_count_by_group)
254 assert_nil assigns(:issue_count_by_group)
255 end
255 end
256
256
257 def test_index_with_query_grouped_by_tracker
257 def test_index_with_query_grouped_by_tracker
258 get :index, :project_id => 1, :query_id => 6
258 get :index, :project_id => 1, :query_id => 6
259 assert_response :success
259 assert_response :success
260 assert_template 'index'
260 assert_template 'index'
261 assert_not_nil assigns(:issues)
261 assert_not_nil assigns(:issues)
262 assert_not_nil assigns(:issue_count_by_group)
262 assert_not_nil assigns(:issue_count_by_group)
263 end
263 end
264
264
265 def test_index_with_query_grouped_by_list_custom_field
265 def test_index_with_query_grouped_by_list_custom_field
266 get :index, :project_id => 1, :query_id => 9
266 get :index, :project_id => 1, :query_id => 9
267 assert_response :success
267 assert_response :success
268 assert_template 'index'
268 assert_template 'index'
269 assert_not_nil assigns(:issues)
269 assert_not_nil assigns(:issues)
270 assert_not_nil assigns(:issue_count_by_group)
270 assert_not_nil assigns(:issue_count_by_group)
271 end
271 end
272
272
273 def test_index_with_query_grouped_by_user_custom_field
273 def test_index_with_query_grouped_by_user_custom_field
274 cf = IssueCustomField.create!(:name => 'User', :is_for_all => true, :tracker_ids => [1,2,3], :field_format => 'user')
274 cf = IssueCustomField.create!(:name => 'User', :is_for_all => true, :tracker_ids => [1,2,3], :field_format => 'user')
275 CustomValue.create!(:custom_field => cf, :customized => Issue.find(1), :value => '2')
275 CustomValue.create!(:custom_field => cf, :customized => Issue.find(1), :value => '2')
276 CustomValue.create!(:custom_field => cf, :customized => Issue.find(2), :value => '3')
276 CustomValue.create!(:custom_field => cf, :customized => Issue.find(2), :value => '3')
277 CustomValue.create!(:custom_field => cf, :customized => Issue.find(3), :value => '3')
277 CustomValue.create!(:custom_field => cf, :customized => Issue.find(3), :value => '3')
278 CustomValue.create!(:custom_field => cf, :customized => Issue.find(5), :value => '')
278 CustomValue.create!(:custom_field => cf, :customized => Issue.find(5), :value => '')
279
279
280 get :index, :project_id => 1, :set_filter => 1, :group_by => "cf_#{cf.id}"
280 get :index, :project_id => 1, :set_filter => 1, :group_by => "cf_#{cf.id}"
281 assert_response :success
281 assert_response :success
282
282
283 assert_select 'tr.group', 3
283 assert_select 'tr.group', 3
284 assert_select 'tr.group' do
284 assert_select 'tr.group' do
285 assert_select 'a', :text => 'John Smith'
285 assert_select 'a', :text => 'John Smith'
286 assert_select 'span.count', :text => '(1)'
286 assert_select 'span.count', :text => '(1)'
287 end
287 end
288 assert_select 'tr.group' do
288 assert_select 'tr.group' do
289 assert_select 'a', :text => 'Dave Lopper'
289 assert_select 'a', :text => 'Dave Lopper'
290 assert_select 'span.count', :text => '(2)'
290 assert_select 'span.count', :text => '(2)'
291 end
291 end
292 end
292 end
293
293
294 def test_index_with_query_id_and_project_id_should_set_session_query
294 def test_index_with_query_id_and_project_id_should_set_session_query
295 get :index, :project_id => 1, :query_id => 4
295 get :index, :project_id => 1, :query_id => 4
296 assert_response :success
296 assert_response :success
297 assert_kind_of Hash, session[:query]
297 assert_kind_of Hash, session[:query]
298 assert_equal 4, session[:query][:id]
298 assert_equal 4, session[:query][:id]
299 assert_equal 1, session[:query][:project_id]
299 assert_equal 1, session[:query][:project_id]
300 end
300 end
301
301
302 def test_index_with_invalid_query_id_should_respond_404
302 def test_index_with_invalid_query_id_should_respond_404
303 get :index, :project_id => 1, :query_id => 999
303 get :index, :project_id => 1, :query_id => 999
304 assert_response 404
304 assert_response 404
305 end
305 end
306
306
307 def test_index_with_cross_project_query_in_session_should_show_project_issues
307 def test_index_with_cross_project_query_in_session_should_show_project_issues
308 q = Query.create!(:name => "test", :user_id => 2, :is_public => false, :project => nil)
308 q = Query.create!(:name => "test", :user_id => 2, :is_public => false, :project => nil)
309 @request.session[:query] = {:id => q.id, :project_id => 1}
309 @request.session[:query] = {:id => q.id, :project_id => 1}
310
310
311 with_settings :display_subprojects_issues => '0' do
311 with_settings :display_subprojects_issues => '0' do
312 get :index, :project_id => 1
312 get :index, :project_id => 1
313 end
313 end
314 assert_response :success
314 assert_response :success
315 assert_not_nil assigns(:query)
315 assert_not_nil assigns(:query)
316 assert_equal q.id, assigns(:query).id
316 assert_equal q.id, assigns(:query).id
317 assert_equal 1, assigns(:query).project_id
317 assert_equal 1, assigns(:query).project_id
318 assert_equal [1], assigns(:issues).map(&:project_id).uniq
318 assert_equal [1], assigns(:issues).map(&:project_id).uniq
319 end
319 end
320
320
321 def test_private_query_should_not_be_available_to_other_users
321 def test_private_query_should_not_be_available_to_other_users
322 q = Query.create!(:name => "private", :user => User.find(2), :is_public => false, :project => nil)
322 q = Query.create!(:name => "private", :user => User.find(2), :is_public => false, :project => nil)
323 @request.session[:user_id] = 3
323 @request.session[:user_id] = 3
324
324
325 get :index, :query_id => q.id
325 get :index, :query_id => q.id
326 assert_response 403
326 assert_response 403
327 end
327 end
328
328
329 def test_private_query_should_be_available_to_its_user
329 def test_private_query_should_be_available_to_its_user
330 q = Query.create!(:name => "private", :user => User.find(2), :is_public => false, :project => nil)
330 q = Query.create!(:name => "private", :user => User.find(2), :is_public => false, :project => nil)
331 @request.session[:user_id] = 2
331 @request.session[:user_id] = 2
332
332
333 get :index, :query_id => q.id
333 get :index, :query_id => q.id
334 assert_response :success
334 assert_response :success
335 end
335 end
336
336
337 def test_public_query_should_be_available_to_other_users
337 def test_public_query_should_be_available_to_other_users
338 q = Query.create!(:name => "private", :user => User.find(2), :is_public => true, :project => nil)
338 q = Query.create!(:name => "private", :user => User.find(2), :is_public => true, :project => nil)
339 @request.session[:user_id] = 3
339 @request.session[:user_id] = 3
340
340
341 get :index, :query_id => q.id
341 get :index, :query_id => q.id
342 assert_response :success
342 assert_response :success
343 end
343 end
344
344
345 def test_index_should_omit_page_param_in_export_links
345 def test_index_should_omit_page_param_in_export_links
346 get :index, :page => 2
346 get :index, :page => 2
347 assert_response :success
347 assert_response :success
348 assert_select 'a.atom[href=/issues.atom]'
348 assert_select 'a.atom[href=/issues.atom]'
349 assert_select 'a.csv[href=/issues.csv]'
349 assert_select 'a.csv[href=/issues.csv]'
350 assert_select 'a.pdf[href=/issues.pdf]'
350 assert_select 'a.pdf[href=/issues.pdf]'
351 assert_select 'form#csv-export-form[action=/issues.csv]'
351 assert_select 'form#csv-export-form[action=/issues.csv]'
352 end
352 end
353
353
354 def test_index_csv
354 def test_index_csv
355 get :index, :format => 'csv'
355 get :index, :format => 'csv'
356 assert_response :success
356 assert_response :success
357 assert_not_nil assigns(:issues)
357 assert_not_nil assigns(:issues)
358 assert_equal 'text/csv; header=present', @response.content_type
358 assert_equal 'text/csv; header=present', @response.content_type
359 assert @response.body.starts_with?("#,")
359 assert @response.body.starts_with?("#,")
360 lines = @response.body.chomp.split("\n")
360 lines = @response.body.chomp.split("\n")
361 assert_equal assigns(:query).columns.size + 1, lines[0].split(',').size
361 assert_equal assigns(:query).columns.size + 1, lines[0].split(',').size
362 end
362 end
363
363
364 def test_index_csv_with_project
364 def test_index_csv_with_project
365 get :index, :project_id => 1, :format => 'csv'
365 get :index, :project_id => 1, :format => 'csv'
366 assert_response :success
366 assert_response :success
367 assert_not_nil assigns(:issues)
367 assert_not_nil assigns(:issues)
368 assert_equal 'text/csv; header=present', @response.content_type
368 assert_equal 'text/csv; header=present', @response.content_type
369 end
369 end
370
370
371 def test_index_csv_with_description
371 def test_index_csv_with_description
372 get :index, :format => 'csv', :description => '1'
372 get :index, :format => 'csv', :description => '1'
373 assert_response :success
373 assert_response :success
374 assert_not_nil assigns(:issues)
374 assert_not_nil assigns(:issues)
375 assert_equal 'text/csv; header=present', @response.content_type
375 assert_equal 'text/csv; header=present', @response.content_type
376 assert @response.body.starts_with?("#,")
376 assert @response.body.starts_with?("#,")
377 lines = @response.body.chomp.split("\n")
377 lines = @response.body.chomp.split("\n")
378 assert_equal assigns(:query).columns.size + 2, lines[0].split(',').size
378 assert_equal assigns(:query).columns.size + 2, lines[0].split(',').size
379 end
379 end
380
380
381 def test_index_csv_with_spent_time_column
381 def test_index_csv_with_spent_time_column
382 issue = Issue.create!(:project_id => 1, :tracker_id => 1, :subject => 'test_index_csv_with_spent_time_column', :author_id => 2)
382 issue = Issue.create!(:project_id => 1, :tracker_id => 1, :subject => 'test_index_csv_with_spent_time_column', :author_id => 2)
383 TimeEntry.create!(:project => issue.project, :issue => issue, :hours => 7.33, :user => User.find(2), :spent_on => Date.today)
383 TimeEntry.create!(:project => issue.project, :issue => issue, :hours => 7.33, :user => User.find(2), :spent_on => Date.today)
384
384
385 get :index, :format => 'csv', :set_filter => '1', :c => %w(subject spent_hours)
385 get :index, :format => 'csv', :set_filter => '1', :c => %w(subject spent_hours)
386 assert_response :success
386 assert_response :success
387 assert_equal 'text/csv; header=present', @response.content_type
387 assert_equal 'text/csv; header=present', @response.content_type
388 lines = @response.body.chomp.split("\n")
388 lines = @response.body.chomp.split("\n")
389 assert_include "#{issue.id},#{issue.subject},7.33", lines
389 assert_include "#{issue.id},#{issue.subject},7.33", lines
390 end
390 end
391
391
392 def test_index_csv_with_all_columns
392 def test_index_csv_with_all_columns
393 get :index, :format => 'csv', :columns => 'all'
393 get :index, :format => 'csv', :columns => 'all'
394 assert_response :success
394 assert_response :success
395 assert_not_nil assigns(:issues)
395 assert_not_nil assigns(:issues)
396 assert_equal 'text/csv; header=present', @response.content_type
396 assert_equal 'text/csv; header=present', @response.content_type
397 assert @response.body.starts_with?("#,")
397 assert @response.body.starts_with?("#,")
398 lines = @response.body.chomp.split("\n")
398 lines = @response.body.chomp.split("\n")
399 assert_equal assigns(:query).available_columns.size + 1, lines[0].split(',').size
399 assert_equal assigns(:query).available_columns.size + 1, lines[0].split(',').size
400 end
400 end
401
401
402 def test_index_csv_with_multi_column_field
402 def test_index_csv_with_multi_column_field
403 CustomField.find(1).update_attribute :multiple, true
403 CustomField.find(1).update_attribute :multiple, true
404 issue = Issue.find(1)
404 issue = Issue.find(1)
405 issue.custom_field_values = {1 => ['MySQL', 'Oracle']}
405 issue.custom_field_values = {1 => ['MySQL', 'Oracle']}
406 issue.save!
406 issue.save!
407
407
408 get :index, :format => 'csv', :columns => 'all'
408 get :index, :format => 'csv', :columns => 'all'
409 assert_response :success
409 assert_response :success
410 lines = @response.body.chomp.split("\n")
410 lines = @response.body.chomp.split("\n")
411 assert lines.detect {|line| line.include?('"MySQL, Oracle"')}
411 assert lines.detect {|line| line.include?('"MySQL, Oracle"')}
412 end
412 end
413
413
414 def test_index_csv_big_5
414 def test_index_csv_big_5
415 with_settings :default_language => "zh-TW" do
415 with_settings :default_language => "zh-TW" do
416 str_utf8 = "\xe4\xb8\x80\xe6\x9c\x88"
416 str_utf8 = "\xe4\xb8\x80\xe6\x9c\x88"
417 str_big5 = "\xa4@\xa4\xeb"
417 str_big5 = "\xa4@\xa4\xeb"
418 if str_utf8.respond_to?(:force_encoding)
418 if str_utf8.respond_to?(:force_encoding)
419 str_utf8.force_encoding('UTF-8')
419 str_utf8.force_encoding('UTF-8')
420 str_big5.force_encoding('Big5')
420 str_big5.force_encoding('Big5')
421 end
421 end
422 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
422 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
423 :status_id => 1, :priority => IssuePriority.all.first,
423 :status_id => 1, :priority => IssuePriority.all.first,
424 :subject => str_utf8)
424 :subject => str_utf8)
425 assert issue.save
425 assert issue.save
426
426
427 get :index, :project_id => 1,
427 get :index, :project_id => 1,
428 :f => ['subject'],
428 :f => ['subject'],
429 :op => '=', :values => [str_utf8],
429 :op => '=', :values => [str_utf8],
430 :format => 'csv'
430 :format => 'csv'
431 assert_equal 'text/csv; header=present', @response.content_type
431 assert_equal 'text/csv; header=present', @response.content_type
432 lines = @response.body.chomp.split("\n")
432 lines = @response.body.chomp.split("\n")
433 s1 = "\xaa\xac\xbaA"
433 s1 = "\xaa\xac\xbaA"
434 if str_utf8.respond_to?(:force_encoding)
434 if str_utf8.respond_to?(:force_encoding)
435 s1.force_encoding('Big5')
435 s1.force_encoding('Big5')
436 end
436 end
437 assert lines[0].include?(s1)
437 assert lines[0].include?(s1)
438 assert lines[1].include?(str_big5)
438 assert lines[1].include?(str_big5)
439 end
439 end
440 end
440 end
441
441
442 def test_index_csv_cannot_convert_should_be_replaced_big_5
442 def test_index_csv_cannot_convert_should_be_replaced_big_5
443 with_settings :default_language => "zh-TW" do
443 with_settings :default_language => "zh-TW" do
444 str_utf8 = "\xe4\xbb\xa5\xe5\x86\x85"
444 str_utf8 = "\xe4\xbb\xa5\xe5\x86\x85"
445 if str_utf8.respond_to?(:force_encoding)
445 if str_utf8.respond_to?(:force_encoding)
446 str_utf8.force_encoding('UTF-8')
446 str_utf8.force_encoding('UTF-8')
447 end
447 end
448 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
448 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
449 :status_id => 1, :priority => IssuePriority.all.first,
449 :status_id => 1, :priority => IssuePriority.all.first,
450 :subject => str_utf8)
450 :subject => str_utf8)
451 assert issue.save
451 assert issue.save
452
452
453 get :index, :project_id => 1,
453 get :index, :project_id => 1,
454 :f => ['subject'],
454 :f => ['subject'],
455 :op => '=', :values => [str_utf8],
455 :op => '=', :values => [str_utf8],
456 :c => ['status', 'subject'],
456 :c => ['status', 'subject'],
457 :format => 'csv',
457 :format => 'csv',
458 :set_filter => 1
458 :set_filter => 1
459 assert_equal 'text/csv; header=present', @response.content_type
459 assert_equal 'text/csv; header=present', @response.content_type
460 lines = @response.body.chomp.split("\n")
460 lines = @response.body.chomp.split("\n")
461 s1 = "\xaa\xac\xbaA" # status
461 s1 = "\xaa\xac\xbaA" # status
462 if str_utf8.respond_to?(:force_encoding)
462 if str_utf8.respond_to?(:force_encoding)
463 s1.force_encoding('Big5')
463 s1.force_encoding('Big5')
464 end
464 end
465 assert lines[0].include?(s1)
465 assert lines[0].include?(s1)
466 s2 = lines[1].split(",")[2]
466 s2 = lines[1].split(",")[2]
467 if s1.respond_to?(:force_encoding)
467 if s1.respond_to?(:force_encoding)
468 s3 = "\xa5H?" # subject
468 s3 = "\xa5H?" # subject
469 s3.force_encoding('Big5')
469 s3.force_encoding('Big5')
470 assert_equal s3, s2
470 assert_equal s3, s2
471 elsif RUBY_PLATFORM == 'java'
471 elsif RUBY_PLATFORM == 'java'
472 assert_equal "??", s2
472 assert_equal "??", s2
473 else
473 else
474 assert_equal "\xa5H???", s2
474 assert_equal "\xa5H???", s2
475 end
475 end
476 end
476 end
477 end
477 end
478
478
479 def test_index_csv_tw
479 def test_index_csv_tw
480 with_settings :default_language => "zh-TW" do
480 with_settings :default_language => "zh-TW" do
481 str1 = "test_index_csv_tw"
481 str1 = "test_index_csv_tw"
482 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
482 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
483 :status_id => 1, :priority => IssuePriority.all.first,
483 :status_id => 1, :priority => IssuePriority.all.first,
484 :subject => str1, :estimated_hours => '1234.5')
484 :subject => str1, :estimated_hours => '1234.5')
485 assert issue.save
485 assert issue.save
486 assert_equal 1234.5, issue.estimated_hours
486 assert_equal 1234.5, issue.estimated_hours
487
487
488 get :index, :project_id => 1,
488 get :index, :project_id => 1,
489 :f => ['subject'],
489 :f => ['subject'],
490 :op => '=', :values => [str1],
490 :op => '=', :values => [str1],
491 :c => ['estimated_hours', 'subject'],
491 :c => ['estimated_hours', 'subject'],
492 :format => 'csv',
492 :format => 'csv',
493 :set_filter => 1
493 :set_filter => 1
494 assert_equal 'text/csv; header=present', @response.content_type
494 assert_equal 'text/csv; header=present', @response.content_type
495 lines = @response.body.chomp.split("\n")
495 lines = @response.body.chomp.split("\n")
496 assert_equal "#{issue.id},1234.50,#{str1}", lines[1]
496 assert_equal "#{issue.id},1234.50,#{str1}", lines[1]
497
497
498 str_tw = "Traditional Chinese (\xe7\xb9\x81\xe9\xab\x94\xe4\xb8\xad\xe6\x96\x87)"
498 str_tw = "Traditional Chinese (\xe7\xb9\x81\xe9\xab\x94\xe4\xb8\xad\xe6\x96\x87)"
499 if str_tw.respond_to?(:force_encoding)
499 if str_tw.respond_to?(:force_encoding)
500 str_tw.force_encoding('UTF-8')
500 str_tw.force_encoding('UTF-8')
501 end
501 end
502 assert_equal str_tw, l(:general_lang_name)
502 assert_equal str_tw, l(:general_lang_name)
503 assert_equal ',', l(:general_csv_separator)
503 assert_equal ',', l(:general_csv_separator)
504 assert_equal '.', l(:general_csv_decimal_separator)
504 assert_equal '.', l(:general_csv_decimal_separator)
505 end
505 end
506 end
506 end
507
507
508 def test_index_csv_fr
508 def test_index_csv_fr
509 with_settings :default_language => "fr" do
509 with_settings :default_language => "fr" do
510 str1 = "test_index_csv_fr"
510 str1 = "test_index_csv_fr"
511 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
511 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
512 :status_id => 1, :priority => IssuePriority.all.first,
512 :status_id => 1, :priority => IssuePriority.all.first,
513 :subject => str1, :estimated_hours => '1234.5')
513 :subject => str1, :estimated_hours => '1234.5')
514 assert issue.save
514 assert issue.save
515 assert_equal 1234.5, issue.estimated_hours
515 assert_equal 1234.5, issue.estimated_hours
516
516
517 get :index, :project_id => 1,
517 get :index, :project_id => 1,
518 :f => ['subject'],
518 :f => ['subject'],
519 :op => '=', :values => [str1],
519 :op => '=', :values => [str1],
520 :c => ['estimated_hours', 'subject'],
520 :c => ['estimated_hours', 'subject'],
521 :format => 'csv',
521 :format => 'csv',
522 :set_filter => 1
522 :set_filter => 1
523 assert_equal 'text/csv; header=present', @response.content_type
523 assert_equal 'text/csv; header=present', @response.content_type
524 lines = @response.body.chomp.split("\n")
524 lines = @response.body.chomp.split("\n")
525 assert_equal "#{issue.id};1234,50;#{str1}", lines[1]
525 assert_equal "#{issue.id};1234,50;#{str1}", lines[1]
526
526
527 str_fr = "Fran\xc3\xa7ais"
527 str_fr = "Fran\xc3\xa7ais"
528 if str_fr.respond_to?(:force_encoding)
528 if str_fr.respond_to?(:force_encoding)
529 str_fr.force_encoding('UTF-8')
529 str_fr.force_encoding('UTF-8')
530 end
530 end
531 assert_equal str_fr, l(:general_lang_name)
531 assert_equal str_fr, l(:general_lang_name)
532 assert_equal ';', l(:general_csv_separator)
532 assert_equal ';', l(:general_csv_separator)
533 assert_equal ',', l(:general_csv_decimal_separator)
533 assert_equal ',', l(:general_csv_decimal_separator)
534 end
534 end
535 end
535 end
536
536
537 def test_index_pdf
537 def test_index_pdf
538 ["en", "zh", "zh-TW", "ja", "ko"].each do |lang|
538 ["en", "zh", "zh-TW", "ja", "ko"].each do |lang|
539 with_settings :default_language => lang do
539 with_settings :default_language => lang do
540
540
541 get :index
541 get :index
542 assert_response :success
542 assert_response :success
543 assert_template 'index'
543 assert_template 'index'
544
544
545 if lang == "ja"
545 if lang == "ja"
546 if RUBY_PLATFORM != 'java'
546 if RUBY_PLATFORM != 'java'
547 assert_equal "CP932", l(:general_pdf_encoding)
547 assert_equal "CP932", l(:general_pdf_encoding)
548 end
548 end
549 if RUBY_PLATFORM == 'java' && l(:general_pdf_encoding) == "CP932"
549 if RUBY_PLATFORM == 'java' && l(:general_pdf_encoding) == "CP932"
550 next
550 next
551 end
551 end
552 end
552 end
553
553
554 get :index, :format => 'pdf'
554 get :index, :format => 'pdf'
555 assert_response :success
555 assert_response :success
556 assert_not_nil assigns(:issues)
556 assert_not_nil assigns(:issues)
557 assert_equal 'application/pdf', @response.content_type
557 assert_equal 'application/pdf', @response.content_type
558
558
559 get :index, :project_id => 1, :format => 'pdf'
559 get :index, :project_id => 1, :format => 'pdf'
560 assert_response :success
560 assert_response :success
561 assert_not_nil assigns(:issues)
561 assert_not_nil assigns(:issues)
562 assert_equal 'application/pdf', @response.content_type
562 assert_equal 'application/pdf', @response.content_type
563
563
564 get :index, :project_id => 1, :query_id => 6, :format => 'pdf'
564 get :index, :project_id => 1, :query_id => 6, :format => 'pdf'
565 assert_response :success
565 assert_response :success
566 assert_not_nil assigns(:issues)
566 assert_not_nil assigns(:issues)
567 assert_equal 'application/pdf', @response.content_type
567 assert_equal 'application/pdf', @response.content_type
568 end
568 end
569 end
569 end
570 end
570 end
571
571
572 def test_index_pdf_with_query_grouped_by_list_custom_field
572 def test_index_pdf_with_query_grouped_by_list_custom_field
573 get :index, :project_id => 1, :query_id => 9, :format => 'pdf'
573 get :index, :project_id => 1, :query_id => 9, :format => 'pdf'
574 assert_response :success
574 assert_response :success
575 assert_not_nil assigns(:issues)
575 assert_not_nil assigns(:issues)
576 assert_not_nil assigns(:issue_count_by_group)
576 assert_not_nil assigns(:issue_count_by_group)
577 assert_equal 'application/pdf', @response.content_type
577 assert_equal 'application/pdf', @response.content_type
578 end
578 end
579
579
580 def test_index_atom
580 def test_index_atom
581 get :index, :project_id => 'ecookbook', :format => 'atom'
581 get :index, :project_id => 'ecookbook', :format => 'atom'
582 assert_response :success
582 assert_response :success
583 assert_template 'common/feed'
583 assert_template 'common/feed'
584
584
585 assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil },
585 assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil },
586 :attributes => {:rel => 'self', :href => 'http://test.host/projects/ecookbook/issues.atom'}
586 :attributes => {:rel => 'self', :href => 'http://test.host/projects/ecookbook/issues.atom'}
587 assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil },
587 assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil },
588 :attributes => {:rel => 'alternate', :href => 'http://test.host/projects/ecookbook/issues'}
588 :attributes => {:rel => 'alternate', :href => 'http://test.host/projects/ecookbook/issues'}
589
589
590 assert_tag :tag => 'entry', :child => {
590 assert_tag :tag => 'entry', :child => {
591 :tag => 'link',
591 :tag => 'link',
592 :attributes => {:href => 'http://test.host/issues/1'}}
592 :attributes => {:href => 'http://test.host/issues/1'}}
593 end
593 end
594
594
595 def test_index_sort
595 def test_index_sort
596 get :index, :sort => 'tracker,id:desc'
596 get :index, :sort => 'tracker,id:desc'
597 assert_response :success
597 assert_response :success
598
598
599 sort_params = @request.session['issues_index_sort']
599 sort_params = @request.session['issues_index_sort']
600 assert sort_params.is_a?(String)
600 assert sort_params.is_a?(String)
601 assert_equal 'tracker,id:desc', sort_params
601 assert_equal 'tracker,id:desc', sort_params
602
602
603 issues = assigns(:issues)
603 issues = assigns(:issues)
604 assert_not_nil issues
604 assert_not_nil issues
605 assert !issues.empty?
605 assert !issues.empty?
606 assert_equal issues.sort {|a,b| a.tracker == b.tracker ? b.id <=> a.id : a.tracker <=> b.tracker }.collect(&:id), issues.collect(&:id)
606 assert_equal issues.sort {|a,b| a.tracker == b.tracker ? b.id <=> a.id : a.tracker <=> b.tracker }.collect(&:id), issues.collect(&:id)
607 end
607 end
608
608
609 def test_index_sort_by_field_not_included_in_columns
609 def test_index_sort_by_field_not_included_in_columns
610 Setting.issue_list_default_columns = %w(subject author)
610 Setting.issue_list_default_columns = %w(subject author)
611 get :index, :sort => 'tracker'
611 get :index, :sort => 'tracker'
612 end
612 end
613
613
614 def test_index_sort_by_assigned_to
614 def test_index_sort_by_assigned_to
615 get :index, :sort => 'assigned_to'
615 get :index, :sort => 'assigned_to'
616 assert_response :success
616 assert_response :success
617 assignees = assigns(:issues).collect(&:assigned_to).compact
617 assignees = assigns(:issues).collect(&:assigned_to).compact
618 assert_equal assignees.sort, assignees
618 assert_equal assignees.sort, assignees
619 end
619 end
620
620
621 def test_index_sort_by_assigned_to_desc
621 def test_index_sort_by_assigned_to_desc
622 get :index, :sort => 'assigned_to:desc'
622 get :index, :sort => 'assigned_to:desc'
623 assert_response :success
623 assert_response :success
624 assignees = assigns(:issues).collect(&:assigned_to).compact
624 assignees = assigns(:issues).collect(&:assigned_to).compact
625 assert_equal assignees.sort.reverse, assignees
625 assert_equal assignees.sort.reverse, assignees
626 end
626 end
627
627
628 def test_index_group_by_assigned_to
628 def test_index_group_by_assigned_to
629 get :index, :group_by => 'assigned_to', :sort => 'priority'
629 get :index, :group_by => 'assigned_to', :sort => 'priority'
630 assert_response :success
630 assert_response :success
631 end
631 end
632
632
633 def test_index_sort_by_author
633 def test_index_sort_by_author
634 get :index, :sort => 'author'
634 get :index, :sort => 'author'
635 assert_response :success
635 assert_response :success
636 authors = assigns(:issues).collect(&:author)
636 authors = assigns(:issues).collect(&:author)
637 assert_equal authors.sort, authors
637 assert_equal authors.sort, authors
638 end
638 end
639
639
640 def test_index_sort_by_author_desc
640 def test_index_sort_by_author_desc
641 get :index, :sort => 'author:desc'
641 get :index, :sort => 'author:desc'
642 assert_response :success
642 assert_response :success
643 authors = assigns(:issues).collect(&:author)
643 authors = assigns(:issues).collect(&:author)
644 assert_equal authors.sort.reverse, authors
644 assert_equal authors.sort.reverse, authors
645 end
645 end
646
646
647 def test_index_group_by_author
647 def test_index_group_by_author
648 get :index, :group_by => 'author', :sort => 'priority'
648 get :index, :group_by => 'author', :sort => 'priority'
649 assert_response :success
649 assert_response :success
650 end
650 end
651
651
652 def test_index_sort_by_spent_hours
652 def test_index_sort_by_spent_hours
653 get :index, :sort => 'spent_hours:desc'
653 get :index, :sort => 'spent_hours:desc'
654 assert_response :success
654 assert_response :success
655 hours = assigns(:issues).collect(&:spent_hours)
655 hours = assigns(:issues).collect(&:spent_hours)
656 assert_equal hours.sort.reverse, hours
656 assert_equal hours.sort.reverse, hours
657 end
657 end
658
658
659 def test_index_sort_by_user_custom_field
659 def test_index_sort_by_user_custom_field
660 cf = IssueCustomField.create!(:name => 'User', :is_for_all => true, :tracker_ids => [1,2,3], :field_format => 'user')
660 cf = IssueCustomField.create!(:name => 'User', :is_for_all => true, :tracker_ids => [1,2,3], :field_format => 'user')
661 CustomValue.create!(:custom_field => cf, :customized => Issue.find(1), :value => '2')
661 CustomValue.create!(:custom_field => cf, :customized => Issue.find(1), :value => '2')
662 CustomValue.create!(:custom_field => cf, :customized => Issue.find(2), :value => '3')
662 CustomValue.create!(:custom_field => cf, :customized => Issue.find(2), :value => '3')
663 CustomValue.create!(:custom_field => cf, :customized => Issue.find(3), :value => '3')
663 CustomValue.create!(:custom_field => cf, :customized => Issue.find(3), :value => '3')
664 CustomValue.create!(:custom_field => cf, :customized => Issue.find(5), :value => '')
664 CustomValue.create!(:custom_field => cf, :customized => Issue.find(5), :value => '')
665
665
666 get :index, :project_id => 1, :set_filter => 1, :sort => "cf_#{cf.id},id"
666 get :index, :project_id => 1, :set_filter => 1, :sort => "cf_#{cf.id},id"
667 assert_response :success
667 assert_response :success
668
668
669 assert_equal [2, 3, 1], assigns(:issues).select {|issue| issue.custom_field_value(cf).present?}.map(&:id)
669 assert_equal [2, 3, 1], assigns(:issues).select {|issue| issue.custom_field_value(cf).present?}.map(&:id)
670 end
670 end
671
671
672 def test_index_with_columns
672 def test_index_with_columns
673 columns = ['tracker', 'subject', 'assigned_to']
673 columns = ['tracker', 'subject', 'assigned_to']
674 get :index, :set_filter => 1, :c => columns
674 get :index, :set_filter => 1, :c => columns
675 assert_response :success
675 assert_response :success
676
676
677 # query should use specified columns
677 # query should use specified columns
678 query = assigns(:query)
678 query = assigns(:query)
679 assert_kind_of Query, query
679 assert_kind_of Query, query
680 assert_equal columns, query.column_names.map(&:to_s)
680 assert_equal columns, query.column_names.map(&:to_s)
681
681
682 # columns should be stored in session
682 # columns should be stored in session
683 assert_kind_of Hash, session[:query]
683 assert_kind_of Hash, session[:query]
684 assert_kind_of Array, session[:query][:column_names]
684 assert_kind_of Array, session[:query][:column_names]
685 assert_equal columns, session[:query][:column_names].map(&:to_s)
685 assert_equal columns, session[:query][:column_names].map(&:to_s)
686
686
687 # ensure only these columns are kept in the selected columns list
687 # ensure only these columns are kept in the selected columns list
688 assert_tag :tag => 'select', :attributes => { :id => 'selected_columns' },
688 assert_tag :tag => 'select', :attributes => { :id => 'selected_columns' },
689 :children => { :count => 3 }
689 :children => { :count => 3 }
690 assert_no_tag :tag => 'option', :attributes => { :value => 'project' },
690 assert_no_tag :tag => 'option', :attributes => { :value => 'project' },
691 :parent => { :tag => 'select', :attributes => { :id => "selected_columns" } }
691 :parent => { :tag => 'select', :attributes => { :id => "selected_columns" } }
692 end
692 end
693
693
694 def test_index_without_project_should_implicitly_add_project_column_to_default_columns
694 def test_index_without_project_should_implicitly_add_project_column_to_default_columns
695 Setting.issue_list_default_columns = ['tracker', 'subject', 'assigned_to']
695 Setting.issue_list_default_columns = ['tracker', 'subject', 'assigned_to']
696 get :index, :set_filter => 1
696 get :index, :set_filter => 1
697
697
698 # query should use specified columns
698 # query should use specified columns
699 query = assigns(:query)
699 query = assigns(:query)
700 assert_kind_of Query, query
700 assert_kind_of Query, query
701 assert_equal [:project, :tracker, :subject, :assigned_to], query.columns.map(&:name)
701 assert_equal [:project, :tracker, :subject, :assigned_to], query.columns.map(&:name)
702 end
702 end
703
703
704 def test_index_without_project_and_explicit_default_columns_should_not_add_project_column
704 def test_index_without_project_and_explicit_default_columns_should_not_add_project_column
705 Setting.issue_list_default_columns = ['tracker', 'subject', 'assigned_to']
705 Setting.issue_list_default_columns = ['tracker', 'subject', 'assigned_to']
706 columns = ['tracker', 'subject', 'assigned_to']
706 columns = ['tracker', 'subject', 'assigned_to']
707 get :index, :set_filter => 1, :c => columns
707 get :index, :set_filter => 1, :c => columns
708
708
709 # query should use specified columns
709 # query should use specified columns
710 query = assigns(:query)
710 query = assigns(:query)
711 assert_kind_of Query, query
711 assert_kind_of Query, query
712 assert_equal columns.map(&:to_sym), query.columns.map(&:name)
712 assert_equal columns.map(&:to_sym), query.columns.map(&:name)
713 end
713 end
714
714
715 def test_index_with_custom_field_column
715 def test_index_with_custom_field_column
716 columns = %w(tracker subject cf_2)
716 columns = %w(tracker subject cf_2)
717 get :index, :set_filter => 1, :c => columns
717 get :index, :set_filter => 1, :c => columns
718 assert_response :success
718 assert_response :success
719
719
720 # query should use specified columns
720 # query should use specified columns
721 query = assigns(:query)
721 query = assigns(:query)
722 assert_kind_of Query, query
722 assert_kind_of Query, query
723 assert_equal columns, query.column_names.map(&:to_s)
723 assert_equal columns, query.column_names.map(&:to_s)
724
724
725 assert_tag :td,
725 assert_tag :td,
726 :attributes => {:class => 'cf_2 string'},
726 :attributes => {:class => 'cf_2 string'},
727 :ancestor => {:tag => 'table', :attributes => {:class => /issues/}}
727 :ancestor => {:tag => 'table', :attributes => {:class => /issues/}}
728 end
728 end
729
729
730 def test_index_with_multi_custom_field_column
730 def test_index_with_multi_custom_field_column
731 field = CustomField.find(1)
731 field = CustomField.find(1)
732 field.update_attribute :multiple, true
732 field.update_attribute :multiple, true
733 issue = Issue.find(1)
733 issue = Issue.find(1)
734 issue.custom_field_values = {1 => ['MySQL', 'Oracle']}
734 issue.custom_field_values = {1 => ['MySQL', 'Oracle']}
735 issue.save!
735 issue.save!
736
736
737 get :index, :set_filter => 1, :c => %w(tracker subject cf_1)
737 get :index, :set_filter => 1, :c => %w(tracker subject cf_1)
738 assert_response :success
738 assert_response :success
739
739
740 assert_tag :td,
740 assert_tag :td,
741 :attributes => {:class => /cf_1/},
741 :attributes => {:class => /cf_1/},
742 :content => 'MySQL, Oracle'
742 :content => 'MySQL, Oracle'
743 end
743 end
744
744
745 def test_index_with_multi_user_custom_field_column
745 def test_index_with_multi_user_custom_field_column
746 field = IssueCustomField.create!(:name => 'Multi user', :field_format => 'user', :multiple => true,
746 field = IssueCustomField.create!(:name => 'Multi user', :field_format => 'user', :multiple => true,
747 :tracker_ids => [1], :is_for_all => true)
747 :tracker_ids => [1], :is_for_all => true)
748 issue = Issue.find(1)
748 issue = Issue.find(1)
749 issue.custom_field_values = {field.id => ['2', '3']}
749 issue.custom_field_values = {field.id => ['2', '3']}
750 issue.save!
750 issue.save!
751
751
752 get :index, :set_filter => 1, :c => ['tracker', 'subject', "cf_#{field.id}"]
752 get :index, :set_filter => 1, :c => ['tracker', 'subject', "cf_#{field.id}"]
753 assert_response :success
753 assert_response :success
754
754
755 assert_tag :td,
755 assert_tag :td,
756 :attributes => {:class => /cf_#{field.id}/},
756 :attributes => {:class => /cf_#{field.id}/},
757 :child => {:tag => 'a', :content => 'John Smith'}
757 :child => {:tag => 'a', :content => 'John Smith'}
758 end
758 end
759
759
760 def test_index_with_date_column
760 def test_index_with_date_column
761 Issue.find(1).update_attribute :start_date, '1987-08-24'
761 Issue.find(1).update_attribute :start_date, '1987-08-24'
762
762
763 with_settings :date_format => '%d/%m/%Y' do
763 with_settings :date_format => '%d/%m/%Y' do
764 get :index, :set_filter => 1, :c => %w(start_date)
764 get :index, :set_filter => 1, :c => %w(start_date)
765 assert_tag 'td', :attributes => {:class => /start_date/}, :content => '24/08/1987'
765 assert_tag 'td', :attributes => {:class => /start_date/}, :content => '24/08/1987'
766 end
766 end
767 end
767 end
768
768
769 def test_index_with_done_ratio
769 def test_index_with_done_ratio
770 Issue.find(1).update_attribute :done_ratio, 40
770 Issue.find(1).update_attribute :done_ratio, 40
771
771
772 get :index, :set_filter => 1, :c => %w(done_ratio)
772 get :index, :set_filter => 1, :c => %w(done_ratio)
773 assert_tag 'td', :attributes => {:class => /done_ratio/},
773 assert_tag 'td', :attributes => {:class => /done_ratio/},
774 :child => {:tag => 'table', :attributes => {:class => 'progress'},
774 :child => {:tag => 'table', :attributes => {:class => 'progress'},
775 :descendant => {:tag => 'td', :attributes => {:class => 'closed', :style => 'width: 40%;'}}
775 :descendant => {:tag => 'td', :attributes => {:class => 'closed', :style => 'width: 40%;'}}
776 }
776 }
777 end
777 end
778
778
779 def test_index_with_spent_hours_column
779 def test_index_with_spent_hours_column
780 get :index, :set_filter => 1, :c => %w(subject spent_hours)
780 get :index, :set_filter => 1, :c => %w(subject spent_hours)
781
781
782 assert_tag 'tr', :attributes => {:id => 'issue-3'},
782 assert_tag 'tr', :attributes => {:id => 'issue-3'},
783 :child => {
783 :child => {
784 :tag => 'td', :attributes => {:class => /spent_hours/}, :content => '1.00'
784 :tag => 'td', :attributes => {:class => /spent_hours/}, :content => '1.00'
785 }
785 }
786 end
786 end
787
787
788 def test_index_should_not_show_spent_hours_column_without_permission
788 def test_index_should_not_show_spent_hours_column_without_permission
789 Role.anonymous.remove_permission! :view_time_entries
789 Role.anonymous.remove_permission! :view_time_entries
790 get :index, :set_filter => 1, :c => %w(subject spent_hours)
790 get :index, :set_filter => 1, :c => %w(subject spent_hours)
791
791
792 assert_no_tag 'td', :attributes => {:class => /spent_hours/}
792 assert_no_tag 'td', :attributes => {:class => /spent_hours/}
793 end
793 end
794
794
795 def test_index_with_fixed_version
795 def test_index_with_fixed_version
796 get :index, :set_filter => 1, :c => %w(fixed_version)
796 get :index, :set_filter => 1, :c => %w(fixed_version)
797 assert_tag 'td', :attributes => {:class => /fixed_version/},
797 assert_tag 'td', :attributes => {:class => /fixed_version/},
798 :child => {:tag => 'a', :content => '1.0', :attributes => {:href => '/versions/2'}}
798 :child => {:tag => 'a', :content => '1.0', :attributes => {:href => '/versions/2'}}
799 end
799 end
800
800
801 def test_index_send_html_if_query_is_invalid
801 def test_index_send_html_if_query_is_invalid
802 get :index, :f => ['start_date'], :op => {:start_date => '='}
802 get :index, :f => ['start_date'], :op => {:start_date => '='}
803 assert_equal 'text/html', @response.content_type
803 assert_equal 'text/html', @response.content_type
804 assert_template 'index'
804 assert_template 'index'
805 end
805 end
806
806
807 def test_index_send_nothing_if_query_is_invalid
807 def test_index_send_nothing_if_query_is_invalid
808 get :index, :f => ['start_date'], :op => {:start_date => '='}, :format => 'csv'
808 get :index, :f => ['start_date'], :op => {:start_date => '='}, :format => 'csv'
809 assert_equal 'text/csv', @response.content_type
809 assert_equal 'text/csv', @response.content_type
810 assert @response.body.blank?
810 assert @response.body.blank?
811 end
811 end
812
812
813 def test_show_by_anonymous
813 def test_show_by_anonymous
814 get :show, :id => 1
814 get :show, :id => 1
815 assert_response :success
815 assert_response :success
816 assert_template 'show'
816 assert_template 'show'
817 assert_not_nil assigns(:issue)
817 assert_not_nil assigns(:issue)
818 assert_equal Issue.find(1), assigns(:issue)
818 assert_equal Issue.find(1), assigns(:issue)
819
819
820 # anonymous role is allowed to add a note
820 # anonymous role is allowed to add a note
821 assert_tag :tag => 'form',
821 assert_tag :tag => 'form',
822 :descendant => { :tag => 'fieldset',
822 :descendant => { :tag => 'fieldset',
823 :child => { :tag => 'legend',
823 :child => { :tag => 'legend',
824 :content => /Notes/ } }
824 :content => /Notes/ } }
825 assert_tag :tag => 'title',
825 assert_tag :tag => 'title',
826 :content => "Bug #1: Can&#x27;t print recipes - eCookbook - Redmine"
826 :content => "Bug #1: Can&#x27;t print recipes - eCookbook - Redmine"
827 end
827 end
828
828
829 def test_show_by_manager
829 def test_show_by_manager
830 @request.session[:user_id] = 2
830 @request.session[:user_id] = 2
831 get :show, :id => 1
831 get :show, :id => 1
832 assert_response :success
832 assert_response :success
833
833
834 assert_tag :tag => 'a',
834 assert_tag :tag => 'a',
835 :content => /Quote/
835 :content => /Quote/
836
836
837 assert_tag :tag => 'form',
837 assert_tag :tag => 'form',
838 :descendant => { :tag => 'fieldset',
838 :descendant => { :tag => 'fieldset',
839 :child => { :tag => 'legend',
839 :child => { :tag => 'legend',
840 :content => /Change properties/ } },
840 :content => /Change properties/ } },
841 :descendant => { :tag => 'fieldset',
841 :descendant => { :tag => 'fieldset',
842 :child => { :tag => 'legend',
842 :child => { :tag => 'legend',
843 :content => /Log time/ } },
843 :content => /Log time/ } },
844 :descendant => { :tag => 'fieldset',
844 :descendant => { :tag => 'fieldset',
845 :child => { :tag => 'legend',
845 :child => { :tag => 'legend',
846 :content => /Notes/ } }
846 :content => /Notes/ } }
847 end
847 end
848
848
849 def test_show_should_display_update_form
849 def test_show_should_display_update_form
850 @request.session[:user_id] = 2
850 @request.session[:user_id] = 2
851 get :show, :id => 1
851 get :show, :id => 1
852 assert_response :success
852 assert_response :success
853
853
854 assert_tag 'form', :attributes => {:id => 'issue-form'}
854 assert_tag 'form', :attributes => {:id => 'issue-form'}
855 assert_tag 'input', :attributes => {:name => 'issue[is_private]'}
855 assert_tag 'input', :attributes => {:name => 'issue[is_private]'}
856 assert_tag 'select', :attributes => {:name => 'issue[project_id]'}
856 assert_tag 'select', :attributes => {:name => 'issue[project_id]'}
857 assert_tag 'select', :attributes => {:name => 'issue[tracker_id]'}
857 assert_tag 'select', :attributes => {:name => 'issue[tracker_id]'}
858 assert_tag 'input', :attributes => {:name => 'issue[subject]'}
858 assert_tag 'input', :attributes => {:name => 'issue[subject]'}
859 assert_tag 'textarea', :attributes => {:name => 'issue[description]'}
859 assert_tag 'textarea', :attributes => {:name => 'issue[description]'}
860 assert_tag 'select', :attributes => {:name => 'issue[status_id]'}
860 assert_tag 'select', :attributes => {:name => 'issue[status_id]'}
861 assert_tag 'select', :attributes => {:name => 'issue[priority_id]'}
861 assert_tag 'select', :attributes => {:name => 'issue[priority_id]'}
862 assert_tag 'select', :attributes => {:name => 'issue[assigned_to_id]'}
862 assert_tag 'select', :attributes => {:name => 'issue[assigned_to_id]'}
863 assert_tag 'select', :attributes => {:name => 'issue[category_id]'}
863 assert_tag 'select', :attributes => {:name => 'issue[category_id]'}
864 assert_tag 'select', :attributes => {:name => 'issue[fixed_version_id]'}
864 assert_tag 'select', :attributes => {:name => 'issue[fixed_version_id]'}
865 assert_tag 'input', :attributes => {:name => 'issue[parent_issue_id]'}
865 assert_tag 'input', :attributes => {:name => 'issue[parent_issue_id]'}
866 assert_tag 'input', :attributes => {:name => 'issue[start_date]'}
866 assert_tag 'input', :attributes => {:name => 'issue[start_date]'}
867 assert_tag 'input', :attributes => {:name => 'issue[due_date]'}
867 assert_tag 'input', :attributes => {:name => 'issue[due_date]'}
868 assert_tag 'select', :attributes => {:name => 'issue[done_ratio]'}
868 assert_tag 'select', :attributes => {:name => 'issue[done_ratio]'}
869 assert_tag 'input', :attributes => { :name => 'issue[custom_field_values][2]' }
869 assert_tag 'input', :attributes => { :name => 'issue[custom_field_values][2]' }
870 assert_no_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]'}
870 assert_no_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]'}
871 assert_tag 'textarea', :attributes => {:name => 'notes'}
871 assert_tag 'textarea', :attributes => {:name => 'notes'}
872 end
872 end
873
873
874 def test_show_should_display_update_form_with_minimal_permissions
874 def test_show_should_display_update_form_with_minimal_permissions
875 Role.find(1).update_attribute :permissions, [:view_issues, :add_issue_notes]
875 Role.find(1).update_attribute :permissions, [:view_issues, :add_issue_notes]
876 WorkflowTransition.delete_all :role_id => 1
876 WorkflowTransition.delete_all :role_id => 1
877
877
878 @request.session[:user_id] = 2
878 @request.session[:user_id] = 2
879 get :show, :id => 1
879 get :show, :id => 1
880 assert_response :success
880 assert_response :success
881
881
882 assert_tag 'form', :attributes => {:id => 'issue-form'}
882 assert_tag 'form', :attributes => {:id => 'issue-form'}
883 assert_no_tag 'input', :attributes => {:name => 'issue[is_private]'}
883 assert_no_tag 'input', :attributes => {:name => 'issue[is_private]'}
884 assert_no_tag 'select', :attributes => {:name => 'issue[project_id]'}
884 assert_no_tag 'select', :attributes => {:name => 'issue[project_id]'}
885 assert_no_tag 'select', :attributes => {:name => 'issue[tracker_id]'}
885 assert_no_tag 'select', :attributes => {:name => 'issue[tracker_id]'}
886 assert_no_tag 'input', :attributes => {:name => 'issue[subject]'}
886 assert_no_tag 'input', :attributes => {:name => 'issue[subject]'}
887 assert_no_tag 'textarea', :attributes => {:name => 'issue[description]'}
887 assert_no_tag 'textarea', :attributes => {:name => 'issue[description]'}
888 assert_no_tag 'select', :attributes => {:name => 'issue[status_id]'}
888 assert_no_tag 'select', :attributes => {:name => 'issue[status_id]'}
889 assert_no_tag 'select', :attributes => {:name => 'issue[priority_id]'}
889 assert_no_tag 'select', :attributes => {:name => 'issue[priority_id]'}
890 assert_no_tag 'select', :attributes => {:name => 'issue[assigned_to_id]'}
890 assert_no_tag 'select', :attributes => {:name => 'issue[assigned_to_id]'}
891 assert_no_tag 'select', :attributes => {:name => 'issue[category_id]'}
891 assert_no_tag 'select', :attributes => {:name => 'issue[category_id]'}
892 assert_no_tag 'select', :attributes => {:name => 'issue[fixed_version_id]'}
892 assert_no_tag 'select', :attributes => {:name => 'issue[fixed_version_id]'}
893 assert_no_tag 'input', :attributes => {:name => 'issue[parent_issue_id]'}
893 assert_no_tag 'input', :attributes => {:name => 'issue[parent_issue_id]'}
894 assert_no_tag 'input', :attributes => {:name => 'issue[start_date]'}
894 assert_no_tag 'input', :attributes => {:name => 'issue[start_date]'}
895 assert_no_tag 'input', :attributes => {:name => 'issue[due_date]'}
895 assert_no_tag 'input', :attributes => {:name => 'issue[due_date]'}
896 assert_no_tag 'select', :attributes => {:name => 'issue[done_ratio]'}
896 assert_no_tag 'select', :attributes => {:name => 'issue[done_ratio]'}
897 assert_no_tag 'input', :attributes => { :name => 'issue[custom_field_values][2]' }
897 assert_no_tag 'input', :attributes => { :name => 'issue[custom_field_values][2]' }
898 assert_no_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]'}
898 assert_no_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]'}
899 assert_tag 'textarea', :attributes => {:name => 'notes'}
899 assert_tag 'textarea', :attributes => {:name => 'notes'}
900 end
900 end
901
901
902 def test_show_should_display_update_form_with_workflow_permissions
902 def test_show_should_display_update_form_with_workflow_permissions
903 Role.find(1).update_attribute :permissions, [:view_issues, :add_issue_notes]
903 Role.find(1).update_attribute :permissions, [:view_issues, :add_issue_notes]
904
904
905 @request.session[:user_id] = 2
905 @request.session[:user_id] = 2
906 get :show, :id => 1
906 get :show, :id => 1
907 assert_response :success
907 assert_response :success
908
908
909 assert_tag 'form', :attributes => {:id => 'issue-form'}
909 assert_tag 'form', :attributes => {:id => 'issue-form'}
910 assert_no_tag 'input', :attributes => {:name => 'issue[is_private]'}
910 assert_no_tag 'input', :attributes => {:name => 'issue[is_private]'}
911 assert_no_tag 'select', :attributes => {:name => 'issue[project_id]'}
911 assert_no_tag 'select', :attributes => {:name => 'issue[project_id]'}
912 assert_no_tag 'select', :attributes => {:name => 'issue[tracker_id]'}
912 assert_no_tag 'select', :attributes => {:name => 'issue[tracker_id]'}
913 assert_no_tag 'input', :attributes => {:name => 'issue[subject]'}
913 assert_no_tag 'input', :attributes => {:name => 'issue[subject]'}
914 assert_no_tag 'textarea', :attributes => {:name => 'issue[description]'}
914 assert_no_tag 'textarea', :attributes => {:name => 'issue[description]'}
915 assert_tag 'select', :attributes => {:name => 'issue[status_id]'}
915 assert_tag 'select', :attributes => {:name => 'issue[status_id]'}
916 assert_no_tag 'select', :attributes => {:name => 'issue[priority_id]'}
916 assert_no_tag 'select', :attributes => {:name => 'issue[priority_id]'}
917 assert_tag 'select', :attributes => {:name => 'issue[assigned_to_id]'}
917 assert_tag 'select', :attributes => {:name => 'issue[assigned_to_id]'}
918 assert_no_tag 'select', :attributes => {:name => 'issue[category_id]'}
918 assert_no_tag 'select', :attributes => {:name => 'issue[category_id]'}
919 assert_tag 'select', :attributes => {:name => 'issue[fixed_version_id]'}
919 assert_tag 'select', :attributes => {:name => 'issue[fixed_version_id]'}
920 assert_no_tag 'input', :attributes => {:name => 'issue[parent_issue_id]'}
920 assert_no_tag 'input', :attributes => {:name => 'issue[parent_issue_id]'}
921 assert_no_tag 'input', :attributes => {:name => 'issue[start_date]'}
921 assert_no_tag 'input', :attributes => {:name => 'issue[start_date]'}
922 assert_no_tag 'input', :attributes => {:name => 'issue[due_date]'}
922 assert_no_tag 'input', :attributes => {:name => 'issue[due_date]'}
923 assert_tag 'select', :attributes => {:name => 'issue[done_ratio]'}
923 assert_tag 'select', :attributes => {:name => 'issue[done_ratio]'}
924 assert_no_tag 'input', :attributes => { :name => 'issue[custom_field_values][2]' }
924 assert_no_tag 'input', :attributes => { :name => 'issue[custom_field_values][2]' }
925 assert_no_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]'}
925 assert_no_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]'}
926 assert_tag 'textarea', :attributes => {:name => 'notes'}
926 assert_tag 'textarea', :attributes => {:name => 'notes'}
927 end
927 end
928
928
929 def test_show_should_not_display_update_form_without_permissions
929 def test_show_should_not_display_update_form_without_permissions
930 Role.find(1).update_attribute :permissions, [:view_issues]
930 Role.find(1).update_attribute :permissions, [:view_issues]
931
931
932 @request.session[:user_id] = 2
932 @request.session[:user_id] = 2
933 get :show, :id => 1
933 get :show, :id => 1
934 assert_response :success
934 assert_response :success
935
935
936 assert_no_tag 'form', :attributes => {:id => 'issue-form'}
936 assert_no_tag 'form', :attributes => {:id => 'issue-form'}
937 end
937 end
938
938
939 def test_update_form_should_not_display_inactive_enumerations
939 def test_update_form_should_not_display_inactive_enumerations
940 @request.session[:user_id] = 2
940 @request.session[:user_id] = 2
941 get :show, :id => 1
941 get :show, :id => 1
942 assert_response :success
942 assert_response :success
943
943
944 assert ! IssuePriority.find(15).active?
944 assert ! IssuePriority.find(15).active?
945 assert_no_tag :option, :attributes => {:value => '15'},
945 assert_no_tag :option, :attributes => {:value => '15'},
946 :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} }
946 :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} }
947 end
947 end
948
948
949 def test_update_form_should_allow_attachment_upload
949 def test_update_form_should_allow_attachment_upload
950 @request.session[:user_id] = 2
950 @request.session[:user_id] = 2
951 get :show, :id => 1
951 get :show, :id => 1
952
952
953 assert_tag :tag => 'form',
953 assert_tag :tag => 'form',
954 :attributes => {:id => 'issue-form', :method => 'post', :enctype => 'multipart/form-data'},
954 :attributes => {:id => 'issue-form', :method => 'post', :enctype => 'multipart/form-data'},
955 :descendant => {
955 :descendant => {
956 :tag => 'input',
956 :tag => 'input',
957 :attributes => {:type => 'file', :name => 'attachments[1][file]'}
957 :attributes => {:type => 'file', :name => 'attachments[1][file]'}
958 }
958 }
959 end
959 end
960
960
961 def test_show_should_deny_anonymous_access_without_permission
961 def test_show_should_deny_anonymous_access_without_permission
962 Role.anonymous.remove_permission!(:view_issues)
962 Role.anonymous.remove_permission!(:view_issues)
963 get :show, :id => 1
963 get :show, :id => 1
964 assert_response :redirect
964 assert_response :redirect
965 end
965 end
966
966
967 def test_show_should_deny_anonymous_access_to_private_issue
967 def test_show_should_deny_anonymous_access_to_private_issue
968 Issue.update_all(["is_private = ?", true], "id = 1")
968 Issue.update_all(["is_private = ?", true], "id = 1")
969 get :show, :id => 1
969 get :show, :id => 1
970 assert_response :redirect
970 assert_response :redirect
971 end
971 end
972
972
973 def test_show_should_deny_non_member_access_without_permission
973 def test_show_should_deny_non_member_access_without_permission
974 Role.non_member.remove_permission!(:view_issues)
974 Role.non_member.remove_permission!(:view_issues)
975 @request.session[:user_id] = 9
975 @request.session[:user_id] = 9
976 get :show, :id => 1
976 get :show, :id => 1
977 assert_response 403
977 assert_response 403
978 end
978 end
979
979
980 def test_show_should_deny_non_member_access_to_private_issue
980 def test_show_should_deny_non_member_access_to_private_issue
981 Issue.update_all(["is_private = ?", true], "id = 1")
981 Issue.update_all(["is_private = ?", true], "id = 1")
982 @request.session[:user_id] = 9
982 @request.session[:user_id] = 9
983 get :show, :id => 1
983 get :show, :id => 1
984 assert_response 403
984 assert_response 403
985 end
985 end
986
986
987 def test_show_should_deny_member_access_without_permission
987 def test_show_should_deny_member_access_without_permission
988 Role.find(1).remove_permission!(:view_issues)
988 Role.find(1).remove_permission!(:view_issues)
989 @request.session[:user_id] = 2
989 @request.session[:user_id] = 2
990 get :show, :id => 1
990 get :show, :id => 1
991 assert_response 403
991 assert_response 403
992 end
992 end
993
993
994 def test_show_should_deny_member_access_to_private_issue_without_permission
994 def test_show_should_deny_member_access_to_private_issue_without_permission
995 Issue.update_all(["is_private = ?", true], "id = 1")
995 Issue.update_all(["is_private = ?", true], "id = 1")
996 @request.session[:user_id] = 3
996 @request.session[:user_id] = 3
997 get :show, :id => 1
997 get :show, :id => 1
998 assert_response 403
998 assert_response 403
999 end
999 end
1000
1000
1001 def test_show_should_allow_author_access_to_private_issue
1001 def test_show_should_allow_author_access_to_private_issue
1002 Issue.update_all(["is_private = ?, author_id = 3", true], "id = 1")
1002 Issue.update_all(["is_private = ?, author_id = 3", true], "id = 1")
1003 @request.session[:user_id] = 3
1003 @request.session[:user_id] = 3
1004 get :show, :id => 1
1004 get :show, :id => 1
1005 assert_response :success
1005 assert_response :success
1006 end
1006 end
1007
1007
1008 def test_show_should_allow_assignee_access_to_private_issue
1008 def test_show_should_allow_assignee_access_to_private_issue
1009 Issue.update_all(["is_private = ?, assigned_to_id = 3", true], "id = 1")
1009 Issue.update_all(["is_private = ?, assigned_to_id = 3", true], "id = 1")
1010 @request.session[:user_id] = 3
1010 @request.session[:user_id] = 3
1011 get :show, :id => 1
1011 get :show, :id => 1
1012 assert_response :success
1012 assert_response :success
1013 end
1013 end
1014
1014
1015 def test_show_should_allow_member_access_to_private_issue_with_permission
1015 def test_show_should_allow_member_access_to_private_issue_with_permission
1016 Issue.update_all(["is_private = ?", true], "id = 1")
1016 Issue.update_all(["is_private = ?", true], "id = 1")
1017 User.find(3).roles_for_project(Project.find(1)).first.update_attribute :issues_visibility, 'all'
1017 User.find(3).roles_for_project(Project.find(1)).first.update_attribute :issues_visibility, 'all'
1018 @request.session[:user_id] = 3
1018 @request.session[:user_id] = 3
1019 get :show, :id => 1
1019 get :show, :id => 1
1020 assert_response :success
1020 assert_response :success
1021 end
1021 end
1022
1022
1023 def test_show_should_not_disclose_relations_to_invisible_issues
1023 def test_show_should_not_disclose_relations_to_invisible_issues
1024 Setting.cross_project_issue_relations = '1'
1024 Setting.cross_project_issue_relations = '1'
1025 IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(2), :relation_type => 'relates')
1025 IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(2), :relation_type => 'relates')
1026 # Relation to a private project issue
1026 # Relation to a private project issue
1027 IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(4), :relation_type => 'relates')
1027 IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(4), :relation_type => 'relates')
1028
1028
1029 get :show, :id => 1
1029 get :show, :id => 1
1030 assert_response :success
1030 assert_response :success
1031
1031
1032 assert_tag :div, :attributes => { :id => 'relations' },
1032 assert_tag :div, :attributes => { :id => 'relations' },
1033 :descendant => { :tag => 'a', :content => /#2$/ }
1033 :descendant => { :tag => 'a', :content => /#2$/ }
1034 assert_no_tag :div, :attributes => { :id => 'relations' },
1034 assert_no_tag :div, :attributes => { :id => 'relations' },
1035 :descendant => { :tag => 'a', :content => /#4$/ }
1035 :descendant => { :tag => 'a', :content => /#4$/ }
1036 end
1036 end
1037
1037
1038 def test_show_should_list_subtasks
1038 def test_show_should_list_subtasks
1039 Issue.create!(:project_id => 1, :author_id => 1, :tracker_id => 1, :parent_issue_id => 1, :subject => 'Child Issue')
1039 Issue.create!(:project_id => 1, :author_id => 1, :tracker_id => 1, :parent_issue_id => 1, :subject => 'Child Issue')
1040
1040
1041 get :show, :id => 1
1041 get :show, :id => 1
1042 assert_response :success
1042 assert_response :success
1043 assert_tag 'div', :attributes => {:id => 'issue_tree'},
1043 assert_tag 'div', :attributes => {:id => 'issue_tree'},
1044 :descendant => {:tag => 'td', :content => /Child Issue/, :attributes => {:class => /subject/}}
1044 :descendant => {:tag => 'td', :content => /Child Issue/, :attributes => {:class => /subject/}}
1045 end
1045 end
1046
1046
1047 def test_show_should_list_parents
1047 def test_show_should_list_parents
1048 issue = Issue.create!(:project_id => 1, :author_id => 1, :tracker_id => 1, :parent_issue_id => 1, :subject => 'Child Issue')
1048 issue = Issue.create!(:project_id => 1, :author_id => 1, :tracker_id => 1, :parent_issue_id => 1, :subject => 'Child Issue')
1049
1049
1050 get :show, :id => issue.id
1050 get :show, :id => issue.id
1051 assert_response :success
1051 assert_response :success
1052 assert_tag 'div', :attributes => {:class => 'subject'},
1052 assert_tag 'div', :attributes => {:class => 'subject'},
1053 :descendant => {:tag => 'h3', :content => 'Child Issue'}
1053 :descendant => {:tag => 'h3', :content => 'Child Issue'}
1054 assert_tag 'div', :attributes => {:class => 'subject'},
1054 assert_tag 'div', :attributes => {:class => 'subject'},
1055 :descendant => {:tag => 'a', :attributes => {:href => '/issues/1'}}
1055 :descendant => {:tag => 'a', :attributes => {:href => '/issues/1'}}
1056 end
1056 end
1057
1057
1058 def test_show_should_not_display_prev_next_links_without_query_in_session
1058 def test_show_should_not_display_prev_next_links_without_query_in_session
1059 get :show, :id => 1
1059 get :show, :id => 1
1060 assert_response :success
1060 assert_response :success
1061 assert_nil assigns(:prev_issue_id)
1061 assert_nil assigns(:prev_issue_id)
1062 assert_nil assigns(:next_issue_id)
1062 assert_nil assigns(:next_issue_id)
1063
1063
1064 assert_no_tag 'div', :attributes => {:class => /next-prev-links/}
1064 assert_no_tag 'div', :attributes => {:class => /next-prev-links/}
1065 end
1065 end
1066
1066
1067 def test_show_should_display_prev_next_links_with_query_in_session
1067 def test_show_should_display_prev_next_links_with_query_in_session
1068 @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => nil}
1068 @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => nil}
1069 @request.session['issues_index_sort'] = 'id'
1069 @request.session['issues_index_sort'] = 'id'
1070
1070
1071 with_settings :display_subprojects_issues => '0' do
1071 with_settings :display_subprojects_issues => '0' do
1072 get :show, :id => 3
1072 get :show, :id => 3
1073 end
1073 end
1074
1074
1075 assert_response :success
1075 assert_response :success
1076 # Previous and next issues for all projects
1076 # Previous and next issues for all projects
1077 assert_equal 2, assigns(:prev_issue_id)
1077 assert_equal 2, assigns(:prev_issue_id)
1078 assert_equal 5, assigns(:next_issue_id)
1078 assert_equal 5, assigns(:next_issue_id)
1079
1079
1080 assert_tag 'div', :attributes => {:class => /next-prev-links/}
1080 assert_tag 'div', :attributes => {:class => /next-prev-links/}
1081 assert_tag 'a', :attributes => {:href => '/issues/2'}, :content => /Previous/
1081 assert_tag 'a', :attributes => {:href => '/issues/2'}, :content => /Previous/
1082 assert_tag 'a', :attributes => {:href => '/issues/5'}, :content => /Next/
1082 assert_tag 'a', :attributes => {:href => '/issues/5'}, :content => /Next/
1083
1083
1084 count = Issue.open.visible.count
1084 count = Issue.open.visible.count
1085 assert_tag 'span', :attributes => {:class => 'position'}, :content => "3 of #{count}"
1085 assert_tag 'span', :attributes => {:class => 'position'}, :content => "3 of #{count}"
1086 end
1086 end
1087
1087
1088 def test_show_should_display_prev_next_links_with_saved_query_in_session
1088 def test_show_should_display_prev_next_links_with_saved_query_in_session
1089 query = Query.create!(:name => 'test', :is_public => true, :user_id => 1,
1089 query = Query.create!(:name => 'test', :is_public => true, :user_id => 1,
1090 :filters => {'status_id' => {:values => ['5'], :operator => '='}},
1090 :filters => {'status_id' => {:values => ['5'], :operator => '='}},
1091 :sort_criteria => [['id', 'asc']])
1091 :sort_criteria => [['id', 'asc']])
1092 @request.session[:query] = {:id => query.id, :project_id => nil}
1092 @request.session[:query] = {:id => query.id, :project_id => nil}
1093
1093
1094 get :show, :id => 11
1094 get :show, :id => 11
1095
1095
1096 assert_response :success
1096 assert_response :success
1097 assert_equal query, assigns(:query)
1097 assert_equal query, assigns(:query)
1098 # Previous and next issues for all projects
1098 # Previous and next issues for all projects
1099 assert_equal 8, assigns(:prev_issue_id)
1099 assert_equal 8, assigns(:prev_issue_id)
1100 assert_equal 12, assigns(:next_issue_id)
1100 assert_equal 12, assigns(:next_issue_id)
1101
1101
1102 assert_tag 'a', :attributes => {:href => '/issues/8'}, :content => /Previous/
1102 assert_tag 'a', :attributes => {:href => '/issues/8'}, :content => /Previous/
1103 assert_tag 'a', :attributes => {:href => '/issues/12'}, :content => /Next/
1103 assert_tag 'a', :attributes => {:href => '/issues/12'}, :content => /Next/
1104 end
1104 end
1105
1105
1106 def test_show_should_display_prev_next_links_with_query_and_sort_on_association
1106 def test_show_should_display_prev_next_links_with_query_and_sort_on_association
1107 @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => nil}
1107 @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => nil}
1108
1108
1109 %w(project tracker status priority author assigned_to category fixed_version).each do |assoc_sort|
1109 %w(project tracker status priority author assigned_to category fixed_version).each do |assoc_sort|
1110 @request.session['issues_index_sort'] = assoc_sort
1110 @request.session['issues_index_sort'] = assoc_sort
1111
1111
1112 get :show, :id => 3
1112 get :show, :id => 3
1113 assert_response :success, "Wrong response status for #{assoc_sort} sort"
1113 assert_response :success, "Wrong response status for #{assoc_sort} sort"
1114
1114
1115 assert_tag 'div', :attributes => {:class => /next-prev-links/}, :content => /Previous/
1115 assert_tag 'div', :attributes => {:class => /next-prev-links/}, :content => /Previous/
1116 assert_tag 'div', :attributes => {:class => /next-prev-links/}, :content => /Next/
1116 assert_tag 'div', :attributes => {:class => /next-prev-links/}, :content => /Next/
1117 end
1117 end
1118 end
1118 end
1119
1119
1120 def test_show_should_display_prev_next_links_with_project_query_in_session
1120 def test_show_should_display_prev_next_links_with_project_query_in_session
1121 @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => 1}
1121 @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => 1}
1122 @request.session['issues_index_sort'] = 'id'
1122 @request.session['issues_index_sort'] = 'id'
1123
1123
1124 with_settings :display_subprojects_issues => '0' do
1124 with_settings :display_subprojects_issues => '0' do
1125 get :show, :id => 3
1125 get :show, :id => 3
1126 end
1126 end
1127
1127
1128 assert_response :success
1128 assert_response :success
1129 # Previous and next issues inside project
1129 # Previous and next issues inside project
1130 assert_equal 2, assigns(:prev_issue_id)
1130 assert_equal 2, assigns(:prev_issue_id)
1131 assert_equal 7, assigns(:next_issue_id)
1131 assert_equal 7, assigns(:next_issue_id)
1132
1132
1133 assert_tag 'a', :attributes => {:href => '/issues/2'}, :content => /Previous/
1133 assert_tag 'a', :attributes => {:href => '/issues/2'}, :content => /Previous/
1134 assert_tag 'a', :attributes => {:href => '/issues/7'}, :content => /Next/
1134 assert_tag 'a', :attributes => {:href => '/issues/7'}, :content => /Next/
1135 end
1135 end
1136
1136
1137 def test_show_should_not_display_prev_link_for_first_issue
1137 def test_show_should_not_display_prev_link_for_first_issue
1138 @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => 1}
1138 @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => 1}
1139 @request.session['issues_index_sort'] = 'id'
1139 @request.session['issues_index_sort'] = 'id'
1140
1140
1141 with_settings :display_subprojects_issues => '0' do
1141 with_settings :display_subprojects_issues => '0' do
1142 get :show, :id => 1
1142 get :show, :id => 1
1143 end
1143 end
1144
1144
1145 assert_response :success
1145 assert_response :success
1146 assert_nil assigns(:prev_issue_id)
1146 assert_nil assigns(:prev_issue_id)
1147 assert_equal 2, assigns(:next_issue_id)
1147 assert_equal 2, assigns(:next_issue_id)
1148
1148
1149 assert_no_tag 'a', :content => /Previous/
1149 assert_no_tag 'a', :content => /Previous/
1150 assert_tag 'a', :attributes => {:href => '/issues/2'}, :content => /Next/
1150 assert_tag 'a', :attributes => {:href => '/issues/2'}, :content => /Next/
1151 end
1151 end
1152
1152
1153 def test_show_should_not_display_prev_next_links_for_issue_not_in_query_results
1153 def test_show_should_not_display_prev_next_links_for_issue_not_in_query_results
1154 @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'c'}}, :project_id => 1}
1154 @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'c'}}, :project_id => 1}
1155 @request.session['issues_index_sort'] = 'id'
1155 @request.session['issues_index_sort'] = 'id'
1156
1156
1157 get :show, :id => 1
1157 get :show, :id => 1
1158
1158
1159 assert_response :success
1159 assert_response :success
1160 assert_nil assigns(:prev_issue_id)
1160 assert_nil assigns(:prev_issue_id)
1161 assert_nil assigns(:next_issue_id)
1161 assert_nil assigns(:next_issue_id)
1162
1162
1163 assert_no_tag 'a', :content => /Previous/
1163 assert_no_tag 'a', :content => /Previous/
1164 assert_no_tag 'a', :content => /Next/
1164 assert_no_tag 'a', :content => /Next/
1165 end
1165 end
1166
1166
1167 def test_show_show_should_display_prev_next_links_with_query_sort_by_user_custom_field
1167 def test_show_show_should_display_prev_next_links_with_query_sort_by_user_custom_field
1168 cf = IssueCustomField.create!(:name => 'User', :is_for_all => true, :tracker_ids => [1,2,3], :field_format => 'user')
1168 cf = IssueCustomField.create!(:name => 'User', :is_for_all => true, :tracker_ids => [1,2,3], :field_format => 'user')
1169 CustomValue.create!(:custom_field => cf, :customized => Issue.find(1), :value => '2')
1169 CustomValue.create!(:custom_field => cf, :customized => Issue.find(1), :value => '2')
1170 CustomValue.create!(:custom_field => cf, :customized => Issue.find(2), :value => '3')
1170 CustomValue.create!(:custom_field => cf, :customized => Issue.find(2), :value => '3')
1171 CustomValue.create!(:custom_field => cf, :customized => Issue.find(3), :value => '3')
1171 CustomValue.create!(:custom_field => cf, :customized => Issue.find(3), :value => '3')
1172 CustomValue.create!(:custom_field => cf, :customized => Issue.find(5), :value => '')
1172 CustomValue.create!(:custom_field => cf, :customized => Issue.find(5), :value => '')
1173
1173
1174 query = Query.create!(:name => 'test', :is_public => true, :user_id => 1, :filters => {},
1174 query = Query.create!(:name => 'test', :is_public => true, :user_id => 1, :filters => {},
1175 :sort_criteria => [["cf_#{cf.id}", 'asc'], ['id', 'asc']])
1175 :sort_criteria => [["cf_#{cf.id}", 'asc'], ['id', 'asc']])
1176 @request.session[:query] = {:id => query.id, :project_id => nil}
1176 @request.session[:query] = {:id => query.id, :project_id => nil}
1177
1177
1178 get :show, :id => 3
1178 get :show, :id => 3
1179 assert_response :success
1179 assert_response :success
1180
1180
1181 assert_equal 2, assigns(:prev_issue_id)
1181 assert_equal 2, assigns(:prev_issue_id)
1182 assert_equal 1, assigns(:next_issue_id)
1182 assert_equal 1, assigns(:next_issue_id)
1183 end
1183 end
1184
1184
1185 def test_show_should_display_link_to_the_assignee
1185 def test_show_should_display_link_to_the_assignee
1186 get :show, :id => 2
1186 get :show, :id => 2
1187 assert_response :success
1187 assert_response :success
1188 assert_select '.assigned-to' do
1188 assert_select '.assigned-to' do
1189 assert_select 'a[href=/users/3]'
1189 assert_select 'a[href=/users/3]'
1190 end
1190 end
1191 end
1191 end
1192
1192
1193 def test_show_should_display_visible_changesets_from_other_projects
1193 def test_show_should_display_visible_changesets_from_other_projects
1194 project = Project.find(2)
1194 project = Project.find(2)
1195 issue = project.issues.first
1195 issue = project.issues.first
1196 issue.changeset_ids = [102]
1196 issue.changeset_ids = [102]
1197 issue.save!
1197 issue.save!
1198 project.disable_module! :repository
1198 project.disable_module! :repository
1199
1199
1200 @request.session[:user_id] = 2
1200 @request.session[:user_id] = 2
1201 get :show, :id => issue.id
1201 get :show, :id => issue.id
1202 assert_tag 'a', :attributes => {:href => "/projects/ecookbook/repository/revisions/3"}
1202 assert_tag 'a', :attributes => {:href => "/projects/ecookbook/repository/revisions/3"}
1203 end
1203 end
1204
1204
1205 def test_show_should_display_watchers
1205 def test_show_should_display_watchers
1206 @request.session[:user_id] = 2
1206 @request.session[:user_id] = 2
1207 Issue.find(1).add_watcher User.find(2)
1207 Issue.find(1).add_watcher User.find(2)
1208
1208
1209 get :show, :id => 1
1209 get :show, :id => 1
1210 assert_select 'div#watchers ul' do
1210 assert_select 'div#watchers ul' do
1211 assert_select 'li' do
1211 assert_select 'li' do
1212 assert_select 'a[href=/users/2]'
1212 assert_select 'a[href=/users/2]'
1213 assert_select 'a img[alt=Delete]'
1213 assert_select 'a img[alt=Delete]'
1214 end
1214 end
1215 end
1215 end
1216 end
1216 end
1217
1217
1218 def test_show_should_display_watchers_with_gravatars
1218 def test_show_should_display_watchers_with_gravatars
1219 @request.session[:user_id] = 2
1219 @request.session[:user_id] = 2
1220 Issue.find(1).add_watcher User.find(2)
1220 Issue.find(1).add_watcher User.find(2)
1221
1221
1222 with_settings :gravatar_enabled => '1' do
1222 with_settings :gravatar_enabled => '1' do
1223 get :show, :id => 1
1223 get :show, :id => 1
1224 end
1224 end
1225
1225
1226 assert_select 'div#watchers ul' do
1226 assert_select 'div#watchers ul' do
1227 assert_select 'li' do
1227 assert_select 'li' do
1228 assert_select 'img.gravatar'
1228 assert_select 'img.gravatar'
1229 assert_select 'a[href=/users/2]'
1229 assert_select 'a[href=/users/2]'
1230 assert_select 'a img[alt=Delete]'
1230 assert_select 'a img[alt=Delete]'
1231 end
1231 end
1232 end
1232 end
1233 end
1233 end
1234
1234
1235 def test_show_with_thumbnails_enabled_should_display_thumbnails
1235 def test_show_with_thumbnails_enabled_should_display_thumbnails
1236 @request.session[:user_id] = 2
1236 @request.session[:user_id] = 2
1237
1237
1238 with_settings :thumbnails_enabled => '1' do
1238 with_settings :thumbnails_enabled => '1' do
1239 get :show, :id => 14
1239 get :show, :id => 14
1240 assert_response :success
1240 assert_response :success
1241 end
1241 end
1242
1242
1243 assert_select 'div.thumbnails' do
1243 assert_select 'div.thumbnails' do
1244 assert_select 'a[href=/attachments/16/testfile.png]' do
1244 assert_select 'a[href=/attachments/16/testfile.png]' do
1245 assert_select 'img[src=/attachments/thumbnail/16]'
1245 assert_select 'img[src=/attachments/thumbnail/16]'
1246 end
1246 end
1247 end
1247 end
1248 end
1248 end
1249
1249
1250 def test_show_with_thumbnails_disabled_should_not_display_thumbnails
1250 def test_show_with_thumbnails_disabled_should_not_display_thumbnails
1251 @request.session[:user_id] = 2
1251 @request.session[:user_id] = 2
1252
1252
1253 with_settings :thumbnails_enabled => '0' do
1253 with_settings :thumbnails_enabled => '0' do
1254 get :show, :id => 14
1254 get :show, :id => 14
1255 assert_response :success
1255 assert_response :success
1256 end
1256 end
1257
1257
1258 assert_select 'div.thumbnails', 0
1258 assert_select 'div.thumbnails', 0
1259 end
1259 end
1260
1260
1261 def test_show_with_multi_custom_field
1261 def test_show_with_multi_custom_field
1262 field = CustomField.find(1)
1262 field = CustomField.find(1)
1263 field.update_attribute :multiple, true
1263 field.update_attribute :multiple, true
1264 issue = Issue.find(1)
1264 issue = Issue.find(1)
1265 issue.custom_field_values = {1 => ['MySQL', 'Oracle']}
1265 issue.custom_field_values = {1 => ['MySQL', 'Oracle']}
1266 issue.save!
1266 issue.save!
1267
1267
1268 get :show, :id => 1
1268 get :show, :id => 1
1269 assert_response :success
1269 assert_response :success
1270
1270
1271 assert_tag :td, :content => 'MySQL, Oracle'
1271 assert_tag :td, :content => 'MySQL, Oracle'
1272 end
1272 end
1273
1273
1274 def test_show_with_multi_user_custom_field
1274 def test_show_with_multi_user_custom_field
1275 field = IssueCustomField.create!(:name => 'Multi user', :field_format => 'user', :multiple => true,
1275 field = IssueCustomField.create!(:name => 'Multi user', :field_format => 'user', :multiple => true,
1276 :tracker_ids => [1], :is_for_all => true)
1276 :tracker_ids => [1], :is_for_all => true)
1277 issue = Issue.find(1)
1277 issue = Issue.find(1)
1278 issue.custom_field_values = {field.id => ['2', '3']}
1278 issue.custom_field_values = {field.id => ['2', '3']}
1279 issue.save!
1279 issue.save!
1280
1280
1281 get :show, :id => 1
1281 get :show, :id => 1
1282 assert_response :success
1282 assert_response :success
1283
1283
1284 # TODO: should display links
1284 # TODO: should display links
1285 assert_tag :td, :content => 'Dave Lopper, John Smith'
1285 assert_tag :td, :content => 'Dave Lopper, John Smith'
1286 end
1286 end
1287
1287
1288 def test_show_atom
1288 def test_show_atom
1289 get :show, :id => 2, :format => 'atom'
1289 get :show, :id => 2, :format => 'atom'
1290 assert_response :success
1290 assert_response :success
1291 assert_template 'journals/index'
1291 assert_template 'journals/index'
1292 # Inline image
1292 # Inline image
1293 assert_select 'content', :text => Regexp.new(Regexp.quote('http://test.host/attachments/download/10'))
1293 assert_select 'content', :text => Regexp.new(Regexp.quote('http://test.host/attachments/download/10'))
1294 end
1294 end
1295
1295
1296 def test_show_export_to_pdf
1296 def test_show_export_to_pdf
1297 get :show, :id => 3, :format => 'pdf'
1297 get :show, :id => 3, :format => 'pdf'
1298 assert_response :success
1298 assert_response :success
1299 assert_equal 'application/pdf', @response.content_type
1299 assert_equal 'application/pdf', @response.content_type
1300 assert @response.body.starts_with?('%PDF')
1300 assert @response.body.starts_with?('%PDF')
1301 assert_not_nil assigns(:issue)
1301 assert_not_nil assigns(:issue)
1302 end
1302 end
1303
1303
1304 def test_show_export_to_pdf_with_ancestors
1304 def test_show_export_to_pdf_with_ancestors
1305 issue = Issue.generate!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => 1)
1305 issue = Issue.generate!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => 1)
1306
1306
1307 get :show, :id => issue.id, :format => 'pdf'
1307 get :show, :id => issue.id, :format => 'pdf'
1308 assert_response :success
1308 assert_response :success
1309 assert_equal 'application/pdf', @response.content_type
1309 assert_equal 'application/pdf', @response.content_type
1310 assert @response.body.starts_with?('%PDF')
1310 assert @response.body.starts_with?('%PDF')
1311 end
1311 end
1312
1312
1313 def test_show_export_to_pdf_with_descendants
1313 def test_show_export_to_pdf_with_descendants
1314 c1 = Issue.generate!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => 1)
1314 c1 = Issue.generate!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => 1)
1315 c2 = Issue.generate!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => 1)
1315 c2 = Issue.generate!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => 1)
1316 c3 = Issue.generate!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => c1.id)
1316 c3 = Issue.generate!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => c1.id)
1317
1317
1318 get :show, :id => 1, :format => 'pdf'
1318 get :show, :id => 1, :format => 'pdf'
1319 assert_response :success
1319 assert_response :success
1320 assert_equal 'application/pdf', @response.content_type
1320 assert_equal 'application/pdf', @response.content_type
1321 assert @response.body.starts_with?('%PDF')
1321 assert @response.body.starts_with?('%PDF')
1322 end
1322 end
1323
1323
1324 def test_show_export_to_pdf_with_journals
1324 def test_show_export_to_pdf_with_journals
1325 get :show, :id => 1, :format => 'pdf'
1325 get :show, :id => 1, :format => 'pdf'
1326 assert_response :success
1326 assert_response :success
1327 assert_equal 'application/pdf', @response.content_type
1327 assert_equal 'application/pdf', @response.content_type
1328 assert @response.body.starts_with?('%PDF')
1328 assert @response.body.starts_with?('%PDF')
1329 end
1329 end
1330
1330
1331 def test_show_export_to_pdf_with_changesets
1331 def test_show_export_to_pdf_with_changesets
1332 Issue.find(3).changesets = Changeset.find_all_by_id(100, 101, 102)
1332 Issue.find(3).changesets = Changeset.find_all_by_id(100, 101, 102)
1333
1333
1334 get :show, :id => 3, :format => 'pdf'
1334 get :show, :id => 3, :format => 'pdf'
1335 assert_response :success
1335 assert_response :success
1336 assert_equal 'application/pdf', @response.content_type
1336 assert_equal 'application/pdf', @response.content_type
1337 assert @response.body.starts_with?('%PDF')
1337 assert @response.body.starts_with?('%PDF')
1338 end
1338 end
1339
1339
1340 def test_get_new
1340 def test_get_new
1341 @request.session[:user_id] = 2
1341 @request.session[:user_id] = 2
1342 get :new, :project_id => 1, :tracker_id => 1
1342 get :new, :project_id => 1, :tracker_id => 1
1343 assert_response :success
1343 assert_response :success
1344 assert_template 'new'
1344 assert_template 'new'
1345
1345
1346 assert_tag 'input', :attributes => {:name => 'issue[is_private]'}
1346 assert_tag 'input', :attributes => {:name => 'issue[is_private]'}
1347 assert_no_tag 'select', :attributes => {:name => 'issue[project_id]'}
1347 assert_no_tag 'select', :attributes => {:name => 'issue[project_id]'}
1348 assert_tag 'select', :attributes => {:name => 'issue[tracker_id]'}
1348 assert_tag 'select', :attributes => {:name => 'issue[tracker_id]'}
1349 assert_tag 'input', :attributes => {:name => 'issue[subject]'}
1349 assert_tag 'input', :attributes => {:name => 'issue[subject]'}
1350 assert_tag 'textarea', :attributes => {:name => 'issue[description]'}
1350 assert_tag 'textarea', :attributes => {:name => 'issue[description]'}
1351 assert_tag 'select', :attributes => {:name => 'issue[status_id]'}
1351 assert_tag 'select', :attributes => {:name => 'issue[status_id]'}
1352 assert_tag 'select', :attributes => {:name => 'issue[priority_id]'}
1352 assert_tag 'select', :attributes => {:name => 'issue[priority_id]'}
1353 assert_tag 'select', :attributes => {:name => 'issue[assigned_to_id]'}
1353 assert_tag 'select', :attributes => {:name => 'issue[assigned_to_id]'}
1354 assert_tag 'select', :attributes => {:name => 'issue[category_id]'}
1354 assert_tag 'select', :attributes => {:name => 'issue[category_id]'}
1355 assert_tag 'select', :attributes => {:name => 'issue[fixed_version_id]'}
1355 assert_tag 'select', :attributes => {:name => 'issue[fixed_version_id]'}
1356 assert_tag 'input', :attributes => {:name => 'issue[parent_issue_id]'}
1356 assert_tag 'input', :attributes => {:name => 'issue[parent_issue_id]'}
1357 assert_tag 'input', :attributes => {:name => 'issue[start_date]'}
1357 assert_tag 'input', :attributes => {:name => 'issue[start_date]'}
1358 assert_tag 'input', :attributes => {:name => 'issue[due_date]'}
1358 assert_tag 'input', :attributes => {:name => 'issue[due_date]'}
1359 assert_tag 'select', :attributes => {:name => 'issue[done_ratio]'}
1359 assert_tag 'select', :attributes => {:name => 'issue[done_ratio]'}
1360 assert_tag 'input', :attributes => { :name => 'issue[custom_field_values][2]', :value => 'Default string' }
1360 assert_tag 'input', :attributes => { :name => 'issue[custom_field_values][2]', :value => 'Default string' }
1361 assert_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]'}
1361 assert_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]'}
1362
1362
1363 # Be sure we don't display inactive IssuePriorities
1363 # Be sure we don't display inactive IssuePriorities
1364 assert ! IssuePriority.find(15).active?
1364 assert ! IssuePriority.find(15).active?
1365 assert_no_tag :option, :attributes => {:value => '15'},
1365 assert_no_tag :option, :attributes => {:value => '15'},
1366 :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} }
1366 :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} }
1367 end
1367 end
1368
1368
1369 def test_get_new_with_minimal_permissions
1369 def test_get_new_with_minimal_permissions
1370 Role.find(1).update_attribute :permissions, [:add_issues]
1370 Role.find(1).update_attribute :permissions, [:add_issues]
1371 WorkflowTransition.delete_all :role_id => 1
1371 WorkflowTransition.delete_all :role_id => 1
1372
1372
1373 @request.session[:user_id] = 2
1373 @request.session[:user_id] = 2
1374 get :new, :project_id => 1, :tracker_id => 1
1374 get :new, :project_id => 1, :tracker_id => 1
1375 assert_response :success
1375 assert_response :success
1376 assert_template 'new'
1376 assert_template 'new'
1377
1377
1378 assert_no_tag 'input', :attributes => {:name => 'issue[is_private]'}
1378 assert_no_tag 'input', :attributes => {:name => 'issue[is_private]'}
1379 assert_no_tag 'select', :attributes => {:name => 'issue[project_id]'}
1379 assert_no_tag 'select', :attributes => {:name => 'issue[project_id]'}
1380 assert_tag 'select', :attributes => {:name => 'issue[tracker_id]'}
1380 assert_tag 'select', :attributes => {:name => 'issue[tracker_id]'}
1381 assert_tag 'input', :attributes => {:name => 'issue[subject]'}
1381 assert_tag 'input', :attributes => {:name => 'issue[subject]'}
1382 assert_tag 'textarea', :attributes => {:name => 'issue[description]'}
1382 assert_tag 'textarea', :attributes => {:name => 'issue[description]'}
1383 assert_tag 'select', :attributes => {:name => 'issue[status_id]'}
1383 assert_tag 'select', :attributes => {:name => 'issue[status_id]'}
1384 assert_tag 'select', :attributes => {:name => 'issue[priority_id]'}
1384 assert_tag 'select', :attributes => {:name => 'issue[priority_id]'}
1385 assert_tag 'select', :attributes => {:name => 'issue[assigned_to_id]'}
1385 assert_tag 'select', :attributes => {:name => 'issue[assigned_to_id]'}
1386 assert_tag 'select', :attributes => {:name => 'issue[category_id]'}
1386 assert_tag 'select', :attributes => {:name => 'issue[category_id]'}
1387 assert_tag 'select', :attributes => {:name => 'issue[fixed_version_id]'}
1387 assert_tag 'select', :attributes => {:name => 'issue[fixed_version_id]'}
1388 assert_no_tag 'input', :attributes => {:name => 'issue[parent_issue_id]'}
1388 assert_no_tag 'input', :attributes => {:name => 'issue[parent_issue_id]'}
1389 assert_tag 'input', :attributes => {:name => 'issue[start_date]'}
1389 assert_tag 'input', :attributes => {:name => 'issue[start_date]'}
1390 assert_tag 'input', :attributes => {:name => 'issue[due_date]'}
1390 assert_tag 'input', :attributes => {:name => 'issue[due_date]'}
1391 assert_tag 'select', :attributes => {:name => 'issue[done_ratio]'}
1391 assert_tag 'select', :attributes => {:name => 'issue[done_ratio]'}
1392 assert_tag 'input', :attributes => { :name => 'issue[custom_field_values][2]', :value => 'Default string' }
1392 assert_tag 'input', :attributes => { :name => 'issue[custom_field_values][2]', :value => 'Default string' }
1393 assert_no_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]'}
1393 assert_no_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]'}
1394 end
1394 end
1395
1395
1396 def test_get_new_with_list_custom_field
1396 def test_get_new_with_list_custom_field
1397 @request.session[:user_id] = 2
1397 @request.session[:user_id] = 2
1398 get :new, :project_id => 1, :tracker_id => 1
1398 get :new, :project_id => 1, :tracker_id => 1
1399 assert_response :success
1399 assert_response :success
1400 assert_template 'new'
1400 assert_template 'new'
1401
1401
1402 assert_tag 'select',
1402 assert_tag 'select',
1403 :attributes => {:name => 'issue[custom_field_values][1]', :class => 'list_cf'},
1403 :attributes => {:name => 'issue[custom_field_values][1]', :class => 'list_cf'},
1404 :children => {:count => 4},
1404 :children => {:count => 4},
1405 :child => {:tag => 'option', :attributes => {:value => 'MySQL'}, :content => 'MySQL'}
1405 :child => {:tag => 'option', :attributes => {:value => 'MySQL'}, :content => 'MySQL'}
1406 end
1406 end
1407
1407
1408 def test_get_new_with_multi_custom_field
1408 def test_get_new_with_multi_custom_field
1409 field = IssueCustomField.find(1)
1409 field = IssueCustomField.find(1)
1410 field.update_attribute :multiple, true
1410 field.update_attribute :multiple, true
1411
1411
1412 @request.session[:user_id] = 2
1412 @request.session[:user_id] = 2
1413 get :new, :project_id => 1, :tracker_id => 1
1413 get :new, :project_id => 1, :tracker_id => 1
1414 assert_response :success
1414 assert_response :success
1415 assert_template 'new'
1415 assert_template 'new'
1416
1416
1417 assert_tag 'select',
1417 assert_tag 'select',
1418 :attributes => {:name => 'issue[custom_field_values][1][]', :multiple => 'multiple'},
1418 :attributes => {:name => 'issue[custom_field_values][1][]', :multiple => 'multiple'},
1419 :children => {:count => 3},
1419 :children => {:count => 3},
1420 :child => {:tag => 'option', :attributes => {:value => 'MySQL'}, :content => 'MySQL'}
1420 :child => {:tag => 'option', :attributes => {:value => 'MySQL'}, :content => 'MySQL'}
1421 assert_tag 'input',
1421 assert_tag 'input',
1422 :attributes => {:name => 'issue[custom_field_values][1][]', :value => ''}
1422 :attributes => {:name => 'issue[custom_field_values][1][]', :value => ''}
1423 end
1423 end
1424
1424
1425 def test_get_new_with_multi_user_custom_field
1425 def test_get_new_with_multi_user_custom_field
1426 field = IssueCustomField.create!(:name => 'Multi user', :field_format => 'user', :multiple => true,
1426 field = IssueCustomField.create!(:name => 'Multi user', :field_format => 'user', :multiple => true,
1427 :tracker_ids => [1], :is_for_all => true)
1427 :tracker_ids => [1], :is_for_all => true)
1428
1428
1429 @request.session[:user_id] = 2
1429 @request.session[:user_id] = 2
1430 get :new, :project_id => 1, :tracker_id => 1
1430 get :new, :project_id => 1, :tracker_id => 1
1431 assert_response :success
1431 assert_response :success
1432 assert_template 'new'
1432 assert_template 'new'
1433
1433
1434 assert_tag 'select',
1434 assert_tag 'select',
1435 :attributes => {:name => "issue[custom_field_values][#{field.id}][]", :multiple => 'multiple'},
1435 :attributes => {:name => "issue[custom_field_values][#{field.id}][]", :multiple => 'multiple'},
1436 :children => {:count => Project.find(1).users.count},
1436 :children => {:count => Project.find(1).users.count},
1437 :child => {:tag => 'option', :attributes => {:value => '2'}, :content => 'John Smith'}
1437 :child => {:tag => 'option', :attributes => {:value => '2'}, :content => 'John Smith'}
1438 assert_tag 'input',
1438 assert_tag 'input',
1439 :attributes => {:name => "issue[custom_field_values][#{field.id}][]", :value => ''}
1439 :attributes => {:name => "issue[custom_field_values][#{field.id}][]", :value => ''}
1440 end
1440 end
1441
1441
1442 def test_get_new_with_date_custom_field
1442 def test_get_new_with_date_custom_field
1443 field = IssueCustomField.create!(:name => 'Date', :field_format => 'date', :tracker_ids => [1], :is_for_all => true)
1443 field = IssueCustomField.create!(:name => 'Date', :field_format => 'date', :tracker_ids => [1], :is_for_all => true)
1444
1444
1445 @request.session[:user_id] = 2
1445 @request.session[:user_id] = 2
1446 get :new, :project_id => 1, :tracker_id => 1
1446 get :new, :project_id => 1, :tracker_id => 1
1447 assert_response :success
1447 assert_response :success
1448
1448
1449 assert_select 'input[name=?]', "issue[custom_field_values][#{field.id}]"
1449 assert_select 'input[name=?]', "issue[custom_field_values][#{field.id}]"
1450 end
1450 end
1451
1451
1452 def test_get_new_with_text_custom_field
1452 def test_get_new_with_text_custom_field
1453 field = IssueCustomField.create!(:name => 'Text', :field_format => 'text', :tracker_ids => [1], :is_for_all => true)
1453 field = IssueCustomField.create!(:name => 'Text', :field_format => 'text', :tracker_ids => [1], :is_for_all => true)
1454
1454
1455 @request.session[:user_id] = 2
1455 @request.session[:user_id] = 2
1456 get :new, :project_id => 1, :tracker_id => 1
1456 get :new, :project_id => 1, :tracker_id => 1
1457 assert_response :success
1457 assert_response :success
1458
1458
1459 assert_select 'textarea[name=?]', "issue[custom_field_values][#{field.id}]"
1459 assert_select 'textarea[name=?]', "issue[custom_field_values][#{field.id}]"
1460 end
1460 end
1461
1461
1462 def test_get_new_without_default_start_date_is_creation_date
1462 def test_get_new_without_default_start_date_is_creation_date
1463 Setting.default_issue_start_date_to_creation_date = 0
1463 Setting.default_issue_start_date_to_creation_date = 0
1464
1464
1465 @request.session[:user_id] = 2
1465 @request.session[:user_id] = 2
1466 get :new, :project_id => 1, :tracker_id => 1
1466 get :new, :project_id => 1, :tracker_id => 1
1467 assert_response :success
1467 assert_response :success
1468 assert_template 'new'
1468 assert_template 'new'
1469
1469
1470 assert_tag :tag => 'input', :attributes => { :name => 'issue[start_date]',
1470 assert_tag :tag => 'input', :attributes => { :name => 'issue[start_date]',
1471 :value => nil }
1471 :value => nil }
1472 end
1472 end
1473
1473
1474 def test_get_new_with_default_start_date_is_creation_date
1474 def test_get_new_with_default_start_date_is_creation_date
1475 Setting.default_issue_start_date_to_creation_date = 1
1475 Setting.default_issue_start_date_to_creation_date = 1
1476
1476
1477 @request.session[:user_id] = 2
1477 @request.session[:user_id] = 2
1478 get :new, :project_id => 1, :tracker_id => 1
1478 get :new, :project_id => 1, :tracker_id => 1
1479 assert_response :success
1479 assert_response :success
1480 assert_template 'new'
1480 assert_template 'new'
1481
1481
1482 assert_tag :tag => 'input', :attributes => { :name => 'issue[start_date]',
1482 assert_tag :tag => 'input', :attributes => { :name => 'issue[start_date]',
1483 :value => Date.today.to_s }
1483 :value => Date.today.to_s }
1484 end
1484 end
1485
1485
1486 def test_get_new_form_should_allow_attachment_upload
1486 def test_get_new_form_should_allow_attachment_upload
1487 @request.session[:user_id] = 2
1487 @request.session[:user_id] = 2
1488 get :new, :project_id => 1, :tracker_id => 1
1488 get :new, :project_id => 1, :tracker_id => 1
1489
1489
1490 assert_select 'form[id=issue-form][method=post][enctype=multipart/form-data]' do
1490 assert_select 'form[id=issue-form][method=post][enctype=multipart/form-data]' do
1491 assert_select 'input[name=?][type=file]', 'attachments[1][file]'
1491 assert_select 'input[name=?][type=file]', 'attachments[1][file]'
1492 assert_select 'input[name=?][maxlength=255]', 'attachments[1][description]'
1492 assert_select 'input[name=?][maxlength=255]', 'attachments[1][description]'
1493 end
1493 end
1494 end
1494 end
1495
1495
1496 def test_get_new_should_prefill_the_form_from_params
1496 def test_get_new_should_prefill_the_form_from_params
1497 @request.session[:user_id] = 2
1497 @request.session[:user_id] = 2
1498 get :new, :project_id => 1,
1498 get :new, :project_id => 1,
1499 :issue => {:tracker_id => 3, :description => 'Prefilled', :custom_field_values => {'2' => 'Custom field value'}}
1499 :issue => {:tracker_id => 3, :description => 'Prefilled', :custom_field_values => {'2' => 'Custom field value'}}
1500
1500
1501 issue = assigns(:issue)
1501 issue = assigns(:issue)
1502 assert_equal 3, issue.tracker_id
1502 assert_equal 3, issue.tracker_id
1503 assert_equal 'Prefilled', issue.description
1503 assert_equal 'Prefilled', issue.description
1504 assert_equal 'Custom field value', issue.custom_field_value(2)
1504 assert_equal 'Custom field value', issue.custom_field_value(2)
1505
1505
1506 assert_tag 'select',
1506 assert_tag 'select',
1507 :attributes => {:name => 'issue[tracker_id]'},
1507 :attributes => {:name => 'issue[tracker_id]'},
1508 :child => {:tag => 'option', :attributes => {:value => '3', :selected => 'selected'}}
1508 :child => {:tag => 'option', :attributes => {:value => '3', :selected => 'selected'}}
1509 assert_tag 'textarea',
1509 assert_tag 'textarea',
1510 :attributes => {:name => 'issue[description]'}, :content => "\nPrefilled"
1510 :attributes => {:name => 'issue[description]'}, :content => "\nPrefilled"
1511 assert_tag 'input',
1511 assert_tag 'input',
1512 :attributes => {:name => 'issue[custom_field_values][2]', :value => 'Custom field value'}
1512 :attributes => {:name => 'issue[custom_field_values][2]', :value => 'Custom field value'}
1513 end
1513 end
1514
1514
1515 def test_get_new_should_mark_required_fields
1515 def test_get_new_should_mark_required_fields
1516 cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1516 cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1517 cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1517 cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1518 WorkflowPermission.delete_all
1518 WorkflowPermission.delete_all
1519 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'required')
1519 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'required')
1520 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'required')
1520 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'required')
1521 @request.session[:user_id] = 2
1521 @request.session[:user_id] = 2
1522
1522
1523 get :new, :project_id => 1
1523 get :new, :project_id => 1
1524 assert_response :success
1524 assert_response :success
1525 assert_template 'new'
1525 assert_template 'new'
1526
1526
1527 assert_select 'label[for=issue_start_date]' do
1527 assert_select 'label[for=issue_start_date]' do
1528 assert_select 'span[class=required]', 0
1528 assert_select 'span[class=required]', 0
1529 end
1529 end
1530 assert_select 'label[for=issue_due_date]' do
1530 assert_select 'label[for=issue_due_date]' do
1531 assert_select 'span[class=required]'
1531 assert_select 'span[class=required]'
1532 end
1532 end
1533 assert_select 'label[for=?]', "issue_custom_field_values_#{cf1.id}" do
1533 assert_select 'label[for=?]', "issue_custom_field_values_#{cf1.id}" do
1534 assert_select 'span[class=required]', 0
1534 assert_select 'span[class=required]', 0
1535 end
1535 end
1536 assert_select 'label[for=?]', "issue_custom_field_values_#{cf2.id}" do
1536 assert_select 'label[for=?]', "issue_custom_field_values_#{cf2.id}" do
1537 assert_select 'span[class=required]'
1537 assert_select 'span[class=required]'
1538 end
1538 end
1539 end
1539 end
1540
1540
1541 def test_get_new_should_not_display_readonly_fields
1541 def test_get_new_should_not_display_readonly_fields
1542 cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1542 cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1543 cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1543 cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1544 WorkflowPermission.delete_all
1544 WorkflowPermission.delete_all
1545 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
1545 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
1546 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'readonly')
1546 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'readonly')
1547 @request.session[:user_id] = 2
1547 @request.session[:user_id] = 2
1548
1548
1549 get :new, :project_id => 1
1549 get :new, :project_id => 1
1550 assert_response :success
1550 assert_response :success
1551 assert_template 'new'
1551 assert_template 'new'
1552
1552
1553 assert_select 'input[name=?]', 'issue[start_date]'
1553 assert_select 'input[name=?]', 'issue[start_date]'
1554 assert_select 'input[name=?]', 'issue[due_date]', 0
1554 assert_select 'input[name=?]', 'issue[due_date]', 0
1555 assert_select 'input[name=?]', "issue[custom_field_values][#{cf1.id}]"
1555 assert_select 'input[name=?]', "issue[custom_field_values][#{cf1.id}]"
1556 assert_select 'input[name=?]', "issue[custom_field_values][#{cf2.id}]", 0
1556 assert_select 'input[name=?]', "issue[custom_field_values][#{cf2.id}]", 0
1557 end
1557 end
1558
1558
1559 def test_get_new_without_tracker_id
1559 def test_get_new_without_tracker_id
1560 @request.session[:user_id] = 2
1560 @request.session[:user_id] = 2
1561 get :new, :project_id => 1
1561 get :new, :project_id => 1
1562 assert_response :success
1562 assert_response :success
1563 assert_template 'new'
1563 assert_template 'new'
1564
1564
1565 issue = assigns(:issue)
1565 issue = assigns(:issue)
1566 assert_not_nil issue
1566 assert_not_nil issue
1567 assert_equal Project.find(1).trackers.first, issue.tracker
1567 assert_equal Project.find(1).trackers.first, issue.tracker
1568 end
1568 end
1569
1569
1570 def test_get_new_with_no_default_status_should_display_an_error
1570 def test_get_new_with_no_default_status_should_display_an_error
1571 @request.session[:user_id] = 2
1571 @request.session[:user_id] = 2
1572 IssueStatus.delete_all
1572 IssueStatus.delete_all
1573
1573
1574 get :new, :project_id => 1
1574 get :new, :project_id => 1
1575 assert_response 500
1575 assert_response 500
1576 assert_error_tag :content => /No default issue/
1576 assert_error_tag :content => /No default issue/
1577 end
1577 end
1578
1578
1579 def test_get_new_with_no_tracker_should_display_an_error
1579 def test_get_new_with_no_tracker_should_display_an_error
1580 @request.session[:user_id] = 2
1580 @request.session[:user_id] = 2
1581 Tracker.delete_all
1581 Tracker.delete_all
1582
1582
1583 get :new, :project_id => 1
1583 get :new, :project_id => 1
1584 assert_response 500
1584 assert_response 500
1585 assert_error_tag :content => /No tracker/
1585 assert_error_tag :content => /No tracker/
1586 end
1586 end
1587
1587
1588 def test_update_new_form
1588 def test_update_new_form
1589 @request.session[:user_id] = 2
1589 @request.session[:user_id] = 2
1590 xhr :post, :new, :project_id => 1,
1590 xhr :post, :new, :project_id => 1,
1591 :issue => {:tracker_id => 2,
1591 :issue => {:tracker_id => 2,
1592 :subject => 'This is the test_new issue',
1592 :subject => 'This is the test_new issue',
1593 :description => 'This is the description',
1593 :description => 'This is the description',
1594 :priority_id => 5}
1594 :priority_id => 5}
1595 assert_response :success
1595 assert_response :success
1596 assert_template 'update_form'
1596 assert_template 'update_form'
1597 assert_template 'form'
1597 assert_template 'form'
1598 assert_equal 'text/javascript', response.content_type
1598 assert_equal 'text/javascript', response.content_type
1599
1599
1600 issue = assigns(:issue)
1600 issue = assigns(:issue)
1601 assert_kind_of Issue, issue
1601 assert_kind_of Issue, issue
1602 assert_equal 1, issue.project_id
1602 assert_equal 1, issue.project_id
1603 assert_equal 2, issue.tracker_id
1603 assert_equal 2, issue.tracker_id
1604 assert_equal 'This is the test_new issue', issue.subject
1604 assert_equal 'This is the test_new issue', issue.subject
1605 end
1605 end
1606
1606
1607 def test_update_new_form_should_propose_transitions_based_on_initial_status
1607 def test_update_new_form_should_propose_transitions_based_on_initial_status
1608 @request.session[:user_id] = 2
1608 @request.session[:user_id] = 2
1609 WorkflowTransition.delete_all
1609 WorkflowTransition.delete_all
1610 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2)
1610 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2)
1611 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5)
1611 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5)
1612 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4)
1612 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4)
1613
1613
1614 xhr :post, :new, :project_id => 1,
1614 xhr :post, :new, :project_id => 1,
1615 :issue => {:tracker_id => 1,
1615 :issue => {:tracker_id => 1,
1616 :status_id => 5,
1616 :status_id => 5,
1617 :subject => 'This is an issue'}
1617 :subject => 'This is an issue'}
1618
1618
1619 assert_equal 5, assigns(:issue).status_id
1619 assert_equal 5, assigns(:issue).status_id
1620 assert_equal [1,2,5], assigns(:allowed_statuses).map(&:id).sort
1620 assert_equal [1,2,5], assigns(:allowed_statuses).map(&:id).sort
1621 end
1621 end
1622
1622
1623 def test_post_create
1623 def test_post_create
1624 @request.session[:user_id] = 2
1624 @request.session[:user_id] = 2
1625 assert_difference 'Issue.count' do
1625 assert_difference 'Issue.count' do
1626 post :create, :project_id => 1,
1626 post :create, :project_id => 1,
1627 :issue => {:tracker_id => 3,
1627 :issue => {:tracker_id => 3,
1628 :status_id => 2,
1628 :status_id => 2,
1629 :subject => 'This is the test_new issue',
1629 :subject => 'This is the test_new issue',
1630 :description => 'This is the description',
1630 :description => 'This is the description',
1631 :priority_id => 5,
1631 :priority_id => 5,
1632 :start_date => '2010-11-07',
1632 :start_date => '2010-11-07',
1633 :estimated_hours => '',
1633 :estimated_hours => '',
1634 :custom_field_values => {'2' => 'Value for field 2'}}
1634 :custom_field_values => {'2' => 'Value for field 2'}}
1635 end
1635 end
1636 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
1636 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
1637
1637
1638 issue = Issue.find_by_subject('This is the test_new issue')
1638 issue = Issue.find_by_subject('This is the test_new issue')
1639 assert_not_nil issue
1639 assert_not_nil issue
1640 assert_equal 2, issue.author_id
1640 assert_equal 2, issue.author_id
1641 assert_equal 3, issue.tracker_id
1641 assert_equal 3, issue.tracker_id
1642 assert_equal 2, issue.status_id
1642 assert_equal 2, issue.status_id
1643 assert_equal Date.parse('2010-11-07'), issue.start_date
1643 assert_equal Date.parse('2010-11-07'), issue.start_date
1644 assert_nil issue.estimated_hours
1644 assert_nil issue.estimated_hours
1645 v = issue.custom_values.find(:first, :conditions => {:custom_field_id => 2})
1645 v = issue.custom_values.find(:first, :conditions => {:custom_field_id => 2})
1646 assert_not_nil v
1646 assert_not_nil v
1647 assert_equal 'Value for field 2', v.value
1647 assert_equal 'Value for field 2', v.value
1648 end
1648 end
1649
1649
1650 def test_post_new_with_group_assignment
1650 def test_post_new_with_group_assignment
1651 group = Group.find(11)
1651 group = Group.find(11)
1652 project = Project.find(1)
1652 project = Project.find(1)
1653 project.members << Member.new(:principal => group, :roles => [Role.givable.first])
1653 project.members << Member.new(:principal => group, :roles => [Role.givable.first])
1654
1654
1655 with_settings :issue_group_assignment => '1' do
1655 with_settings :issue_group_assignment => '1' do
1656 @request.session[:user_id] = 2
1656 @request.session[:user_id] = 2
1657 assert_difference 'Issue.count' do
1657 assert_difference 'Issue.count' do
1658 post :create, :project_id => project.id,
1658 post :create, :project_id => project.id,
1659 :issue => {:tracker_id => 3,
1659 :issue => {:tracker_id => 3,
1660 :status_id => 1,
1660 :status_id => 1,
1661 :subject => 'This is the test_new_with_group_assignment issue',
1661 :subject => 'This is the test_new_with_group_assignment issue',
1662 :assigned_to_id => group.id}
1662 :assigned_to_id => group.id}
1663 end
1663 end
1664 end
1664 end
1665 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
1665 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
1666
1666
1667 issue = Issue.find_by_subject('This is the test_new_with_group_assignment issue')
1667 issue = Issue.find_by_subject('This is the test_new_with_group_assignment issue')
1668 assert_not_nil issue
1668 assert_not_nil issue
1669 assert_equal group, issue.assigned_to
1669 assert_equal group, issue.assigned_to
1670 end
1670 end
1671
1671
1672 def test_post_create_without_start_date_and_default_start_date_is_not_creation_date
1672 def test_post_create_without_start_date_and_default_start_date_is_not_creation_date
1673 Setting.default_issue_start_date_to_creation_date = 0
1673 Setting.default_issue_start_date_to_creation_date = 0
1674
1674
1675 @request.session[:user_id] = 2
1675 @request.session[:user_id] = 2
1676 assert_difference 'Issue.count' do
1676 assert_difference 'Issue.count' do
1677 post :create, :project_id => 1,
1677 post :create, :project_id => 1,
1678 :issue => {:tracker_id => 3,
1678 :issue => {:tracker_id => 3,
1679 :status_id => 2,
1679 :status_id => 2,
1680 :subject => 'This is the test_new issue',
1680 :subject => 'This is the test_new issue',
1681 :description => 'This is the description',
1681 :description => 'This is the description',
1682 :priority_id => 5,
1682 :priority_id => 5,
1683 :estimated_hours => '',
1683 :estimated_hours => '',
1684 :custom_field_values => {'2' => 'Value for field 2'}}
1684 :custom_field_values => {'2' => 'Value for field 2'}}
1685 end
1685 end
1686 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
1686 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
1687
1687
1688 issue = Issue.find_by_subject('This is the test_new issue')
1688 issue = Issue.find_by_subject('This is the test_new issue')
1689 assert_not_nil issue
1689 assert_not_nil issue
1690 assert_nil issue.start_date
1690 assert_nil issue.start_date
1691 end
1691 end
1692
1692
1693 def test_post_create_without_start_date_and_default_start_date_is_creation_date
1693 def test_post_create_without_start_date_and_default_start_date_is_creation_date
1694 Setting.default_issue_start_date_to_creation_date = 1
1694 Setting.default_issue_start_date_to_creation_date = 1
1695
1695
1696 @request.session[:user_id] = 2
1696 @request.session[:user_id] = 2
1697 assert_difference 'Issue.count' do
1697 assert_difference 'Issue.count' do
1698 post :create, :project_id => 1,
1698 post :create, :project_id => 1,
1699 :issue => {:tracker_id => 3,
1699 :issue => {:tracker_id => 3,
1700 :status_id => 2,
1700 :status_id => 2,
1701 :subject => 'This is the test_new issue',
1701 :subject => 'This is the test_new issue',
1702 :description => 'This is the description',
1702 :description => 'This is the description',
1703 :priority_id => 5,
1703 :priority_id => 5,
1704 :estimated_hours => '',
1704 :estimated_hours => '',
1705 :custom_field_values => {'2' => 'Value for field 2'}}
1705 :custom_field_values => {'2' => 'Value for field 2'}}
1706 end
1706 end
1707 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
1707 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
1708
1708
1709 issue = Issue.find_by_subject('This is the test_new issue')
1709 issue = Issue.find_by_subject('This is the test_new issue')
1710 assert_not_nil issue
1710 assert_not_nil issue
1711 assert_equal Date.today, issue.start_date
1711 assert_equal Date.today, issue.start_date
1712 end
1712 end
1713
1713
1714 def test_post_create_and_continue
1714 def test_post_create_and_continue
1715 @request.session[:user_id] = 2
1715 @request.session[:user_id] = 2
1716 assert_difference 'Issue.count' do
1716 assert_difference 'Issue.count' do
1717 post :create, :project_id => 1,
1717 post :create, :project_id => 1,
1718 :issue => {:tracker_id => 3, :subject => 'This is first issue', :priority_id => 5},
1718 :issue => {:tracker_id => 3, :subject => 'This is first issue', :priority_id => 5},
1719 :continue => ''
1719 :continue => ''
1720 end
1720 end
1721
1721
1722 issue = Issue.first(:order => 'id DESC')
1722 issue = Issue.first(:order => 'id DESC')
1723 assert_redirected_to :controller => 'issues', :action => 'new', :project_id => 'ecookbook', :issue => {:tracker_id => 3}
1723 assert_redirected_to :controller => 'issues', :action => 'new', :project_id => 'ecookbook', :issue => {:tracker_id => 3}
1724 assert_not_nil flash[:notice], "flash was not set"
1724 assert_not_nil flash[:notice], "flash was not set"
1725 assert_include %|<a href="/issues/#{issue.id}" title="This is first issue">##{issue.id}</a>|, flash[:notice], "issue link not found in the flash message"
1725 assert_include %|<a href="/issues/#{issue.id}" title="This is first issue">##{issue.id}</a>|, flash[:notice], "issue link not found in the flash message"
1726 end
1726 end
1727
1727
1728 def test_post_create_without_custom_fields_param
1728 def test_post_create_without_custom_fields_param
1729 @request.session[:user_id] = 2
1729 @request.session[:user_id] = 2
1730 assert_difference 'Issue.count' do
1730 assert_difference 'Issue.count' do
1731 post :create, :project_id => 1,
1731 post :create, :project_id => 1,
1732 :issue => {:tracker_id => 1,
1732 :issue => {:tracker_id => 1,
1733 :subject => 'This is the test_new issue',
1733 :subject => 'This is the test_new issue',
1734 :description => 'This is the description',
1734 :description => 'This is the description',
1735 :priority_id => 5}
1735 :priority_id => 5}
1736 end
1736 end
1737 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
1737 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
1738 end
1738 end
1739
1739
1740 def test_post_create_with_multi_custom_field
1740 def test_post_create_with_multi_custom_field
1741 field = IssueCustomField.find_by_name('Database')
1741 field = IssueCustomField.find_by_name('Database')
1742 field.update_attribute(:multiple, true)
1742 field.update_attribute(:multiple, true)
1743
1743
1744 @request.session[:user_id] = 2
1744 @request.session[:user_id] = 2
1745 assert_difference 'Issue.count' do
1745 assert_difference 'Issue.count' do
1746 post :create, :project_id => 1,
1746 post :create, :project_id => 1,
1747 :issue => {:tracker_id => 1,
1747 :issue => {:tracker_id => 1,
1748 :subject => 'This is the test_new issue',
1748 :subject => 'This is the test_new issue',
1749 :description => 'This is the description',
1749 :description => 'This is the description',
1750 :priority_id => 5,
1750 :priority_id => 5,
1751 :custom_field_values => {'1' => ['', 'MySQL', 'Oracle']}}
1751 :custom_field_values => {'1' => ['', 'MySQL', 'Oracle']}}
1752 end
1752 end
1753 assert_response 302
1753 assert_response 302
1754 issue = Issue.first(:order => 'id DESC')
1754 issue = Issue.first(:order => 'id DESC')
1755 assert_equal ['MySQL', 'Oracle'], issue.custom_field_value(1).sort
1755 assert_equal ['MySQL', 'Oracle'], issue.custom_field_value(1).sort
1756 end
1756 end
1757
1757
1758 def test_post_create_with_empty_multi_custom_field
1758 def test_post_create_with_empty_multi_custom_field
1759 field = IssueCustomField.find_by_name('Database')
1759 field = IssueCustomField.find_by_name('Database')
1760 field.update_attribute(:multiple, true)
1760 field.update_attribute(:multiple, true)
1761
1761
1762 @request.session[:user_id] = 2
1762 @request.session[:user_id] = 2
1763 assert_difference 'Issue.count' do
1763 assert_difference 'Issue.count' do
1764 post :create, :project_id => 1,
1764 post :create, :project_id => 1,
1765 :issue => {:tracker_id => 1,
1765 :issue => {:tracker_id => 1,
1766 :subject => 'This is the test_new issue',
1766 :subject => 'This is the test_new issue',
1767 :description => 'This is the description',
1767 :description => 'This is the description',
1768 :priority_id => 5,
1768 :priority_id => 5,
1769 :custom_field_values => {'1' => ['']}}
1769 :custom_field_values => {'1' => ['']}}
1770 end
1770 end
1771 assert_response 302
1771 assert_response 302
1772 issue = Issue.first(:order => 'id DESC')
1772 issue = Issue.first(:order => 'id DESC')
1773 assert_equal [''], issue.custom_field_value(1).sort
1773 assert_equal [''], issue.custom_field_value(1).sort
1774 end
1774 end
1775
1775
1776 def test_post_create_with_multi_user_custom_field
1776 def test_post_create_with_multi_user_custom_field
1777 field = IssueCustomField.create!(:name => 'Multi user', :field_format => 'user', :multiple => true,
1777 field = IssueCustomField.create!(:name => 'Multi user', :field_format => 'user', :multiple => true,
1778 :tracker_ids => [1], :is_for_all => true)
1778 :tracker_ids => [1], :is_for_all => true)
1779
1779
1780 @request.session[:user_id] = 2
1780 @request.session[:user_id] = 2
1781 assert_difference 'Issue.count' do
1781 assert_difference 'Issue.count' do
1782 post :create, :project_id => 1,
1782 post :create, :project_id => 1,
1783 :issue => {:tracker_id => 1,
1783 :issue => {:tracker_id => 1,
1784 :subject => 'This is the test_new issue',
1784 :subject => 'This is the test_new issue',
1785 :description => 'This is the description',
1785 :description => 'This is the description',
1786 :priority_id => 5,
1786 :priority_id => 5,
1787 :custom_field_values => {field.id.to_s => ['', '2', '3']}}
1787 :custom_field_values => {field.id.to_s => ['', '2', '3']}}
1788 end
1788 end
1789 assert_response 302
1789 assert_response 302
1790 issue = Issue.first(:order => 'id DESC')
1790 issue = Issue.first(:order => 'id DESC')
1791 assert_equal ['2', '3'], issue.custom_field_value(field).sort
1791 assert_equal ['2', '3'], issue.custom_field_value(field).sort
1792 end
1792 end
1793
1793
1794 def test_post_create_with_required_custom_field_and_without_custom_fields_param
1794 def test_post_create_with_required_custom_field_and_without_custom_fields_param
1795 field = IssueCustomField.find_by_name('Database')
1795 field = IssueCustomField.find_by_name('Database')
1796 field.update_attribute(:is_required, true)
1796 field.update_attribute(:is_required, true)
1797
1797
1798 @request.session[:user_id] = 2
1798 @request.session[:user_id] = 2
1799 assert_no_difference 'Issue.count' do
1799 assert_no_difference 'Issue.count' do
1800 post :create, :project_id => 1,
1800 post :create, :project_id => 1,
1801 :issue => {:tracker_id => 1,
1801 :issue => {:tracker_id => 1,
1802 :subject => 'This is the test_new issue',
1802 :subject => 'This is the test_new issue',
1803 :description => 'This is the description',
1803 :description => 'This is the description',
1804 :priority_id => 5}
1804 :priority_id => 5}
1805 end
1805 end
1806 assert_response :success
1806 assert_response :success
1807 assert_template 'new'
1807 assert_template 'new'
1808 issue = assigns(:issue)
1808 issue = assigns(:issue)
1809 assert_not_nil issue
1809 assert_not_nil issue
1810 assert_error_tag :content => /Database can&#x27;t be blank/
1810 assert_error_tag :content => /Database can&#x27;t be blank/
1811 end
1811 end
1812
1812
1813 def test_create_should_validate_required_fields
1813 def test_create_should_validate_required_fields
1814 cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1814 cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1815 cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1815 cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1816 WorkflowPermission.delete_all
1816 WorkflowPermission.delete_all
1817 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => 'due_date', :rule => 'required')
1817 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => 'due_date', :rule => 'required')
1818 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'required')
1818 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'required')
1819 @request.session[:user_id] = 2
1819 @request.session[:user_id] = 2
1820
1820
1821 assert_no_difference 'Issue.count' do
1821 assert_no_difference 'Issue.count' do
1822 post :create, :project_id => 1, :issue => {
1822 post :create, :project_id => 1, :issue => {
1823 :tracker_id => 2,
1823 :tracker_id => 2,
1824 :status_id => 1,
1824 :status_id => 1,
1825 :subject => 'Test',
1825 :subject => 'Test',
1826 :start_date => '',
1826 :start_date => '',
1827 :due_date => '',
1827 :due_date => '',
1828 :custom_field_values => {cf1.id.to_s => '', cf2.id.to_s => ''}
1828 :custom_field_values => {cf1.id.to_s => '', cf2.id.to_s => ''}
1829 }
1829 }
1830 assert_response :success
1830 assert_response :success
1831 assert_template 'new'
1831 assert_template 'new'
1832 end
1832 end
1833
1833
1834 assert_error_tag :content => /Due date can&#x27;t be blank/i
1834 assert_error_tag :content => /Due date can&#x27;t be blank/i
1835 assert_error_tag :content => /Bar can&#x27;t be blank/i
1835 assert_error_tag :content => /Bar can&#x27;t be blank/i
1836 end
1836 end
1837
1837
1838 def test_create_should_ignore_readonly_fields
1838 def test_create_should_ignore_readonly_fields
1839 cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1839 cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1840 cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1840 cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1841 WorkflowPermission.delete_all
1841 WorkflowPermission.delete_all
1842 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
1842 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
1843 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'readonly')
1843 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'readonly')
1844 @request.session[:user_id] = 2
1844 @request.session[:user_id] = 2
1845
1845
1846 assert_difference 'Issue.count' do
1846 assert_difference 'Issue.count' do
1847 post :create, :project_id => 1, :issue => {
1847 post :create, :project_id => 1, :issue => {
1848 :tracker_id => 2,
1848 :tracker_id => 2,
1849 :status_id => 1,
1849 :status_id => 1,
1850 :subject => 'Test',
1850 :subject => 'Test',
1851 :start_date => '2012-07-14',
1851 :start_date => '2012-07-14',
1852 :due_date => '2012-07-16',
1852 :due_date => '2012-07-16',
1853 :custom_field_values => {cf1.id.to_s => 'value1', cf2.id.to_s => 'value2'}
1853 :custom_field_values => {cf1.id.to_s => 'value1', cf2.id.to_s => 'value2'}
1854 }
1854 }
1855 assert_response 302
1855 assert_response 302
1856 end
1856 end
1857
1857
1858 issue = Issue.first(:order => 'id DESC')
1858 issue = Issue.first(:order => 'id DESC')
1859 assert_equal Date.parse('2012-07-14'), issue.start_date
1859 assert_equal Date.parse('2012-07-14'), issue.start_date
1860 assert_nil issue.due_date
1860 assert_nil issue.due_date
1861 assert_equal 'value1', issue.custom_field_value(cf1)
1861 assert_equal 'value1', issue.custom_field_value(cf1)
1862 assert_nil issue.custom_field_value(cf2)
1862 assert_nil issue.custom_field_value(cf2)
1863 end
1863 end
1864
1864
1865 def test_post_create_with_watchers
1865 def test_post_create_with_watchers
1866 @request.session[:user_id] = 2
1866 @request.session[:user_id] = 2
1867 ActionMailer::Base.deliveries.clear
1867 ActionMailer::Base.deliveries.clear
1868
1868
1869 assert_difference 'Watcher.count', 2 do
1869 assert_difference 'Watcher.count', 2 do
1870 post :create, :project_id => 1,
1870 post :create, :project_id => 1,
1871 :issue => {:tracker_id => 1,
1871 :issue => {:tracker_id => 1,
1872 :subject => 'This is a new issue with watchers',
1872 :subject => 'This is a new issue with watchers',
1873 :description => 'This is the description',
1873 :description => 'This is the description',
1874 :priority_id => 5,
1874 :priority_id => 5,
1875 :watcher_user_ids => ['2', '3']}
1875 :watcher_user_ids => ['2', '3']}
1876 end
1876 end
1877 issue = Issue.find_by_subject('This is a new issue with watchers')
1877 issue = Issue.find_by_subject('This is a new issue with watchers')
1878 assert_not_nil issue
1878 assert_not_nil issue
1879 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
1879 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
1880
1880
1881 # Watchers added
1881 # Watchers added
1882 assert_equal [2, 3], issue.watcher_user_ids.sort
1882 assert_equal [2, 3], issue.watcher_user_ids.sort
1883 assert issue.watched_by?(User.find(3))
1883 assert issue.watched_by?(User.find(3))
1884 # Watchers notified
1884 # Watchers notified
1885 mail = ActionMailer::Base.deliveries.last
1885 mail = ActionMailer::Base.deliveries.last
1886 assert_not_nil mail
1886 assert_not_nil mail
1887 assert [mail.bcc, mail.cc].flatten.include?(User.find(3).mail)
1887 assert [mail.bcc, mail.cc].flatten.include?(User.find(3).mail)
1888 end
1888 end
1889
1889
1890 def test_post_create_subissue
1890 def test_post_create_subissue
1891 @request.session[:user_id] = 2
1891 @request.session[:user_id] = 2
1892
1892
1893 assert_difference 'Issue.count' do
1893 assert_difference 'Issue.count' do
1894 post :create, :project_id => 1,
1894 post :create, :project_id => 1,
1895 :issue => {:tracker_id => 1,
1895 :issue => {:tracker_id => 1,
1896 :subject => 'This is a child issue',
1896 :subject => 'This is a child issue',
1897 :parent_issue_id => 2}
1897 :parent_issue_id => 2}
1898 end
1898 end
1899 issue = Issue.find_by_subject('This is a child issue')
1899 issue = Issue.find_by_subject('This is a child issue')
1900 assert_not_nil issue
1900 assert_not_nil issue
1901 assert_equal Issue.find(2), issue.parent
1901 assert_equal Issue.find(2), issue.parent
1902 end
1902 end
1903
1903
1904 def test_post_create_subissue_with_non_numeric_parent_id
1904 def test_post_create_subissue_with_non_numeric_parent_id
1905 @request.session[:user_id] = 2
1905 @request.session[:user_id] = 2
1906
1906
1907 assert_difference 'Issue.count' do
1907 assert_difference 'Issue.count' do
1908 post :create, :project_id => 1,
1908 post :create, :project_id => 1,
1909 :issue => {:tracker_id => 1,
1909 :issue => {:tracker_id => 1,
1910 :subject => 'This is a child issue',
1910 :subject => 'This is a child issue',
1911 :parent_issue_id => 'ABC'}
1911 :parent_issue_id => 'ABC'}
1912 end
1912 end
1913 issue = Issue.find_by_subject('This is a child issue')
1913 issue = Issue.find_by_subject('This is a child issue')
1914 assert_not_nil issue
1914 assert_not_nil issue
1915 assert_nil issue.parent
1915 assert_nil issue.parent
1916 end
1916 end
1917
1917
1918 def test_post_create_private
1918 def test_post_create_private
1919 @request.session[:user_id] = 2
1919 @request.session[:user_id] = 2
1920
1920
1921 assert_difference 'Issue.count' do
1921 assert_difference 'Issue.count' do
1922 post :create, :project_id => 1,
1922 post :create, :project_id => 1,
1923 :issue => {:tracker_id => 1,
1923 :issue => {:tracker_id => 1,
1924 :subject => 'This is a private issue',
1924 :subject => 'This is a private issue',
1925 :is_private => '1'}
1925 :is_private => '1'}
1926 end
1926 end
1927 issue = Issue.first(:order => 'id DESC')
1927 issue = Issue.first(:order => 'id DESC')
1928 assert issue.is_private?
1928 assert issue.is_private?
1929 end
1929 end
1930
1930
1931 def test_post_create_private_with_set_own_issues_private_permission
1931 def test_post_create_private_with_set_own_issues_private_permission
1932 role = Role.find(1)
1932 role = Role.find(1)
1933 role.remove_permission! :set_issues_private
1933 role.remove_permission! :set_issues_private
1934 role.add_permission! :set_own_issues_private
1934 role.add_permission! :set_own_issues_private
1935
1935
1936 @request.session[:user_id] = 2
1936 @request.session[:user_id] = 2
1937
1937
1938 assert_difference 'Issue.count' do
1938 assert_difference 'Issue.count' do
1939 post :create, :project_id => 1,
1939 post :create, :project_id => 1,
1940 :issue => {:tracker_id => 1,
1940 :issue => {:tracker_id => 1,
1941 :subject => 'This is a private issue',
1941 :subject => 'This is a private issue',
1942 :is_private => '1'}
1942 :is_private => '1'}
1943 end
1943 end
1944 issue = Issue.first(:order => 'id DESC')
1944 issue = Issue.first(:order => 'id DESC')
1945 assert issue.is_private?
1945 assert issue.is_private?
1946 end
1946 end
1947
1947
1948 def test_post_create_should_send_a_notification
1948 def test_post_create_should_send_a_notification
1949 ActionMailer::Base.deliveries.clear
1949 ActionMailer::Base.deliveries.clear
1950 @request.session[:user_id] = 2
1950 @request.session[:user_id] = 2
1951 assert_difference 'Issue.count' do
1951 assert_difference 'Issue.count' do
1952 post :create, :project_id => 1,
1952 post :create, :project_id => 1,
1953 :issue => {:tracker_id => 3,
1953 :issue => {:tracker_id => 3,
1954 :subject => 'This is the test_new issue',
1954 :subject => 'This is the test_new issue',
1955 :description => 'This is the description',
1955 :description => 'This is the description',
1956 :priority_id => 5,
1956 :priority_id => 5,
1957 :estimated_hours => '',
1957 :estimated_hours => '',
1958 :custom_field_values => {'2' => 'Value for field 2'}}
1958 :custom_field_values => {'2' => 'Value for field 2'}}
1959 end
1959 end
1960 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
1960 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
1961
1961
1962 assert_equal 1, ActionMailer::Base.deliveries.size
1962 assert_equal 1, ActionMailer::Base.deliveries.size
1963 end
1963 end
1964
1964
1965 def test_post_create_should_preserve_fields_values_on_validation_failure
1965 def test_post_create_should_preserve_fields_values_on_validation_failure
1966 @request.session[:user_id] = 2
1966 @request.session[:user_id] = 2
1967 post :create, :project_id => 1,
1967 post :create, :project_id => 1,
1968 :issue => {:tracker_id => 1,
1968 :issue => {:tracker_id => 1,
1969 # empty subject
1969 # empty subject
1970 :subject => '',
1970 :subject => '',
1971 :description => 'This is a description',
1971 :description => 'This is a description',
1972 :priority_id => 6,
1972 :priority_id => 6,
1973 :custom_field_values => {'1' => 'Oracle', '2' => 'Value for field 2'}}
1973 :custom_field_values => {'1' => 'Oracle', '2' => 'Value for field 2'}}
1974 assert_response :success
1974 assert_response :success
1975 assert_template 'new'
1975 assert_template 'new'
1976
1976
1977 assert_tag :textarea, :attributes => { :name => 'issue[description]' },
1977 assert_tag :textarea, :attributes => { :name => 'issue[description]' },
1978 :content => "\nThis is a description"
1978 :content => "\nThis is a description"
1979 assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
1979 assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
1980 :child => { :tag => 'option', :attributes => { :selected => 'selected',
1980 :child => { :tag => 'option', :attributes => { :selected => 'selected',
1981 :value => '6' },
1981 :value => '6' },
1982 :content => 'High' }
1982 :content => 'High' }
1983 # Custom fields
1983 # Custom fields
1984 assert_tag :select, :attributes => { :name => 'issue[custom_field_values][1]' },
1984 assert_tag :select, :attributes => { :name => 'issue[custom_field_values][1]' },
1985 :child => { :tag => 'option', :attributes => { :selected => 'selected',
1985 :child => { :tag => 'option', :attributes => { :selected => 'selected',
1986 :value => 'Oracle' },
1986 :value => 'Oracle' },
1987 :content => 'Oracle' }
1987 :content => 'Oracle' }
1988 assert_tag :input, :attributes => { :name => 'issue[custom_field_values][2]',
1988 assert_tag :input, :attributes => { :name => 'issue[custom_field_values][2]',
1989 :value => 'Value for field 2'}
1989 :value => 'Value for field 2'}
1990 end
1990 end
1991
1991
1992 def test_post_create_with_failure_should_preserve_watchers
1992 def test_post_create_with_failure_should_preserve_watchers
1993 assert !User.find(8).member_of?(Project.find(1))
1993 assert !User.find(8).member_of?(Project.find(1))
1994
1994
1995 @request.session[:user_id] = 2
1995 @request.session[:user_id] = 2
1996 post :create, :project_id => 1,
1996 post :create, :project_id => 1,
1997 :issue => {:tracker_id => 1,
1997 :issue => {:tracker_id => 1,
1998 :watcher_user_ids => ['3', '8']}
1998 :watcher_user_ids => ['3', '8']}
1999 assert_response :success
1999 assert_response :success
2000 assert_template 'new'
2000 assert_template 'new'
2001
2001
2002 assert_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]', :value => '2', :checked => nil}
2002 assert_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]', :value => '2', :checked => nil}
2003 assert_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]', :value => '3', :checked => 'checked'}
2003 assert_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]', :value => '3', :checked => 'checked'}
2004 assert_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]', :value => '8', :checked => 'checked'}
2004 assert_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]', :value => '8', :checked => 'checked'}
2005 end
2005 end
2006
2006
2007 def test_post_create_should_ignore_non_safe_attributes
2007 def test_post_create_should_ignore_non_safe_attributes
2008 @request.session[:user_id] = 2
2008 @request.session[:user_id] = 2
2009 assert_nothing_raised do
2009 assert_nothing_raised do
2010 post :create, :project_id => 1, :issue => { :tracker => "A param can not be a Tracker" }
2010 post :create, :project_id => 1, :issue => { :tracker => "A param can not be a Tracker" }
2011 end
2011 end
2012 end
2012 end
2013
2013
2014 def test_post_create_with_attachment
2014 def test_post_create_with_attachment
2015 set_tmp_attachments_directory
2015 set_tmp_attachments_directory
2016 @request.session[:user_id] = 2
2016 @request.session[:user_id] = 2
2017
2017
2018 assert_difference 'Issue.count' do
2018 assert_difference 'Issue.count' do
2019 assert_difference 'Attachment.count' do
2019 assert_difference 'Attachment.count' do
2020 post :create, :project_id => 1,
2020 post :create, :project_id => 1,
2021 :issue => { :tracker_id => '1', :subject => 'With attachment' },
2021 :issue => { :tracker_id => '1', :subject => 'With attachment' },
2022 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
2022 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
2023 end
2023 end
2024 end
2024 end
2025
2025
2026 issue = Issue.first(:order => 'id DESC')
2026 issue = Issue.first(:order => 'id DESC')
2027 attachment = Attachment.first(:order => 'id DESC')
2027 attachment = Attachment.first(:order => 'id DESC')
2028
2028
2029 assert_equal issue, attachment.container
2029 assert_equal issue, attachment.container
2030 assert_equal 2, attachment.author_id
2030 assert_equal 2, attachment.author_id
2031 assert_equal 'testfile.txt', attachment.filename
2031 assert_equal 'testfile.txt', attachment.filename
2032 assert_equal 'text/plain', attachment.content_type
2032 assert_equal 'text/plain', attachment.content_type
2033 assert_equal 'test file', attachment.description
2033 assert_equal 'test file', attachment.description
2034 assert_equal 59, attachment.filesize
2034 assert_equal 59, attachment.filesize
2035 assert File.exists?(attachment.diskfile)
2035 assert File.exists?(attachment.diskfile)
2036 assert_equal 59, File.size(attachment.diskfile)
2036 assert_equal 59, File.size(attachment.diskfile)
2037 end
2037 end
2038
2038
2039 def test_post_create_with_failure_should_save_attachments
2039 def test_post_create_with_failure_should_save_attachments
2040 set_tmp_attachments_directory
2040 set_tmp_attachments_directory
2041 @request.session[:user_id] = 2
2041 @request.session[:user_id] = 2
2042
2042
2043 assert_no_difference 'Issue.count' do
2043 assert_no_difference 'Issue.count' do
2044 assert_difference 'Attachment.count' do
2044 assert_difference 'Attachment.count' do
2045 post :create, :project_id => 1,
2045 post :create, :project_id => 1,
2046 :issue => { :tracker_id => '1', :subject => '' },
2046 :issue => { :tracker_id => '1', :subject => '' },
2047 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
2047 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
2048 assert_response :success
2048 assert_response :success
2049 assert_template 'new'
2049 assert_template 'new'
2050 end
2050 end
2051 end
2051 end
2052
2052
2053 attachment = Attachment.first(:order => 'id DESC')
2053 attachment = Attachment.first(:order => 'id DESC')
2054 assert_equal 'testfile.txt', attachment.filename
2054 assert_equal 'testfile.txt', attachment.filename
2055 assert File.exists?(attachment.diskfile)
2055 assert File.exists?(attachment.diskfile)
2056 assert_nil attachment.container
2056 assert_nil attachment.container
2057
2057
2058 assert_tag 'input', :attributes => {:name => 'attachments[p0][token]', :value => attachment.token}
2058 assert_tag 'input', :attributes => {:name => 'attachments[p0][token]', :value => attachment.token}
2059 assert_tag 'span', :content => /testfile.txt/
2059 assert_tag 'span', :content => /testfile.txt/
2060 end
2060 end
2061
2061
2062 def test_post_create_with_failure_should_keep_saved_attachments
2062 def test_post_create_with_failure_should_keep_saved_attachments
2063 set_tmp_attachments_directory
2063 set_tmp_attachments_directory
2064 attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2)
2064 attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2)
2065 @request.session[:user_id] = 2
2065 @request.session[:user_id] = 2
2066
2066
2067 assert_no_difference 'Issue.count' do
2067 assert_no_difference 'Issue.count' do
2068 assert_no_difference 'Attachment.count' do
2068 assert_no_difference 'Attachment.count' do
2069 post :create, :project_id => 1,
2069 post :create, :project_id => 1,
2070 :issue => { :tracker_id => '1', :subject => '' },
2070 :issue => { :tracker_id => '1', :subject => '' },
2071 :attachments => {'p0' => {'token' => attachment.token}}
2071 :attachments => {'p0' => {'token' => attachment.token}}
2072 assert_response :success
2072 assert_response :success
2073 assert_template 'new'
2073 assert_template 'new'
2074 end
2074 end
2075 end
2075 end
2076
2076
2077 assert_tag 'input', :attributes => {:name => 'attachments[p0][token]', :value => attachment.token}
2077 assert_tag 'input', :attributes => {:name => 'attachments[p0][token]', :value => attachment.token}
2078 assert_tag 'span', :content => /testfile.txt/
2078 assert_tag 'span', :content => /testfile.txt/
2079 end
2079 end
2080
2080
2081 def test_post_create_should_attach_saved_attachments
2081 def test_post_create_should_attach_saved_attachments
2082 set_tmp_attachments_directory
2082 set_tmp_attachments_directory
2083 attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2)
2083 attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2)
2084 @request.session[:user_id] = 2
2084 @request.session[:user_id] = 2
2085
2085
2086 assert_difference 'Issue.count' do
2086 assert_difference 'Issue.count' do
2087 assert_no_difference 'Attachment.count' do
2087 assert_no_difference 'Attachment.count' do
2088 post :create, :project_id => 1,
2088 post :create, :project_id => 1,
2089 :issue => { :tracker_id => '1', :subject => 'Saved attachments' },
2089 :issue => { :tracker_id => '1', :subject => 'Saved attachments' },
2090 :attachments => {'p0' => {'token' => attachment.token}}
2090 :attachments => {'p0' => {'token' => attachment.token}}
2091 assert_response 302
2091 assert_response 302
2092 end
2092 end
2093 end
2093 end
2094
2094
2095 issue = Issue.first(:order => 'id DESC')
2095 issue = Issue.first(:order => 'id DESC')
2096 assert_equal 1, issue.attachments.count
2096 assert_equal 1, issue.attachments.count
2097
2097
2098 attachment.reload
2098 attachment.reload
2099 assert_equal issue, attachment.container
2099 assert_equal issue, attachment.container
2100 end
2100 end
2101
2101
2102 context "without workflow privilege" do
2102 context "without workflow privilege" do
2103 setup do
2103 setup do
2104 WorkflowTransition.delete_all(["role_id = ?", Role.anonymous.id])
2104 WorkflowTransition.delete_all(["role_id = ?", Role.anonymous.id])
2105 Role.anonymous.add_permission! :add_issues, :add_issue_notes
2105 Role.anonymous.add_permission! :add_issues, :add_issue_notes
2106 end
2106 end
2107
2107
2108 context "#new" do
2108 context "#new" do
2109 should "propose default status only" do
2109 should "propose default status only" do
2110 get :new, :project_id => 1
2110 get :new, :project_id => 1
2111 assert_response :success
2111 assert_response :success
2112 assert_template 'new'
2112 assert_template 'new'
2113 assert_tag :tag => 'select',
2113 assert_tag :tag => 'select',
2114 :attributes => {:name => 'issue[status_id]'},
2114 :attributes => {:name => 'issue[status_id]'},
2115 :children => {:count => 1},
2115 :children => {:count => 1},
2116 :child => {:tag => 'option', :attributes => {:value => IssueStatus.default.id.to_s}}
2116 :child => {:tag => 'option', :attributes => {:value => IssueStatus.default.id.to_s}}
2117 end
2117 end
2118
2118
2119 should "accept default status" do
2119 should "accept default status" do
2120 assert_difference 'Issue.count' do
2120 assert_difference 'Issue.count' do
2121 post :create, :project_id => 1,
2121 post :create, :project_id => 1,
2122 :issue => {:tracker_id => 1,
2122 :issue => {:tracker_id => 1,
2123 :subject => 'This is an issue',
2123 :subject => 'This is an issue',
2124 :status_id => 1}
2124 :status_id => 1}
2125 end
2125 end
2126 issue = Issue.last(:order => 'id')
2126 issue = Issue.last(:order => 'id')
2127 assert_equal IssueStatus.default, issue.status
2127 assert_equal IssueStatus.default, issue.status
2128 end
2128 end
2129
2129
2130 should "ignore unauthorized status" do
2130 should "ignore unauthorized status" do
2131 assert_difference 'Issue.count' do
2131 assert_difference 'Issue.count' do
2132 post :create, :project_id => 1,
2132 post :create, :project_id => 1,
2133 :issue => {:tracker_id => 1,
2133 :issue => {:tracker_id => 1,
2134 :subject => 'This is an issue',
2134 :subject => 'This is an issue',
2135 :status_id => 3}
2135 :status_id => 3}
2136 end
2136 end
2137 issue = Issue.last(:order => 'id')
2137 issue = Issue.last(:order => 'id')
2138 assert_equal IssueStatus.default, issue.status
2138 assert_equal IssueStatus.default, issue.status
2139 end
2139 end
2140 end
2140 end
2141
2141
2142 context "#update" do
2142 context "#update" do
2143 should "ignore status change" do
2143 should "ignore status change" do
2144 assert_difference 'Journal.count' do
2144 assert_difference 'Journal.count' do
2145 put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 3}
2145 put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 3}
2146 end
2146 end
2147 assert_equal 1, Issue.find(1).status_id
2147 assert_equal 1, Issue.find(1).status_id
2148 end
2148 end
2149
2149
2150 should "ignore attributes changes" do
2150 should "ignore attributes changes" do
2151 assert_difference 'Journal.count' do
2151 assert_difference 'Journal.count' do
2152 put :update, :id => 1, :notes => 'just trying', :issue => {:subject => 'changed', :assigned_to_id => 2}
2152 put :update, :id => 1, :notes => 'just trying', :issue => {:subject => 'changed', :assigned_to_id => 2}
2153 end
2153 end
2154 issue = Issue.find(1)
2154 issue = Issue.find(1)
2155 assert_equal "Can't print recipes", issue.subject
2155 assert_equal "Can't print recipes", issue.subject
2156 assert_nil issue.assigned_to
2156 assert_nil issue.assigned_to
2157 end
2157 end
2158 end
2158 end
2159 end
2159 end
2160
2160
2161 context "with workflow privilege" do
2161 context "with workflow privilege" do
2162 setup do
2162 setup do
2163 WorkflowTransition.delete_all(["role_id = ?", Role.anonymous.id])
2163 WorkflowTransition.delete_all(["role_id = ?", Role.anonymous.id])
2164 WorkflowTransition.create!(:role => Role.anonymous, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3)
2164 WorkflowTransition.create!(:role => Role.anonymous, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3)
2165 WorkflowTransition.create!(:role => Role.anonymous, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4)
2165 WorkflowTransition.create!(:role => Role.anonymous, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4)
2166 Role.anonymous.add_permission! :add_issues, :add_issue_notes
2166 Role.anonymous.add_permission! :add_issues, :add_issue_notes
2167 end
2167 end
2168
2168
2169 context "#update" do
2169 context "#update" do
2170 should "accept authorized status" do
2170 should "accept authorized status" do
2171 assert_difference 'Journal.count' do
2171 assert_difference 'Journal.count' do
2172 put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 3}
2172 put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 3}
2173 end
2173 end
2174 assert_equal 3, Issue.find(1).status_id
2174 assert_equal 3, Issue.find(1).status_id
2175 end
2175 end
2176
2176
2177 should "ignore unauthorized status" do
2177 should "ignore unauthorized status" do
2178 assert_difference 'Journal.count' do
2178 assert_difference 'Journal.count' do
2179 put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 2}
2179 put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 2}
2180 end
2180 end
2181 assert_equal 1, Issue.find(1).status_id
2181 assert_equal 1, Issue.find(1).status_id
2182 end
2182 end
2183
2183
2184 should "accept authorized attributes changes" do
2184 should "accept authorized attributes changes" do
2185 assert_difference 'Journal.count' do
2185 assert_difference 'Journal.count' do
2186 put :update, :id => 1, :notes => 'just trying', :issue => {:assigned_to_id => 2}
2186 put :update, :id => 1, :notes => 'just trying', :issue => {:assigned_to_id => 2}
2187 end
2187 end
2188 issue = Issue.find(1)
2188 issue = Issue.find(1)
2189 assert_equal 2, issue.assigned_to_id
2189 assert_equal 2, issue.assigned_to_id
2190 end
2190 end
2191
2191
2192 should "ignore unauthorized attributes changes" do
2192 should "ignore unauthorized attributes changes" do
2193 assert_difference 'Journal.count' do
2193 assert_difference 'Journal.count' do
2194 put :update, :id => 1, :notes => 'just trying', :issue => {:subject => 'changed'}
2194 put :update, :id => 1, :notes => 'just trying', :issue => {:subject => 'changed'}
2195 end
2195 end
2196 issue = Issue.find(1)
2196 issue = Issue.find(1)
2197 assert_equal "Can't print recipes", issue.subject
2197 assert_equal "Can't print recipes", issue.subject
2198 end
2198 end
2199 end
2199 end
2200
2200
2201 context "and :edit_issues permission" do
2201 context "and :edit_issues permission" do
2202 setup do
2202 setup do
2203 Role.anonymous.add_permission! :add_issues, :edit_issues
2203 Role.anonymous.add_permission! :add_issues, :edit_issues
2204 end
2204 end
2205
2205
2206 should "accept authorized status" do
2206 should "accept authorized status" do
2207 assert_difference 'Journal.count' do
2207 assert_difference 'Journal.count' do
2208 put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 3}
2208 put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 3}
2209 end
2209 end
2210 assert_equal 3, Issue.find(1).status_id
2210 assert_equal 3, Issue.find(1).status_id
2211 end
2211 end
2212
2212
2213 should "ignore unauthorized status" do
2213 should "ignore unauthorized status" do
2214 assert_difference 'Journal.count' do
2214 assert_difference 'Journal.count' do
2215 put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 2}
2215 put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 2}
2216 end
2216 end
2217 assert_equal 1, Issue.find(1).status_id
2217 assert_equal 1, Issue.find(1).status_id
2218 end
2218 end
2219
2219
2220 should "accept authorized attributes changes" do
2220 should "accept authorized attributes changes" do
2221 assert_difference 'Journal.count' do
2221 assert_difference 'Journal.count' do
2222 put :update, :id => 1, :notes => 'just trying', :issue => {:subject => 'changed', :assigned_to_id => 2}
2222 put :update, :id => 1, :notes => 'just trying', :issue => {:subject => 'changed', :assigned_to_id => 2}
2223 end
2223 end
2224 issue = Issue.find(1)
2224 issue = Issue.find(1)
2225 assert_equal "changed", issue.subject
2225 assert_equal "changed", issue.subject
2226 assert_equal 2, issue.assigned_to_id
2226 assert_equal 2, issue.assigned_to_id
2227 end
2227 end
2228 end
2228 end
2229 end
2229 end
2230
2230
2231 def test_new_as_copy
2231 def test_new_as_copy
2232 @request.session[:user_id] = 2
2232 @request.session[:user_id] = 2
2233 get :new, :project_id => 1, :copy_from => 1
2233 get :new, :project_id => 1, :copy_from => 1
2234
2234
2235 assert_response :success
2235 assert_response :success
2236 assert_template 'new'
2236 assert_template 'new'
2237
2237
2238 assert_not_nil assigns(:issue)
2238 assert_not_nil assigns(:issue)
2239 orig = Issue.find(1)
2239 orig = Issue.find(1)
2240 assert_equal 1, assigns(:issue).project_id
2240 assert_equal 1, assigns(:issue).project_id
2241 assert_equal orig.subject, assigns(:issue).subject
2241 assert_equal orig.subject, assigns(:issue).subject
2242 assert assigns(:issue).copy?
2242 assert assigns(:issue).copy?
2243
2243
2244 assert_tag 'form', :attributes => {:id => 'issue-form', :action => '/projects/ecookbook/issues'}
2244 assert_tag 'form', :attributes => {:id => 'issue-form', :action => '/projects/ecookbook/issues'}
2245 assert_tag 'select', :attributes => {:name => 'issue[project_id]'}
2245 assert_tag 'select', :attributes => {:name => 'issue[project_id]'}
2246 assert_tag 'select', :attributes => {:name => 'issue[project_id]'},
2246 assert_tag 'select', :attributes => {:name => 'issue[project_id]'},
2247 :child => {:tag => 'option', :attributes => {:value => '1', :selected => 'selected'}, :content => 'eCookbook'}
2247 :child => {:tag => 'option', :attributes => {:value => '1', :selected => 'selected'}, :content => 'eCookbook'}
2248 assert_tag 'select', :attributes => {:name => 'issue[project_id]'},
2248 assert_tag 'select', :attributes => {:name => 'issue[project_id]'},
2249 :child => {:tag => 'option', :attributes => {:value => '2', :selected => nil}, :content => 'OnlineStore'}
2249 :child => {:tag => 'option', :attributes => {:value => '2', :selected => nil}, :content => 'OnlineStore'}
2250 assert_tag 'input', :attributes => {:name => 'copy_from', :value => '1'}
2250 assert_tag 'input', :attributes => {:name => 'copy_from', :value => '1'}
2251 end
2251 end
2252
2252
2253 def test_new_as_copy_with_attachments_should_show_copy_attachments_checkbox
2253 def test_new_as_copy_with_attachments_should_show_copy_attachments_checkbox
2254 @request.session[:user_id] = 2
2254 @request.session[:user_id] = 2
2255 issue = Issue.find(3)
2255 issue = Issue.find(3)
2256 assert issue.attachments.count > 0
2256 assert issue.attachments.count > 0
2257 get :new, :project_id => 1, :copy_from => 3
2257 get :new, :project_id => 1, :copy_from => 3
2258
2258
2259 assert_tag 'input', :attributes => {:name => 'copy_attachments', :type => 'checkbox', :checked => 'checked', :value => '1'}
2259 assert_tag 'input', :attributes => {:name => 'copy_attachments', :type => 'checkbox', :checked => 'checked', :value => '1'}
2260 end
2260 end
2261
2261
2262 def test_new_as_copy_without_attachments_should_not_show_copy_attachments_checkbox
2262 def test_new_as_copy_without_attachments_should_not_show_copy_attachments_checkbox
2263 @request.session[:user_id] = 2
2263 @request.session[:user_id] = 2
2264 issue = Issue.find(3)
2264 issue = Issue.find(3)
2265 issue.attachments.delete_all
2265 issue.attachments.delete_all
2266 get :new, :project_id => 1, :copy_from => 3
2266 get :new, :project_id => 1, :copy_from => 3
2267
2267
2268 assert_no_tag 'input', :attributes => {:name => 'copy_attachments', :type => 'checkbox', :checked => 'checked', :value => '1'}
2268 assert_no_tag 'input', :attributes => {:name => 'copy_attachments', :type => 'checkbox', :checked => 'checked', :value => '1'}
2269 end
2269 end
2270
2270
2271 def test_new_as_copy_with_subtasks_should_show_copy_subtasks_checkbox
2271 def test_new_as_copy_with_subtasks_should_show_copy_subtasks_checkbox
2272 @request.session[:user_id] = 2
2272 @request.session[:user_id] = 2
2273 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
2273 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
2274 get :new, :project_id => 1, :copy_from => issue.id
2274 get :new, :project_id => 1, :copy_from => issue.id
2275
2275
2276 assert_select 'input[type=checkbox][name=copy_subtasks][checked=checked][value=1]'
2276 assert_select 'input[type=checkbox][name=copy_subtasks][checked=checked][value=1]'
2277 end
2277 end
2278
2278
2279 def test_new_as_copy_with_invalid_issue_should_respond_with_404
2279 def test_new_as_copy_with_invalid_issue_should_respond_with_404
2280 @request.session[:user_id] = 2
2280 @request.session[:user_id] = 2
2281 get :new, :project_id => 1, :copy_from => 99999
2281 get :new, :project_id => 1, :copy_from => 99999
2282 assert_response 404
2282 assert_response 404
2283 end
2283 end
2284
2284
2285 def test_create_as_copy_on_different_project
2285 def test_create_as_copy_on_different_project
2286 @request.session[:user_id] = 2
2286 @request.session[:user_id] = 2
2287 assert_difference 'Issue.count' do
2287 assert_difference 'Issue.count' do
2288 post :create, :project_id => 1, :copy_from => 1,
2288 post :create, :project_id => 1, :copy_from => 1,
2289 :issue => {:project_id => '2', :tracker_id => '3', :status_id => '1', :subject => 'Copy'}
2289 :issue => {:project_id => '2', :tracker_id => '3', :status_id => '1', :subject => 'Copy'}
2290
2290
2291 assert_not_nil assigns(:issue)
2291 assert_not_nil assigns(:issue)
2292 assert assigns(:issue).copy?
2292 assert assigns(:issue).copy?
2293 end
2293 end
2294 issue = Issue.first(:order => 'id DESC')
2294 issue = Issue.first(:order => 'id DESC')
2295 assert_redirected_to "/issues/#{issue.id}"
2295 assert_redirected_to "/issues/#{issue.id}"
2296
2296
2297 assert_equal 2, issue.project_id
2297 assert_equal 2, issue.project_id
2298 assert_equal 3, issue.tracker_id
2298 assert_equal 3, issue.tracker_id
2299 assert_equal 'Copy', issue.subject
2299 assert_equal 'Copy', issue.subject
2300 end
2300 end
2301
2301
2302 def test_create_as_copy_should_copy_attachments
2302 def test_create_as_copy_should_copy_attachments
2303 @request.session[:user_id] = 2
2303 @request.session[:user_id] = 2
2304 issue = Issue.find(3)
2304 issue = Issue.find(3)
2305 count = issue.attachments.count
2305 count = issue.attachments.count
2306 assert count > 0
2306 assert count > 0
2307
2307
2308 assert_difference 'Issue.count' do
2308 assert_difference 'Issue.count' do
2309 assert_difference 'Attachment.count', count do
2309 assert_difference 'Attachment.count', count do
2310 assert_no_difference 'Journal.count' do
2310 assert_no_difference 'Journal.count' do
2311 post :create, :project_id => 1, :copy_from => 3,
2311 post :create, :project_id => 1, :copy_from => 3,
2312 :issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with attachments'},
2312 :issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with attachments'},
2313 :copy_attachments => '1'
2313 :copy_attachments => '1'
2314 end
2314 end
2315 end
2315 end
2316 end
2316 end
2317 copy = Issue.first(:order => 'id DESC')
2317 copy = Issue.first(:order => 'id DESC')
2318 assert_equal count, copy.attachments.count
2318 assert_equal count, copy.attachments.count
2319 assert_equal issue.attachments.map(&:filename).sort, copy.attachments.map(&:filename).sort
2319 assert_equal issue.attachments.map(&:filename).sort, copy.attachments.map(&:filename).sort
2320 end
2320 end
2321
2321
2322 def test_create_as_copy_without_copy_attachments_option_should_not_copy_attachments
2322 def test_create_as_copy_without_copy_attachments_option_should_not_copy_attachments
2323 @request.session[:user_id] = 2
2323 @request.session[:user_id] = 2
2324 issue = Issue.find(3)
2324 issue = Issue.find(3)
2325 count = issue.attachments.count
2325 count = issue.attachments.count
2326 assert count > 0
2326 assert count > 0
2327
2327
2328 assert_difference 'Issue.count' do
2328 assert_difference 'Issue.count' do
2329 assert_no_difference 'Attachment.count' do
2329 assert_no_difference 'Attachment.count' do
2330 assert_no_difference 'Journal.count' do
2330 assert_no_difference 'Journal.count' do
2331 post :create, :project_id => 1, :copy_from => 3,
2331 post :create, :project_id => 1, :copy_from => 3,
2332 :issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with attachments'}
2332 :issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with attachments'}
2333 end
2333 end
2334 end
2334 end
2335 end
2335 end
2336 copy = Issue.first(:order => 'id DESC')
2336 copy = Issue.first(:order => 'id DESC')
2337 assert_equal 0, copy.attachments.count
2337 assert_equal 0, copy.attachments.count
2338 end
2338 end
2339
2339
2340 def test_create_as_copy_with_attachments_should_add_new_files
2340 def test_create_as_copy_with_attachments_should_add_new_files
2341 @request.session[:user_id] = 2
2341 @request.session[:user_id] = 2
2342 issue = Issue.find(3)
2342 issue = Issue.find(3)
2343 count = issue.attachments.count
2343 count = issue.attachments.count
2344 assert count > 0
2344 assert count > 0
2345
2345
2346 assert_difference 'Issue.count' do
2346 assert_difference 'Issue.count' do
2347 assert_difference 'Attachment.count', count + 1 do
2347 assert_difference 'Attachment.count', count + 1 do
2348 assert_no_difference 'Journal.count' do
2348 assert_no_difference 'Journal.count' do
2349 post :create, :project_id => 1, :copy_from => 3,
2349 post :create, :project_id => 1, :copy_from => 3,
2350 :issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with attachments'},
2350 :issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with attachments'},
2351 :copy_attachments => '1',
2351 :copy_attachments => '1',
2352 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
2352 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
2353 end
2353 end
2354 end
2354 end
2355 end
2355 end
2356 copy = Issue.first(:order => 'id DESC')
2356 copy = Issue.first(:order => 'id DESC')
2357 assert_equal count + 1, copy.attachments.count
2357 assert_equal count + 1, copy.attachments.count
2358 end
2358 end
2359
2359
2360 def test_create_as_copy_should_add_relation_with_copied_issue
2361 @request.session[:user_id] = 2
2362
2363 assert_difference 'Issue.count' do
2364 assert_difference 'IssueRelation.count' do
2365 post :create, :project_id => 1, :copy_from => 1,
2366 :issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy'}
2367 end
2368 end
2369 copy = Issue.first(:order => 'id DESC')
2370 assert_equal 1, copy.relations.size
2371 end
2372
2360 def test_create_as_copy_should_copy_subtasks
2373 def test_create_as_copy_should_copy_subtasks
2361 @request.session[:user_id] = 2
2374 @request.session[:user_id] = 2
2362 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
2375 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
2363 count = issue.descendants.count
2376 count = issue.descendants.count
2364
2377
2365 assert_difference 'Issue.count', count+1 do
2378 assert_difference 'Issue.count', count+1 do
2366 assert_no_difference 'Journal.count' do
2379 assert_no_difference 'Journal.count' do
2367 post :create, :project_id => 1, :copy_from => issue.id,
2380 post :create, :project_id => 1, :copy_from => issue.id,
2368 :issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with subtasks'},
2381 :issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with subtasks'},
2369 :copy_subtasks => '1'
2382 :copy_subtasks => '1'
2370 end
2383 end
2371 end
2384 end
2372 copy = Issue.where(:parent_id => nil).first(:order => 'id DESC')
2385 copy = Issue.where(:parent_id => nil).first(:order => 'id DESC')
2373 assert_equal count, copy.descendants.count
2386 assert_equal count, copy.descendants.count
2374 assert_equal issue.descendants.map(&:subject).sort, copy.descendants.map(&:subject).sort
2387 assert_equal issue.descendants.map(&:subject).sort, copy.descendants.map(&:subject).sort
2375 end
2388 end
2376
2389
2377 def test_create_as_copy_without_copy_subtasks_option_should_not_copy_subtasks
2390 def test_create_as_copy_without_copy_subtasks_option_should_not_copy_subtasks
2378 @request.session[:user_id] = 2
2391 @request.session[:user_id] = 2
2379 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
2392 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
2380
2393
2381 assert_difference 'Issue.count', 1 do
2394 assert_difference 'Issue.count', 1 do
2382 assert_no_difference 'Journal.count' do
2395 assert_no_difference 'Journal.count' do
2383 post :create, :project_id => 1, :copy_from => 3,
2396 post :create, :project_id => 1, :copy_from => 3,
2384 :issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with subtasks'}
2397 :issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with subtasks'}
2385 end
2398 end
2386 end
2399 end
2387 copy = Issue.where(:parent_id => nil).first(:order => 'id DESC')
2400 copy = Issue.where(:parent_id => nil).first(:order => 'id DESC')
2388 assert_equal 0, copy.descendants.count
2401 assert_equal 0, copy.descendants.count
2389 end
2402 end
2390
2403
2391 def test_create_as_copy_with_failure
2404 def test_create_as_copy_with_failure
2392 @request.session[:user_id] = 2
2405 @request.session[:user_id] = 2
2393 post :create, :project_id => 1, :copy_from => 1,
2406 post :create, :project_id => 1, :copy_from => 1,
2394 :issue => {:project_id => '2', :tracker_id => '3', :status_id => '1', :subject => ''}
2407 :issue => {:project_id => '2', :tracker_id => '3', :status_id => '1', :subject => ''}
2395
2408
2396 assert_response :success
2409 assert_response :success
2397 assert_template 'new'
2410 assert_template 'new'
2398
2411
2399 assert_not_nil assigns(:issue)
2412 assert_not_nil assigns(:issue)
2400 assert assigns(:issue).copy?
2413 assert assigns(:issue).copy?
2401
2414
2402 assert_tag 'form', :attributes => {:id => 'issue-form', :action => '/projects/ecookbook/issues'}
2415 assert_tag 'form', :attributes => {:id => 'issue-form', :action => '/projects/ecookbook/issues'}
2403 assert_tag 'select', :attributes => {:name => 'issue[project_id]'}
2416 assert_tag 'select', :attributes => {:name => 'issue[project_id]'}
2404 assert_tag 'select', :attributes => {:name => 'issue[project_id]'},
2417 assert_tag 'select', :attributes => {:name => 'issue[project_id]'},
2405 :child => {:tag => 'option', :attributes => {:value => '1', :selected => nil}, :content => 'eCookbook'}
2418 :child => {:tag => 'option', :attributes => {:value => '1', :selected => nil}, :content => 'eCookbook'}
2406 assert_tag 'select', :attributes => {:name => 'issue[project_id]'},
2419 assert_tag 'select', :attributes => {:name => 'issue[project_id]'},
2407 :child => {:tag => 'option', :attributes => {:value => '2', :selected => 'selected'}, :content => 'OnlineStore'}
2420 :child => {:tag => 'option', :attributes => {:value => '2', :selected => 'selected'}, :content => 'OnlineStore'}
2408 assert_tag 'input', :attributes => {:name => 'copy_from', :value => '1'}
2421 assert_tag 'input', :attributes => {:name => 'copy_from', :value => '1'}
2409 end
2422 end
2410
2423
2411 def test_create_as_copy_on_project_without_permission_should_ignore_target_project
2424 def test_create_as_copy_on_project_without_permission_should_ignore_target_project
2412 @request.session[:user_id] = 2
2425 @request.session[:user_id] = 2
2413 assert !User.find(2).member_of?(Project.find(4))
2426 assert !User.find(2).member_of?(Project.find(4))
2414
2427
2415 assert_difference 'Issue.count' do
2428 assert_difference 'Issue.count' do
2416 post :create, :project_id => 1, :copy_from => 1,
2429 post :create, :project_id => 1, :copy_from => 1,
2417 :issue => {:project_id => '4', :tracker_id => '3', :status_id => '1', :subject => 'Copy'}
2430 :issue => {:project_id => '4', :tracker_id => '3', :status_id => '1', :subject => 'Copy'}
2418 end
2431 end
2419 issue = Issue.first(:order => 'id DESC')
2432 issue = Issue.first(:order => 'id DESC')
2420 assert_equal 1, issue.project_id
2433 assert_equal 1, issue.project_id
2421 end
2434 end
2422
2435
2423 def test_get_edit
2436 def test_get_edit
2424 @request.session[:user_id] = 2
2437 @request.session[:user_id] = 2
2425 get :edit, :id => 1
2438 get :edit, :id => 1
2426 assert_response :success
2439 assert_response :success
2427 assert_template 'edit'
2440 assert_template 'edit'
2428 assert_not_nil assigns(:issue)
2441 assert_not_nil assigns(:issue)
2429 assert_equal Issue.find(1), assigns(:issue)
2442 assert_equal Issue.find(1), assigns(:issue)
2430
2443
2431 # Be sure we don't display inactive IssuePriorities
2444 # Be sure we don't display inactive IssuePriorities
2432 assert ! IssuePriority.find(15).active?
2445 assert ! IssuePriority.find(15).active?
2433 assert_no_tag :option, :attributes => {:value => '15'},
2446 assert_no_tag :option, :attributes => {:value => '15'},
2434 :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} }
2447 :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} }
2435 end
2448 end
2436
2449
2437 def test_get_edit_should_display_the_time_entry_form_with_log_time_permission
2450 def test_get_edit_should_display_the_time_entry_form_with_log_time_permission
2438 @request.session[:user_id] = 2
2451 @request.session[:user_id] = 2
2439 Role.find_by_name('Manager').update_attribute :permissions, [:view_issues, :edit_issues, :log_time]
2452 Role.find_by_name('Manager').update_attribute :permissions, [:view_issues, :edit_issues, :log_time]
2440
2453
2441 get :edit, :id => 1
2454 get :edit, :id => 1
2442 assert_tag 'input', :attributes => {:name => 'time_entry[hours]'}
2455 assert_tag 'input', :attributes => {:name => 'time_entry[hours]'}
2443 end
2456 end
2444
2457
2445 def test_get_edit_should_not_display_the_time_entry_form_without_log_time_permission
2458 def test_get_edit_should_not_display_the_time_entry_form_without_log_time_permission
2446 @request.session[:user_id] = 2
2459 @request.session[:user_id] = 2
2447 Role.find_by_name('Manager').remove_permission! :log_time
2460 Role.find_by_name('Manager').remove_permission! :log_time
2448
2461
2449 get :edit, :id => 1
2462 get :edit, :id => 1
2450 assert_no_tag 'input', :attributes => {:name => 'time_entry[hours]'}
2463 assert_no_tag 'input', :attributes => {:name => 'time_entry[hours]'}
2451 end
2464 end
2452
2465
2453 def test_get_edit_with_params
2466 def test_get_edit_with_params
2454 @request.session[:user_id] = 2
2467 @request.session[:user_id] = 2
2455 get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 },
2468 get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 },
2456 :time_entry => { :hours => '2.5', :comments => 'test_get_edit_with_params', :activity_id => TimeEntryActivity.first.id }
2469 :time_entry => { :hours => '2.5', :comments => 'test_get_edit_with_params', :activity_id => TimeEntryActivity.first.id }
2457 assert_response :success
2470 assert_response :success
2458 assert_template 'edit'
2471 assert_template 'edit'
2459
2472
2460 issue = assigns(:issue)
2473 issue = assigns(:issue)
2461 assert_not_nil issue
2474 assert_not_nil issue
2462
2475
2463 assert_equal 5, issue.status_id
2476 assert_equal 5, issue.status_id
2464 assert_tag :select, :attributes => { :name => 'issue[status_id]' },
2477 assert_tag :select, :attributes => { :name => 'issue[status_id]' },
2465 :child => { :tag => 'option',
2478 :child => { :tag => 'option',
2466 :content => 'Closed',
2479 :content => 'Closed',
2467 :attributes => { :selected => 'selected' } }
2480 :attributes => { :selected => 'selected' } }
2468
2481
2469 assert_equal 7, issue.priority_id
2482 assert_equal 7, issue.priority_id
2470 assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
2483 assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
2471 :child => { :tag => 'option',
2484 :child => { :tag => 'option',
2472 :content => 'Urgent',
2485 :content => 'Urgent',
2473 :attributes => { :selected => 'selected' } }
2486 :attributes => { :selected => 'selected' } }
2474
2487
2475 assert_tag :input, :attributes => { :name => 'time_entry[hours]', :value => '2.5' }
2488 assert_tag :input, :attributes => { :name => 'time_entry[hours]', :value => '2.5' }
2476 assert_tag :select, :attributes => { :name => 'time_entry[activity_id]' },
2489 assert_tag :select, :attributes => { :name => 'time_entry[activity_id]' },
2477 :child => { :tag => 'option',
2490 :child => { :tag => 'option',
2478 :attributes => { :selected => 'selected', :value => TimeEntryActivity.first.id } }
2491 :attributes => { :selected => 'selected', :value => TimeEntryActivity.first.id } }
2479 assert_tag :input, :attributes => { :name => 'time_entry[comments]', :value => 'test_get_edit_with_params' }
2492 assert_tag :input, :attributes => { :name => 'time_entry[comments]', :value => 'test_get_edit_with_params' }
2480 end
2493 end
2481
2494
2482 def test_get_edit_with_multi_custom_field
2495 def test_get_edit_with_multi_custom_field
2483 field = CustomField.find(1)
2496 field = CustomField.find(1)
2484 field.update_attribute :multiple, true
2497 field.update_attribute :multiple, true
2485 issue = Issue.find(1)
2498 issue = Issue.find(1)
2486 issue.custom_field_values = {1 => ['MySQL', 'Oracle']}
2499 issue.custom_field_values = {1 => ['MySQL', 'Oracle']}
2487 issue.save!
2500 issue.save!
2488
2501
2489 @request.session[:user_id] = 2
2502 @request.session[:user_id] = 2
2490 get :edit, :id => 1
2503 get :edit, :id => 1
2491 assert_response :success
2504 assert_response :success
2492 assert_template 'edit'
2505 assert_template 'edit'
2493
2506
2494 assert_tag 'select', :attributes => {:name => 'issue[custom_field_values][1][]', :multiple => 'multiple'}
2507 assert_tag 'select', :attributes => {:name => 'issue[custom_field_values][1][]', :multiple => 'multiple'}
2495 assert_tag 'select', :attributes => {:name => 'issue[custom_field_values][1][]'},
2508 assert_tag 'select', :attributes => {:name => 'issue[custom_field_values][1][]'},
2496 :child => {:tag => 'option', :attributes => {:value => 'MySQL', :selected => 'selected'}}
2509 :child => {:tag => 'option', :attributes => {:value => 'MySQL', :selected => 'selected'}}
2497 assert_tag 'select', :attributes => {:name => 'issue[custom_field_values][1][]'},
2510 assert_tag 'select', :attributes => {:name => 'issue[custom_field_values][1][]'},
2498 :child => {:tag => 'option', :attributes => {:value => 'PostgreSQL', :selected => nil}}
2511 :child => {:tag => 'option', :attributes => {:value => 'PostgreSQL', :selected => nil}}
2499 assert_tag 'select', :attributes => {:name => 'issue[custom_field_values][1][]'},
2512 assert_tag 'select', :attributes => {:name => 'issue[custom_field_values][1][]'},
2500 :child => {:tag => 'option', :attributes => {:value => 'Oracle', :selected => 'selected'}}
2513 :child => {:tag => 'option', :attributes => {:value => 'Oracle', :selected => 'selected'}}
2501 end
2514 end
2502
2515
2503 def test_update_edit_form
2516 def test_update_edit_form
2504 @request.session[:user_id] = 2
2517 @request.session[:user_id] = 2
2505 xhr :put, :new, :project_id => 1,
2518 xhr :put, :new, :project_id => 1,
2506 :id => 1,
2519 :id => 1,
2507 :issue => {:tracker_id => 2,
2520 :issue => {:tracker_id => 2,
2508 :subject => 'This is the test_new issue',
2521 :subject => 'This is the test_new issue',
2509 :description => 'This is the description',
2522 :description => 'This is the description',
2510 :priority_id => 5}
2523 :priority_id => 5}
2511 assert_response :success
2524 assert_response :success
2512 assert_equal 'text/javascript', response.content_type
2525 assert_equal 'text/javascript', response.content_type
2513 assert_template 'update_form'
2526 assert_template 'update_form'
2514 assert_template 'form'
2527 assert_template 'form'
2515
2528
2516 issue = assigns(:issue)
2529 issue = assigns(:issue)
2517 assert_kind_of Issue, issue
2530 assert_kind_of Issue, issue
2518 assert_equal 1, issue.id
2531 assert_equal 1, issue.id
2519 assert_equal 1, issue.project_id
2532 assert_equal 1, issue.project_id
2520 assert_equal 2, issue.tracker_id
2533 assert_equal 2, issue.tracker_id
2521 assert_equal 'This is the test_new issue', issue.subject
2534 assert_equal 'This is the test_new issue', issue.subject
2522 end
2535 end
2523
2536
2524 def test_update_edit_form_should_propose_transitions_based_on_initial_status
2537 def test_update_edit_form_should_propose_transitions_based_on_initial_status
2525 @request.session[:user_id] = 2
2538 @request.session[:user_id] = 2
2526 WorkflowTransition.delete_all
2539 WorkflowTransition.delete_all
2527 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 1)
2540 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 1)
2528 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 5)
2541 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 5)
2529 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 5, :new_status_id => 4)
2542 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 5, :new_status_id => 4)
2530
2543
2531 xhr :put, :new, :project_id => 1,
2544 xhr :put, :new, :project_id => 1,
2532 :id => 2,
2545 :id => 2,
2533 :issue => {:tracker_id => 2,
2546 :issue => {:tracker_id => 2,
2534 :status_id => 5,
2547 :status_id => 5,
2535 :subject => 'This is an issue'}
2548 :subject => 'This is an issue'}
2536
2549
2537 assert_equal 5, assigns(:issue).status_id
2550 assert_equal 5, assigns(:issue).status_id
2538 assert_equal [1,2,5], assigns(:allowed_statuses).map(&:id).sort
2551 assert_equal [1,2,5], assigns(:allowed_statuses).map(&:id).sort
2539 end
2552 end
2540
2553
2541 def test_update_edit_form_with_project_change
2554 def test_update_edit_form_with_project_change
2542 @request.session[:user_id] = 2
2555 @request.session[:user_id] = 2
2543 xhr :put, :new, :project_id => 1,
2556 xhr :put, :new, :project_id => 1,
2544 :id => 1,
2557 :id => 1,
2545 :issue => {:project_id => 2,
2558 :issue => {:project_id => 2,
2546 :tracker_id => 2,
2559 :tracker_id => 2,
2547 :subject => 'This is the test_new issue',
2560 :subject => 'This is the test_new issue',
2548 :description => 'This is the description',
2561 :description => 'This is the description',
2549 :priority_id => 5}
2562 :priority_id => 5}
2550 assert_response :success
2563 assert_response :success
2551 assert_template 'form'
2564 assert_template 'form'
2552
2565
2553 issue = assigns(:issue)
2566 issue = assigns(:issue)
2554 assert_kind_of Issue, issue
2567 assert_kind_of Issue, issue
2555 assert_equal 1, issue.id
2568 assert_equal 1, issue.id
2556 assert_equal 2, issue.project_id
2569 assert_equal 2, issue.project_id
2557 assert_equal 2, issue.tracker_id
2570 assert_equal 2, issue.tracker_id
2558 assert_equal 'This is the test_new issue', issue.subject
2571 assert_equal 'This is the test_new issue', issue.subject
2559 end
2572 end
2560
2573
2561 def test_put_update_without_custom_fields_param
2574 def test_put_update_without_custom_fields_param
2562 @request.session[:user_id] = 2
2575 @request.session[:user_id] = 2
2563 ActionMailer::Base.deliveries.clear
2576 ActionMailer::Base.deliveries.clear
2564
2577
2565 issue = Issue.find(1)
2578 issue = Issue.find(1)
2566 assert_equal '125', issue.custom_value_for(2).value
2579 assert_equal '125', issue.custom_value_for(2).value
2567 old_subject = issue.subject
2580 old_subject = issue.subject
2568 new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
2581 new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
2569
2582
2570 assert_difference('Journal.count') do
2583 assert_difference('Journal.count') do
2571 assert_difference('JournalDetail.count', 2) do
2584 assert_difference('JournalDetail.count', 2) do
2572 put :update, :id => 1, :issue => {:subject => new_subject,
2585 put :update, :id => 1, :issue => {:subject => new_subject,
2573 :priority_id => '6',
2586 :priority_id => '6',
2574 :category_id => '1' # no change
2587 :category_id => '1' # no change
2575 }
2588 }
2576 end
2589 end
2577 end
2590 end
2578 assert_redirected_to :action => 'show', :id => '1'
2591 assert_redirected_to :action => 'show', :id => '1'
2579 issue.reload
2592 issue.reload
2580 assert_equal new_subject, issue.subject
2593 assert_equal new_subject, issue.subject
2581 # Make sure custom fields were not cleared
2594 # Make sure custom fields were not cleared
2582 assert_equal '125', issue.custom_value_for(2).value
2595 assert_equal '125', issue.custom_value_for(2).value
2583
2596
2584 mail = ActionMailer::Base.deliveries.last
2597 mail = ActionMailer::Base.deliveries.last
2585 assert_not_nil mail
2598 assert_not_nil mail
2586 assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
2599 assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
2587 assert_mail_body_match "Subject changed from #{old_subject} to #{new_subject}", mail
2600 assert_mail_body_match "Subject changed from #{old_subject} to #{new_subject}", mail
2588 end
2601 end
2589
2602
2590 def test_put_update_with_project_change
2603 def test_put_update_with_project_change
2591 @request.session[:user_id] = 2
2604 @request.session[:user_id] = 2
2592 ActionMailer::Base.deliveries.clear
2605 ActionMailer::Base.deliveries.clear
2593
2606
2594 assert_difference('Journal.count') do
2607 assert_difference('Journal.count') do
2595 assert_difference('JournalDetail.count', 3) do
2608 assert_difference('JournalDetail.count', 3) do
2596 put :update, :id => 1, :issue => {:project_id => '2',
2609 put :update, :id => 1, :issue => {:project_id => '2',
2597 :tracker_id => '1', # no change
2610 :tracker_id => '1', # no change
2598 :priority_id => '6',
2611 :priority_id => '6',
2599 :category_id => '3'
2612 :category_id => '3'
2600 }
2613 }
2601 end
2614 end
2602 end
2615 end
2603 assert_redirected_to :action => 'show', :id => '1'
2616 assert_redirected_to :action => 'show', :id => '1'
2604 issue = Issue.find(1)
2617 issue = Issue.find(1)
2605 assert_equal 2, issue.project_id
2618 assert_equal 2, issue.project_id
2606 assert_equal 1, issue.tracker_id
2619 assert_equal 1, issue.tracker_id
2607 assert_equal 6, issue.priority_id
2620 assert_equal 6, issue.priority_id
2608 assert_equal 3, issue.category_id
2621 assert_equal 3, issue.category_id
2609
2622
2610 mail = ActionMailer::Base.deliveries.last
2623 mail = ActionMailer::Base.deliveries.last
2611 assert_not_nil mail
2624 assert_not_nil mail
2612 assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
2625 assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
2613 assert_mail_body_match "Project changed from eCookbook to OnlineStore", mail
2626 assert_mail_body_match "Project changed from eCookbook to OnlineStore", mail
2614 end
2627 end
2615
2628
2616 def test_put_update_with_tracker_change
2629 def test_put_update_with_tracker_change
2617 @request.session[:user_id] = 2
2630 @request.session[:user_id] = 2
2618 ActionMailer::Base.deliveries.clear
2631 ActionMailer::Base.deliveries.clear
2619
2632
2620 assert_difference('Journal.count') do
2633 assert_difference('Journal.count') do
2621 assert_difference('JournalDetail.count', 2) do
2634 assert_difference('JournalDetail.count', 2) do
2622 put :update, :id => 1, :issue => {:project_id => '1',
2635 put :update, :id => 1, :issue => {:project_id => '1',
2623 :tracker_id => '2',
2636 :tracker_id => '2',
2624 :priority_id => '6'
2637 :priority_id => '6'
2625 }
2638 }
2626 end
2639 end
2627 end
2640 end
2628 assert_redirected_to :action => 'show', :id => '1'
2641 assert_redirected_to :action => 'show', :id => '1'
2629 issue = Issue.find(1)
2642 issue = Issue.find(1)
2630 assert_equal 1, issue.project_id
2643 assert_equal 1, issue.project_id
2631 assert_equal 2, issue.tracker_id
2644 assert_equal 2, issue.tracker_id
2632 assert_equal 6, issue.priority_id
2645 assert_equal 6, issue.priority_id
2633 assert_equal 1, issue.category_id
2646 assert_equal 1, issue.category_id
2634
2647
2635 mail = ActionMailer::Base.deliveries.last
2648 mail = ActionMailer::Base.deliveries.last
2636 assert_not_nil mail
2649 assert_not_nil mail
2637 assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
2650 assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
2638 assert_mail_body_match "Tracker changed from Bug to Feature request", mail
2651 assert_mail_body_match "Tracker changed from Bug to Feature request", mail
2639 end
2652 end
2640
2653
2641 def test_put_update_with_custom_field_change
2654 def test_put_update_with_custom_field_change
2642 @request.session[:user_id] = 2
2655 @request.session[:user_id] = 2
2643 issue = Issue.find(1)
2656 issue = Issue.find(1)
2644 assert_equal '125', issue.custom_value_for(2).value
2657 assert_equal '125', issue.custom_value_for(2).value
2645
2658
2646 assert_difference('Journal.count') do
2659 assert_difference('Journal.count') do
2647 assert_difference('JournalDetail.count', 3) do
2660 assert_difference('JournalDetail.count', 3) do
2648 put :update, :id => 1, :issue => {:subject => 'Custom field change',
2661 put :update, :id => 1, :issue => {:subject => 'Custom field change',
2649 :priority_id => '6',
2662 :priority_id => '6',
2650 :category_id => '1', # no change
2663 :category_id => '1', # no change
2651 :custom_field_values => { '2' => 'New custom value' }
2664 :custom_field_values => { '2' => 'New custom value' }
2652 }
2665 }
2653 end
2666 end
2654 end
2667 end
2655 assert_redirected_to :action => 'show', :id => '1'
2668 assert_redirected_to :action => 'show', :id => '1'
2656 issue.reload
2669 issue.reload
2657 assert_equal 'New custom value', issue.custom_value_for(2).value
2670 assert_equal 'New custom value', issue.custom_value_for(2).value
2658
2671
2659 mail = ActionMailer::Base.deliveries.last
2672 mail = ActionMailer::Base.deliveries.last
2660 assert_not_nil mail
2673 assert_not_nil mail
2661 assert_mail_body_match "Searchable field changed from 125 to New custom value", mail
2674 assert_mail_body_match "Searchable field changed from 125 to New custom value", mail
2662 end
2675 end
2663
2676
2664 def test_put_update_with_multi_custom_field_change
2677 def test_put_update_with_multi_custom_field_change
2665 field = CustomField.find(1)
2678 field = CustomField.find(1)
2666 field.update_attribute :multiple, true
2679 field.update_attribute :multiple, true
2667 issue = Issue.find(1)
2680 issue = Issue.find(1)
2668 issue.custom_field_values = {1 => ['MySQL', 'Oracle']}
2681 issue.custom_field_values = {1 => ['MySQL', 'Oracle']}
2669 issue.save!
2682 issue.save!
2670
2683
2671 @request.session[:user_id] = 2
2684 @request.session[:user_id] = 2
2672 assert_difference('Journal.count') do
2685 assert_difference('Journal.count') do
2673 assert_difference('JournalDetail.count', 3) do
2686 assert_difference('JournalDetail.count', 3) do
2674 put :update, :id => 1,
2687 put :update, :id => 1,
2675 :issue => {
2688 :issue => {
2676 :subject => 'Custom field change',
2689 :subject => 'Custom field change',
2677 :custom_field_values => { '1' => ['', 'Oracle', 'PostgreSQL'] }
2690 :custom_field_values => { '1' => ['', 'Oracle', 'PostgreSQL'] }
2678 }
2691 }
2679 end
2692 end
2680 end
2693 end
2681 assert_redirected_to :action => 'show', :id => '1'
2694 assert_redirected_to :action => 'show', :id => '1'
2682 assert_equal ['Oracle', 'PostgreSQL'], Issue.find(1).custom_field_value(1).sort
2695 assert_equal ['Oracle', 'PostgreSQL'], Issue.find(1).custom_field_value(1).sort
2683 end
2696 end
2684
2697
2685 def test_put_update_with_status_and_assignee_change
2698 def test_put_update_with_status_and_assignee_change
2686 issue = Issue.find(1)
2699 issue = Issue.find(1)
2687 assert_equal 1, issue.status_id
2700 assert_equal 1, issue.status_id
2688 @request.session[:user_id] = 2
2701 @request.session[:user_id] = 2
2689 assert_difference('TimeEntry.count', 0) do
2702 assert_difference('TimeEntry.count', 0) do
2690 put :update,
2703 put :update,
2691 :id => 1,
2704 :id => 1,
2692 :issue => { :status_id => 2, :assigned_to_id => 3 },
2705 :issue => { :status_id => 2, :assigned_to_id => 3 },
2693 :notes => 'Assigned to dlopper',
2706 :notes => 'Assigned to dlopper',
2694 :time_entry => { :hours => '', :comments => '', :activity_id => TimeEntryActivity.first }
2707 :time_entry => { :hours => '', :comments => '', :activity_id => TimeEntryActivity.first }
2695 end
2708 end
2696 assert_redirected_to :action => 'show', :id => '1'
2709 assert_redirected_to :action => 'show', :id => '1'
2697 issue.reload
2710 issue.reload
2698 assert_equal 2, issue.status_id
2711 assert_equal 2, issue.status_id
2699 j = Journal.find(:first, :order => 'id DESC')
2712 j = Journal.find(:first, :order => 'id DESC')
2700 assert_equal 'Assigned to dlopper', j.notes
2713 assert_equal 'Assigned to dlopper', j.notes
2701 assert_equal 2, j.details.size
2714 assert_equal 2, j.details.size
2702
2715
2703 mail = ActionMailer::Base.deliveries.last
2716 mail = ActionMailer::Base.deliveries.last
2704 assert_mail_body_match "Status changed from New to Assigned", mail
2717 assert_mail_body_match "Status changed from New to Assigned", mail
2705 # subject should contain the new status
2718 # subject should contain the new status
2706 assert mail.subject.include?("(#{ IssueStatus.find(2).name })")
2719 assert mail.subject.include?("(#{ IssueStatus.find(2).name })")
2707 end
2720 end
2708
2721
2709 def test_put_update_with_note_only
2722 def test_put_update_with_note_only
2710 notes = 'Note added by IssuesControllerTest#test_update_with_note_only'
2723 notes = 'Note added by IssuesControllerTest#test_update_with_note_only'
2711 # anonymous user
2724 # anonymous user
2712 put :update,
2725 put :update,
2713 :id => 1,
2726 :id => 1,
2714 :notes => notes
2727 :notes => notes
2715 assert_redirected_to :action => 'show', :id => '1'
2728 assert_redirected_to :action => 'show', :id => '1'
2716 j = Journal.find(:first, :order => 'id DESC')
2729 j = Journal.find(:first, :order => 'id DESC')
2717 assert_equal notes, j.notes
2730 assert_equal notes, j.notes
2718 assert_equal 0, j.details.size
2731 assert_equal 0, j.details.size
2719 assert_equal User.anonymous, j.user
2732 assert_equal User.anonymous, j.user
2720
2733
2721 mail = ActionMailer::Base.deliveries.last
2734 mail = ActionMailer::Base.deliveries.last
2722 assert_mail_body_match notes, mail
2735 assert_mail_body_match notes, mail
2723 end
2736 end
2724
2737
2725 def test_put_update_with_note_and_spent_time
2738 def test_put_update_with_note_and_spent_time
2726 @request.session[:user_id] = 2
2739 @request.session[:user_id] = 2
2727 spent_hours_before = Issue.find(1).spent_hours
2740 spent_hours_before = Issue.find(1).spent_hours
2728 assert_difference('TimeEntry.count') do
2741 assert_difference('TimeEntry.count') do
2729 put :update,
2742 put :update,
2730 :id => 1,
2743 :id => 1,
2731 :notes => '2.5 hours added',
2744 :notes => '2.5 hours added',
2732 :time_entry => { :hours => '2.5', :comments => 'test_put_update_with_note_and_spent_time', :activity_id => TimeEntryActivity.first.id }
2745 :time_entry => { :hours => '2.5', :comments => 'test_put_update_with_note_and_spent_time', :activity_id => TimeEntryActivity.first.id }
2733 end
2746 end
2734 assert_redirected_to :action => 'show', :id => '1'
2747 assert_redirected_to :action => 'show', :id => '1'
2735
2748
2736 issue = Issue.find(1)
2749 issue = Issue.find(1)
2737
2750
2738 j = Journal.find(:first, :order => 'id DESC')
2751 j = Journal.find(:first, :order => 'id DESC')
2739 assert_equal '2.5 hours added', j.notes
2752 assert_equal '2.5 hours added', j.notes
2740 assert_equal 0, j.details.size
2753 assert_equal 0, j.details.size
2741
2754
2742 t = issue.time_entries.find_by_comments('test_put_update_with_note_and_spent_time')
2755 t = issue.time_entries.find_by_comments('test_put_update_with_note_and_spent_time')
2743 assert_not_nil t
2756 assert_not_nil t
2744 assert_equal 2.5, t.hours
2757 assert_equal 2.5, t.hours
2745 assert_equal spent_hours_before + 2.5, issue.spent_hours
2758 assert_equal spent_hours_before + 2.5, issue.spent_hours
2746 end
2759 end
2747
2760
2748 def test_put_update_with_attachment_only
2761 def test_put_update_with_attachment_only
2749 set_tmp_attachments_directory
2762 set_tmp_attachments_directory
2750
2763
2751 # Delete all fixtured journals, a race condition can occur causing the wrong
2764 # Delete all fixtured journals, a race condition can occur causing the wrong
2752 # journal to get fetched in the next find.
2765 # journal to get fetched in the next find.
2753 Journal.delete_all
2766 Journal.delete_all
2754
2767
2755 # anonymous user
2768 # anonymous user
2756 assert_difference 'Attachment.count' do
2769 assert_difference 'Attachment.count' do
2757 put :update, :id => 1,
2770 put :update, :id => 1,
2758 :notes => '',
2771 :notes => '',
2759 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
2772 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
2760 end
2773 end
2761
2774
2762 assert_redirected_to :action => 'show', :id => '1'
2775 assert_redirected_to :action => 'show', :id => '1'
2763 j = Issue.find(1).journals.find(:first, :order => 'id DESC')
2776 j = Issue.find(1).journals.find(:first, :order => 'id DESC')
2764 assert j.notes.blank?
2777 assert j.notes.blank?
2765 assert_equal 1, j.details.size
2778 assert_equal 1, j.details.size
2766 assert_equal 'testfile.txt', j.details.first.value
2779 assert_equal 'testfile.txt', j.details.first.value
2767 assert_equal User.anonymous, j.user
2780 assert_equal User.anonymous, j.user
2768
2781
2769 attachment = Attachment.first(:order => 'id DESC')
2782 attachment = Attachment.first(:order => 'id DESC')
2770 assert_equal Issue.find(1), attachment.container
2783 assert_equal Issue.find(1), attachment.container
2771 assert_equal User.anonymous, attachment.author
2784 assert_equal User.anonymous, attachment.author
2772 assert_equal 'testfile.txt', attachment.filename
2785 assert_equal 'testfile.txt', attachment.filename
2773 assert_equal 'text/plain', attachment.content_type
2786 assert_equal 'text/plain', attachment.content_type
2774 assert_equal 'test file', attachment.description
2787 assert_equal 'test file', attachment.description
2775 assert_equal 59, attachment.filesize
2788 assert_equal 59, attachment.filesize
2776 assert File.exists?(attachment.diskfile)
2789 assert File.exists?(attachment.diskfile)
2777 assert_equal 59, File.size(attachment.diskfile)
2790 assert_equal 59, File.size(attachment.diskfile)
2778
2791
2779 mail = ActionMailer::Base.deliveries.last
2792 mail = ActionMailer::Base.deliveries.last
2780 assert_mail_body_match 'testfile.txt', mail
2793 assert_mail_body_match 'testfile.txt', mail
2781 end
2794 end
2782
2795
2783 def test_put_update_with_failure_should_save_attachments
2796 def test_put_update_with_failure_should_save_attachments
2784 set_tmp_attachments_directory
2797 set_tmp_attachments_directory
2785 @request.session[:user_id] = 2
2798 @request.session[:user_id] = 2
2786
2799
2787 assert_no_difference 'Journal.count' do
2800 assert_no_difference 'Journal.count' do
2788 assert_difference 'Attachment.count' do
2801 assert_difference 'Attachment.count' do
2789 put :update, :id => 1,
2802 put :update, :id => 1,
2790 :issue => { :subject => '' },
2803 :issue => { :subject => '' },
2791 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
2804 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
2792 assert_response :success
2805 assert_response :success
2793 assert_template 'edit'
2806 assert_template 'edit'
2794 end
2807 end
2795 end
2808 end
2796
2809
2797 attachment = Attachment.first(:order => 'id DESC')
2810 attachment = Attachment.first(:order => 'id DESC')
2798 assert_equal 'testfile.txt', attachment.filename
2811 assert_equal 'testfile.txt', attachment.filename
2799 assert File.exists?(attachment.diskfile)
2812 assert File.exists?(attachment.diskfile)
2800 assert_nil attachment.container
2813 assert_nil attachment.container
2801
2814
2802 assert_tag 'input', :attributes => {:name => 'attachments[p0][token]', :value => attachment.token}
2815 assert_tag 'input', :attributes => {:name => 'attachments[p0][token]', :value => attachment.token}
2803 assert_tag 'span', :content => /testfile.txt/
2816 assert_tag 'span', :content => /testfile.txt/
2804 end
2817 end
2805
2818
2806 def test_put_update_with_failure_should_keep_saved_attachments
2819 def test_put_update_with_failure_should_keep_saved_attachments
2807 set_tmp_attachments_directory
2820 set_tmp_attachments_directory
2808 attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2)
2821 attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2)
2809 @request.session[:user_id] = 2
2822 @request.session[:user_id] = 2
2810
2823
2811 assert_no_difference 'Journal.count' do
2824 assert_no_difference 'Journal.count' do
2812 assert_no_difference 'Attachment.count' do
2825 assert_no_difference 'Attachment.count' do
2813 put :update, :id => 1,
2826 put :update, :id => 1,
2814 :issue => { :subject => '' },
2827 :issue => { :subject => '' },
2815 :attachments => {'p0' => {'token' => attachment.token}}
2828 :attachments => {'p0' => {'token' => attachment.token}}
2816 assert_response :success
2829 assert_response :success
2817 assert_template 'edit'
2830 assert_template 'edit'
2818 end
2831 end
2819 end
2832 end
2820
2833
2821 assert_tag 'input', :attributes => {:name => 'attachments[p0][token]', :value => attachment.token}
2834 assert_tag 'input', :attributes => {:name => 'attachments[p0][token]', :value => attachment.token}
2822 assert_tag 'span', :content => /testfile.txt/
2835 assert_tag 'span', :content => /testfile.txt/
2823 end
2836 end
2824
2837
2825 def test_put_update_should_attach_saved_attachments
2838 def test_put_update_should_attach_saved_attachments
2826 set_tmp_attachments_directory
2839 set_tmp_attachments_directory
2827 attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2)
2840 attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2)
2828 @request.session[:user_id] = 2
2841 @request.session[:user_id] = 2
2829
2842
2830 assert_difference 'Journal.count' do
2843 assert_difference 'Journal.count' do
2831 assert_difference 'JournalDetail.count' do
2844 assert_difference 'JournalDetail.count' do
2832 assert_no_difference 'Attachment.count' do
2845 assert_no_difference 'Attachment.count' do
2833 put :update, :id => 1,
2846 put :update, :id => 1,
2834 :notes => 'Attachment added',
2847 :notes => 'Attachment added',
2835 :attachments => {'p0' => {'token' => attachment.token}}
2848 :attachments => {'p0' => {'token' => attachment.token}}
2836 assert_redirected_to '/issues/1'
2849 assert_redirected_to '/issues/1'
2837 end
2850 end
2838 end
2851 end
2839 end
2852 end
2840
2853
2841 attachment.reload
2854 attachment.reload
2842 assert_equal Issue.find(1), attachment.container
2855 assert_equal Issue.find(1), attachment.container
2843
2856
2844 journal = Journal.first(:order => 'id DESC')
2857 journal = Journal.first(:order => 'id DESC')
2845 assert_equal 1, journal.details.size
2858 assert_equal 1, journal.details.size
2846 assert_equal 'testfile.txt', journal.details.first.value
2859 assert_equal 'testfile.txt', journal.details.first.value
2847 end
2860 end
2848
2861
2849 def test_put_update_with_attachment_that_fails_to_save
2862 def test_put_update_with_attachment_that_fails_to_save
2850 set_tmp_attachments_directory
2863 set_tmp_attachments_directory
2851
2864
2852 # Delete all fixtured journals, a race condition can occur causing the wrong
2865 # Delete all fixtured journals, a race condition can occur causing the wrong
2853 # journal to get fetched in the next find.
2866 # journal to get fetched in the next find.
2854 Journal.delete_all
2867 Journal.delete_all
2855
2868
2856 # Mock out the unsaved attachment
2869 # Mock out the unsaved attachment
2857 Attachment.any_instance.stubs(:create).returns(Attachment.new)
2870 Attachment.any_instance.stubs(:create).returns(Attachment.new)
2858
2871
2859 # anonymous user
2872 # anonymous user
2860 put :update,
2873 put :update,
2861 :id => 1,
2874 :id => 1,
2862 :notes => '',
2875 :notes => '',
2863 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
2876 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
2864 assert_redirected_to :action => 'show', :id => '1'
2877 assert_redirected_to :action => 'show', :id => '1'
2865 assert_equal '1 file(s) could not be saved.', flash[:warning]
2878 assert_equal '1 file(s) could not be saved.', flash[:warning]
2866 end
2879 end
2867
2880
2868 def test_put_update_with_no_change
2881 def test_put_update_with_no_change
2869 issue = Issue.find(1)
2882 issue = Issue.find(1)
2870 issue.journals.clear
2883 issue.journals.clear
2871 ActionMailer::Base.deliveries.clear
2884 ActionMailer::Base.deliveries.clear
2872
2885
2873 put :update,
2886 put :update,
2874 :id => 1,
2887 :id => 1,
2875 :notes => ''
2888 :notes => ''
2876 assert_redirected_to :action => 'show', :id => '1'
2889 assert_redirected_to :action => 'show', :id => '1'
2877
2890
2878 issue.reload
2891 issue.reload
2879 assert issue.journals.empty?
2892 assert issue.journals.empty?
2880 # No email should be sent
2893 # No email should be sent
2881 assert ActionMailer::Base.deliveries.empty?
2894 assert ActionMailer::Base.deliveries.empty?
2882 end
2895 end
2883
2896
2884 def test_put_update_should_send_a_notification
2897 def test_put_update_should_send_a_notification
2885 @request.session[:user_id] = 2
2898 @request.session[:user_id] = 2
2886 ActionMailer::Base.deliveries.clear
2899 ActionMailer::Base.deliveries.clear
2887 issue = Issue.find(1)
2900 issue = Issue.find(1)
2888 old_subject = issue.subject
2901 old_subject = issue.subject
2889 new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
2902 new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
2890
2903
2891 put :update, :id => 1, :issue => {:subject => new_subject,
2904 put :update, :id => 1, :issue => {:subject => new_subject,
2892 :priority_id => '6',
2905 :priority_id => '6',
2893 :category_id => '1' # no change
2906 :category_id => '1' # no change
2894 }
2907 }
2895 assert_equal 1, ActionMailer::Base.deliveries.size
2908 assert_equal 1, ActionMailer::Base.deliveries.size
2896 end
2909 end
2897
2910
2898 def test_put_update_with_invalid_spent_time_hours_only
2911 def test_put_update_with_invalid_spent_time_hours_only
2899 @request.session[:user_id] = 2
2912 @request.session[:user_id] = 2
2900 notes = 'Note added by IssuesControllerTest#test_post_edit_with_invalid_spent_time'
2913 notes = 'Note added by IssuesControllerTest#test_post_edit_with_invalid_spent_time'
2901
2914
2902 assert_no_difference('Journal.count') do
2915 assert_no_difference('Journal.count') do
2903 put :update,
2916 put :update,
2904 :id => 1,
2917 :id => 1,
2905 :notes => notes,
2918 :notes => notes,
2906 :time_entry => {"comments"=>"", "activity_id"=>"", "hours"=>"2z"}
2919 :time_entry => {"comments"=>"", "activity_id"=>"", "hours"=>"2z"}
2907 end
2920 end
2908 assert_response :success
2921 assert_response :success
2909 assert_template 'edit'
2922 assert_template 'edit'
2910
2923
2911 assert_error_tag :descendant => {:content => /Activity can&#x27;t be blank/}
2924 assert_error_tag :descendant => {:content => /Activity can&#x27;t be blank/}
2912 assert_tag :textarea, :attributes => { :name => 'notes' }, :content => "\n"+notes
2925 assert_tag :textarea, :attributes => { :name => 'notes' }, :content => "\n"+notes
2913 assert_tag :input, :attributes => { :name => 'time_entry[hours]', :value => "2z" }
2926 assert_tag :input, :attributes => { :name => 'time_entry[hours]', :value => "2z" }
2914 end
2927 end
2915
2928
2916 def test_put_update_with_invalid_spent_time_comments_only
2929 def test_put_update_with_invalid_spent_time_comments_only
2917 @request.session[:user_id] = 2
2930 @request.session[:user_id] = 2
2918 notes = 'Note added by IssuesControllerTest#test_post_edit_with_invalid_spent_time'
2931 notes = 'Note added by IssuesControllerTest#test_post_edit_with_invalid_spent_time'
2919
2932
2920 assert_no_difference('Journal.count') do
2933 assert_no_difference('Journal.count') do
2921 put :update,
2934 put :update,
2922 :id => 1,
2935 :id => 1,
2923 :notes => notes,
2936 :notes => notes,
2924 :time_entry => {"comments"=>"this is my comment", "activity_id"=>"", "hours"=>""}
2937 :time_entry => {"comments"=>"this is my comment", "activity_id"=>"", "hours"=>""}
2925 end
2938 end
2926 assert_response :success
2939 assert_response :success
2927 assert_template 'edit'
2940 assert_template 'edit'
2928
2941
2929 assert_error_tag :descendant => {:content => /Activity can&#x27;t be blank/}
2942 assert_error_tag :descendant => {:content => /Activity can&#x27;t be blank/}
2930 assert_error_tag :descendant => {:content => /Hours can&#x27;t be blank/}
2943 assert_error_tag :descendant => {:content => /Hours can&#x27;t be blank/}
2931 assert_tag :textarea, :attributes => { :name => 'notes' }, :content => "\n"+notes
2944 assert_tag :textarea, :attributes => { :name => 'notes' }, :content => "\n"+notes
2932 assert_tag :input, :attributes => { :name => 'time_entry[comments]', :value => "this is my comment" }
2945 assert_tag :input, :attributes => { :name => 'time_entry[comments]', :value => "this is my comment" }
2933 end
2946 end
2934
2947
2935 def test_put_update_should_allow_fixed_version_to_be_set_to_a_subproject
2948 def test_put_update_should_allow_fixed_version_to_be_set_to_a_subproject
2936 issue = Issue.find(2)
2949 issue = Issue.find(2)
2937 @request.session[:user_id] = 2
2950 @request.session[:user_id] = 2
2938
2951
2939 put :update,
2952 put :update,
2940 :id => issue.id,
2953 :id => issue.id,
2941 :issue => {
2954 :issue => {
2942 :fixed_version_id => 4
2955 :fixed_version_id => 4
2943 }
2956 }
2944
2957
2945 assert_response :redirect
2958 assert_response :redirect
2946 issue.reload
2959 issue.reload
2947 assert_equal 4, issue.fixed_version_id
2960 assert_equal 4, issue.fixed_version_id
2948 assert_not_equal issue.project_id, issue.fixed_version.project_id
2961 assert_not_equal issue.project_id, issue.fixed_version.project_id
2949 end
2962 end
2950
2963
2951 def test_put_update_should_redirect_back_using_the_back_url_parameter
2964 def test_put_update_should_redirect_back_using_the_back_url_parameter
2952 issue = Issue.find(2)
2965 issue = Issue.find(2)
2953 @request.session[:user_id] = 2
2966 @request.session[:user_id] = 2
2954
2967
2955 put :update,
2968 put :update,
2956 :id => issue.id,
2969 :id => issue.id,
2957 :issue => {
2970 :issue => {
2958 :fixed_version_id => 4
2971 :fixed_version_id => 4
2959 },
2972 },
2960 :back_url => '/issues'
2973 :back_url => '/issues'
2961
2974
2962 assert_response :redirect
2975 assert_response :redirect
2963 assert_redirected_to '/issues'
2976 assert_redirected_to '/issues'
2964 end
2977 end
2965
2978
2966 def test_put_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host
2979 def test_put_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host
2967 issue = Issue.find(2)
2980 issue = Issue.find(2)
2968 @request.session[:user_id] = 2
2981 @request.session[:user_id] = 2
2969
2982
2970 put :update,
2983 put :update,
2971 :id => issue.id,
2984 :id => issue.id,
2972 :issue => {
2985 :issue => {
2973 :fixed_version_id => 4
2986 :fixed_version_id => 4
2974 },
2987 },
2975 :back_url => 'http://google.com'
2988 :back_url => 'http://google.com'
2976
2989
2977 assert_response :redirect
2990 assert_response :redirect
2978 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue.id
2991 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue.id
2979 end
2992 end
2980
2993
2981 def test_get_bulk_edit
2994 def test_get_bulk_edit
2982 @request.session[:user_id] = 2
2995 @request.session[:user_id] = 2
2983 get :bulk_edit, :ids => [1, 2]
2996 get :bulk_edit, :ids => [1, 2]
2984 assert_response :success
2997 assert_response :success
2985 assert_template 'bulk_edit'
2998 assert_template 'bulk_edit'
2986
2999
2987 assert_tag :select, :attributes => {:name => 'issue[project_id]'}
3000 assert_tag :select, :attributes => {:name => 'issue[project_id]'}
2988 assert_tag :input, :attributes => {:name => 'issue[parent_issue_id]'}
3001 assert_tag :input, :attributes => {:name => 'issue[parent_issue_id]'}
2989
3002
2990 # Project specific custom field, date type
3003 # Project specific custom field, date type
2991 field = CustomField.find(9)
3004 field = CustomField.find(9)
2992 assert !field.is_for_all?
3005 assert !field.is_for_all?
2993 assert_equal 'date', field.field_format
3006 assert_equal 'date', field.field_format
2994 assert_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'}
3007 assert_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'}
2995
3008
2996 # System wide custom field
3009 # System wide custom field
2997 assert CustomField.find(1).is_for_all?
3010 assert CustomField.find(1).is_for_all?
2998 assert_tag :select, :attributes => {:name => 'issue[custom_field_values][1]'}
3011 assert_tag :select, :attributes => {:name => 'issue[custom_field_values][1]'}
2999
3012
3000 # Be sure we don't display inactive IssuePriorities
3013 # Be sure we don't display inactive IssuePriorities
3001 assert ! IssuePriority.find(15).active?
3014 assert ! IssuePriority.find(15).active?
3002 assert_no_tag :option, :attributes => {:value => '15'},
3015 assert_no_tag :option, :attributes => {:value => '15'},
3003 :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} }
3016 :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} }
3004 end
3017 end
3005
3018
3006 def test_get_bulk_edit_on_different_projects
3019 def test_get_bulk_edit_on_different_projects
3007 @request.session[:user_id] = 2
3020 @request.session[:user_id] = 2
3008 get :bulk_edit, :ids => [1, 2, 6]
3021 get :bulk_edit, :ids => [1, 2, 6]
3009 assert_response :success
3022 assert_response :success
3010 assert_template 'bulk_edit'
3023 assert_template 'bulk_edit'
3011
3024
3012 # Can not set issues from different projects as children of an issue
3025 # Can not set issues from different projects as children of an issue
3013 assert_no_tag :input, :attributes => {:name => 'issue[parent_issue_id]'}
3026 assert_no_tag :input, :attributes => {:name => 'issue[parent_issue_id]'}
3014
3027
3015 # Project specific custom field, date type
3028 # Project specific custom field, date type
3016 field = CustomField.find(9)
3029 field = CustomField.find(9)
3017 assert !field.is_for_all?
3030 assert !field.is_for_all?
3018 assert !field.project_ids.include?(Issue.find(6).project_id)
3031 assert !field.project_ids.include?(Issue.find(6).project_id)
3019 assert_no_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'}
3032 assert_no_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'}
3020 end
3033 end
3021
3034
3022 def test_get_bulk_edit_with_user_custom_field
3035 def test_get_bulk_edit_with_user_custom_field
3023 field = IssueCustomField.create!(:name => 'Tester', :field_format => 'user', :is_for_all => true)
3036 field = IssueCustomField.create!(:name => 'Tester', :field_format => 'user', :is_for_all => true)
3024
3037
3025 @request.session[:user_id] = 2
3038 @request.session[:user_id] = 2
3026 get :bulk_edit, :ids => [1, 2]
3039 get :bulk_edit, :ids => [1, 2]
3027 assert_response :success
3040 assert_response :success
3028 assert_template 'bulk_edit'
3041 assert_template 'bulk_edit'
3029
3042
3030 assert_tag :select,
3043 assert_tag :select,
3031 :attributes => {:name => "issue[custom_field_values][#{field.id}]", :class => 'user_cf'},
3044 :attributes => {:name => "issue[custom_field_values][#{field.id}]", :class => 'user_cf'},
3032 :children => {
3045 :children => {
3033 :only => {:tag => 'option'},
3046 :only => {:tag => 'option'},
3034 :count => Project.find(1).users.count + 2 # "no change" + "none" options
3047 :count => Project.find(1).users.count + 2 # "no change" + "none" options
3035 }
3048 }
3036 end
3049 end
3037
3050
3038 def test_get_bulk_edit_with_version_custom_field
3051 def test_get_bulk_edit_with_version_custom_field
3039 field = IssueCustomField.create!(:name => 'Affected version', :field_format => 'version', :is_for_all => true)
3052 field = IssueCustomField.create!(:name => 'Affected version', :field_format => 'version', :is_for_all => true)
3040
3053
3041 @request.session[:user_id] = 2
3054 @request.session[:user_id] = 2
3042 get :bulk_edit, :ids => [1, 2]
3055 get :bulk_edit, :ids => [1, 2]
3043 assert_response :success
3056 assert_response :success
3044 assert_template 'bulk_edit'
3057 assert_template 'bulk_edit'
3045
3058
3046 assert_tag :select,
3059 assert_tag :select,
3047 :attributes => {:name => "issue[custom_field_values][#{field.id}]"},
3060 :attributes => {:name => "issue[custom_field_values][#{field.id}]"},
3048 :children => {
3061 :children => {
3049 :only => {:tag => 'option'},
3062 :only => {:tag => 'option'},
3050 :count => Project.find(1).shared_versions.count + 2 # "no change" + "none" options
3063 :count => Project.find(1).shared_versions.count + 2 # "no change" + "none" options
3051 }
3064 }
3052 end
3065 end
3053
3066
3054 def test_get_bulk_edit_with_multi_custom_field
3067 def test_get_bulk_edit_with_multi_custom_field
3055 field = CustomField.find(1)
3068 field = CustomField.find(1)
3056 field.update_attribute :multiple, true
3069 field.update_attribute :multiple, true
3057
3070
3058 @request.session[:user_id] = 2
3071 @request.session[:user_id] = 2
3059 get :bulk_edit, :ids => [1, 2]
3072 get :bulk_edit, :ids => [1, 2]
3060 assert_response :success
3073 assert_response :success
3061 assert_template 'bulk_edit'
3074 assert_template 'bulk_edit'
3062
3075
3063 assert_tag :select,
3076 assert_tag :select,
3064 :attributes => {:name => "issue[custom_field_values][1][]"},
3077 :attributes => {:name => "issue[custom_field_values][1][]"},
3065 :children => {
3078 :children => {
3066 :only => {:tag => 'option'},
3079 :only => {:tag => 'option'},
3067 :count => field.possible_values.size + 1 # "none" options
3080 :count => field.possible_values.size + 1 # "none" options
3068 }
3081 }
3069 end
3082 end
3070
3083
3071 def test_bulk_edit_should_only_propose_statuses_allowed_for_all_issues
3084 def test_bulk_edit_should_only_propose_statuses_allowed_for_all_issues
3072 WorkflowTransition.delete_all
3085 WorkflowTransition.delete_all
3073 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 1)
3086 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 1)
3074 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3)
3087 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3)
3075 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4)
3088 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4)
3076 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 1)
3089 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 1)
3077 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 3)
3090 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 3)
3078 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 5)
3091 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 5)
3079 @request.session[:user_id] = 2
3092 @request.session[:user_id] = 2
3080 get :bulk_edit, :ids => [1, 2]
3093 get :bulk_edit, :ids => [1, 2]
3081
3094
3082 assert_response :success
3095 assert_response :success
3083 statuses = assigns(:available_statuses)
3096 statuses = assigns(:available_statuses)
3084 assert_not_nil statuses
3097 assert_not_nil statuses
3085 assert_equal [1, 3], statuses.map(&:id).sort
3098 assert_equal [1, 3], statuses.map(&:id).sort
3086
3099
3087 assert_tag 'select', :attributes => {:name => 'issue[status_id]'},
3100 assert_tag 'select', :attributes => {:name => 'issue[status_id]'},
3088 :children => {:count => 3} # 2 statuses + "no change" option
3101 :children => {:count => 3} # 2 statuses + "no change" option
3089 end
3102 end
3090
3103
3091 def test_bulk_edit_should_propose_target_project_open_shared_versions
3104 def test_bulk_edit_should_propose_target_project_open_shared_versions
3092 @request.session[:user_id] = 2
3105 @request.session[:user_id] = 2
3093 post :bulk_edit, :ids => [1, 2, 6], :issue => {:project_id => 1}
3106 post :bulk_edit, :ids => [1, 2, 6], :issue => {:project_id => 1}
3094 assert_response :success
3107 assert_response :success
3095 assert_template 'bulk_edit'
3108 assert_template 'bulk_edit'
3096 assert_equal Project.find(1).shared_versions.open.all.sort, assigns(:versions).sort
3109 assert_equal Project.find(1).shared_versions.open.all.sort, assigns(:versions).sort
3097 assert_tag 'select',
3110 assert_tag 'select',
3098 :attributes => {:name => 'issue[fixed_version_id]'},
3111 :attributes => {:name => 'issue[fixed_version_id]'},
3099 :descendant => {:tag => 'option', :content => '2.0'}
3112 :descendant => {:tag => 'option', :content => '2.0'}
3100 end
3113 end
3101
3114
3102 def test_bulk_edit_should_propose_target_project_categories
3115 def test_bulk_edit_should_propose_target_project_categories
3103 @request.session[:user_id] = 2
3116 @request.session[:user_id] = 2
3104 post :bulk_edit, :ids => [1, 2, 6], :issue => {:project_id => 1}
3117 post :bulk_edit, :ids => [1, 2, 6], :issue => {:project_id => 1}
3105 assert_response :success
3118 assert_response :success
3106 assert_template 'bulk_edit'
3119 assert_template 'bulk_edit'
3107 assert_equal Project.find(1).issue_categories.sort, assigns(:categories).sort
3120 assert_equal Project.find(1).issue_categories.sort, assigns(:categories).sort
3108 assert_tag 'select',
3121 assert_tag 'select',
3109 :attributes => {:name => 'issue[category_id]'},
3122 :attributes => {:name => 'issue[category_id]'},
3110 :descendant => {:tag => 'option', :content => 'Recipes'}
3123 :descendant => {:tag => 'option', :content => 'Recipes'}
3111 end
3124 end
3112
3125
3113 def test_bulk_update
3126 def test_bulk_update
3114 @request.session[:user_id] = 2
3127 @request.session[:user_id] = 2
3115 # update issues priority
3128 # update issues priority
3116 post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing',
3129 post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing',
3117 :issue => {:priority_id => 7,
3130 :issue => {:priority_id => 7,
3118 :assigned_to_id => '',
3131 :assigned_to_id => '',
3119 :custom_field_values => {'2' => ''}}
3132 :custom_field_values => {'2' => ''}}
3120
3133
3121 assert_response 302
3134 assert_response 302
3122 # check that the issues were updated
3135 # check that the issues were updated
3123 assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id}
3136 assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id}
3124
3137
3125 issue = Issue.find(1)
3138 issue = Issue.find(1)
3126 journal = issue.journals.find(:first, :order => 'created_on DESC')
3139 journal = issue.journals.find(:first, :order => 'created_on DESC')
3127 assert_equal '125', issue.custom_value_for(2).value
3140 assert_equal '125', issue.custom_value_for(2).value
3128 assert_equal 'Bulk editing', journal.notes
3141 assert_equal 'Bulk editing', journal.notes
3129 assert_equal 1, journal.details.size
3142 assert_equal 1, journal.details.size
3130 end
3143 end
3131
3144
3132 def test_bulk_update_with_group_assignee
3145 def test_bulk_update_with_group_assignee
3133 group = Group.find(11)
3146 group = Group.find(11)
3134 project = Project.find(1)
3147 project = Project.find(1)
3135 project.members << Member.new(:principal => group, :roles => [Role.givable.first])
3148 project.members << Member.new(:principal => group, :roles => [Role.givable.first])
3136
3149
3137 @request.session[:user_id] = 2
3150 @request.session[:user_id] = 2
3138 # update issues assignee
3151 # update issues assignee
3139 post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing',
3152 post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing',
3140 :issue => {:priority_id => '',
3153 :issue => {:priority_id => '',
3141 :assigned_to_id => group.id,
3154 :assigned_to_id => group.id,
3142 :custom_field_values => {'2' => ''}}
3155 :custom_field_values => {'2' => ''}}
3143
3156
3144 assert_response 302
3157 assert_response 302
3145 assert_equal [group, group], Issue.find_all_by_id([1, 2]).collect {|i| i.assigned_to}
3158 assert_equal [group, group], Issue.find_all_by_id([1, 2]).collect {|i| i.assigned_to}
3146 end
3159 end
3147
3160
3148 def test_bulk_update_on_different_projects
3161 def test_bulk_update_on_different_projects
3149 @request.session[:user_id] = 2
3162 @request.session[:user_id] = 2
3150 # update issues priority
3163 # update issues priority
3151 post :bulk_update, :ids => [1, 2, 6], :notes => 'Bulk editing',
3164 post :bulk_update, :ids => [1, 2, 6], :notes => 'Bulk editing',
3152 :issue => {:priority_id => 7,
3165 :issue => {:priority_id => 7,
3153 :assigned_to_id => '',
3166 :assigned_to_id => '',
3154 :custom_field_values => {'2' => ''}}
3167 :custom_field_values => {'2' => ''}}
3155
3168
3156 assert_response 302
3169 assert_response 302
3157 # check that the issues were updated
3170 # check that the issues were updated
3158 assert_equal [7, 7, 7], Issue.find([1,2,6]).map(&:priority_id)
3171 assert_equal [7, 7, 7], Issue.find([1,2,6]).map(&:priority_id)
3159
3172
3160 issue = Issue.find(1)
3173 issue = Issue.find(1)
3161 journal = issue.journals.find(:first, :order => 'created_on DESC')
3174 journal = issue.journals.find(:first, :order => 'created_on DESC')
3162 assert_equal '125', issue.custom_value_for(2).value
3175 assert_equal '125', issue.custom_value_for(2).value
3163 assert_equal 'Bulk editing', journal.notes
3176 assert_equal 'Bulk editing', journal.notes
3164 assert_equal 1, journal.details.size
3177 assert_equal 1, journal.details.size
3165 end
3178 end
3166
3179
3167 def test_bulk_update_on_different_projects_without_rights
3180 def test_bulk_update_on_different_projects_without_rights
3168 @request.session[:user_id] = 3
3181 @request.session[:user_id] = 3
3169 user = User.find(3)
3182 user = User.find(3)
3170 action = { :controller => "issues", :action => "bulk_update" }
3183 action = { :controller => "issues", :action => "bulk_update" }
3171 assert user.allowed_to?(action, Issue.find(1).project)
3184 assert user.allowed_to?(action, Issue.find(1).project)
3172 assert ! user.allowed_to?(action, Issue.find(6).project)
3185 assert ! user.allowed_to?(action, Issue.find(6).project)
3173 post :bulk_update, :ids => [1, 6], :notes => 'Bulk should fail',
3186 post :bulk_update, :ids => [1, 6], :notes => 'Bulk should fail',
3174 :issue => {:priority_id => 7,
3187 :issue => {:priority_id => 7,
3175 :assigned_to_id => '',
3188 :assigned_to_id => '',
3176 :custom_field_values => {'2' => ''}}
3189 :custom_field_values => {'2' => ''}}
3177 assert_response 403
3190 assert_response 403
3178 assert_not_equal "Bulk should fail", Journal.last.notes
3191 assert_not_equal "Bulk should fail", Journal.last.notes
3179 end
3192 end
3180
3193
3181 def test_bullk_update_should_send_a_notification
3194 def test_bullk_update_should_send_a_notification
3182 @request.session[:user_id] = 2
3195 @request.session[:user_id] = 2
3183 ActionMailer::Base.deliveries.clear
3196 ActionMailer::Base.deliveries.clear
3184 post(:bulk_update,
3197 post(:bulk_update,
3185 {
3198 {
3186 :ids => [1, 2],
3199 :ids => [1, 2],
3187 :notes => 'Bulk editing',
3200 :notes => 'Bulk editing',
3188 :issue => {
3201 :issue => {
3189 :priority_id => 7,
3202 :priority_id => 7,
3190 :assigned_to_id => '',
3203 :assigned_to_id => '',
3191 :custom_field_values => {'2' => ''}
3204 :custom_field_values => {'2' => ''}
3192 }
3205 }
3193 })
3206 })
3194
3207
3195 assert_response 302
3208 assert_response 302
3196 assert_equal 2, ActionMailer::Base.deliveries.size
3209 assert_equal 2, ActionMailer::Base.deliveries.size
3197 end
3210 end
3198
3211
3199 def test_bulk_update_project
3212 def test_bulk_update_project
3200 @request.session[:user_id] = 2
3213 @request.session[:user_id] = 2
3201 post :bulk_update, :ids => [1, 2], :issue => {:project_id => '2'}
3214 post :bulk_update, :ids => [1, 2], :issue => {:project_id => '2'}
3202 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
3215 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
3203 # Issues moved to project 2
3216 # Issues moved to project 2
3204 assert_equal 2, Issue.find(1).project_id
3217 assert_equal 2, Issue.find(1).project_id
3205 assert_equal 2, Issue.find(2).project_id
3218 assert_equal 2, Issue.find(2).project_id
3206 # No tracker change
3219 # No tracker change
3207 assert_equal 1, Issue.find(1).tracker_id
3220 assert_equal 1, Issue.find(1).tracker_id
3208 assert_equal 2, Issue.find(2).tracker_id
3221 assert_equal 2, Issue.find(2).tracker_id
3209 end
3222 end
3210
3223
3211 def test_bulk_update_project_on_single_issue_should_follow_when_needed
3224 def test_bulk_update_project_on_single_issue_should_follow_when_needed
3212 @request.session[:user_id] = 2
3225 @request.session[:user_id] = 2
3213 post :bulk_update, :id => 1, :issue => {:project_id => '2'}, :follow => '1'
3226 post :bulk_update, :id => 1, :issue => {:project_id => '2'}, :follow => '1'
3214 assert_redirected_to '/issues/1'
3227 assert_redirected_to '/issues/1'
3215 end
3228 end
3216
3229
3217 def test_bulk_update_project_on_multiple_issues_should_follow_when_needed
3230 def test_bulk_update_project_on_multiple_issues_should_follow_when_needed
3218 @request.session[:user_id] = 2
3231 @request.session[:user_id] = 2
3219 post :bulk_update, :id => [1, 2], :issue => {:project_id => '2'}, :follow => '1'
3232 post :bulk_update, :id => [1, 2], :issue => {:project_id => '2'}, :follow => '1'
3220 assert_redirected_to '/projects/onlinestore/issues'
3233 assert_redirected_to '/projects/onlinestore/issues'
3221 end
3234 end
3222
3235
3223 def test_bulk_update_tracker
3236 def test_bulk_update_tracker
3224 @request.session[:user_id] = 2
3237 @request.session[:user_id] = 2
3225 post :bulk_update, :ids => [1, 2], :issue => {:tracker_id => '2'}
3238 post :bulk_update, :ids => [1, 2], :issue => {:tracker_id => '2'}
3226 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
3239 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
3227 assert_equal 2, Issue.find(1).tracker_id
3240 assert_equal 2, Issue.find(1).tracker_id
3228 assert_equal 2, Issue.find(2).tracker_id
3241 assert_equal 2, Issue.find(2).tracker_id
3229 end
3242 end
3230
3243
3231 def test_bulk_update_status
3244 def test_bulk_update_status
3232 @request.session[:user_id] = 2
3245 @request.session[:user_id] = 2
3233 # update issues priority
3246 # update issues priority
3234 post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing status',
3247 post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing status',
3235 :issue => {:priority_id => '',
3248 :issue => {:priority_id => '',
3236 :assigned_to_id => '',
3249 :assigned_to_id => '',
3237 :status_id => '5'}
3250 :status_id => '5'}
3238
3251
3239 assert_response 302
3252 assert_response 302
3240 issue = Issue.find(1)
3253 issue = Issue.find(1)
3241 assert issue.closed?
3254 assert issue.closed?
3242 end
3255 end
3243
3256
3244 def test_bulk_update_priority
3257 def test_bulk_update_priority
3245 @request.session[:user_id] = 2
3258 @request.session[:user_id] = 2
3246 post :bulk_update, :ids => [1, 2], :issue => {:priority_id => 6}
3259 post :bulk_update, :ids => [1, 2], :issue => {:priority_id => 6}
3247
3260
3248 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
3261 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
3249 assert_equal 6, Issue.find(1).priority_id
3262 assert_equal 6, Issue.find(1).priority_id
3250 assert_equal 6, Issue.find(2).priority_id
3263 assert_equal 6, Issue.find(2).priority_id
3251 end
3264 end
3252
3265
3253 def test_bulk_update_with_notes
3266 def test_bulk_update_with_notes
3254 @request.session[:user_id] = 2
3267 @request.session[:user_id] = 2
3255 post :bulk_update, :ids => [1, 2], :notes => 'Moving two issues'
3268 post :bulk_update, :ids => [1, 2], :notes => 'Moving two issues'
3256
3269
3257 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
3270 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
3258 assert_equal 'Moving two issues', Issue.find(1).journals.sort_by(&:id).last.notes
3271 assert_equal 'Moving two issues', Issue.find(1).journals.sort_by(&:id).last.notes
3259 assert_equal 'Moving two issues', Issue.find(2).journals.sort_by(&:id).last.notes
3272 assert_equal 'Moving two issues', Issue.find(2).journals.sort_by(&:id).last.notes
3260 end
3273 end
3261
3274
3262 def test_bulk_update_parent_id
3275 def test_bulk_update_parent_id
3263 @request.session[:user_id] = 2
3276 @request.session[:user_id] = 2
3264 post :bulk_update, :ids => [1, 3],
3277 post :bulk_update, :ids => [1, 3],
3265 :notes => 'Bulk editing parent',
3278 :notes => 'Bulk editing parent',
3266 :issue => {:priority_id => '', :assigned_to_id => '', :status_id => '', :parent_issue_id => '2'}
3279 :issue => {:priority_id => '', :assigned_to_id => '', :status_id => '', :parent_issue_id => '2'}
3267
3280
3268 assert_response 302
3281 assert_response 302
3269 parent = Issue.find(2)
3282 parent = Issue.find(2)
3270 assert_equal parent.id, Issue.find(1).parent_id
3283 assert_equal parent.id, Issue.find(1).parent_id
3271 assert_equal parent.id, Issue.find(3).parent_id
3284 assert_equal parent.id, Issue.find(3).parent_id
3272 assert_equal [1, 3], parent.children.collect(&:id).sort
3285 assert_equal [1, 3], parent.children.collect(&:id).sort
3273 end
3286 end
3274
3287
3275 def test_bulk_update_custom_field
3288 def test_bulk_update_custom_field
3276 @request.session[:user_id] = 2
3289 @request.session[:user_id] = 2
3277 # update issues priority
3290 # update issues priority
3278 post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing custom field',
3291 post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing custom field',
3279 :issue => {:priority_id => '',
3292 :issue => {:priority_id => '',
3280 :assigned_to_id => '',
3293 :assigned_to_id => '',
3281 :custom_field_values => {'2' => '777'}}
3294 :custom_field_values => {'2' => '777'}}
3282
3295
3283 assert_response 302
3296 assert_response 302
3284
3297
3285 issue = Issue.find(1)
3298 issue = Issue.find(1)
3286 journal = issue.journals.find(:first, :order => 'created_on DESC')
3299 journal = issue.journals.find(:first, :order => 'created_on DESC')
3287 assert_equal '777', issue.custom_value_for(2).value
3300 assert_equal '777', issue.custom_value_for(2).value
3288 assert_equal 1, journal.details.size
3301 assert_equal 1, journal.details.size
3289 assert_equal '125', journal.details.first.old_value
3302 assert_equal '125', journal.details.first.old_value
3290 assert_equal '777', journal.details.first.value
3303 assert_equal '777', journal.details.first.value
3291 end
3304 end
3292
3305
3293 def test_bulk_update_custom_field_to_blank
3306 def test_bulk_update_custom_field_to_blank
3294 @request.session[:user_id] = 2
3307 @request.session[:user_id] = 2
3295 post :bulk_update, :ids => [1, 3], :notes => 'Bulk editing custom field',
3308 post :bulk_update, :ids => [1, 3], :notes => 'Bulk editing custom field',
3296 :issue => {:priority_id => '',
3309 :issue => {:priority_id => '',
3297 :assigned_to_id => '',
3310 :assigned_to_id => '',
3298 :custom_field_values => {'1' => '__none__'}}
3311 :custom_field_values => {'1' => '__none__'}}
3299 assert_response 302
3312 assert_response 302
3300 assert_equal '', Issue.find(1).custom_field_value(1)
3313 assert_equal '', Issue.find(1).custom_field_value(1)
3301 assert_equal '', Issue.find(3).custom_field_value(1)
3314 assert_equal '', Issue.find(3).custom_field_value(1)
3302 end
3315 end
3303
3316
3304 def test_bulk_update_multi_custom_field
3317 def test_bulk_update_multi_custom_field
3305 field = CustomField.find(1)
3318 field = CustomField.find(1)
3306 field.update_attribute :multiple, true
3319 field.update_attribute :multiple, true
3307
3320
3308 @request.session[:user_id] = 2
3321 @request.session[:user_id] = 2
3309 post :bulk_update, :ids => [1, 2, 3], :notes => 'Bulk editing multi custom field',
3322 post :bulk_update, :ids => [1, 2, 3], :notes => 'Bulk editing multi custom field',
3310 :issue => {:priority_id => '',
3323 :issue => {:priority_id => '',
3311 :assigned_to_id => '',
3324 :assigned_to_id => '',
3312 :custom_field_values => {'1' => ['MySQL', 'Oracle']}}
3325 :custom_field_values => {'1' => ['MySQL', 'Oracle']}}
3313
3326
3314 assert_response 302
3327 assert_response 302
3315
3328
3316 assert_equal ['MySQL', 'Oracle'], Issue.find(1).custom_field_value(1).sort
3329 assert_equal ['MySQL', 'Oracle'], Issue.find(1).custom_field_value(1).sort
3317 assert_equal ['MySQL', 'Oracle'], Issue.find(3).custom_field_value(1).sort
3330 assert_equal ['MySQL', 'Oracle'], Issue.find(3).custom_field_value(1).sort
3318 # the custom field is not associated with the issue tracker
3331 # the custom field is not associated with the issue tracker
3319 assert_nil Issue.find(2).custom_field_value(1)
3332 assert_nil Issue.find(2).custom_field_value(1)
3320 end
3333 end
3321
3334
3322 def test_bulk_update_multi_custom_field_to_blank
3335 def test_bulk_update_multi_custom_field_to_blank
3323 field = CustomField.find(1)
3336 field = CustomField.find(1)
3324 field.update_attribute :multiple, true
3337 field.update_attribute :multiple, true
3325
3338
3326 @request.session[:user_id] = 2
3339 @request.session[:user_id] = 2
3327 post :bulk_update, :ids => [1, 3], :notes => 'Bulk editing multi custom field',
3340 post :bulk_update, :ids => [1, 3], :notes => 'Bulk editing multi custom field',
3328 :issue => {:priority_id => '',
3341 :issue => {:priority_id => '',
3329 :assigned_to_id => '',
3342 :assigned_to_id => '',
3330 :custom_field_values => {'1' => ['__none__']}}
3343 :custom_field_values => {'1' => ['__none__']}}
3331 assert_response 302
3344 assert_response 302
3332 assert_equal [''], Issue.find(1).custom_field_value(1)
3345 assert_equal [''], Issue.find(1).custom_field_value(1)
3333 assert_equal [''], Issue.find(3).custom_field_value(1)
3346 assert_equal [''], Issue.find(3).custom_field_value(1)
3334 end
3347 end
3335
3348
3336 def test_bulk_update_unassign
3349 def test_bulk_update_unassign
3337 assert_not_nil Issue.find(2).assigned_to
3350 assert_not_nil Issue.find(2).assigned_to
3338 @request.session[:user_id] = 2
3351 @request.session[:user_id] = 2
3339 # unassign issues
3352 # unassign issues
3340 post :bulk_update, :ids => [1, 2], :notes => 'Bulk unassigning', :issue => {:assigned_to_id => 'none'}
3353 post :bulk_update, :ids => [1, 2], :notes => 'Bulk unassigning', :issue => {:assigned_to_id => 'none'}
3341 assert_response 302
3354 assert_response 302
3342 # check that the issues were updated
3355 # check that the issues were updated
3343 assert_nil Issue.find(2).assigned_to
3356 assert_nil Issue.find(2).assigned_to
3344 end
3357 end
3345
3358
3346 def test_post_bulk_update_should_allow_fixed_version_to_be_set_to_a_subproject
3359 def test_post_bulk_update_should_allow_fixed_version_to_be_set_to_a_subproject
3347 @request.session[:user_id] = 2
3360 @request.session[:user_id] = 2
3348
3361
3349 post :bulk_update, :ids => [1,2], :issue => {:fixed_version_id => 4}
3362 post :bulk_update, :ids => [1,2], :issue => {:fixed_version_id => 4}
3350
3363
3351 assert_response :redirect
3364 assert_response :redirect
3352 issues = Issue.find([1,2])
3365 issues = Issue.find([1,2])
3353 issues.each do |issue|
3366 issues.each do |issue|
3354 assert_equal 4, issue.fixed_version_id
3367 assert_equal 4, issue.fixed_version_id
3355 assert_not_equal issue.project_id, issue.fixed_version.project_id
3368 assert_not_equal issue.project_id, issue.fixed_version.project_id
3356 end
3369 end
3357 end
3370 end
3358
3371
3359 def test_post_bulk_update_should_redirect_back_using_the_back_url_parameter
3372 def test_post_bulk_update_should_redirect_back_using_the_back_url_parameter
3360 @request.session[:user_id] = 2
3373 @request.session[:user_id] = 2
3361 post :bulk_update, :ids => [1,2], :back_url => '/issues'
3374 post :bulk_update, :ids => [1,2], :back_url => '/issues'
3362
3375
3363 assert_response :redirect
3376 assert_response :redirect
3364 assert_redirected_to '/issues'
3377 assert_redirected_to '/issues'
3365 end
3378 end
3366
3379
3367 def test_post_bulk_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host
3380 def test_post_bulk_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host
3368 @request.session[:user_id] = 2
3381 @request.session[:user_id] = 2
3369 post :bulk_update, :ids => [1,2], :back_url => 'http://google.com'
3382 post :bulk_update, :ids => [1,2], :back_url => 'http://google.com'
3370
3383
3371 assert_response :redirect
3384 assert_response :redirect
3372 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => Project.find(1).identifier
3385 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => Project.find(1).identifier
3373 end
3386 end
3374
3387
3375 def test_bulk_update_with_failure_should_set_flash
3388 def test_bulk_update_with_failure_should_set_flash
3376 @request.session[:user_id] = 2
3389 @request.session[:user_id] = 2
3377 Issue.update_all("subject = ''", "id = 2") # Make it invalid
3390 Issue.update_all("subject = ''", "id = 2") # Make it invalid
3378 post :bulk_update, :ids => [1, 2], :issue => {:priority_id => 6}
3391 post :bulk_update, :ids => [1, 2], :issue => {:priority_id => 6}
3379
3392
3380 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
3393 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
3381 assert_equal 'Failed to save 1 issue(s) on 2 selected: #2.', flash[:error]
3394 assert_equal 'Failed to save 1 issue(s) on 2 selected: #2.', flash[:error]
3382 end
3395 end
3383
3396
3384 def test_get_bulk_copy
3397 def test_get_bulk_copy
3385 @request.session[:user_id] = 2
3398 @request.session[:user_id] = 2
3386 get :bulk_edit, :ids => [1, 2, 3], :copy => '1'
3399 get :bulk_edit, :ids => [1, 2, 3], :copy => '1'
3387 assert_response :success
3400 assert_response :success
3388 assert_template 'bulk_edit'
3401 assert_template 'bulk_edit'
3389
3402
3390 issues = assigns(:issues)
3403 issues = assigns(:issues)
3391 assert_not_nil issues
3404 assert_not_nil issues
3392 assert_equal [1, 2, 3], issues.map(&:id).sort
3405 assert_equal [1, 2, 3], issues.map(&:id).sort
3393
3406
3394 assert_select 'input[name=copy_attachments]'
3407 assert_select 'input[name=copy_attachments]'
3395 end
3408 end
3396
3409
3397 def test_bulk_copy_to_another_project
3410 def test_bulk_copy_to_another_project
3398 @request.session[:user_id] = 2
3411 @request.session[:user_id] = 2
3399 assert_difference 'Issue.count', 2 do
3412 assert_difference 'Issue.count', 2 do
3400 assert_no_difference 'Project.find(1).issues.count' do
3413 assert_no_difference 'Project.find(1).issues.count' do
3401 post :bulk_update, :ids => [1, 2], :issue => {:project_id => '2'}, :copy => '1'
3414 post :bulk_update, :ids => [1, 2], :issue => {:project_id => '2'}, :copy => '1'
3402 end
3415 end
3403 end
3416 end
3404 assert_redirected_to '/projects/ecookbook/issues'
3417 assert_redirected_to '/projects/ecookbook/issues'
3405
3418
3406 copies = Issue.all(:order => 'id DESC', :limit => issues.size)
3419 copies = Issue.all(:order => 'id DESC', :limit => issues.size)
3407 copies.each do |copy|
3420 copies.each do |copy|
3408 assert_equal 2, copy.project_id
3421 assert_equal 2, copy.project_id
3409 end
3422 end
3410 end
3423 end
3411
3424
3412 def test_bulk_copy_should_allow_not_changing_the_issue_attributes
3425 def test_bulk_copy_should_allow_not_changing_the_issue_attributes
3413 @request.session[:user_id] = 2
3426 @request.session[:user_id] = 2
3414 issues = [
3427 issues = [
3415 Issue.create!(:project_id => 1, :tracker_id => 1, :status_id => 1, :priority_id => 2, :subject => 'issue 1', :author_id => 1, :assigned_to_id => nil),
3428 Issue.create!(:project_id => 1, :tracker_id => 1, :status_id => 1, :priority_id => 2, :subject => 'issue 1', :author_id => 1, :assigned_to_id => nil),
3416 Issue.create!(:project_id => 2, :tracker_id => 3, :status_id => 2, :priority_id => 1, :subject => 'issue 2', :author_id => 2, :assigned_to_id => 3)
3429 Issue.create!(:project_id => 2, :tracker_id => 3, :status_id => 2, :priority_id => 1, :subject => 'issue 2', :author_id => 2, :assigned_to_id => 3)
3417 ]
3430 ]
3418
3431
3419 assert_difference 'Issue.count', issues.size do
3432 assert_difference 'Issue.count', issues.size do
3420 post :bulk_update, :ids => issues.map(&:id), :copy => '1',
3433 post :bulk_update, :ids => issues.map(&:id), :copy => '1',
3421 :issue => {
3434 :issue => {
3422 :project_id => '', :tracker_id => '', :assigned_to_id => '',
3435 :project_id => '', :tracker_id => '', :assigned_to_id => '',
3423 :status_id => '', :start_date => '', :due_date => ''
3436 :status_id => '', :start_date => '', :due_date => ''
3424 }
3437 }
3425 end
3438 end
3426
3439
3427 copies = Issue.all(:order => 'id DESC', :limit => issues.size)
3440 copies = Issue.all(:order => 'id DESC', :limit => issues.size)
3428 issues.each do |orig|
3441 issues.each do |orig|
3429 copy = copies.detect {|c| c.subject == orig.subject}
3442 copy = copies.detect {|c| c.subject == orig.subject}
3430 assert_not_nil copy
3443 assert_not_nil copy
3431 assert_equal orig.project_id, copy.project_id
3444 assert_equal orig.project_id, copy.project_id
3432 assert_equal orig.tracker_id, copy.tracker_id
3445 assert_equal orig.tracker_id, copy.tracker_id
3433 assert_equal orig.status_id, copy.status_id
3446 assert_equal orig.status_id, copy.status_id
3434 assert_equal orig.assigned_to_id, copy.assigned_to_id
3447 assert_equal orig.assigned_to_id, copy.assigned_to_id
3435 assert_equal orig.priority_id, copy.priority_id
3448 assert_equal orig.priority_id, copy.priority_id
3436 end
3449 end
3437 end
3450 end
3438
3451
3439 def test_bulk_copy_should_allow_changing_the_issue_attributes
3452 def test_bulk_copy_should_allow_changing_the_issue_attributes
3440 # Fixes random test failure with Mysql
3453 # Fixes random test failure with Mysql
3441 # where Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2})
3454 # where Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2})
3442 # doesn't return the expected results
3455 # doesn't return the expected results
3443 Issue.delete_all("project_id=2")
3456 Issue.delete_all("project_id=2")
3444
3457
3445 @request.session[:user_id] = 2
3458 @request.session[:user_id] = 2
3446 assert_difference 'Issue.count', 2 do
3459 assert_difference 'Issue.count', 2 do
3447 assert_no_difference 'Project.find(1).issues.count' do
3460 assert_no_difference 'Project.find(1).issues.count' do
3448 post :bulk_update, :ids => [1, 2], :copy => '1',
3461 post :bulk_update, :ids => [1, 2], :copy => '1',
3449 :issue => {
3462 :issue => {
3450 :project_id => '2', :tracker_id => '', :assigned_to_id => '4',
3463 :project_id => '2', :tracker_id => '', :assigned_to_id => '4',
3451 :status_id => '1', :start_date => '2009-12-01', :due_date => '2009-12-31'
3464 :status_id => '1', :start_date => '2009-12-01', :due_date => '2009-12-31'
3452 }
3465 }
3453 end
3466 end
3454 end
3467 end
3455
3468
3456 copied_issues = Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2})
3469 copied_issues = Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2})
3457 assert_equal 2, copied_issues.size
3470 assert_equal 2, copied_issues.size
3458 copied_issues.each do |issue|
3471 copied_issues.each do |issue|
3459 assert_equal 2, issue.project_id, "Project is incorrect"
3472 assert_equal 2, issue.project_id, "Project is incorrect"
3460 assert_equal 4, issue.assigned_to_id, "Assigned to is incorrect"
3473 assert_equal 4, issue.assigned_to_id, "Assigned to is incorrect"
3461 assert_equal 1, issue.status_id, "Status is incorrect"
3474 assert_equal 1, issue.status_id, "Status is incorrect"
3462 assert_equal '2009-12-01', issue.start_date.to_s, "Start date is incorrect"
3475 assert_equal '2009-12-01', issue.start_date.to_s, "Start date is incorrect"
3463 assert_equal '2009-12-31', issue.due_date.to_s, "Due date is incorrect"
3476 assert_equal '2009-12-31', issue.due_date.to_s, "Due date is incorrect"
3464 end
3477 end
3465 end
3478 end
3466
3479
3467 def test_bulk_copy_should_allow_adding_a_note
3480 def test_bulk_copy_should_allow_adding_a_note
3468 @request.session[:user_id] = 2
3481 @request.session[:user_id] = 2
3469 assert_difference 'Issue.count', 1 do
3482 assert_difference 'Issue.count', 1 do
3470 post :bulk_update, :ids => [1], :copy => '1',
3483 post :bulk_update, :ids => [1], :copy => '1',
3471 :notes => 'Copying one issue',
3484 :notes => 'Copying one issue',
3472 :issue => {
3485 :issue => {
3473 :project_id => '', :tracker_id => '', :assigned_to_id => '4',
3486 :project_id => '', :tracker_id => '', :assigned_to_id => '4',
3474 :status_id => '3', :start_date => '2009-12-01', :due_date => '2009-12-31'
3487 :status_id => '3', :start_date => '2009-12-01', :due_date => '2009-12-31'
3475 }
3488 }
3476 end
3489 end
3477
3490
3478 issue = Issue.first(:order => 'id DESC')
3491 issue = Issue.first(:order => 'id DESC')
3479 assert_equal 1, issue.journals.size
3492 assert_equal 1, issue.journals.size
3480 journal = issue.journals.first
3493 journal = issue.journals.first
3481 assert_equal 0, journal.details.size
3494 assert_equal 0, journal.details.size
3482 assert_equal 'Copying one issue', journal.notes
3495 assert_equal 'Copying one issue', journal.notes
3483 end
3496 end
3484
3497
3485 def test_bulk_copy_should_allow_not_copying_the_attachments
3498 def test_bulk_copy_should_allow_not_copying_the_attachments
3486 attachment_count = Issue.find(3).attachments.size
3499 attachment_count = Issue.find(3).attachments.size
3487 assert attachment_count > 0
3500 assert attachment_count > 0
3488 @request.session[:user_id] = 2
3501 @request.session[:user_id] = 2
3489
3502
3490 assert_difference 'Issue.count', 1 do
3503 assert_difference 'Issue.count', 1 do
3491 assert_no_difference 'Attachment.count' do
3504 assert_no_difference 'Attachment.count' do
3492 post :bulk_update, :ids => [3], :copy => '1',
3505 post :bulk_update, :ids => [3], :copy => '1',
3493 :issue => {
3506 :issue => {
3494 :project_id => ''
3507 :project_id => ''
3495 }
3508 }
3496 end
3509 end
3497 end
3510 end
3498 end
3511 end
3499
3512
3500 def test_bulk_copy_should_allow_copying_the_attachments
3513 def test_bulk_copy_should_allow_copying_the_attachments
3501 attachment_count = Issue.find(3).attachments.size
3514 attachment_count = Issue.find(3).attachments.size
3502 assert attachment_count > 0
3515 assert attachment_count > 0
3503 @request.session[:user_id] = 2
3516 @request.session[:user_id] = 2
3504
3517
3505 assert_difference 'Issue.count', 1 do
3518 assert_difference 'Issue.count', 1 do
3506 assert_difference 'Attachment.count', attachment_count do
3519 assert_difference 'Attachment.count', attachment_count do
3507 post :bulk_update, :ids => [3], :copy => '1', :copy_attachments => '1',
3520 post :bulk_update, :ids => [3], :copy => '1', :copy_attachments => '1',
3508 :issue => {
3521 :issue => {
3509 :project_id => ''
3522 :project_id => ''
3510 }
3523 }
3511 end
3524 end
3512 end
3525 end
3513 end
3526 end
3514
3527
3528 def test_bulk_copy_should_add_relations_with_copied_issues
3529 @request.session[:user_id] = 2
3530
3531 assert_difference 'Issue.count', 2 do
3532 assert_difference 'IssueRelation.count', 2 do
3533 post :bulk_update, :ids => [1, 3], :copy => '1',
3534 :issue => {
3535 :project_id => '1'
3536 }
3537 end
3538 end
3539 end
3540
3515 def test_bulk_copy_should_allow_not_copying_the_subtasks
3541 def test_bulk_copy_should_allow_not_copying_the_subtasks
3516 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
3542 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
3517 @request.session[:user_id] = 2
3543 @request.session[:user_id] = 2
3518
3544
3519 assert_difference 'Issue.count', 1 do
3545 assert_difference 'Issue.count', 1 do
3520 post :bulk_update, :ids => [issue.id], :copy => '1',
3546 post :bulk_update, :ids => [issue.id], :copy => '1',
3521 :issue => {
3547 :issue => {
3522 :project_id => ''
3548 :project_id => ''
3523 }
3549 }
3524 end
3550 end
3525 end
3551 end
3526
3552
3527 def test_bulk_copy_should_allow_copying_the_subtasks
3553 def test_bulk_copy_should_allow_copying_the_subtasks
3528 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
3554 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
3529 count = issue.descendants.count
3555 count = issue.descendants.count
3530 @request.session[:user_id] = 2
3556 @request.session[:user_id] = 2
3531
3557
3532 assert_difference 'Issue.count', count+1 do
3558 assert_difference 'Issue.count', count+1 do
3533 post :bulk_update, :ids => [issue.id], :copy => '1', :copy_subtasks => '1',
3559 post :bulk_update, :ids => [issue.id], :copy => '1', :copy_subtasks => '1',
3534 :issue => {
3560 :issue => {
3535 :project_id => ''
3561 :project_id => ''
3536 }
3562 }
3537 end
3563 end
3538 copy = Issue.where(:parent_id => nil).order("id DESC").first
3564 copy = Issue.where(:parent_id => nil).order("id DESC").first
3539 assert_equal count, copy.descendants.count
3565 assert_equal count, copy.descendants.count
3540 end
3566 end
3541
3567
3542 def test_bulk_copy_should_not_copy_selected_subtasks_twice
3568 def test_bulk_copy_should_not_copy_selected_subtasks_twice
3543 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
3569 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
3544 count = issue.descendants.count
3570 count = issue.descendants.count
3545 @request.session[:user_id] = 2
3571 @request.session[:user_id] = 2
3546
3572
3547 assert_difference 'Issue.count', count+1 do
3573 assert_difference 'Issue.count', count+1 do
3548 post :bulk_update, :ids => issue.self_and_descendants.map(&:id), :copy => '1', :copy_subtasks => '1',
3574 post :bulk_update, :ids => issue.self_and_descendants.map(&:id), :copy => '1', :copy_subtasks => '1',
3549 :issue => {
3575 :issue => {
3550 :project_id => ''
3576 :project_id => ''
3551 }
3577 }
3552 end
3578 end
3553 copy = Issue.where(:parent_id => nil).order("id DESC").first
3579 copy = Issue.where(:parent_id => nil).order("id DESC").first
3554 assert_equal count, copy.descendants.count
3580 assert_equal count, copy.descendants.count
3555 end
3581 end
3556
3582
3557 def test_bulk_copy_to_another_project_should_follow_when_needed
3583 def test_bulk_copy_to_another_project_should_follow_when_needed
3558 @request.session[:user_id] = 2
3584 @request.session[:user_id] = 2
3559 post :bulk_update, :ids => [1], :copy => '1', :issue => {:project_id => 2}, :follow => '1'
3585 post :bulk_update, :ids => [1], :copy => '1', :issue => {:project_id => 2}, :follow => '1'
3560 issue = Issue.first(:order => 'id DESC')
3586 issue = Issue.first(:order => 'id DESC')
3561 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
3587 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
3562 end
3588 end
3563
3589
3564 def test_destroy_issue_with_no_time_entries
3590 def test_destroy_issue_with_no_time_entries
3565 assert_nil TimeEntry.find_by_issue_id(2)
3591 assert_nil TimeEntry.find_by_issue_id(2)
3566 @request.session[:user_id] = 2
3592 @request.session[:user_id] = 2
3567
3593
3568 assert_difference 'Issue.count', -1 do
3594 assert_difference 'Issue.count', -1 do
3569 delete :destroy, :id => 2
3595 delete :destroy, :id => 2
3570 end
3596 end
3571 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
3597 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
3572 assert_nil Issue.find_by_id(2)
3598 assert_nil Issue.find_by_id(2)
3573 end
3599 end
3574
3600
3575 def test_destroy_issues_with_time_entries
3601 def test_destroy_issues_with_time_entries
3576 @request.session[:user_id] = 2
3602 @request.session[:user_id] = 2
3577
3603
3578 assert_no_difference 'Issue.count' do
3604 assert_no_difference 'Issue.count' do
3579 delete :destroy, :ids => [1, 3]
3605 delete :destroy, :ids => [1, 3]
3580 end
3606 end
3581 assert_response :success
3607 assert_response :success
3582 assert_template 'destroy'
3608 assert_template 'destroy'
3583 assert_not_nil assigns(:hours)
3609 assert_not_nil assigns(:hours)
3584 assert Issue.find_by_id(1) && Issue.find_by_id(3)
3610 assert Issue.find_by_id(1) && Issue.find_by_id(3)
3585 assert_tag 'form',
3611 assert_tag 'form',
3586 :descendant => {:tag => 'input', :attributes => {:name => '_method', :value => 'delete'}}
3612 :descendant => {:tag => 'input', :attributes => {:name => '_method', :value => 'delete'}}
3587 end
3613 end
3588
3614
3589 def test_destroy_issues_and_destroy_time_entries
3615 def test_destroy_issues_and_destroy_time_entries
3590 @request.session[:user_id] = 2
3616 @request.session[:user_id] = 2
3591
3617
3592 assert_difference 'Issue.count', -2 do
3618 assert_difference 'Issue.count', -2 do
3593 assert_difference 'TimeEntry.count', -3 do
3619 assert_difference 'TimeEntry.count', -3 do
3594 delete :destroy, :ids => [1, 3], :todo => 'destroy'
3620 delete :destroy, :ids => [1, 3], :todo => 'destroy'
3595 end
3621 end
3596 end
3622 end
3597 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
3623 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
3598 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
3624 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
3599 assert_nil TimeEntry.find_by_id([1, 2])
3625 assert_nil TimeEntry.find_by_id([1, 2])
3600 end
3626 end
3601
3627
3602 def test_destroy_issues_and_assign_time_entries_to_project
3628 def test_destroy_issues_and_assign_time_entries_to_project
3603 @request.session[:user_id] = 2
3629 @request.session[:user_id] = 2
3604
3630
3605 assert_difference 'Issue.count', -2 do
3631 assert_difference 'Issue.count', -2 do
3606 assert_no_difference 'TimeEntry.count' do
3632 assert_no_difference 'TimeEntry.count' do
3607 delete :destroy, :ids => [1, 3], :todo => 'nullify'
3633 delete :destroy, :ids => [1, 3], :todo => 'nullify'
3608 end
3634 end
3609 end
3635 end
3610 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
3636 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
3611 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
3637 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
3612 assert_nil TimeEntry.find(1).issue_id
3638 assert_nil TimeEntry.find(1).issue_id
3613 assert_nil TimeEntry.find(2).issue_id
3639 assert_nil TimeEntry.find(2).issue_id
3614 end
3640 end
3615
3641
3616 def test_destroy_issues_and_reassign_time_entries_to_another_issue
3642 def test_destroy_issues_and_reassign_time_entries_to_another_issue
3617 @request.session[:user_id] = 2
3643 @request.session[:user_id] = 2
3618
3644
3619 assert_difference 'Issue.count', -2 do
3645 assert_difference 'Issue.count', -2 do
3620 assert_no_difference 'TimeEntry.count' do
3646 assert_no_difference 'TimeEntry.count' do
3621 delete :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2
3647 delete :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2
3622 end
3648 end
3623 end
3649 end
3624 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
3650 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
3625 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
3651 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
3626 assert_equal 2, TimeEntry.find(1).issue_id
3652 assert_equal 2, TimeEntry.find(1).issue_id
3627 assert_equal 2, TimeEntry.find(2).issue_id
3653 assert_equal 2, TimeEntry.find(2).issue_id
3628 end
3654 end
3629
3655
3630 def test_destroy_issues_from_different_projects
3656 def test_destroy_issues_from_different_projects
3631 @request.session[:user_id] = 2
3657 @request.session[:user_id] = 2
3632
3658
3633 assert_difference 'Issue.count', -3 do
3659 assert_difference 'Issue.count', -3 do
3634 delete :destroy, :ids => [1, 2, 6], :todo => 'destroy'
3660 delete :destroy, :ids => [1, 2, 6], :todo => 'destroy'
3635 end
3661 end
3636 assert_redirected_to :controller => 'issues', :action => 'index'
3662 assert_redirected_to :controller => 'issues', :action => 'index'
3637 assert !(Issue.find_by_id(1) || Issue.find_by_id(2) || Issue.find_by_id(6))
3663 assert !(Issue.find_by_id(1) || Issue.find_by_id(2) || Issue.find_by_id(6))
3638 end
3664 end
3639
3665
3640 def test_destroy_parent_and_child_issues
3666 def test_destroy_parent_and_child_issues
3641 parent = Issue.create!(:project_id => 1, :author_id => 1, :tracker_id => 1, :subject => 'Parent Issue')
3667 parent = Issue.create!(:project_id => 1, :author_id => 1, :tracker_id => 1, :subject => 'Parent Issue')
3642 child = Issue.create!(:project_id => 1, :author_id => 1, :tracker_id => 1, :subject => 'Child Issue', :parent_issue_id => parent.id)
3668 child = Issue.create!(:project_id => 1, :author_id => 1, :tracker_id => 1, :subject => 'Child Issue', :parent_issue_id => parent.id)
3643 assert child.is_descendant_of?(parent.reload)
3669 assert child.is_descendant_of?(parent.reload)
3644
3670
3645 @request.session[:user_id] = 2
3671 @request.session[:user_id] = 2
3646 assert_difference 'Issue.count', -2 do
3672 assert_difference 'Issue.count', -2 do
3647 delete :destroy, :ids => [parent.id, child.id], :todo => 'destroy'
3673 delete :destroy, :ids => [parent.id, child.id], :todo => 'destroy'
3648 end
3674 end
3649 assert_response 302
3675 assert_response 302
3650 end
3676 end
3651
3677
3652 def test_default_search_scope
3678 def test_default_search_scope
3653 get :index
3679 get :index
3654 assert_tag :div, :attributes => {:id => 'quick-search'},
3680 assert_tag :div, :attributes => {:id => 'quick-search'},
3655 :child => {:tag => 'form',
3681 :child => {:tag => 'form',
3656 :child => {:tag => 'input', :attributes => {:name => 'issues', :type => 'hidden', :value => '1'}}}
3682 :child => {:tag => 'input', :attributes => {:name => 'issues', :type => 'hidden', :value => '1'}}}
3657 end
3683 end
3658 end
3684 end
@@ -1,1579 +1,1592
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang
2 # Copyright (C) 2006-2012 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.expand_path('../../test_helper', __FILE__)
18 require File.expand_path('../../test_helper', __FILE__)
19
19
20 class IssueTest < ActiveSupport::TestCase
20 class IssueTest < ActiveSupport::TestCase
21 fixtures :projects, :users, :members, :member_roles, :roles,
21 fixtures :projects, :users, :members, :member_roles, :roles,
22 :groups_users,
22 :groups_users,
23 :trackers, :projects_trackers,
23 :trackers, :projects_trackers,
24 :enabled_modules,
24 :enabled_modules,
25 :versions,
25 :versions,
26 :issue_statuses, :issue_categories, :issue_relations, :workflows,
26 :issue_statuses, :issue_categories, :issue_relations, :workflows,
27 :enumerations,
27 :enumerations,
28 :issues, :journals, :journal_details,
28 :issues, :journals, :journal_details,
29 :custom_fields, :custom_fields_projects, :custom_fields_trackers, :custom_values,
29 :custom_fields, :custom_fields_projects, :custom_fields_trackers, :custom_values,
30 :time_entries
30 :time_entries
31
31
32 include Redmine::I18n
32 include Redmine::I18n
33
33
34 def teardown
34 def teardown
35 User.current = nil
35 User.current = nil
36 end
36 end
37
37
38 def test_create
38 def test_create
39 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
39 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
40 :status_id => 1, :priority => IssuePriority.all.first,
40 :status_id => 1, :priority => IssuePriority.all.first,
41 :subject => 'test_create',
41 :subject => 'test_create',
42 :description => 'IssueTest#test_create', :estimated_hours => '1:30')
42 :description => 'IssueTest#test_create', :estimated_hours => '1:30')
43 assert issue.save
43 assert issue.save
44 issue.reload
44 issue.reload
45 assert_equal 1.5, issue.estimated_hours
45 assert_equal 1.5, issue.estimated_hours
46 end
46 end
47
47
48 def test_create_minimal
48 def test_create_minimal
49 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
49 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
50 :status_id => 1, :priority => IssuePriority.all.first,
50 :status_id => 1, :priority => IssuePriority.all.first,
51 :subject => 'test_create')
51 :subject => 'test_create')
52 assert issue.save
52 assert issue.save
53 assert issue.description.nil?
53 assert issue.description.nil?
54 assert_nil issue.estimated_hours
54 assert_nil issue.estimated_hours
55 end
55 end
56
56
57 def test_create_with_required_custom_field
57 def test_create_with_required_custom_field
58 set_language_if_valid 'en'
58 set_language_if_valid 'en'
59 field = IssueCustomField.find_by_name('Database')
59 field = IssueCustomField.find_by_name('Database')
60 field.update_attribute(:is_required, true)
60 field.update_attribute(:is_required, true)
61
61
62 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1,
62 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1,
63 :status_id => 1, :subject => 'test_create',
63 :status_id => 1, :subject => 'test_create',
64 :description => 'IssueTest#test_create_with_required_custom_field')
64 :description => 'IssueTest#test_create_with_required_custom_field')
65 assert issue.available_custom_fields.include?(field)
65 assert issue.available_custom_fields.include?(field)
66 # No value for the custom field
66 # No value for the custom field
67 assert !issue.save
67 assert !issue.save
68 assert_equal ["Database can't be blank"], issue.errors.full_messages
68 assert_equal ["Database can't be blank"], issue.errors.full_messages
69 # Blank value
69 # Blank value
70 issue.custom_field_values = { field.id => '' }
70 issue.custom_field_values = { field.id => '' }
71 assert !issue.save
71 assert !issue.save
72 assert_equal ["Database can't be blank"], issue.errors.full_messages
72 assert_equal ["Database can't be blank"], issue.errors.full_messages
73 # Invalid value
73 # Invalid value
74 issue.custom_field_values = { field.id => 'SQLServer' }
74 issue.custom_field_values = { field.id => 'SQLServer' }
75 assert !issue.save
75 assert !issue.save
76 assert_equal ["Database is not included in the list"], issue.errors.full_messages
76 assert_equal ["Database is not included in the list"], issue.errors.full_messages
77 # Valid value
77 # Valid value
78 issue.custom_field_values = { field.id => 'PostgreSQL' }
78 issue.custom_field_values = { field.id => 'PostgreSQL' }
79 assert issue.save
79 assert issue.save
80 issue.reload
80 issue.reload
81 assert_equal 'PostgreSQL', issue.custom_value_for(field).value
81 assert_equal 'PostgreSQL', issue.custom_value_for(field).value
82 end
82 end
83
83
84 def test_create_with_group_assignment
84 def test_create_with_group_assignment
85 with_settings :issue_group_assignment => '1' do
85 with_settings :issue_group_assignment => '1' do
86 assert Issue.new(:project_id => 2, :tracker_id => 1, :author_id => 1,
86 assert Issue.new(:project_id => 2, :tracker_id => 1, :author_id => 1,
87 :subject => 'Group assignment',
87 :subject => 'Group assignment',
88 :assigned_to_id => 11).save
88 :assigned_to_id => 11).save
89 issue = Issue.first(:order => 'id DESC')
89 issue = Issue.first(:order => 'id DESC')
90 assert_kind_of Group, issue.assigned_to
90 assert_kind_of Group, issue.assigned_to
91 assert_equal Group.find(11), issue.assigned_to
91 assert_equal Group.find(11), issue.assigned_to
92 end
92 end
93 end
93 end
94
94
95 def assert_visibility_match(user, issues)
95 def assert_visibility_match(user, issues)
96 assert_equal issues.collect(&:id).sort, Issue.all.select {|issue| issue.visible?(user)}.collect(&:id).sort
96 assert_equal issues.collect(&:id).sort, Issue.all.select {|issue| issue.visible?(user)}.collect(&:id).sort
97 end
97 end
98
98
99 def test_visible_scope_for_anonymous
99 def test_visible_scope_for_anonymous
100 # Anonymous user should see issues of public projects only
100 # Anonymous user should see issues of public projects only
101 issues = Issue.visible(User.anonymous).all
101 issues = Issue.visible(User.anonymous).all
102 assert issues.any?
102 assert issues.any?
103 assert_nil issues.detect {|issue| !issue.project.is_public?}
103 assert_nil issues.detect {|issue| !issue.project.is_public?}
104 assert_nil issues.detect {|issue| issue.is_private?}
104 assert_nil issues.detect {|issue| issue.is_private?}
105 assert_visibility_match User.anonymous, issues
105 assert_visibility_match User.anonymous, issues
106 end
106 end
107
107
108 def test_visible_scope_for_anonymous_without_view_issues_permissions
108 def test_visible_scope_for_anonymous_without_view_issues_permissions
109 # Anonymous user should not see issues without permission
109 # Anonymous user should not see issues without permission
110 Role.anonymous.remove_permission!(:view_issues)
110 Role.anonymous.remove_permission!(:view_issues)
111 issues = Issue.visible(User.anonymous).all
111 issues = Issue.visible(User.anonymous).all
112 assert issues.empty?
112 assert issues.empty?
113 assert_visibility_match User.anonymous, issues
113 assert_visibility_match User.anonymous, issues
114 end
114 end
115
115
116 def test_anonymous_should_not_see_private_issues_with_issues_visibility_set_to_default
116 def test_anonymous_should_not_see_private_issues_with_issues_visibility_set_to_default
117 assert Role.anonymous.update_attribute(:issues_visibility, 'default')
117 assert Role.anonymous.update_attribute(:issues_visibility, 'default')
118 issue = Issue.generate_for_project!(Project.find(1), :author => User.anonymous, :assigned_to => User.anonymous, :is_private => true)
118 issue = Issue.generate_for_project!(Project.find(1), :author => User.anonymous, :assigned_to => User.anonymous, :is_private => true)
119 assert_nil Issue.where(:id => issue.id).visible(User.anonymous).first
119 assert_nil Issue.where(:id => issue.id).visible(User.anonymous).first
120 assert !issue.visible?(User.anonymous)
120 assert !issue.visible?(User.anonymous)
121 end
121 end
122
122
123 def test_anonymous_should_not_see_private_issues_with_issues_visibility_set_to_own
123 def test_anonymous_should_not_see_private_issues_with_issues_visibility_set_to_own
124 assert Role.anonymous.update_attribute(:issues_visibility, 'own')
124 assert Role.anonymous.update_attribute(:issues_visibility, 'own')
125 issue = Issue.generate_for_project!(Project.find(1), :author => User.anonymous, :assigned_to => User.anonymous, :is_private => true)
125 issue = Issue.generate_for_project!(Project.find(1), :author => User.anonymous, :assigned_to => User.anonymous, :is_private => true)
126 assert_nil Issue.where(:id => issue.id).visible(User.anonymous).first
126 assert_nil Issue.where(:id => issue.id).visible(User.anonymous).first
127 assert !issue.visible?(User.anonymous)
127 assert !issue.visible?(User.anonymous)
128 end
128 end
129
129
130 def test_visible_scope_for_non_member
130 def test_visible_scope_for_non_member
131 user = User.find(9)
131 user = User.find(9)
132 assert user.projects.empty?
132 assert user.projects.empty?
133 # Non member user should see issues of public projects only
133 # Non member user should see issues of public projects only
134 issues = Issue.visible(user).all
134 issues = Issue.visible(user).all
135 assert issues.any?
135 assert issues.any?
136 assert_nil issues.detect {|issue| !issue.project.is_public?}
136 assert_nil issues.detect {|issue| !issue.project.is_public?}
137 assert_nil issues.detect {|issue| issue.is_private?}
137 assert_nil issues.detect {|issue| issue.is_private?}
138 assert_visibility_match user, issues
138 assert_visibility_match user, issues
139 end
139 end
140
140
141 def test_visible_scope_for_non_member_with_own_issues_visibility
141 def test_visible_scope_for_non_member_with_own_issues_visibility
142 Role.non_member.update_attribute :issues_visibility, 'own'
142 Role.non_member.update_attribute :issues_visibility, 'own'
143 Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 9, :subject => 'Issue by non member')
143 Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 9, :subject => 'Issue by non member')
144 user = User.find(9)
144 user = User.find(9)
145
145
146 issues = Issue.visible(user).all
146 issues = Issue.visible(user).all
147 assert issues.any?
147 assert issues.any?
148 assert_nil issues.detect {|issue| issue.author != user}
148 assert_nil issues.detect {|issue| issue.author != user}
149 assert_visibility_match user, issues
149 assert_visibility_match user, issues
150 end
150 end
151
151
152 def test_visible_scope_for_non_member_without_view_issues_permissions
152 def test_visible_scope_for_non_member_without_view_issues_permissions
153 # Non member user should not see issues without permission
153 # Non member user should not see issues without permission
154 Role.non_member.remove_permission!(:view_issues)
154 Role.non_member.remove_permission!(:view_issues)
155 user = User.find(9)
155 user = User.find(9)
156 assert user.projects.empty?
156 assert user.projects.empty?
157 issues = Issue.visible(user).all
157 issues = Issue.visible(user).all
158 assert issues.empty?
158 assert issues.empty?
159 assert_visibility_match user, issues
159 assert_visibility_match user, issues
160 end
160 end
161
161
162 def test_visible_scope_for_member
162 def test_visible_scope_for_member
163 user = User.find(9)
163 user = User.find(9)
164 # User should see issues of projects for which he has view_issues permissions only
164 # User should see issues of projects for which he has view_issues permissions only
165 Role.non_member.remove_permission!(:view_issues)
165 Role.non_member.remove_permission!(:view_issues)
166 Member.create!(:principal => user, :project_id => 3, :role_ids => [2])
166 Member.create!(:principal => user, :project_id => 3, :role_ids => [2])
167 issues = Issue.visible(user).all
167 issues = Issue.visible(user).all
168 assert issues.any?
168 assert issues.any?
169 assert_nil issues.detect {|issue| issue.project_id != 3}
169 assert_nil issues.detect {|issue| issue.project_id != 3}
170 assert_nil issues.detect {|issue| issue.is_private?}
170 assert_nil issues.detect {|issue| issue.is_private?}
171 assert_visibility_match user, issues
171 assert_visibility_match user, issues
172 end
172 end
173
173
174 def test_visible_scope_for_member_with_groups_should_return_assigned_issues
174 def test_visible_scope_for_member_with_groups_should_return_assigned_issues
175 user = User.find(8)
175 user = User.find(8)
176 assert user.groups.any?
176 assert user.groups.any?
177 Member.create!(:principal => user.groups.first, :project_id => 1, :role_ids => [2])
177 Member.create!(:principal => user.groups.first, :project_id => 1, :role_ids => [2])
178 Role.non_member.remove_permission!(:view_issues)
178 Role.non_member.remove_permission!(:view_issues)
179
179
180 issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3,
180 issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3,
181 :status_id => 1, :priority => IssuePriority.all.first,
181 :status_id => 1, :priority => IssuePriority.all.first,
182 :subject => 'Assignment test',
182 :subject => 'Assignment test',
183 :assigned_to => user.groups.first,
183 :assigned_to => user.groups.first,
184 :is_private => true)
184 :is_private => true)
185
185
186 Role.find(2).update_attribute :issues_visibility, 'default'
186 Role.find(2).update_attribute :issues_visibility, 'default'
187 issues = Issue.visible(User.find(8)).all
187 issues = Issue.visible(User.find(8)).all
188 assert issues.any?
188 assert issues.any?
189 assert issues.include?(issue)
189 assert issues.include?(issue)
190
190
191 Role.find(2).update_attribute :issues_visibility, 'own'
191 Role.find(2).update_attribute :issues_visibility, 'own'
192 issues = Issue.visible(User.find(8)).all
192 issues = Issue.visible(User.find(8)).all
193 assert issues.any?
193 assert issues.any?
194 assert issues.include?(issue)
194 assert issues.include?(issue)
195 end
195 end
196
196
197 def test_visible_scope_for_admin
197 def test_visible_scope_for_admin
198 user = User.find(1)
198 user = User.find(1)
199 user.members.each(&:destroy)
199 user.members.each(&:destroy)
200 assert user.projects.empty?
200 assert user.projects.empty?
201 issues = Issue.visible(user).all
201 issues = Issue.visible(user).all
202 assert issues.any?
202 assert issues.any?
203 # Admin should see issues on private projects that he does not belong to
203 # Admin should see issues on private projects that he does not belong to
204 assert issues.detect {|issue| !issue.project.is_public?}
204 assert issues.detect {|issue| !issue.project.is_public?}
205 # Admin should see private issues of other users
205 # Admin should see private issues of other users
206 assert issues.detect {|issue| issue.is_private? && issue.author != user}
206 assert issues.detect {|issue| issue.is_private? && issue.author != user}
207 assert_visibility_match user, issues
207 assert_visibility_match user, issues
208 end
208 end
209
209
210 def test_visible_scope_with_project
210 def test_visible_scope_with_project
211 project = Project.find(1)
211 project = Project.find(1)
212 issues = Issue.visible(User.find(2), :project => project).all
212 issues = Issue.visible(User.find(2), :project => project).all
213 projects = issues.collect(&:project).uniq
213 projects = issues.collect(&:project).uniq
214 assert_equal 1, projects.size
214 assert_equal 1, projects.size
215 assert_equal project, projects.first
215 assert_equal project, projects.first
216 end
216 end
217
217
218 def test_visible_scope_with_project_and_subprojects
218 def test_visible_scope_with_project_and_subprojects
219 project = Project.find(1)
219 project = Project.find(1)
220 issues = Issue.visible(User.find(2), :project => project, :with_subprojects => true).all
220 issues = Issue.visible(User.find(2), :project => project, :with_subprojects => true).all
221 projects = issues.collect(&:project).uniq
221 projects = issues.collect(&:project).uniq
222 assert projects.size > 1
222 assert projects.size > 1
223 assert_equal [], projects.select {|p| !p.is_or_is_descendant_of?(project)}
223 assert_equal [], projects.select {|p| !p.is_or_is_descendant_of?(project)}
224 end
224 end
225
225
226 def test_visible_and_nested_set_scopes
226 def test_visible_and_nested_set_scopes
227 assert_equal 0, Issue.find(1).descendants.visible.all.size
227 assert_equal 0, Issue.find(1).descendants.visible.all.size
228 end
228 end
229
229
230 def test_open_scope
230 def test_open_scope
231 issues = Issue.open.all
231 issues = Issue.open.all
232 assert_nil issues.detect(&:closed?)
232 assert_nil issues.detect(&:closed?)
233 end
233 end
234
234
235 def test_open_scope_with_arg
235 def test_open_scope_with_arg
236 issues = Issue.open(false).all
236 issues = Issue.open(false).all
237 assert_equal issues, issues.select(&:closed?)
237 assert_equal issues, issues.select(&:closed?)
238 end
238 end
239
239
240 def test_errors_full_messages_should_include_custom_fields_errors
240 def test_errors_full_messages_should_include_custom_fields_errors
241 field = IssueCustomField.find_by_name('Database')
241 field = IssueCustomField.find_by_name('Database')
242
242
243 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1,
243 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1,
244 :status_id => 1, :subject => 'test_create',
244 :status_id => 1, :subject => 'test_create',
245 :description => 'IssueTest#test_create_with_required_custom_field')
245 :description => 'IssueTest#test_create_with_required_custom_field')
246 assert issue.available_custom_fields.include?(field)
246 assert issue.available_custom_fields.include?(field)
247 # Invalid value
247 # Invalid value
248 issue.custom_field_values = { field.id => 'SQLServer' }
248 issue.custom_field_values = { field.id => 'SQLServer' }
249
249
250 assert !issue.valid?
250 assert !issue.valid?
251 assert_equal 1, issue.errors.full_messages.size
251 assert_equal 1, issue.errors.full_messages.size
252 assert_equal "Database #{I18n.translate('activerecord.errors.messages.inclusion')}",
252 assert_equal "Database #{I18n.translate('activerecord.errors.messages.inclusion')}",
253 issue.errors.full_messages.first
253 issue.errors.full_messages.first
254 end
254 end
255
255
256 def test_update_issue_with_required_custom_field
256 def test_update_issue_with_required_custom_field
257 field = IssueCustomField.find_by_name('Database')
257 field = IssueCustomField.find_by_name('Database')
258 field.update_attribute(:is_required, true)
258 field.update_attribute(:is_required, true)
259
259
260 issue = Issue.find(1)
260 issue = Issue.find(1)
261 assert_nil issue.custom_value_for(field)
261 assert_nil issue.custom_value_for(field)
262 assert issue.available_custom_fields.include?(field)
262 assert issue.available_custom_fields.include?(field)
263 # No change to custom values, issue can be saved
263 # No change to custom values, issue can be saved
264 assert issue.save
264 assert issue.save
265 # Blank value
265 # Blank value
266 issue.custom_field_values = { field.id => '' }
266 issue.custom_field_values = { field.id => '' }
267 assert !issue.save
267 assert !issue.save
268 # Valid value
268 # Valid value
269 issue.custom_field_values = { field.id => 'PostgreSQL' }
269 issue.custom_field_values = { field.id => 'PostgreSQL' }
270 assert issue.save
270 assert issue.save
271 issue.reload
271 issue.reload
272 assert_equal 'PostgreSQL', issue.custom_value_for(field).value
272 assert_equal 'PostgreSQL', issue.custom_value_for(field).value
273 end
273 end
274
274
275 def test_should_not_update_attributes_if_custom_fields_validation_fails
275 def test_should_not_update_attributes_if_custom_fields_validation_fails
276 issue = Issue.find(1)
276 issue = Issue.find(1)
277 field = IssueCustomField.find_by_name('Database')
277 field = IssueCustomField.find_by_name('Database')
278 assert issue.available_custom_fields.include?(field)
278 assert issue.available_custom_fields.include?(field)
279
279
280 issue.custom_field_values = { field.id => 'Invalid' }
280 issue.custom_field_values = { field.id => 'Invalid' }
281 issue.subject = 'Should be not be saved'
281 issue.subject = 'Should be not be saved'
282 assert !issue.save
282 assert !issue.save
283
283
284 issue.reload
284 issue.reload
285 assert_equal "Can't print recipes", issue.subject
285 assert_equal "Can't print recipes", issue.subject
286 end
286 end
287
287
288 def test_should_not_recreate_custom_values_objects_on_update
288 def test_should_not_recreate_custom_values_objects_on_update
289 field = IssueCustomField.find_by_name('Database')
289 field = IssueCustomField.find_by_name('Database')
290
290
291 issue = Issue.find(1)
291 issue = Issue.find(1)
292 issue.custom_field_values = { field.id => 'PostgreSQL' }
292 issue.custom_field_values = { field.id => 'PostgreSQL' }
293 assert issue.save
293 assert issue.save
294 custom_value = issue.custom_value_for(field)
294 custom_value = issue.custom_value_for(field)
295 issue.reload
295 issue.reload
296 issue.custom_field_values = { field.id => 'MySQL' }
296 issue.custom_field_values = { field.id => 'MySQL' }
297 assert issue.save
297 assert issue.save
298 issue.reload
298 issue.reload
299 assert_equal custom_value.id, issue.custom_value_for(field).id
299 assert_equal custom_value.id, issue.custom_value_for(field).id
300 end
300 end
301
301
302 def test_should_not_update_custom_fields_on_changing_tracker_with_different_custom_fields
302 def test_should_not_update_custom_fields_on_changing_tracker_with_different_custom_fields
303 issue = Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :subject => 'Test', :custom_field_values => {'2' => 'Test'})
303 issue = Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :subject => 'Test', :custom_field_values => {'2' => 'Test'})
304 assert !Tracker.find(2).custom_field_ids.include?(2)
304 assert !Tracker.find(2).custom_field_ids.include?(2)
305
305
306 issue = Issue.find(issue.id)
306 issue = Issue.find(issue.id)
307 issue.attributes = {:tracker_id => 2, :custom_field_values => {'1' => ''}}
307 issue.attributes = {:tracker_id => 2, :custom_field_values => {'1' => ''}}
308
308
309 issue = Issue.find(issue.id)
309 issue = Issue.find(issue.id)
310 custom_value = issue.custom_value_for(2)
310 custom_value = issue.custom_value_for(2)
311 assert_not_nil custom_value
311 assert_not_nil custom_value
312 assert_equal 'Test', custom_value.value
312 assert_equal 'Test', custom_value.value
313 end
313 end
314
314
315 def test_assigning_tracker_id_should_reload_custom_fields_values
315 def test_assigning_tracker_id_should_reload_custom_fields_values
316 issue = Issue.new(:project => Project.find(1))
316 issue = Issue.new(:project => Project.find(1))
317 assert issue.custom_field_values.empty?
317 assert issue.custom_field_values.empty?
318 issue.tracker_id = 1
318 issue.tracker_id = 1
319 assert issue.custom_field_values.any?
319 assert issue.custom_field_values.any?
320 end
320 end
321
321
322 def test_assigning_attributes_should_assign_project_and_tracker_first
322 def test_assigning_attributes_should_assign_project_and_tracker_first
323 seq = sequence('seq')
323 seq = sequence('seq')
324 issue = Issue.new
324 issue = Issue.new
325 issue.expects(:project_id=).in_sequence(seq)
325 issue.expects(:project_id=).in_sequence(seq)
326 issue.expects(:tracker_id=).in_sequence(seq)
326 issue.expects(:tracker_id=).in_sequence(seq)
327 issue.expects(:subject=).in_sequence(seq)
327 issue.expects(:subject=).in_sequence(seq)
328 issue.attributes = {:tracker_id => 2, :project_id => 1, :subject => 'Test'}
328 issue.attributes = {:tracker_id => 2, :project_id => 1, :subject => 'Test'}
329 end
329 end
330
330
331 def test_assigning_tracker_and_custom_fields_should_assign_custom_fields
331 def test_assigning_tracker_and_custom_fields_should_assign_custom_fields
332 attributes = ActiveSupport::OrderedHash.new
332 attributes = ActiveSupport::OrderedHash.new
333 attributes['custom_field_values'] = { '1' => 'MySQL' }
333 attributes['custom_field_values'] = { '1' => 'MySQL' }
334 attributes['tracker_id'] = '1'
334 attributes['tracker_id'] = '1'
335 issue = Issue.new(:project => Project.find(1))
335 issue = Issue.new(:project => Project.find(1))
336 issue.attributes = attributes
336 issue.attributes = attributes
337 assert_equal 'MySQL', issue.custom_field_value(1)
337 assert_equal 'MySQL', issue.custom_field_value(1)
338 end
338 end
339
339
340 def test_should_update_issue_with_disabled_tracker
340 def test_should_update_issue_with_disabled_tracker
341 p = Project.find(1)
341 p = Project.find(1)
342 issue = Issue.find(1)
342 issue = Issue.find(1)
343
343
344 p.trackers.delete(issue.tracker)
344 p.trackers.delete(issue.tracker)
345 assert !p.trackers.include?(issue.tracker)
345 assert !p.trackers.include?(issue.tracker)
346
346
347 issue.reload
347 issue.reload
348 issue.subject = 'New subject'
348 issue.subject = 'New subject'
349 assert issue.save
349 assert issue.save
350 end
350 end
351
351
352 def test_should_not_set_a_disabled_tracker
352 def test_should_not_set_a_disabled_tracker
353 p = Project.find(1)
353 p = Project.find(1)
354 p.trackers.delete(Tracker.find(2))
354 p.trackers.delete(Tracker.find(2))
355
355
356 issue = Issue.find(1)
356 issue = Issue.find(1)
357 issue.tracker_id = 2
357 issue.tracker_id = 2
358 issue.subject = 'New subject'
358 issue.subject = 'New subject'
359 assert !issue.save
359 assert !issue.save
360 assert_not_nil issue.errors[:tracker_id]
360 assert_not_nil issue.errors[:tracker_id]
361 end
361 end
362
362
363 def test_category_based_assignment
363 def test_category_based_assignment
364 issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3,
364 issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3,
365 :status_id => 1, :priority => IssuePriority.all.first,
365 :status_id => 1, :priority => IssuePriority.all.first,
366 :subject => 'Assignment test',
366 :subject => 'Assignment test',
367 :description => 'Assignment test', :category_id => 1)
367 :description => 'Assignment test', :category_id => 1)
368 assert_equal IssueCategory.find(1).assigned_to, issue.assigned_to
368 assert_equal IssueCategory.find(1).assigned_to, issue.assigned_to
369 end
369 end
370
370
371 def test_new_statuses_allowed_to
371 def test_new_statuses_allowed_to
372 WorkflowTransition.delete_all
372 WorkflowTransition.delete_all
373
373
374 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2, :author => false, :assignee => false)
374 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2, :author => false, :assignee => false)
375 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3, :author => true, :assignee => false)
375 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3, :author => true, :assignee => false)
376 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4, :author => false, :assignee => true)
376 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4, :author => false, :assignee => true)
377 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5, :author => true, :assignee => true)
377 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5, :author => true, :assignee => true)
378 status = IssueStatus.find(1)
378 status = IssueStatus.find(1)
379 role = Role.find(1)
379 role = Role.find(1)
380 tracker = Tracker.find(1)
380 tracker = Tracker.find(1)
381 user = User.find(2)
381 user = User.find(2)
382
382
383 issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :author_id => 1)
383 issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :author_id => 1)
384 assert_equal [1, 2], issue.new_statuses_allowed_to(user).map(&:id)
384 assert_equal [1, 2], issue.new_statuses_allowed_to(user).map(&:id)
385
385
386 issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :author => user)
386 issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :author => user)
387 assert_equal [1, 2, 3, 5], issue.new_statuses_allowed_to(user).map(&:id)
387 assert_equal [1, 2, 3, 5], issue.new_statuses_allowed_to(user).map(&:id)
388
388
389 issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :author_id => 1, :assigned_to => user)
389 issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :author_id => 1, :assigned_to => user)
390 assert_equal [1, 2, 4, 5], issue.new_statuses_allowed_to(user).map(&:id)
390 assert_equal [1, 2, 4, 5], issue.new_statuses_allowed_to(user).map(&:id)
391
391
392 issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :author => user, :assigned_to => user)
392 issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :author => user, :assigned_to => user)
393 assert_equal [1, 2, 3, 4, 5], issue.new_statuses_allowed_to(user).map(&:id)
393 assert_equal [1, 2, 3, 4, 5], issue.new_statuses_allowed_to(user).map(&:id)
394 end
394 end
395
395
396 def test_new_statuses_allowed_to_should_return_all_transitions_for_admin
396 def test_new_statuses_allowed_to_should_return_all_transitions_for_admin
397 admin = User.find(1)
397 admin = User.find(1)
398 issue = Issue.find(1)
398 issue = Issue.find(1)
399 assert !admin.member_of?(issue.project)
399 assert !admin.member_of?(issue.project)
400 expected_statuses = [issue.status] + WorkflowTransition.find_all_by_old_status_id(issue.status_id).map(&:new_status).uniq.sort
400 expected_statuses = [issue.status] + WorkflowTransition.find_all_by_old_status_id(issue.status_id).map(&:new_status).uniq.sort
401
401
402 assert_equal expected_statuses, issue.new_statuses_allowed_to(admin)
402 assert_equal expected_statuses, issue.new_statuses_allowed_to(admin)
403 end
403 end
404
404
405 def test_new_statuses_allowed_to_should_return_default_and_current_status_when_copying
405 def test_new_statuses_allowed_to_should_return_default_and_current_status_when_copying
406 issue = Issue.find(1).copy
406 issue = Issue.find(1).copy
407 assert_equal [1], issue.new_statuses_allowed_to(User.find(2)).map(&:id)
407 assert_equal [1], issue.new_statuses_allowed_to(User.find(2)).map(&:id)
408
408
409 issue = Issue.find(2).copy
409 issue = Issue.find(2).copy
410 assert_equal [1, 2], issue.new_statuses_allowed_to(User.find(2)).map(&:id)
410 assert_equal [1, 2], issue.new_statuses_allowed_to(User.find(2)).map(&:id)
411 end
411 end
412
412
413 def test_safe_attributes_names_should_not_include_disabled_field
413 def test_safe_attributes_names_should_not_include_disabled_field
414 tracker = Tracker.new(:core_fields => %w(assigned_to_id fixed_version_id))
414 tracker = Tracker.new(:core_fields => %w(assigned_to_id fixed_version_id))
415
415
416 issue = Issue.new(:tracker => tracker)
416 issue = Issue.new(:tracker => tracker)
417 assert_include 'tracker_id', issue.safe_attribute_names
417 assert_include 'tracker_id', issue.safe_attribute_names
418 assert_include 'status_id', issue.safe_attribute_names
418 assert_include 'status_id', issue.safe_attribute_names
419 assert_include 'subject', issue.safe_attribute_names
419 assert_include 'subject', issue.safe_attribute_names
420 assert_include 'description', issue.safe_attribute_names
420 assert_include 'description', issue.safe_attribute_names
421 assert_include 'custom_field_values', issue.safe_attribute_names
421 assert_include 'custom_field_values', issue.safe_attribute_names
422 assert_include 'custom_fields', issue.safe_attribute_names
422 assert_include 'custom_fields', issue.safe_attribute_names
423 assert_include 'lock_version', issue.safe_attribute_names
423 assert_include 'lock_version', issue.safe_attribute_names
424
424
425 tracker.core_fields.each do |field|
425 tracker.core_fields.each do |field|
426 assert_include field, issue.safe_attribute_names
426 assert_include field, issue.safe_attribute_names
427 end
427 end
428
428
429 tracker.disabled_core_fields.each do |field|
429 tracker.disabled_core_fields.each do |field|
430 assert_not_include field, issue.safe_attribute_names
430 assert_not_include field, issue.safe_attribute_names
431 end
431 end
432 end
432 end
433
433
434 def test_safe_attributes_should_ignore_disabled_fields
434 def test_safe_attributes_should_ignore_disabled_fields
435 tracker = Tracker.find(1)
435 tracker = Tracker.find(1)
436 tracker.core_fields = %w(assigned_to_id due_date)
436 tracker.core_fields = %w(assigned_to_id due_date)
437 tracker.save!
437 tracker.save!
438
438
439 issue = Issue.new(:tracker => tracker)
439 issue = Issue.new(:tracker => tracker)
440 issue.safe_attributes = {'start_date' => '2012-07-14', 'due_date' => '2012-07-14'}
440 issue.safe_attributes = {'start_date' => '2012-07-14', 'due_date' => '2012-07-14'}
441 assert_nil issue.start_date
441 assert_nil issue.start_date
442 assert_equal Date.parse('2012-07-14'), issue.due_date
442 assert_equal Date.parse('2012-07-14'), issue.due_date
443 end
443 end
444
444
445 def test_safe_attributes_should_accept_target_tracker_enabled_fields
445 def test_safe_attributes_should_accept_target_tracker_enabled_fields
446 source = Tracker.find(1)
446 source = Tracker.find(1)
447 source.core_fields = []
447 source.core_fields = []
448 source.save!
448 source.save!
449 target = Tracker.find(2)
449 target = Tracker.find(2)
450 target.core_fields = %w(assigned_to_id due_date)
450 target.core_fields = %w(assigned_to_id due_date)
451 target.save!
451 target.save!
452
452
453 issue = Issue.new(:tracker => source)
453 issue = Issue.new(:tracker => source)
454 issue.safe_attributes = {'tracker_id' => 2, 'due_date' => '2012-07-14'}
454 issue.safe_attributes = {'tracker_id' => 2, 'due_date' => '2012-07-14'}
455 assert_equal target, issue.tracker
455 assert_equal target, issue.tracker
456 assert_equal Date.parse('2012-07-14'), issue.due_date
456 assert_equal Date.parse('2012-07-14'), issue.due_date
457 end
457 end
458
458
459 def test_safe_attributes_should_not_include_readonly_fields
459 def test_safe_attributes_should_not_include_readonly_fields
460 WorkflowPermission.delete_all
460 WorkflowPermission.delete_all
461 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
461 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
462 user = User.find(2)
462 user = User.find(2)
463
463
464 issue = Issue.new(:project_id => 1, :tracker_id => 1)
464 issue = Issue.new(:project_id => 1, :tracker_id => 1)
465 assert_equal %w(due_date), issue.read_only_attribute_names(user)
465 assert_equal %w(due_date), issue.read_only_attribute_names(user)
466 assert_not_include 'due_date', issue.safe_attribute_names(user)
466 assert_not_include 'due_date', issue.safe_attribute_names(user)
467
467
468 issue.send :safe_attributes=, {'start_date' => '2012-07-14', 'due_date' => '2012-07-14'}, user
468 issue.send :safe_attributes=, {'start_date' => '2012-07-14', 'due_date' => '2012-07-14'}, user
469 assert_equal Date.parse('2012-07-14'), issue.start_date
469 assert_equal Date.parse('2012-07-14'), issue.start_date
470 assert_nil issue.due_date
470 assert_nil issue.due_date
471 end
471 end
472
472
473 def test_safe_attributes_should_not_include_readonly_custom_fields
473 def test_safe_attributes_should_not_include_readonly_custom_fields
474 cf1 = IssueCustomField.create!(:name => 'Writable field', :field_format => 'string', :is_for_all => true, :tracker_ids => [1])
474 cf1 = IssueCustomField.create!(:name => 'Writable field', :field_format => 'string', :is_for_all => true, :tracker_ids => [1])
475 cf2 = IssueCustomField.create!(:name => 'Readonly field', :field_format => 'string', :is_for_all => true, :tracker_ids => [1])
475 cf2 = IssueCustomField.create!(:name => 'Readonly field', :field_format => 'string', :is_for_all => true, :tracker_ids => [1])
476
476
477 WorkflowPermission.delete_all
477 WorkflowPermission.delete_all
478 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'readonly')
478 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'readonly')
479 user = User.find(2)
479 user = User.find(2)
480
480
481 issue = Issue.new(:project_id => 1, :tracker_id => 1)
481 issue = Issue.new(:project_id => 1, :tracker_id => 1)
482 assert_equal [cf2.id.to_s], issue.read_only_attribute_names(user)
482 assert_equal [cf2.id.to_s], issue.read_only_attribute_names(user)
483 assert_not_include cf2.id.to_s, issue.safe_attribute_names(user)
483 assert_not_include cf2.id.to_s, issue.safe_attribute_names(user)
484
484
485 issue.send :safe_attributes=, {'custom_field_values' => {cf1.id.to_s => 'value1', cf2.id.to_s => 'value2'}}, user
485 issue.send :safe_attributes=, {'custom_field_values' => {cf1.id.to_s => 'value1', cf2.id.to_s => 'value2'}}, user
486 assert_equal 'value1', issue.custom_field_value(cf1)
486 assert_equal 'value1', issue.custom_field_value(cf1)
487 assert_nil issue.custom_field_value(cf2)
487 assert_nil issue.custom_field_value(cf2)
488
488
489 issue.send :safe_attributes=, {'custom_fields' => [{'id' => cf1.id.to_s, 'value' => 'valuea'}, {'id' => cf2.id.to_s, 'value' => 'valueb'}]}, user
489 issue.send :safe_attributes=, {'custom_fields' => [{'id' => cf1.id.to_s, 'value' => 'valuea'}, {'id' => cf2.id.to_s, 'value' => 'valueb'}]}, user
490 assert_equal 'valuea', issue.custom_field_value(cf1)
490 assert_equal 'valuea', issue.custom_field_value(cf1)
491 assert_nil issue.custom_field_value(cf2)
491 assert_nil issue.custom_field_value(cf2)
492 end
492 end
493
493
494 def test_editable_custom_field_values_should_return_non_readonly_custom_values
494 def test_editable_custom_field_values_should_return_non_readonly_custom_values
495 cf1 = IssueCustomField.create!(:name => 'Writable field', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
495 cf1 = IssueCustomField.create!(:name => 'Writable field', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
496 cf2 = IssueCustomField.create!(:name => 'Readonly field', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
496 cf2 = IssueCustomField.create!(:name => 'Readonly field', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
497
497
498 WorkflowPermission.delete_all
498 WorkflowPermission.delete_all
499 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'readonly')
499 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'readonly')
500 user = User.find(2)
500 user = User.find(2)
501
501
502 issue = Issue.new(:project_id => 1, :tracker_id => 1)
502 issue = Issue.new(:project_id => 1, :tracker_id => 1)
503 values = issue.editable_custom_field_values(user)
503 values = issue.editable_custom_field_values(user)
504 assert values.detect {|value| value.custom_field == cf1}
504 assert values.detect {|value| value.custom_field == cf1}
505 assert_nil values.detect {|value| value.custom_field == cf2}
505 assert_nil values.detect {|value| value.custom_field == cf2}
506
506
507 issue.tracker_id = 2
507 issue.tracker_id = 2
508 values = issue.editable_custom_field_values(user)
508 values = issue.editable_custom_field_values(user)
509 assert values.detect {|value| value.custom_field == cf1}
509 assert values.detect {|value| value.custom_field == cf1}
510 assert values.detect {|value| value.custom_field == cf2}
510 assert values.detect {|value| value.custom_field == cf2}
511 end
511 end
512
512
513 def test_safe_attributes_should_accept_target_tracker_writable_fields
513 def test_safe_attributes_should_accept_target_tracker_writable_fields
514 WorkflowPermission.delete_all
514 WorkflowPermission.delete_all
515 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
515 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
516 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => 'start_date', :rule => 'readonly')
516 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => 'start_date', :rule => 'readonly')
517 user = User.find(2)
517 user = User.find(2)
518
518
519 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1)
519 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1)
520
520
521 issue.send :safe_attributes=, {'start_date' => '2012-07-12', 'due_date' => '2012-07-14'}, user
521 issue.send :safe_attributes=, {'start_date' => '2012-07-12', 'due_date' => '2012-07-14'}, user
522 assert_equal Date.parse('2012-07-12'), issue.start_date
522 assert_equal Date.parse('2012-07-12'), issue.start_date
523 assert_nil issue.due_date
523 assert_nil issue.due_date
524
524
525 issue.send :safe_attributes=, {'start_date' => '2012-07-15', 'due_date' => '2012-07-16', 'tracker_id' => 2}, user
525 issue.send :safe_attributes=, {'start_date' => '2012-07-15', 'due_date' => '2012-07-16', 'tracker_id' => 2}, user
526 assert_equal Date.parse('2012-07-12'), issue.start_date
526 assert_equal Date.parse('2012-07-12'), issue.start_date
527 assert_equal Date.parse('2012-07-16'), issue.due_date
527 assert_equal Date.parse('2012-07-16'), issue.due_date
528 end
528 end
529
529
530 def test_safe_attributes_should_accept_target_status_writable_fields
530 def test_safe_attributes_should_accept_target_status_writable_fields
531 WorkflowPermission.delete_all
531 WorkflowPermission.delete_all
532 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
532 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
533 WorkflowPermission.create!(:old_status_id => 2, :tracker_id => 1, :role_id => 1, :field_name => 'start_date', :rule => 'readonly')
533 WorkflowPermission.create!(:old_status_id => 2, :tracker_id => 1, :role_id => 1, :field_name => 'start_date', :rule => 'readonly')
534 user = User.find(2)
534 user = User.find(2)
535
535
536 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1)
536 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1)
537
537
538 issue.send :safe_attributes=, {'start_date' => '2012-07-12', 'due_date' => '2012-07-14'}, user
538 issue.send :safe_attributes=, {'start_date' => '2012-07-12', 'due_date' => '2012-07-14'}, user
539 assert_equal Date.parse('2012-07-12'), issue.start_date
539 assert_equal Date.parse('2012-07-12'), issue.start_date
540 assert_nil issue.due_date
540 assert_nil issue.due_date
541
541
542 issue.send :safe_attributes=, {'start_date' => '2012-07-15', 'due_date' => '2012-07-16', 'status_id' => 2}, user
542 issue.send :safe_attributes=, {'start_date' => '2012-07-15', 'due_date' => '2012-07-16', 'status_id' => 2}, user
543 assert_equal Date.parse('2012-07-12'), issue.start_date
543 assert_equal Date.parse('2012-07-12'), issue.start_date
544 assert_equal Date.parse('2012-07-16'), issue.due_date
544 assert_equal Date.parse('2012-07-16'), issue.due_date
545 end
545 end
546
546
547 def test_required_attributes_should_be_validated
547 def test_required_attributes_should_be_validated
548 cf = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
548 cf = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
549
549
550 WorkflowPermission.delete_all
550 WorkflowPermission.delete_all
551 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'required')
551 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'required')
552 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'category_id', :rule => 'required')
552 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'category_id', :rule => 'required')
553 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => cf.id.to_s, :rule => 'required')
553 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => cf.id.to_s, :rule => 'required')
554
554
555 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => 'start_date', :rule => 'required')
555 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => 'start_date', :rule => 'required')
556 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => cf.id.to_s, :rule => 'required')
556 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => cf.id.to_s, :rule => 'required')
557 user = User.find(2)
557 user = User.find(2)
558
558
559 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1, :subject => 'Required fields', :author => user)
559 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1, :subject => 'Required fields', :author => user)
560 assert_equal [cf.id.to_s, "category_id", "due_date"], issue.required_attribute_names(user).sort
560 assert_equal [cf.id.to_s, "category_id", "due_date"], issue.required_attribute_names(user).sort
561 assert !issue.save, "Issue was saved"
561 assert !issue.save, "Issue was saved"
562 assert_equal ["Category can't be blank", "Due date can't be blank", "Foo can't be blank"], issue.errors.full_messages.sort
562 assert_equal ["Category can't be blank", "Due date can't be blank", "Foo can't be blank"], issue.errors.full_messages.sort
563
563
564 issue.tracker_id = 2
564 issue.tracker_id = 2
565 assert_equal [cf.id.to_s, "start_date"], issue.required_attribute_names(user).sort
565 assert_equal [cf.id.to_s, "start_date"], issue.required_attribute_names(user).sort
566 assert !issue.save, "Issue was saved"
566 assert !issue.save, "Issue was saved"
567 assert_equal ["Foo can't be blank", "Start date can't be blank"], issue.errors.full_messages.sort
567 assert_equal ["Foo can't be blank", "Start date can't be blank"], issue.errors.full_messages.sort
568
568
569 issue.start_date = Date.today
569 issue.start_date = Date.today
570 issue.custom_field_values = {cf.id.to_s => 'bar'}
570 issue.custom_field_values = {cf.id.to_s => 'bar'}
571 assert issue.save
571 assert issue.save
572 end
572 end
573
573
574 def test_required_attribute_names_for_multiple_roles_should_intersect_rules
574 def test_required_attribute_names_for_multiple_roles_should_intersect_rules
575 WorkflowPermission.delete_all
575 WorkflowPermission.delete_all
576 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'required')
576 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'required')
577 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'start_date', :rule => 'required')
577 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'start_date', :rule => 'required')
578 user = User.find(2)
578 user = User.find(2)
579 member = Member.find(1)
579 member = Member.find(1)
580 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1)
580 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1)
581
581
582 assert_equal %w(due_date start_date), issue.required_attribute_names(user).sort
582 assert_equal %w(due_date start_date), issue.required_attribute_names(user).sort
583
583
584 member.role_ids = [1, 2]
584 member.role_ids = [1, 2]
585 member.save!
585 member.save!
586 assert_equal [], issue.required_attribute_names(user.reload)
586 assert_equal [], issue.required_attribute_names(user.reload)
587
587
588 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 2, :field_name => 'due_date', :rule => 'required')
588 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 2, :field_name => 'due_date', :rule => 'required')
589 assert_equal %w(due_date), issue.required_attribute_names(user)
589 assert_equal %w(due_date), issue.required_attribute_names(user)
590
590
591 member.role_ids = [1, 2, 3]
591 member.role_ids = [1, 2, 3]
592 member.save!
592 member.save!
593 assert_equal [], issue.required_attribute_names(user.reload)
593 assert_equal [], issue.required_attribute_names(user.reload)
594
594
595 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 2, :field_name => 'due_date', :rule => 'readonly')
595 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 2, :field_name => 'due_date', :rule => 'readonly')
596 # required + readonly => required
596 # required + readonly => required
597 assert_equal %w(due_date), issue.required_attribute_names(user)
597 assert_equal %w(due_date), issue.required_attribute_names(user)
598 end
598 end
599
599
600 def test_read_only_attribute_names_for_multiple_roles_should_intersect_rules
600 def test_read_only_attribute_names_for_multiple_roles_should_intersect_rules
601 WorkflowPermission.delete_all
601 WorkflowPermission.delete_all
602 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
602 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
603 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'start_date', :rule => 'readonly')
603 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'start_date', :rule => 'readonly')
604 user = User.find(2)
604 user = User.find(2)
605 member = Member.find(1)
605 member = Member.find(1)
606 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1)
606 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1)
607
607
608 assert_equal %w(due_date start_date), issue.read_only_attribute_names(user).sort
608 assert_equal %w(due_date start_date), issue.read_only_attribute_names(user).sort
609
609
610 member.role_ids = [1, 2]
610 member.role_ids = [1, 2]
611 member.save!
611 member.save!
612 assert_equal [], issue.read_only_attribute_names(user.reload)
612 assert_equal [], issue.read_only_attribute_names(user.reload)
613
613
614 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 2, :field_name => 'due_date', :rule => 'readonly')
614 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 2, :field_name => 'due_date', :rule => 'readonly')
615 assert_equal %w(due_date), issue.read_only_attribute_names(user)
615 assert_equal %w(due_date), issue.read_only_attribute_names(user)
616 end
616 end
617
617
618 def test_copy
618 def test_copy
619 issue = Issue.new.copy_from(1)
619 issue = Issue.new.copy_from(1)
620 assert issue.copy?
620 assert issue.copy?
621 assert issue.save
621 assert issue.save
622 issue.reload
622 issue.reload
623 orig = Issue.find(1)
623 orig = Issue.find(1)
624 assert_equal orig.subject, issue.subject
624 assert_equal orig.subject, issue.subject
625 assert_equal orig.tracker, issue.tracker
625 assert_equal orig.tracker, issue.tracker
626 assert_equal "125", issue.custom_value_for(2).value
626 assert_equal "125", issue.custom_value_for(2).value
627 end
627 end
628
628
629 def test_copy_should_copy_status
629 def test_copy_should_copy_status
630 orig = Issue.find(8)
630 orig = Issue.find(8)
631 assert orig.status != IssueStatus.default
631 assert orig.status != IssueStatus.default
632
632
633 issue = Issue.new.copy_from(orig)
633 issue = Issue.new.copy_from(orig)
634 assert issue.save
634 assert issue.save
635 issue.reload
635 issue.reload
636 assert_equal orig.status, issue.status
636 assert_equal orig.status, issue.status
637 end
637 end
638
638
639 def test_copy_should_add_relation_with_copied_issue
640 copied = Issue.find(1)
641 issue = Issue.new.copy_from(copied)
642 assert issue.save
643 issue.reload
644
645 assert_equal 1, issue.relations.size
646 relation = issue.relations.first
647 assert_equal 'copied_to', relation.relation_type
648 assert_equal copied, relation.issue_from
649 assert_equal issue, relation.issue_to
650 end
651
639 def test_copy_should_copy_subtasks
652 def test_copy_should_copy_subtasks
640 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
653 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
641
654
642 copy = issue.reload.copy
655 copy = issue.reload.copy
643 copy.author = User.find(7)
656 copy.author = User.find(7)
644 assert_difference 'Issue.count', 1+issue.descendants.count do
657 assert_difference 'Issue.count', 1+issue.descendants.count do
645 assert copy.save
658 assert copy.save
646 end
659 end
647 copy.reload
660 copy.reload
648 assert_equal %w(Child1 Child2), copy.children.map(&:subject).sort
661 assert_equal %w(Child1 Child2), copy.children.map(&:subject).sort
649 child_copy = copy.children.detect {|c| c.subject == 'Child1'}
662 child_copy = copy.children.detect {|c| c.subject == 'Child1'}
650 assert_equal %w(Child11), child_copy.children.map(&:subject).sort
663 assert_equal %w(Child11), child_copy.children.map(&:subject).sort
651 assert_equal copy.author, child_copy.author
664 assert_equal copy.author, child_copy.author
652 end
665 end
653
666
654 def test_copy_should_copy_subtasks_to_target_project
667 def test_copy_should_copy_subtasks_to_target_project
655 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
668 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
656
669
657 copy = issue.copy(:project_id => 3)
670 copy = issue.copy(:project_id => 3)
658 assert_difference 'Issue.count', 1+issue.descendants.count do
671 assert_difference 'Issue.count', 1+issue.descendants.count do
659 assert copy.save
672 assert copy.save
660 end
673 end
661 assert_equal [3], copy.reload.descendants.map(&:project_id).uniq
674 assert_equal [3], copy.reload.descendants.map(&:project_id).uniq
662 end
675 end
663
676
664 def test_copy_should_not_copy_subtasks_twice_when_saving_twice
677 def test_copy_should_not_copy_subtasks_twice_when_saving_twice
665 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
678 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
666
679
667 copy = issue.reload.copy
680 copy = issue.reload.copy
668 assert_difference 'Issue.count', 1+issue.descendants.count do
681 assert_difference 'Issue.count', 1+issue.descendants.count do
669 assert copy.save
682 assert copy.save
670 assert copy.save
683 assert copy.save
671 end
684 end
672 end
685 end
673
686
674 def test_should_not_call_after_project_change_on_creation
687 def test_should_not_call_after_project_change_on_creation
675 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1, :subject => 'Test', :author_id => 1)
688 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1, :subject => 'Test', :author_id => 1)
676 issue.expects(:after_project_change).never
689 issue.expects(:after_project_change).never
677 issue.save!
690 issue.save!
678 end
691 end
679
692
680 def test_should_not_call_after_project_change_on_update
693 def test_should_not_call_after_project_change_on_update
681 issue = Issue.find(1)
694 issue = Issue.find(1)
682 issue.project = Project.find(1)
695 issue.project = Project.find(1)
683 issue.subject = 'No project change'
696 issue.subject = 'No project change'
684 issue.expects(:after_project_change).never
697 issue.expects(:after_project_change).never
685 issue.save!
698 issue.save!
686 end
699 end
687
700
688 def test_should_call_after_project_change_on_project_change
701 def test_should_call_after_project_change_on_project_change
689 issue = Issue.find(1)
702 issue = Issue.find(1)
690 issue.project = Project.find(2)
703 issue.project = Project.find(2)
691 issue.expects(:after_project_change).once
704 issue.expects(:after_project_change).once
692 issue.save!
705 issue.save!
693 end
706 end
694
707
695 def test_adding_journal_should_update_timestamp
708 def test_adding_journal_should_update_timestamp
696 issue = Issue.find(1)
709 issue = Issue.find(1)
697 updated_on_was = issue.updated_on
710 updated_on_was = issue.updated_on
698
711
699 issue.init_journal(User.first, "Adding notes")
712 issue.init_journal(User.first, "Adding notes")
700 assert_difference 'Journal.count' do
713 assert_difference 'Journal.count' do
701 assert issue.save
714 assert issue.save
702 end
715 end
703 issue.reload
716 issue.reload
704
717
705 assert_not_equal updated_on_was, issue.updated_on
718 assert_not_equal updated_on_was, issue.updated_on
706 end
719 end
707
720
708 def test_should_close_duplicates
721 def test_should_close_duplicates
709 # Create 3 issues
722 # Create 3 issues
710 project = Project.find(1)
723 project = Project.find(1)
711 issue1 = Issue.generate_for_project!(project)
724 issue1 = Issue.generate_for_project!(project)
712 issue2 = Issue.generate_for_project!(project)
725 issue2 = Issue.generate_for_project!(project)
713 issue3 = Issue.generate_for_project!(project)
726 issue3 = Issue.generate_for_project!(project)
714
727
715 # 2 is a dupe of 1
728 # 2 is a dupe of 1
716 IssueRelation.create!(:issue_from => issue2, :issue_to => issue1, :relation_type => IssueRelation::TYPE_DUPLICATES)
729 IssueRelation.create!(:issue_from => issue2, :issue_to => issue1, :relation_type => IssueRelation::TYPE_DUPLICATES)
717 # And 3 is a dupe of 2
730 # And 3 is a dupe of 2
718 IssueRelation.create!(:issue_from => issue3, :issue_to => issue2, :relation_type => IssueRelation::TYPE_DUPLICATES)
731 IssueRelation.create!(:issue_from => issue3, :issue_to => issue2, :relation_type => IssueRelation::TYPE_DUPLICATES)
719 # And 3 is a dupe of 1 (circular duplicates)
732 # And 3 is a dupe of 1 (circular duplicates)
720 IssueRelation.create!(:issue_from => issue3, :issue_to => issue1, :relation_type => IssueRelation::TYPE_DUPLICATES)
733 IssueRelation.create!(:issue_from => issue3, :issue_to => issue1, :relation_type => IssueRelation::TYPE_DUPLICATES)
721
734
722 assert issue1.reload.duplicates.include?(issue2)
735 assert issue1.reload.duplicates.include?(issue2)
723
736
724 # Closing issue 1
737 # Closing issue 1
725 issue1.init_journal(User.find(:first), "Closing issue1")
738 issue1.init_journal(User.find(:first), "Closing issue1")
726 issue1.status = IssueStatus.find :first, :conditions => {:is_closed => true}
739 issue1.status = IssueStatus.find :first, :conditions => {:is_closed => true}
727 assert issue1.save
740 assert issue1.save
728 # 2 and 3 should be also closed
741 # 2 and 3 should be also closed
729 assert issue2.reload.closed?
742 assert issue2.reload.closed?
730 assert issue3.reload.closed?
743 assert issue3.reload.closed?
731 end
744 end
732
745
733 def test_should_not_close_duplicated_issue
746 def test_should_not_close_duplicated_issue
734 project = Project.find(1)
747 project = Project.find(1)
735 issue1 = Issue.generate_for_project!(project)
748 issue1 = Issue.generate_for_project!(project)
736 issue2 = Issue.generate_for_project!(project)
749 issue2 = Issue.generate_for_project!(project)
737
750
738 # 2 is a dupe of 1
751 # 2 is a dupe of 1
739 IssueRelation.create(:issue_from => issue2, :issue_to => issue1, :relation_type => IssueRelation::TYPE_DUPLICATES)
752 IssueRelation.create(:issue_from => issue2, :issue_to => issue1, :relation_type => IssueRelation::TYPE_DUPLICATES)
740 # 2 is a dup of 1 but 1 is not a duplicate of 2
753 # 2 is a dup of 1 but 1 is not a duplicate of 2
741 assert !issue2.reload.duplicates.include?(issue1)
754 assert !issue2.reload.duplicates.include?(issue1)
742
755
743 # Closing issue 2
756 # Closing issue 2
744 issue2.init_journal(User.find(:first), "Closing issue2")
757 issue2.init_journal(User.find(:first), "Closing issue2")
745 issue2.status = IssueStatus.find :first, :conditions => {:is_closed => true}
758 issue2.status = IssueStatus.find :first, :conditions => {:is_closed => true}
746 assert issue2.save
759 assert issue2.save
747 # 1 should not be also closed
760 # 1 should not be also closed
748 assert !issue1.reload.closed?
761 assert !issue1.reload.closed?
749 end
762 end
750
763
751 def test_assignable_versions
764 def test_assignable_versions
752 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 1, :subject => 'New issue')
765 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 1, :subject => 'New issue')
753 assert_equal ['open'], issue.assignable_versions.collect(&:status).uniq
766 assert_equal ['open'], issue.assignable_versions.collect(&:status).uniq
754 end
767 end
755
768
756 def test_should_not_be_able_to_assign_a_new_issue_to_a_closed_version
769 def test_should_not_be_able_to_assign_a_new_issue_to_a_closed_version
757 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 1, :subject => 'New issue')
770 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 1, :subject => 'New issue')
758 assert !issue.save
771 assert !issue.save
759 assert_not_nil issue.errors[:fixed_version_id]
772 assert_not_nil issue.errors[:fixed_version_id]
760 end
773 end
761
774
762 def test_should_not_be_able_to_assign_a_new_issue_to_a_locked_version
775 def test_should_not_be_able_to_assign_a_new_issue_to_a_locked_version
763 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 2, :subject => 'New issue')
776 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 2, :subject => 'New issue')
764 assert !issue.save
777 assert !issue.save
765 assert_not_nil issue.errors[:fixed_version_id]
778 assert_not_nil issue.errors[:fixed_version_id]
766 end
779 end
767
780
768 def test_should_be_able_to_assign_a_new_issue_to_an_open_version
781 def test_should_be_able_to_assign_a_new_issue_to_an_open_version
769 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 3, :subject => 'New issue')
782 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 3, :subject => 'New issue')
770 assert issue.save
783 assert issue.save
771 end
784 end
772
785
773 def test_should_be_able_to_update_an_issue_assigned_to_a_closed_version
786 def test_should_be_able_to_update_an_issue_assigned_to_a_closed_version
774 issue = Issue.find(11)
787 issue = Issue.find(11)
775 assert_equal 'closed', issue.fixed_version.status
788 assert_equal 'closed', issue.fixed_version.status
776 issue.subject = 'Subject changed'
789 issue.subject = 'Subject changed'
777 assert issue.save
790 assert issue.save
778 end
791 end
779
792
780 def test_should_not_be_able_to_reopen_an_issue_assigned_to_a_closed_version
793 def test_should_not_be_able_to_reopen_an_issue_assigned_to_a_closed_version
781 issue = Issue.find(11)
794 issue = Issue.find(11)
782 issue.status_id = 1
795 issue.status_id = 1
783 assert !issue.save
796 assert !issue.save
784 assert_not_nil issue.errors[:base]
797 assert_not_nil issue.errors[:base]
785 end
798 end
786
799
787 def test_should_be_able_to_reopen_and_reassign_an_issue_assigned_to_a_closed_version
800 def test_should_be_able_to_reopen_and_reassign_an_issue_assigned_to_a_closed_version
788 issue = Issue.find(11)
801 issue = Issue.find(11)
789 issue.status_id = 1
802 issue.status_id = 1
790 issue.fixed_version_id = 3
803 issue.fixed_version_id = 3
791 assert issue.save
804 assert issue.save
792 end
805 end
793
806
794 def test_should_be_able_to_reopen_an_issue_assigned_to_a_locked_version
807 def test_should_be_able_to_reopen_an_issue_assigned_to_a_locked_version
795 issue = Issue.find(12)
808 issue = Issue.find(12)
796 assert_equal 'locked', issue.fixed_version.status
809 assert_equal 'locked', issue.fixed_version.status
797 issue.status_id = 1
810 issue.status_id = 1
798 assert issue.save
811 assert issue.save
799 end
812 end
800
813
801 def test_should_not_be_able_to_keep_unshared_version_when_changing_project
814 def test_should_not_be_able_to_keep_unshared_version_when_changing_project
802 issue = Issue.find(2)
815 issue = Issue.find(2)
803 assert_equal 2, issue.fixed_version_id
816 assert_equal 2, issue.fixed_version_id
804 issue.project_id = 3
817 issue.project_id = 3
805 assert_nil issue.fixed_version_id
818 assert_nil issue.fixed_version_id
806 issue.fixed_version_id = 2
819 issue.fixed_version_id = 2
807 assert !issue.save
820 assert !issue.save
808 assert_include 'Target version is not included in the list', issue.errors.full_messages
821 assert_include 'Target version is not included in the list', issue.errors.full_messages
809 end
822 end
810
823
811 def test_should_keep_shared_version_when_changing_project
824 def test_should_keep_shared_version_when_changing_project
812 Version.find(2).update_attribute :sharing, 'tree'
825 Version.find(2).update_attribute :sharing, 'tree'
813
826
814 issue = Issue.find(2)
827 issue = Issue.find(2)
815 assert_equal 2, issue.fixed_version_id
828 assert_equal 2, issue.fixed_version_id
816 issue.project_id = 3
829 issue.project_id = 3
817 assert_equal 2, issue.fixed_version_id
830 assert_equal 2, issue.fixed_version_id
818 assert issue.save
831 assert issue.save
819 end
832 end
820
833
821 def test_allowed_target_projects_on_move_should_include_projects_with_issue_tracking_enabled
834 def test_allowed_target_projects_on_move_should_include_projects_with_issue_tracking_enabled
822 assert_include Project.find(2), Issue.allowed_target_projects_on_move(User.find(2))
835 assert_include Project.find(2), Issue.allowed_target_projects_on_move(User.find(2))
823 end
836 end
824
837
825 def test_allowed_target_projects_on_move_should_not_include_projects_with_issue_tracking_disabled
838 def test_allowed_target_projects_on_move_should_not_include_projects_with_issue_tracking_disabled
826 Project.find(2).disable_module! :issue_tracking
839 Project.find(2).disable_module! :issue_tracking
827 assert_not_include Project.find(2), Issue.allowed_target_projects_on_move(User.find(2))
840 assert_not_include Project.find(2), Issue.allowed_target_projects_on_move(User.find(2))
828 end
841 end
829
842
830 def test_move_to_another_project_with_same_category
843 def test_move_to_another_project_with_same_category
831 issue = Issue.find(1)
844 issue = Issue.find(1)
832 issue.project = Project.find(2)
845 issue.project = Project.find(2)
833 assert issue.save
846 assert issue.save
834 issue.reload
847 issue.reload
835 assert_equal 2, issue.project_id
848 assert_equal 2, issue.project_id
836 # Category changes
849 # Category changes
837 assert_equal 4, issue.category_id
850 assert_equal 4, issue.category_id
838 # Make sure time entries were move to the target project
851 # Make sure time entries were move to the target project
839 assert_equal 2, issue.time_entries.first.project_id
852 assert_equal 2, issue.time_entries.first.project_id
840 end
853 end
841
854
842 def test_move_to_another_project_without_same_category
855 def test_move_to_another_project_without_same_category
843 issue = Issue.find(2)
856 issue = Issue.find(2)
844 issue.project = Project.find(2)
857 issue.project = Project.find(2)
845 assert issue.save
858 assert issue.save
846 issue.reload
859 issue.reload
847 assert_equal 2, issue.project_id
860 assert_equal 2, issue.project_id
848 # Category cleared
861 # Category cleared
849 assert_nil issue.category_id
862 assert_nil issue.category_id
850 end
863 end
851
864
852 def test_move_to_another_project_should_clear_fixed_version_when_not_shared
865 def test_move_to_another_project_should_clear_fixed_version_when_not_shared
853 issue = Issue.find(1)
866 issue = Issue.find(1)
854 issue.update_attribute(:fixed_version_id, 1)
867 issue.update_attribute(:fixed_version_id, 1)
855 issue.project = Project.find(2)
868 issue.project = Project.find(2)
856 assert issue.save
869 assert issue.save
857 issue.reload
870 issue.reload
858 assert_equal 2, issue.project_id
871 assert_equal 2, issue.project_id
859 # Cleared fixed_version
872 # Cleared fixed_version
860 assert_equal nil, issue.fixed_version
873 assert_equal nil, issue.fixed_version
861 end
874 end
862
875
863 def test_move_to_another_project_should_keep_fixed_version_when_shared_with_the_target_project
876 def test_move_to_another_project_should_keep_fixed_version_when_shared_with_the_target_project
864 issue = Issue.find(1)
877 issue = Issue.find(1)
865 issue.update_attribute(:fixed_version_id, 4)
878 issue.update_attribute(:fixed_version_id, 4)
866 issue.project = Project.find(5)
879 issue.project = Project.find(5)
867 assert issue.save
880 assert issue.save
868 issue.reload
881 issue.reload
869 assert_equal 5, issue.project_id
882 assert_equal 5, issue.project_id
870 # Keep fixed_version
883 # Keep fixed_version
871 assert_equal 4, issue.fixed_version_id
884 assert_equal 4, issue.fixed_version_id
872 end
885 end
873
886
874 def test_move_to_another_project_should_clear_fixed_version_when_not_shared_with_the_target_project
887 def test_move_to_another_project_should_clear_fixed_version_when_not_shared_with_the_target_project
875 issue = Issue.find(1)
888 issue = Issue.find(1)
876 issue.update_attribute(:fixed_version_id, 1)
889 issue.update_attribute(:fixed_version_id, 1)
877 issue.project = Project.find(5)
890 issue.project = Project.find(5)
878 assert issue.save
891 assert issue.save
879 issue.reload
892 issue.reload
880 assert_equal 5, issue.project_id
893 assert_equal 5, issue.project_id
881 # Cleared fixed_version
894 # Cleared fixed_version
882 assert_equal nil, issue.fixed_version
895 assert_equal nil, issue.fixed_version
883 end
896 end
884
897
885 def test_move_to_another_project_should_keep_fixed_version_when_shared_systemwide
898 def test_move_to_another_project_should_keep_fixed_version_when_shared_systemwide
886 issue = Issue.find(1)
899 issue = Issue.find(1)
887 issue.update_attribute(:fixed_version_id, 7)
900 issue.update_attribute(:fixed_version_id, 7)
888 issue.project = Project.find(2)
901 issue.project = Project.find(2)
889 assert issue.save
902 assert issue.save
890 issue.reload
903 issue.reload
891 assert_equal 2, issue.project_id
904 assert_equal 2, issue.project_id
892 # Keep fixed_version
905 # Keep fixed_version
893 assert_equal 7, issue.fixed_version_id
906 assert_equal 7, issue.fixed_version_id
894 end
907 end
895
908
896 def test_move_to_another_project_with_disabled_tracker
909 def test_move_to_another_project_with_disabled_tracker
897 issue = Issue.find(1)
910 issue = Issue.find(1)
898 target = Project.find(2)
911 target = Project.find(2)
899 target.tracker_ids = [3]
912 target.tracker_ids = [3]
900 target.save
913 target.save
901 issue.project = target
914 issue.project = target
902 assert issue.save
915 assert issue.save
903 issue.reload
916 issue.reload
904 assert_equal 2, issue.project_id
917 assert_equal 2, issue.project_id
905 assert_equal 3, issue.tracker_id
918 assert_equal 3, issue.tracker_id
906 end
919 end
907
920
908 def test_copy_to_the_same_project
921 def test_copy_to_the_same_project
909 issue = Issue.find(1)
922 issue = Issue.find(1)
910 copy = issue.copy
923 copy = issue.copy
911 assert_difference 'Issue.count' do
924 assert_difference 'Issue.count' do
912 copy.save!
925 copy.save!
913 end
926 end
914 assert_kind_of Issue, copy
927 assert_kind_of Issue, copy
915 assert_equal issue.project, copy.project
928 assert_equal issue.project, copy.project
916 assert_equal "125", copy.custom_value_for(2).value
929 assert_equal "125", copy.custom_value_for(2).value
917 end
930 end
918
931
919 def test_copy_to_another_project_and_tracker
932 def test_copy_to_another_project_and_tracker
920 issue = Issue.find(1)
933 issue = Issue.find(1)
921 copy = issue.copy(:project_id => 3, :tracker_id => 2)
934 copy = issue.copy(:project_id => 3, :tracker_id => 2)
922 assert_difference 'Issue.count' do
935 assert_difference 'Issue.count' do
923 copy.save!
936 copy.save!
924 end
937 end
925 copy.reload
938 copy.reload
926 assert_kind_of Issue, copy
939 assert_kind_of Issue, copy
927 assert_equal Project.find(3), copy.project
940 assert_equal Project.find(3), copy.project
928 assert_equal Tracker.find(2), copy.tracker
941 assert_equal Tracker.find(2), copy.tracker
929 # Custom field #2 is not associated with target tracker
942 # Custom field #2 is not associated with target tracker
930 assert_nil copy.custom_value_for(2)
943 assert_nil copy.custom_value_for(2)
931 end
944 end
932
945
933 context "#copy" do
946 context "#copy" do
934 setup do
947 setup do
935 @issue = Issue.find(1)
948 @issue = Issue.find(1)
936 end
949 end
937
950
938 should "not create a journal" do
951 should "not create a journal" do
939 copy = @issue.copy(:project_id => 3, :tracker_id => 2, :assigned_to_id => 3)
952 copy = @issue.copy(:project_id => 3, :tracker_id => 2, :assigned_to_id => 3)
940 copy.save!
953 copy.save!
941 assert_equal 0, copy.reload.journals.size
954 assert_equal 0, copy.reload.journals.size
942 end
955 end
943
956
944 should "allow assigned_to changes" do
957 should "allow assigned_to changes" do
945 copy = @issue.copy(:project_id => 3, :tracker_id => 2, :assigned_to_id => 3)
958 copy = @issue.copy(:project_id => 3, :tracker_id => 2, :assigned_to_id => 3)
946 assert_equal 3, copy.assigned_to_id
959 assert_equal 3, copy.assigned_to_id
947 end
960 end
948
961
949 should "allow status changes" do
962 should "allow status changes" do
950 copy = @issue.copy(:project_id => 3, :tracker_id => 2, :status_id => 2)
963 copy = @issue.copy(:project_id => 3, :tracker_id => 2, :status_id => 2)
951 assert_equal 2, copy.status_id
964 assert_equal 2, copy.status_id
952 end
965 end
953
966
954 should "allow start date changes" do
967 should "allow start date changes" do
955 date = Date.today
968 date = Date.today
956 copy = @issue.copy(:project_id => 3, :tracker_id => 2, :start_date => date)
969 copy = @issue.copy(:project_id => 3, :tracker_id => 2, :start_date => date)
957 assert_equal date, copy.start_date
970 assert_equal date, copy.start_date
958 end
971 end
959
972
960 should "allow due date changes" do
973 should "allow due date changes" do
961 date = Date.today
974 date = Date.today
962 copy = @issue.copy(:project_id => 3, :tracker_id => 2, :due_date => date)
975 copy = @issue.copy(:project_id => 3, :tracker_id => 2, :due_date => date)
963 assert_equal date, copy.due_date
976 assert_equal date, copy.due_date
964 end
977 end
965
978
966 should "set current user as author" do
979 should "set current user as author" do
967 User.current = User.find(9)
980 User.current = User.find(9)
968 copy = @issue.copy(:project_id => 3, :tracker_id => 2)
981 copy = @issue.copy(:project_id => 3, :tracker_id => 2)
969 assert_equal User.current, copy.author
982 assert_equal User.current, copy.author
970 end
983 end
971
984
972 should "create a journal with notes" do
985 should "create a journal with notes" do
973 date = Date.today
986 date = Date.today
974 notes = "Notes added when copying"
987 notes = "Notes added when copying"
975 copy = @issue.copy(:project_id => 3, :tracker_id => 2, :start_date => date)
988 copy = @issue.copy(:project_id => 3, :tracker_id => 2, :start_date => date)
976 copy.init_journal(User.current, notes)
989 copy.init_journal(User.current, notes)
977 copy.save!
990 copy.save!
978
991
979 assert_equal 1, copy.journals.size
992 assert_equal 1, copy.journals.size
980 journal = copy.journals.first
993 journal = copy.journals.first
981 assert_equal 0, journal.details.size
994 assert_equal 0, journal.details.size
982 assert_equal notes, journal.notes
995 assert_equal notes, journal.notes
983 end
996 end
984 end
997 end
985
998
986 def test_recipients_should_include_previous_assignee
999 def test_recipients_should_include_previous_assignee
987 user = User.find(3)
1000 user = User.find(3)
988 user.members.update_all ["mail_notification = ?", false]
1001 user.members.update_all ["mail_notification = ?", false]
989 user.update_attribute :mail_notification, 'only_assigned'
1002 user.update_attribute :mail_notification, 'only_assigned'
990
1003
991 issue = Issue.find(2)
1004 issue = Issue.find(2)
992 issue.assigned_to = nil
1005 issue.assigned_to = nil
993 assert_include user.mail, issue.recipients
1006 assert_include user.mail, issue.recipients
994 issue.save!
1007 issue.save!
995 assert !issue.recipients.include?(user.mail)
1008 assert !issue.recipients.include?(user.mail)
996 end
1009 end
997
1010
998 def test_recipients_should_not_include_users_that_cannot_view_the_issue
1011 def test_recipients_should_not_include_users_that_cannot_view_the_issue
999 issue = Issue.find(12)
1012 issue = Issue.find(12)
1000 assert issue.recipients.include?(issue.author.mail)
1013 assert issue.recipients.include?(issue.author.mail)
1001 # copy the issue to a private project
1014 # copy the issue to a private project
1002 copy = issue.copy(:project_id => 5, :tracker_id => 2)
1015 copy = issue.copy(:project_id => 5, :tracker_id => 2)
1003 # author is not a member of project anymore
1016 # author is not a member of project anymore
1004 assert !copy.recipients.include?(copy.author.mail)
1017 assert !copy.recipients.include?(copy.author.mail)
1005 end
1018 end
1006
1019
1007 def test_recipients_should_include_the_assigned_group_members
1020 def test_recipients_should_include_the_assigned_group_members
1008 group_member = User.generate!
1021 group_member = User.generate!
1009 group = Group.generate!
1022 group = Group.generate!
1010 group.users << group_member
1023 group.users << group_member
1011
1024
1012 issue = Issue.find(12)
1025 issue = Issue.find(12)
1013 issue.assigned_to = group
1026 issue.assigned_to = group
1014 assert issue.recipients.include?(group_member.mail)
1027 assert issue.recipients.include?(group_member.mail)
1015 end
1028 end
1016
1029
1017 def test_watcher_recipients_should_not_include_users_that_cannot_view_the_issue
1030 def test_watcher_recipients_should_not_include_users_that_cannot_view_the_issue
1018 user = User.find(3)
1031 user = User.find(3)
1019 issue = Issue.find(9)
1032 issue = Issue.find(9)
1020 Watcher.create!(:user => user, :watchable => issue)
1033 Watcher.create!(:user => user, :watchable => issue)
1021 assert issue.watched_by?(user)
1034 assert issue.watched_by?(user)
1022 assert !issue.watcher_recipients.include?(user.mail)
1035 assert !issue.watcher_recipients.include?(user.mail)
1023 end
1036 end
1024
1037
1025 def test_issue_destroy
1038 def test_issue_destroy
1026 Issue.find(1).destroy
1039 Issue.find(1).destroy
1027 assert_nil Issue.find_by_id(1)
1040 assert_nil Issue.find_by_id(1)
1028 assert_nil TimeEntry.find_by_issue_id(1)
1041 assert_nil TimeEntry.find_by_issue_id(1)
1029 end
1042 end
1030
1043
1031 def test_destroying_a_deleted_issue_should_not_raise_an_error
1044 def test_destroying_a_deleted_issue_should_not_raise_an_error
1032 issue = Issue.find(1)
1045 issue = Issue.find(1)
1033 Issue.find(1).destroy
1046 Issue.find(1).destroy
1034
1047
1035 assert_nothing_raised do
1048 assert_nothing_raised do
1036 assert_no_difference 'Issue.count' do
1049 assert_no_difference 'Issue.count' do
1037 issue.destroy
1050 issue.destroy
1038 end
1051 end
1039 assert issue.destroyed?
1052 assert issue.destroyed?
1040 end
1053 end
1041 end
1054 end
1042
1055
1043 def test_destroying_a_stale_issue_should_not_raise_an_error
1056 def test_destroying_a_stale_issue_should_not_raise_an_error
1044 issue = Issue.find(1)
1057 issue = Issue.find(1)
1045 Issue.find(1).update_attribute :subject, "Updated"
1058 Issue.find(1).update_attribute :subject, "Updated"
1046
1059
1047 assert_nothing_raised do
1060 assert_nothing_raised do
1048 assert_difference 'Issue.count', -1 do
1061 assert_difference 'Issue.count', -1 do
1049 issue.destroy
1062 issue.destroy
1050 end
1063 end
1051 assert issue.destroyed?
1064 assert issue.destroyed?
1052 end
1065 end
1053 end
1066 end
1054
1067
1055 def test_blocked
1068 def test_blocked
1056 blocked_issue = Issue.find(9)
1069 blocked_issue = Issue.find(9)
1057 blocking_issue = Issue.find(10)
1070 blocking_issue = Issue.find(10)
1058
1071
1059 assert blocked_issue.blocked?
1072 assert blocked_issue.blocked?
1060 assert !blocking_issue.blocked?
1073 assert !blocking_issue.blocked?
1061 end
1074 end
1062
1075
1063 def test_blocked_issues_dont_allow_closed_statuses
1076 def test_blocked_issues_dont_allow_closed_statuses
1064 blocked_issue = Issue.find(9)
1077 blocked_issue = Issue.find(9)
1065
1078
1066 allowed_statuses = blocked_issue.new_statuses_allowed_to(users(:users_002))
1079 allowed_statuses = blocked_issue.new_statuses_allowed_to(users(:users_002))
1067 assert !allowed_statuses.empty?
1080 assert !allowed_statuses.empty?
1068 closed_statuses = allowed_statuses.select {|st| st.is_closed?}
1081 closed_statuses = allowed_statuses.select {|st| st.is_closed?}
1069 assert closed_statuses.empty?
1082 assert closed_statuses.empty?
1070 end
1083 end
1071
1084
1072 def test_unblocked_issues_allow_closed_statuses
1085 def test_unblocked_issues_allow_closed_statuses
1073 blocking_issue = Issue.find(10)
1086 blocking_issue = Issue.find(10)
1074
1087
1075 allowed_statuses = blocking_issue.new_statuses_allowed_to(users(:users_002))
1088 allowed_statuses = blocking_issue.new_statuses_allowed_to(users(:users_002))
1076 assert !allowed_statuses.empty?
1089 assert !allowed_statuses.empty?
1077 closed_statuses = allowed_statuses.select {|st| st.is_closed?}
1090 closed_statuses = allowed_statuses.select {|st| st.is_closed?}
1078 assert !closed_statuses.empty?
1091 assert !closed_statuses.empty?
1079 end
1092 end
1080
1093
1081 def test_rescheduling_an_issue_should_reschedule_following_issue
1094 def test_rescheduling_an_issue_should_reschedule_following_issue
1082 issue1 = Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :subject => '-', :start_date => Date.today, :due_date => Date.today + 2)
1095 issue1 = Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :subject => '-', :start_date => Date.today, :due_date => Date.today + 2)
1083 issue2 = Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :subject => '-', :start_date => Date.today, :due_date => Date.today + 2)
1096 issue2 = Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :subject => '-', :start_date => Date.today, :due_date => Date.today + 2)
1084 IssueRelation.create!(:issue_from => issue1, :issue_to => issue2, :relation_type => IssueRelation::TYPE_PRECEDES)
1097 IssueRelation.create!(:issue_from => issue1, :issue_to => issue2, :relation_type => IssueRelation::TYPE_PRECEDES)
1085 assert_equal issue1.due_date + 1, issue2.reload.start_date
1098 assert_equal issue1.due_date + 1, issue2.reload.start_date
1086
1099
1087 issue1.due_date = Date.today + 5
1100 issue1.due_date = Date.today + 5
1088 issue1.save!
1101 issue1.save!
1089 assert_equal issue1.due_date + 1, issue2.reload.start_date
1102 assert_equal issue1.due_date + 1, issue2.reload.start_date
1090 end
1103 end
1091
1104
1092 def test_rescheduling_a_stale_issue_should_not_raise_an_error
1105 def test_rescheduling_a_stale_issue_should_not_raise_an_error
1093 stale = Issue.find(1)
1106 stale = Issue.find(1)
1094 issue = Issue.find(1)
1107 issue = Issue.find(1)
1095 issue.subject = "Updated"
1108 issue.subject = "Updated"
1096 issue.save!
1109 issue.save!
1097
1110
1098 date = 10.days.from_now.to_date
1111 date = 10.days.from_now.to_date
1099 assert_nothing_raised do
1112 assert_nothing_raised do
1100 stale.reschedule_after(date)
1113 stale.reschedule_after(date)
1101 end
1114 end
1102 assert_equal date, stale.reload.start_date
1115 assert_equal date, stale.reload.start_date
1103 end
1116 end
1104
1117
1105 def test_overdue
1118 def test_overdue
1106 assert Issue.new(:due_date => 1.day.ago.to_date).overdue?
1119 assert Issue.new(:due_date => 1.day.ago.to_date).overdue?
1107 assert !Issue.new(:due_date => Date.today).overdue?
1120 assert !Issue.new(:due_date => Date.today).overdue?
1108 assert !Issue.new(:due_date => 1.day.from_now.to_date).overdue?
1121 assert !Issue.new(:due_date => 1.day.from_now.to_date).overdue?
1109 assert !Issue.new(:due_date => nil).overdue?
1122 assert !Issue.new(:due_date => nil).overdue?
1110 assert !Issue.new(:due_date => 1.day.ago.to_date, :status => IssueStatus.find(:first, :conditions => {:is_closed => true})).overdue?
1123 assert !Issue.new(:due_date => 1.day.ago.to_date, :status => IssueStatus.find(:first, :conditions => {:is_closed => true})).overdue?
1111 end
1124 end
1112
1125
1113 context "#behind_schedule?" do
1126 context "#behind_schedule?" do
1114 should "be false if the issue has no start_date" do
1127 should "be false if the issue has no start_date" do
1115 assert !Issue.new(:start_date => nil, :due_date => 1.day.from_now.to_date, :done_ratio => 0).behind_schedule?
1128 assert !Issue.new(:start_date => nil, :due_date => 1.day.from_now.to_date, :done_ratio => 0).behind_schedule?
1116 end
1129 end
1117
1130
1118 should "be false if the issue has no end_date" do
1131 should "be false if the issue has no end_date" do
1119 assert !Issue.new(:start_date => 1.day.from_now.to_date, :due_date => nil, :done_ratio => 0).behind_schedule?
1132 assert !Issue.new(:start_date => 1.day.from_now.to_date, :due_date => nil, :done_ratio => 0).behind_schedule?
1120 end
1133 end
1121
1134
1122 should "be false if the issue has more done than it's calendar time" do
1135 should "be false if the issue has more done than it's calendar time" do
1123 assert !Issue.new(:start_date => 50.days.ago.to_date, :due_date => 50.days.from_now.to_date, :done_ratio => 90).behind_schedule?
1136 assert !Issue.new(:start_date => 50.days.ago.to_date, :due_date => 50.days.from_now.to_date, :done_ratio => 90).behind_schedule?
1124 end
1137 end
1125
1138
1126 should "be true if the issue hasn't been started at all" do
1139 should "be true if the issue hasn't been started at all" do
1127 assert Issue.new(:start_date => 1.day.ago.to_date, :due_date => 1.day.from_now.to_date, :done_ratio => 0).behind_schedule?
1140 assert Issue.new(:start_date => 1.day.ago.to_date, :due_date => 1.day.from_now.to_date, :done_ratio => 0).behind_schedule?
1128 end
1141 end
1129
1142
1130 should "be true if the issue has used more calendar time than it's done ratio" do
1143 should "be true if the issue has used more calendar time than it's done ratio" do
1131 assert Issue.new(:start_date => 100.days.ago.to_date, :due_date => Date.today, :done_ratio => 90).behind_schedule?
1144 assert Issue.new(:start_date => 100.days.ago.to_date, :due_date => Date.today, :done_ratio => 90).behind_schedule?
1132 end
1145 end
1133 end
1146 end
1134
1147
1135 context "#assignable_users" do
1148 context "#assignable_users" do
1136 should "be Users" do
1149 should "be Users" do
1137 assert_kind_of User, Issue.find(1).assignable_users.first
1150 assert_kind_of User, Issue.find(1).assignable_users.first
1138 end
1151 end
1139
1152
1140 should "include the issue author" do
1153 should "include the issue author" do
1141 project = Project.find(1)
1154 project = Project.find(1)
1142 non_project_member = User.generate!
1155 non_project_member = User.generate!
1143 issue = Issue.generate_for_project!(project, :author => non_project_member)
1156 issue = Issue.generate_for_project!(project, :author => non_project_member)
1144
1157
1145 assert issue.assignable_users.include?(non_project_member)
1158 assert issue.assignable_users.include?(non_project_member)
1146 end
1159 end
1147
1160
1148 should "include the current assignee" do
1161 should "include the current assignee" do
1149 project = Project.find(1)
1162 project = Project.find(1)
1150 user = User.generate!
1163 user = User.generate!
1151 issue = Issue.generate_for_project!(project, :assigned_to => user)
1164 issue = Issue.generate_for_project!(project, :assigned_to => user)
1152 user.lock!
1165 user.lock!
1153
1166
1154 assert Issue.find(issue.id).assignable_users.include?(user)
1167 assert Issue.find(issue.id).assignable_users.include?(user)
1155 end
1168 end
1156
1169
1157 should "not show the issue author twice" do
1170 should "not show the issue author twice" do
1158 assignable_user_ids = Issue.find(1).assignable_users.collect(&:id)
1171 assignable_user_ids = Issue.find(1).assignable_users.collect(&:id)
1159 assert_equal 2, assignable_user_ids.length
1172 assert_equal 2, assignable_user_ids.length
1160
1173
1161 assignable_user_ids.each do |user_id|
1174 assignable_user_ids.each do |user_id|
1162 assert_equal 1, assignable_user_ids.select {|i| i == user_id}.length, "User #{user_id} appears more or less than once"
1175 assert_equal 1, assignable_user_ids.select {|i| i == user_id}.length, "User #{user_id} appears more or less than once"
1163 end
1176 end
1164 end
1177 end
1165
1178
1166 context "with issue_group_assignment" do
1179 context "with issue_group_assignment" do
1167 should "include groups" do
1180 should "include groups" do
1168 issue = Issue.new(:project => Project.find(2))
1181 issue = Issue.new(:project => Project.find(2))
1169
1182
1170 with_settings :issue_group_assignment => '1' do
1183 with_settings :issue_group_assignment => '1' do
1171 assert_equal %w(Group User), issue.assignable_users.map {|a| a.class.name}.uniq.sort
1184 assert_equal %w(Group User), issue.assignable_users.map {|a| a.class.name}.uniq.sort
1172 assert issue.assignable_users.include?(Group.find(11))
1185 assert issue.assignable_users.include?(Group.find(11))
1173 end
1186 end
1174 end
1187 end
1175 end
1188 end
1176
1189
1177 context "without issue_group_assignment" do
1190 context "without issue_group_assignment" do
1178 should "not include groups" do
1191 should "not include groups" do
1179 issue = Issue.new(:project => Project.find(2))
1192 issue = Issue.new(:project => Project.find(2))
1180
1193
1181 with_settings :issue_group_assignment => '0' do
1194 with_settings :issue_group_assignment => '0' do
1182 assert_equal %w(User), issue.assignable_users.map {|a| a.class.name}.uniq.sort
1195 assert_equal %w(User), issue.assignable_users.map {|a| a.class.name}.uniq.sort
1183 assert !issue.assignable_users.include?(Group.find(11))
1196 assert !issue.assignable_users.include?(Group.find(11))
1184 end
1197 end
1185 end
1198 end
1186 end
1199 end
1187 end
1200 end
1188
1201
1189 def test_create_should_send_email_notification
1202 def test_create_should_send_email_notification
1190 ActionMailer::Base.deliveries.clear
1203 ActionMailer::Base.deliveries.clear
1191 issue = Issue.new(:project_id => 1, :tracker_id => 1,
1204 issue = Issue.new(:project_id => 1, :tracker_id => 1,
1192 :author_id => 3, :status_id => 1,
1205 :author_id => 3, :status_id => 1,
1193 :priority => IssuePriority.all.first,
1206 :priority => IssuePriority.all.first,
1194 :subject => 'test_create', :estimated_hours => '1:30')
1207 :subject => 'test_create', :estimated_hours => '1:30')
1195
1208
1196 assert issue.save
1209 assert issue.save
1197 assert_equal 1, ActionMailer::Base.deliveries.size
1210 assert_equal 1, ActionMailer::Base.deliveries.size
1198 end
1211 end
1199
1212
1200 def test_stale_issue_should_not_send_email_notification
1213 def test_stale_issue_should_not_send_email_notification
1201 ActionMailer::Base.deliveries.clear
1214 ActionMailer::Base.deliveries.clear
1202 issue = Issue.find(1)
1215 issue = Issue.find(1)
1203 stale = Issue.find(1)
1216 stale = Issue.find(1)
1204
1217
1205 issue.init_journal(User.find(1))
1218 issue.init_journal(User.find(1))
1206 issue.subject = 'Subjet update'
1219 issue.subject = 'Subjet update'
1207 assert issue.save
1220 assert issue.save
1208 assert_equal 1, ActionMailer::Base.deliveries.size
1221 assert_equal 1, ActionMailer::Base.deliveries.size
1209 ActionMailer::Base.deliveries.clear
1222 ActionMailer::Base.deliveries.clear
1210
1223
1211 stale.init_journal(User.find(1))
1224 stale.init_journal(User.find(1))
1212 stale.subject = 'Another subjet update'
1225 stale.subject = 'Another subjet update'
1213 assert_raise ActiveRecord::StaleObjectError do
1226 assert_raise ActiveRecord::StaleObjectError do
1214 stale.save
1227 stale.save
1215 end
1228 end
1216 assert ActionMailer::Base.deliveries.empty?
1229 assert ActionMailer::Base.deliveries.empty?
1217 end
1230 end
1218
1231
1219 def test_journalized_description
1232 def test_journalized_description
1220 IssueCustomField.delete_all
1233 IssueCustomField.delete_all
1221
1234
1222 i = Issue.first
1235 i = Issue.first
1223 old_description = i.description
1236 old_description = i.description
1224 new_description = "This is the new description"
1237 new_description = "This is the new description"
1225
1238
1226 i.init_journal(User.find(2))
1239 i.init_journal(User.find(2))
1227 i.description = new_description
1240 i.description = new_description
1228 assert_difference 'Journal.count', 1 do
1241 assert_difference 'Journal.count', 1 do
1229 assert_difference 'JournalDetail.count', 1 do
1242 assert_difference 'JournalDetail.count', 1 do
1230 i.save!
1243 i.save!
1231 end
1244 end
1232 end
1245 end
1233
1246
1234 detail = JournalDetail.first(:order => 'id DESC')
1247 detail = JournalDetail.first(:order => 'id DESC')
1235 assert_equal i, detail.journal.journalized
1248 assert_equal i, detail.journal.journalized
1236 assert_equal 'attr', detail.property
1249 assert_equal 'attr', detail.property
1237 assert_equal 'description', detail.prop_key
1250 assert_equal 'description', detail.prop_key
1238 assert_equal old_description, detail.old_value
1251 assert_equal old_description, detail.old_value
1239 assert_equal new_description, detail.value
1252 assert_equal new_description, detail.value
1240 end
1253 end
1241
1254
1242 def test_blank_descriptions_should_not_be_journalized
1255 def test_blank_descriptions_should_not_be_journalized
1243 IssueCustomField.delete_all
1256 IssueCustomField.delete_all
1244 Issue.update_all("description = NULL", "id=1")
1257 Issue.update_all("description = NULL", "id=1")
1245
1258
1246 i = Issue.find(1)
1259 i = Issue.find(1)
1247 i.init_journal(User.find(2))
1260 i.init_journal(User.find(2))
1248 i.subject = "blank description"
1261 i.subject = "blank description"
1249 i.description = "\r\n"
1262 i.description = "\r\n"
1250
1263
1251 assert_difference 'Journal.count', 1 do
1264 assert_difference 'Journal.count', 1 do
1252 assert_difference 'JournalDetail.count', 1 do
1265 assert_difference 'JournalDetail.count', 1 do
1253 i.save!
1266 i.save!
1254 end
1267 end
1255 end
1268 end
1256 end
1269 end
1257
1270
1258 def test_journalized_multi_custom_field
1271 def test_journalized_multi_custom_field
1259 field = IssueCustomField.create!(:name => 'filter', :field_format => 'list', :is_filter => true, :is_for_all => true,
1272 field = IssueCustomField.create!(:name => 'filter', :field_format => 'list', :is_filter => true, :is_for_all => true,
1260 :tracker_ids => [1], :possible_values => ['value1', 'value2', 'value3'], :multiple => true)
1273 :tracker_ids => [1], :possible_values => ['value1', 'value2', 'value3'], :multiple => true)
1261
1274
1262 issue = Issue.create!(:project_id => 1, :tracker_id => 1, :subject => 'Test', :author_id => 1)
1275 issue = Issue.create!(:project_id => 1, :tracker_id => 1, :subject => 'Test', :author_id => 1)
1263
1276
1264 assert_difference 'Journal.count' do
1277 assert_difference 'Journal.count' do
1265 assert_difference 'JournalDetail.count' do
1278 assert_difference 'JournalDetail.count' do
1266 issue.init_journal(User.first)
1279 issue.init_journal(User.first)
1267 issue.custom_field_values = {field.id => ['value1']}
1280 issue.custom_field_values = {field.id => ['value1']}
1268 issue.save!
1281 issue.save!
1269 end
1282 end
1270 assert_difference 'JournalDetail.count' do
1283 assert_difference 'JournalDetail.count' do
1271 issue.init_journal(User.first)
1284 issue.init_journal(User.first)
1272 issue.custom_field_values = {field.id => ['value1', 'value2']}
1285 issue.custom_field_values = {field.id => ['value1', 'value2']}
1273 issue.save!
1286 issue.save!
1274 end
1287 end
1275 assert_difference 'JournalDetail.count', 2 do
1288 assert_difference 'JournalDetail.count', 2 do
1276 issue.init_journal(User.first)
1289 issue.init_journal(User.first)
1277 issue.custom_field_values = {field.id => ['value3', 'value2']}
1290 issue.custom_field_values = {field.id => ['value3', 'value2']}
1278 issue.save!
1291 issue.save!
1279 end
1292 end
1280 assert_difference 'JournalDetail.count', 2 do
1293 assert_difference 'JournalDetail.count', 2 do
1281 issue.init_journal(User.first)
1294 issue.init_journal(User.first)
1282 issue.custom_field_values = {field.id => nil}
1295 issue.custom_field_values = {field.id => nil}
1283 issue.save!
1296 issue.save!
1284 end
1297 end
1285 end
1298 end
1286 end
1299 end
1287
1300
1288 def test_description_eol_should_be_normalized
1301 def test_description_eol_should_be_normalized
1289 i = Issue.new(:description => "CR \r LF \n CRLF \r\n")
1302 i = Issue.new(:description => "CR \r LF \n CRLF \r\n")
1290 assert_equal "CR \r\n LF \r\n CRLF \r\n", i.description
1303 assert_equal "CR \r\n LF \r\n CRLF \r\n", i.description
1291 end
1304 end
1292
1305
1293 def test_saving_twice_should_not_duplicate_journal_details
1306 def test_saving_twice_should_not_duplicate_journal_details
1294 i = Issue.find(:first)
1307 i = Issue.find(:first)
1295 i.init_journal(User.find(2), 'Some notes')
1308 i.init_journal(User.find(2), 'Some notes')
1296 # initial changes
1309 # initial changes
1297 i.subject = 'New subject'
1310 i.subject = 'New subject'
1298 i.done_ratio = i.done_ratio + 10
1311 i.done_ratio = i.done_ratio + 10
1299 assert_difference 'Journal.count' do
1312 assert_difference 'Journal.count' do
1300 assert i.save
1313 assert i.save
1301 end
1314 end
1302 # 1 more change
1315 # 1 more change
1303 i.priority = IssuePriority.find(:first, :conditions => ["id <> ?", i.priority_id])
1316 i.priority = IssuePriority.find(:first, :conditions => ["id <> ?", i.priority_id])
1304 assert_no_difference 'Journal.count' do
1317 assert_no_difference 'Journal.count' do
1305 assert_difference 'JournalDetail.count', 1 do
1318 assert_difference 'JournalDetail.count', 1 do
1306 i.save
1319 i.save
1307 end
1320 end
1308 end
1321 end
1309 # no more change
1322 # no more change
1310 assert_no_difference 'Journal.count' do
1323 assert_no_difference 'Journal.count' do
1311 assert_no_difference 'JournalDetail.count' do
1324 assert_no_difference 'JournalDetail.count' do
1312 i.save
1325 i.save
1313 end
1326 end
1314 end
1327 end
1315 end
1328 end
1316
1329
1317 def test_all_dependent_issues
1330 def test_all_dependent_issues
1318 IssueRelation.delete_all
1331 IssueRelation.delete_all
1319 assert IssueRelation.create!(:issue_from => Issue.find(1),
1332 assert IssueRelation.create!(:issue_from => Issue.find(1),
1320 :issue_to => Issue.find(2),
1333 :issue_to => Issue.find(2),
1321 :relation_type => IssueRelation::TYPE_PRECEDES)
1334 :relation_type => IssueRelation::TYPE_PRECEDES)
1322 assert IssueRelation.create!(:issue_from => Issue.find(2),
1335 assert IssueRelation.create!(:issue_from => Issue.find(2),
1323 :issue_to => Issue.find(3),
1336 :issue_to => Issue.find(3),
1324 :relation_type => IssueRelation::TYPE_PRECEDES)
1337 :relation_type => IssueRelation::TYPE_PRECEDES)
1325 assert IssueRelation.create!(:issue_from => Issue.find(3),
1338 assert IssueRelation.create!(:issue_from => Issue.find(3),
1326 :issue_to => Issue.find(8),
1339 :issue_to => Issue.find(8),
1327 :relation_type => IssueRelation::TYPE_PRECEDES)
1340 :relation_type => IssueRelation::TYPE_PRECEDES)
1328
1341
1329 assert_equal [2, 3, 8], Issue.find(1).all_dependent_issues.collect(&:id).sort
1342 assert_equal [2, 3, 8], Issue.find(1).all_dependent_issues.collect(&:id).sort
1330 end
1343 end
1331
1344
1332 def test_all_dependent_issues_with_persistent_circular_dependency
1345 def test_all_dependent_issues_with_persistent_circular_dependency
1333 IssueRelation.delete_all
1346 IssueRelation.delete_all
1334 assert IssueRelation.create!(:issue_from => Issue.find(1),
1347 assert IssueRelation.create!(:issue_from => Issue.find(1),
1335 :issue_to => Issue.find(2),
1348 :issue_to => Issue.find(2),
1336 :relation_type => IssueRelation::TYPE_PRECEDES)
1349 :relation_type => IssueRelation::TYPE_PRECEDES)
1337 assert IssueRelation.create!(:issue_from => Issue.find(2),
1350 assert IssueRelation.create!(:issue_from => Issue.find(2),
1338 :issue_to => Issue.find(3),
1351 :issue_to => Issue.find(3),
1339 :relation_type => IssueRelation::TYPE_PRECEDES)
1352 :relation_type => IssueRelation::TYPE_PRECEDES)
1340
1353
1341 r = IssueRelation.create!(:issue_from => Issue.find(3),
1354 r = IssueRelation.create!(:issue_from => Issue.find(3),
1342 :issue_to => Issue.find(7),
1355 :issue_to => Issue.find(7),
1343 :relation_type => IssueRelation::TYPE_PRECEDES)
1356 :relation_type => IssueRelation::TYPE_PRECEDES)
1344 IssueRelation.update_all("issue_to_id = 1", ["id = ?", r.id])
1357 IssueRelation.update_all("issue_to_id = 1", ["id = ?", r.id])
1345
1358
1346 assert_equal [2, 3], Issue.find(1).all_dependent_issues.collect(&:id).sort
1359 assert_equal [2, 3], Issue.find(1).all_dependent_issues.collect(&:id).sort
1347 end
1360 end
1348
1361
1349 def test_all_dependent_issues_with_persistent_multiple_circular_dependencies
1362 def test_all_dependent_issues_with_persistent_multiple_circular_dependencies
1350 IssueRelation.delete_all
1363 IssueRelation.delete_all
1351 assert IssueRelation.create!(:issue_from => Issue.find(1),
1364 assert IssueRelation.create!(:issue_from => Issue.find(1),
1352 :issue_to => Issue.find(2),
1365 :issue_to => Issue.find(2),
1353 :relation_type => IssueRelation::TYPE_RELATES)
1366 :relation_type => IssueRelation::TYPE_RELATES)
1354 assert IssueRelation.create!(:issue_from => Issue.find(2),
1367 assert IssueRelation.create!(:issue_from => Issue.find(2),
1355 :issue_to => Issue.find(3),
1368 :issue_to => Issue.find(3),
1356 :relation_type => IssueRelation::TYPE_RELATES)
1369 :relation_type => IssueRelation::TYPE_RELATES)
1357 assert IssueRelation.create!(:issue_from => Issue.find(3),
1370 assert IssueRelation.create!(:issue_from => Issue.find(3),
1358 :issue_to => Issue.find(8),
1371 :issue_to => Issue.find(8),
1359 :relation_type => IssueRelation::TYPE_RELATES)
1372 :relation_type => IssueRelation::TYPE_RELATES)
1360
1373
1361 r = IssueRelation.create!(:issue_from => Issue.find(8),
1374 r = IssueRelation.create!(:issue_from => Issue.find(8),
1362 :issue_to => Issue.find(7),
1375 :issue_to => Issue.find(7),
1363 :relation_type => IssueRelation::TYPE_RELATES)
1376 :relation_type => IssueRelation::TYPE_RELATES)
1364 IssueRelation.update_all("issue_to_id = 2", ["id = ?", r.id])
1377 IssueRelation.update_all("issue_to_id = 2", ["id = ?", r.id])
1365
1378
1366 r = IssueRelation.create!(:issue_from => Issue.find(3),
1379 r = IssueRelation.create!(:issue_from => Issue.find(3),
1367 :issue_to => Issue.find(7),
1380 :issue_to => Issue.find(7),
1368 :relation_type => IssueRelation::TYPE_RELATES)
1381 :relation_type => IssueRelation::TYPE_RELATES)
1369 IssueRelation.update_all("issue_to_id = 1", ["id = ?", r.id])
1382 IssueRelation.update_all("issue_to_id = 1", ["id = ?", r.id])
1370
1383
1371 assert_equal [2, 3, 8], Issue.find(1).all_dependent_issues.collect(&:id).sort
1384 assert_equal [2, 3, 8], Issue.find(1).all_dependent_issues.collect(&:id).sort
1372 end
1385 end
1373
1386
1374 context "#done_ratio" do
1387 context "#done_ratio" do
1375 setup do
1388 setup do
1376 @issue = Issue.find(1)
1389 @issue = Issue.find(1)
1377 @issue_status = IssueStatus.find(1)
1390 @issue_status = IssueStatus.find(1)
1378 @issue_status.update_attribute(:default_done_ratio, 50)
1391 @issue_status.update_attribute(:default_done_ratio, 50)
1379 @issue2 = Issue.find(2)
1392 @issue2 = Issue.find(2)
1380 @issue_status2 = IssueStatus.find(2)
1393 @issue_status2 = IssueStatus.find(2)
1381 @issue_status2.update_attribute(:default_done_ratio, 0)
1394 @issue_status2.update_attribute(:default_done_ratio, 0)
1382 end
1395 end
1383
1396
1384 teardown do
1397 teardown do
1385 Setting.issue_done_ratio = 'issue_field'
1398 Setting.issue_done_ratio = 'issue_field'
1386 end
1399 end
1387
1400
1388 context "with Setting.issue_done_ratio using the issue_field" do
1401 context "with Setting.issue_done_ratio using the issue_field" do
1389 setup do
1402 setup do
1390 Setting.issue_done_ratio = 'issue_field'
1403 Setting.issue_done_ratio = 'issue_field'
1391 end
1404 end
1392
1405
1393 should "read the issue's field" do
1406 should "read the issue's field" do
1394 assert_equal 0, @issue.done_ratio
1407 assert_equal 0, @issue.done_ratio
1395 assert_equal 30, @issue2.done_ratio
1408 assert_equal 30, @issue2.done_ratio
1396 end
1409 end
1397 end
1410 end
1398
1411
1399 context "with Setting.issue_done_ratio using the issue_status" do
1412 context "with Setting.issue_done_ratio using the issue_status" do
1400 setup do
1413 setup do
1401 Setting.issue_done_ratio = 'issue_status'
1414 Setting.issue_done_ratio = 'issue_status'
1402 end
1415 end
1403
1416
1404 should "read the Issue Status's default done ratio" do
1417 should "read the Issue Status's default done ratio" do
1405 assert_equal 50, @issue.done_ratio
1418 assert_equal 50, @issue.done_ratio
1406 assert_equal 0, @issue2.done_ratio
1419 assert_equal 0, @issue2.done_ratio
1407 end
1420 end
1408 end
1421 end
1409 end
1422 end
1410
1423
1411 context "#update_done_ratio_from_issue_status" do
1424 context "#update_done_ratio_from_issue_status" do
1412 setup do
1425 setup do
1413 @issue = Issue.find(1)
1426 @issue = Issue.find(1)
1414 @issue_status = IssueStatus.find(1)
1427 @issue_status = IssueStatus.find(1)
1415 @issue_status.update_attribute(:default_done_ratio, 50)
1428 @issue_status.update_attribute(:default_done_ratio, 50)
1416 @issue2 = Issue.find(2)
1429 @issue2 = Issue.find(2)
1417 @issue_status2 = IssueStatus.find(2)
1430 @issue_status2 = IssueStatus.find(2)
1418 @issue_status2.update_attribute(:default_done_ratio, 0)
1431 @issue_status2.update_attribute(:default_done_ratio, 0)
1419 end
1432 end
1420
1433
1421 context "with Setting.issue_done_ratio using the issue_field" do
1434 context "with Setting.issue_done_ratio using the issue_field" do
1422 setup do
1435 setup do
1423 Setting.issue_done_ratio = 'issue_field'
1436 Setting.issue_done_ratio = 'issue_field'
1424 end
1437 end
1425
1438
1426 should "not change the issue" do
1439 should "not change the issue" do
1427 @issue.update_done_ratio_from_issue_status
1440 @issue.update_done_ratio_from_issue_status
1428 @issue2.update_done_ratio_from_issue_status
1441 @issue2.update_done_ratio_from_issue_status
1429
1442
1430 assert_equal 0, @issue.read_attribute(:done_ratio)
1443 assert_equal 0, @issue.read_attribute(:done_ratio)
1431 assert_equal 30, @issue2.read_attribute(:done_ratio)
1444 assert_equal 30, @issue2.read_attribute(:done_ratio)
1432 end
1445 end
1433 end
1446 end
1434
1447
1435 context "with Setting.issue_done_ratio using the issue_status" do
1448 context "with Setting.issue_done_ratio using the issue_status" do
1436 setup do
1449 setup do
1437 Setting.issue_done_ratio = 'issue_status'
1450 Setting.issue_done_ratio = 'issue_status'
1438 end
1451 end
1439
1452
1440 should "change the issue's done ratio" do
1453 should "change the issue's done ratio" do
1441 @issue.update_done_ratio_from_issue_status
1454 @issue.update_done_ratio_from_issue_status
1442 @issue2.update_done_ratio_from_issue_status
1455 @issue2.update_done_ratio_from_issue_status
1443
1456
1444 assert_equal 50, @issue.read_attribute(:done_ratio)
1457 assert_equal 50, @issue.read_attribute(:done_ratio)
1445 assert_equal 0, @issue2.read_attribute(:done_ratio)
1458 assert_equal 0, @issue2.read_attribute(:done_ratio)
1446 end
1459 end
1447 end
1460 end
1448 end
1461 end
1449
1462
1450 test "#by_tracker" do
1463 test "#by_tracker" do
1451 User.current = User.anonymous
1464 User.current = User.anonymous
1452 groups = Issue.by_tracker(Project.find(1))
1465 groups = Issue.by_tracker(Project.find(1))
1453 assert_equal 3, groups.size
1466 assert_equal 3, groups.size
1454 assert_equal 7, groups.inject(0) {|sum, group| sum + group['total'].to_i}
1467 assert_equal 7, groups.inject(0) {|sum, group| sum + group['total'].to_i}
1455 end
1468 end
1456
1469
1457 test "#by_version" do
1470 test "#by_version" do
1458 User.current = User.anonymous
1471 User.current = User.anonymous
1459 groups = Issue.by_version(Project.find(1))
1472 groups = Issue.by_version(Project.find(1))
1460 assert_equal 3, groups.size
1473 assert_equal 3, groups.size
1461 assert_equal 3, groups.inject(0) {|sum, group| sum + group['total'].to_i}
1474 assert_equal 3, groups.inject(0) {|sum, group| sum + group['total'].to_i}
1462 end
1475 end
1463
1476
1464 test "#by_priority" do
1477 test "#by_priority" do
1465 User.current = User.anonymous
1478 User.current = User.anonymous
1466 groups = Issue.by_priority(Project.find(1))
1479 groups = Issue.by_priority(Project.find(1))
1467 assert_equal 4, groups.size
1480 assert_equal 4, groups.size
1468 assert_equal 7, groups.inject(0) {|sum, group| sum + group['total'].to_i}
1481 assert_equal 7, groups.inject(0) {|sum, group| sum + group['total'].to_i}
1469 end
1482 end
1470
1483
1471 test "#by_category" do
1484 test "#by_category" do
1472 User.current = User.anonymous
1485 User.current = User.anonymous
1473 groups = Issue.by_category(Project.find(1))
1486 groups = Issue.by_category(Project.find(1))
1474 assert_equal 2, groups.size
1487 assert_equal 2, groups.size
1475 assert_equal 3, groups.inject(0) {|sum, group| sum + group['total'].to_i}
1488 assert_equal 3, groups.inject(0) {|sum, group| sum + group['total'].to_i}
1476 end
1489 end
1477
1490
1478 test "#by_assigned_to" do
1491 test "#by_assigned_to" do
1479 User.current = User.anonymous
1492 User.current = User.anonymous
1480 groups = Issue.by_assigned_to(Project.find(1))
1493 groups = Issue.by_assigned_to(Project.find(1))
1481 assert_equal 2, groups.size
1494 assert_equal 2, groups.size
1482 assert_equal 2, groups.inject(0) {|sum, group| sum + group['total'].to_i}
1495 assert_equal 2, groups.inject(0) {|sum, group| sum + group['total'].to_i}
1483 end
1496 end
1484
1497
1485 test "#by_author" do
1498 test "#by_author" do
1486 User.current = User.anonymous
1499 User.current = User.anonymous
1487 groups = Issue.by_author(Project.find(1))
1500 groups = Issue.by_author(Project.find(1))
1488 assert_equal 4, groups.size
1501 assert_equal 4, groups.size
1489 assert_equal 7, groups.inject(0) {|sum, group| sum + group['total'].to_i}
1502 assert_equal 7, groups.inject(0) {|sum, group| sum + group['total'].to_i}
1490 end
1503 end
1491
1504
1492 test "#by_subproject" do
1505 test "#by_subproject" do
1493 User.current = User.anonymous
1506 User.current = User.anonymous
1494 groups = Issue.by_subproject(Project.find(1))
1507 groups = Issue.by_subproject(Project.find(1))
1495 # Private descendant not visible
1508 # Private descendant not visible
1496 assert_equal 1, groups.size
1509 assert_equal 1, groups.size
1497 assert_equal 2, groups.inject(0) {|sum, group| sum + group['total'].to_i}
1510 assert_equal 2, groups.inject(0) {|sum, group| sum + group['total'].to_i}
1498 end
1511 end
1499
1512
1500 def test_recently_updated_scope
1513 def test_recently_updated_scope
1501 #should return the last updated issue
1514 #should return the last updated issue
1502 assert_equal Issue.reorder("updated_on DESC").first, Issue.recently_updated.limit(1).first
1515 assert_equal Issue.reorder("updated_on DESC").first, Issue.recently_updated.limit(1).first
1503 end
1516 end
1504
1517
1505 def test_on_active_projects_scope
1518 def test_on_active_projects_scope
1506 assert Project.find(2).archive
1519 assert Project.find(2).archive
1507
1520
1508 before = Issue.on_active_project.length
1521 before = Issue.on_active_project.length
1509 # test inclusion to results
1522 # test inclusion to results
1510 issue = Issue.generate_for_project!(Project.find(1), :tracker => Project.find(2).trackers.first)
1523 issue = Issue.generate_for_project!(Project.find(1), :tracker => Project.find(2).trackers.first)
1511 assert_equal before + 1, Issue.on_active_project.length
1524 assert_equal before + 1, Issue.on_active_project.length
1512
1525
1513 # Move to an archived project
1526 # Move to an archived project
1514 issue.project = Project.find(2)
1527 issue.project = Project.find(2)
1515 assert issue.save
1528 assert issue.save
1516 assert_equal before, Issue.on_active_project.length
1529 assert_equal before, Issue.on_active_project.length
1517 end
1530 end
1518
1531
1519 context "Issue#recipients" do
1532 context "Issue#recipients" do
1520 setup do
1533 setup do
1521 @project = Project.find(1)
1534 @project = Project.find(1)
1522 @author = User.generate!
1535 @author = User.generate!
1523 @assignee = User.generate!
1536 @assignee = User.generate!
1524 @issue = Issue.generate_for_project!(@project, :assigned_to => @assignee, :author => @author)
1537 @issue = Issue.generate_for_project!(@project, :assigned_to => @assignee, :author => @author)
1525 end
1538 end
1526
1539
1527 should "include project recipients" do
1540 should "include project recipients" do
1528 assert @project.recipients.present?
1541 assert @project.recipients.present?
1529 @project.recipients.each do |project_recipient|
1542 @project.recipients.each do |project_recipient|
1530 assert @issue.recipients.include?(project_recipient)
1543 assert @issue.recipients.include?(project_recipient)
1531 end
1544 end
1532 end
1545 end
1533
1546
1534 should "include the author if the author is active" do
1547 should "include the author if the author is active" do
1535 assert @issue.author, "No author set for Issue"
1548 assert @issue.author, "No author set for Issue"
1536 assert @issue.recipients.include?(@issue.author.mail)
1549 assert @issue.recipients.include?(@issue.author.mail)
1537 end
1550 end
1538
1551
1539 should "include the assigned to user if the assigned to user is active" do
1552 should "include the assigned to user if the assigned to user is active" do
1540 assert @issue.assigned_to, "No assigned_to set for Issue"
1553 assert @issue.assigned_to, "No assigned_to set for Issue"
1541 assert @issue.recipients.include?(@issue.assigned_to.mail)
1554 assert @issue.recipients.include?(@issue.assigned_to.mail)
1542 end
1555 end
1543
1556
1544 should "not include users who opt out of all email" do
1557 should "not include users who opt out of all email" do
1545 @author.update_attribute(:mail_notification, :none)
1558 @author.update_attribute(:mail_notification, :none)
1546
1559
1547 assert !@issue.recipients.include?(@issue.author.mail)
1560 assert !@issue.recipients.include?(@issue.author.mail)
1548 end
1561 end
1549
1562
1550 should "not include the issue author if they are only notified of assigned issues" do
1563 should "not include the issue author if they are only notified of assigned issues" do
1551 @author.update_attribute(:mail_notification, :only_assigned)
1564 @author.update_attribute(:mail_notification, :only_assigned)
1552
1565
1553 assert !@issue.recipients.include?(@issue.author.mail)
1566 assert !@issue.recipients.include?(@issue.author.mail)
1554 end
1567 end
1555
1568
1556 should "not include the assigned user if they are only notified of owned issues" do
1569 should "not include the assigned user if they are only notified of owned issues" do
1557 @assignee.update_attribute(:mail_notification, :only_owner)
1570 @assignee.update_attribute(:mail_notification, :only_owner)
1558
1571
1559 assert !@issue.recipients.include?(@issue.assigned_to.mail)
1572 assert !@issue.recipients.include?(@issue.assigned_to.mail)
1560 end
1573 end
1561 end
1574 end
1562
1575
1563 def test_last_journal_id_with_journals_should_return_the_journal_id
1576 def test_last_journal_id_with_journals_should_return_the_journal_id
1564 assert_equal 2, Issue.find(1).last_journal_id
1577 assert_equal 2, Issue.find(1).last_journal_id
1565 end
1578 end
1566
1579
1567 def test_last_journal_id_without_journals_should_return_nil
1580 def test_last_journal_id_without_journals_should_return_nil
1568 assert_nil Issue.find(3).last_journal_id
1581 assert_nil Issue.find(3).last_journal_id
1569 end
1582 end
1570
1583
1571 def test_journals_after_should_return_journals_with_greater_id
1584 def test_journals_after_should_return_journals_with_greater_id
1572 assert_equal [Journal.find(2)], Issue.find(1).journals_after('1')
1585 assert_equal [Journal.find(2)], Issue.find(1).journals_after('1')
1573 assert_equal [], Issue.find(1).journals_after('2')
1586 assert_equal [], Issue.find(1).journals_after('2')
1574 end
1587 end
1575
1588
1576 def test_journals_after_with_blank_arg_should_return_all_journals
1589 def test_journals_after_with_blank_arg_should_return_all_journals
1577 assert_equal [Journal.find(1), Journal.find(2)], Issue.find(1).journals_after('')
1590 assert_equal [Journal.find(1), Journal.find(2)], Issue.find(1).journals_after('')
1578 end
1591 end
1579 end
1592 end
General Comments 0
You need to be logged in to leave comments. Login now