##// 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 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2012 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 class Issue < ActiveRecord::Base
19 19 include Redmine::SafeAttributes
20 20
21 21 belongs_to :project
22 22 belongs_to :tracker
23 23 belongs_to :status, :class_name => 'IssueStatus', :foreign_key => 'status_id'
24 24 belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
25 25 belongs_to :assigned_to, :class_name => 'Principal', :foreign_key => 'assigned_to_id'
26 26 belongs_to :fixed_version, :class_name => 'Version', :foreign_key => 'fixed_version_id'
27 27 belongs_to :priority, :class_name => 'IssuePriority', :foreign_key => 'priority_id'
28 28 belongs_to :category, :class_name => 'IssueCategory', :foreign_key => 'category_id'
29 29
30 30 has_many :journals, :as => :journalized, :dependent => :destroy
31 31 has_many :time_entries, :dependent => :delete_all
32 32 has_and_belongs_to_many :changesets, :order => "#{Changeset.table_name}.committed_on ASC, #{Changeset.table_name}.id ASC"
33 33
34 34 has_many :relations_from, :class_name => 'IssueRelation', :foreign_key => 'issue_from_id', :dependent => :delete_all
35 35 has_many :relations_to, :class_name => 'IssueRelation', :foreign_key => 'issue_to_id', :dependent => :delete_all
36 36
37 37 acts_as_nested_set :scope => 'root_id', :dependent => :destroy
38 38 acts_as_attachable :after_add => :attachment_added, :after_remove => :attachment_removed
39 39 acts_as_customizable
40 40 acts_as_watchable
41 41 acts_as_searchable :columns => ['subject', "#{table_name}.description", "#{Journal.table_name}.notes"],
42 42 :include => [:project, :journals],
43 43 # sort by id so that limited eager loading doesn't break with postgresql
44 44 :order_column => "#{table_name}.id"
45 45 acts_as_event :title => Proc.new {|o| "#{o.tracker.name} ##{o.id} (#{o.status}): #{o.subject}"},
46 46 :url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.id}},
47 47 :type => Proc.new {|o| 'issue' + (o.closed? ? ' closed' : '') }
48 48
49 49 acts_as_activity_provider :find_options => {:include => [:project, :author, :tracker]},
50 50 :author_key => :author_id
51 51
52 52 DONE_RATIO_OPTIONS = %w(issue_field issue_status)
53 53
54 54 attr_reader :current_journal
55 55
56 56 validates_presence_of :subject, :priority, :project, :tracker, :author, :status
57 57
58 58 validates_length_of :subject, :maximum => 255
59 59 validates_inclusion_of :done_ratio, :in => 0..100
60 60 validates_numericality_of :estimated_hours, :allow_nil => true
61 61 validate :validate_issue, :validate_required_fields
62 62
63 63 scope :visible,
64 64 lambda {|*args| { :include => :project,
65 65 :conditions => Issue.visible_condition(args.shift || User.current, *args) } }
66 66
67 67 scope :open, lambda {|*args|
68 68 is_closed = args.size > 0 ? !args.first : false
69 69 {:conditions => ["#{IssueStatus.table_name}.is_closed = ?", is_closed], :include => :status}
70 70 }
71 71
72 72 scope :recently_updated, :order => "#{Issue.table_name}.updated_on DESC"
73 73 scope :on_active_project, :include => [:status, :project, :tracker],
74 74 :conditions => ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"]
75 75
76 76 before_create :default_assign
77 77 before_save :close_duplicates, :update_done_ratio_from_issue_status, :force_updated_on_change
78 78 after_save {|issue| issue.send :after_project_change if !issue.id_changed? && issue.project_id_changed?}
79 79 after_save :reschedule_following_issues, :update_nested_set_attributes, :update_parent_attributes, :create_journal
80 80 # Should be after_create but would be called before previous after_save callbacks
81 81 after_save :after_create_from_copy
82 82 after_destroy :update_parent_attributes
83 83
84 84 # Returns a SQL conditions string used to find all issues visible by the specified user
85 85 def self.visible_condition(user, options={})
86 86 Project.allowed_to_condition(user, :view_issues, options) do |role, user|
87 87 if user.logged?
88 88 case role.issues_visibility
89 89 when 'all'
90 90 nil
91 91 when 'default'
92 92 user_ids = [user.id] + user.groups.map(&:id)
93 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 94 when 'own'
95 95 user_ids = [user.id] + user.groups.map(&:id)
96 96 "(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
97 97 else
98 98 '1=0'
99 99 end
100 100 else
101 101 "(#{table_name}.is_private = #{connection.quoted_false})"
102 102 end
103 103 end
104 104 end
105 105
106 106 # Returns true if usr or current user is allowed to view the issue
107 107 def visible?(usr=nil)
108 108 (usr || User.current).allowed_to?(:view_issues, self.project) do |role, user|
109 109 if user.logged?
110 110 case role.issues_visibility
111 111 when 'all'
112 112 true
113 113 when 'default'
114 114 !self.is_private? || (self.author == user || user.is_or_belongs_to?(assigned_to))
115 115 when 'own'
116 116 self.author == user || user.is_or_belongs_to?(assigned_to)
117 117 else
118 118 false
119 119 end
120 120 else
121 121 !self.is_private?
122 122 end
123 123 end
124 124 end
125 125
126 126 def initialize(attributes=nil, *args)
127 127 super
128 128 if new_record?
129 129 # set default values for new records only
130 130 self.status ||= IssueStatus.default
131 131 self.priority ||= IssuePriority.default
132 132 self.watcher_user_ids = []
133 133 end
134 134 end
135 135
136 136 # AR#Persistence#destroy would raise and RecordNotFound exception
137 137 # if the issue was already deleted or updated (non matching lock_version).
138 138 # This is a problem when bulk deleting issues or deleting a project
139 139 # (because an issue may already be deleted if its parent was deleted
140 140 # first).
141 141 # The issue is reloaded by the nested_set before being deleted so
142 142 # the lock_version condition should not be an issue but we handle it.
143 143 def destroy
144 144 super
145 145 rescue ActiveRecord::RecordNotFound
146 146 # Stale or already deleted
147 147 begin
148 148 reload
149 149 rescue ActiveRecord::RecordNotFound
150 150 # The issue was actually already deleted
151 151 @destroyed = true
152 152 return freeze
153 153 end
154 154 # The issue was stale, retry to destroy
155 155 super
156 156 end
157 157
158 158 def reload(*args)
159 159 @workflow_rule_by_attribute = nil
160 160 @assignable_versions = nil
161 161 super
162 162 end
163 163
164 164 # Overrides Redmine::Acts::Customizable::InstanceMethods#available_custom_fields
165 165 def available_custom_fields
166 166 (project && tracker) ? (project.all_issue_custom_fields & tracker.custom_fields.all) : []
167 167 end
168 168
169 169 # Copies attributes from another issue, arg can be an id or an Issue
170 170 def copy_from(arg, options={})
171 171 issue = arg.is_a?(Issue) ? arg : Issue.visible.find(arg)
172 172 self.attributes = issue.attributes.dup.except("id", "root_id", "parent_id", "lft", "rgt", "created_on", "updated_on")
173 173 self.custom_field_values = issue.custom_field_values.inject({}) {|h,v| h[v.custom_field_id] = v.value; h}
174 174 self.status = issue.status
175 175 self.author = User.current
176 176 unless options[:attachments] == false
177 177 self.attachments = issue.attachments.map do |attachement|
178 178 attachement.copy(:container => self)
179 179 end
180 180 end
181 181 @copied_from = issue
182 182 @copy_options = options
183 183 self
184 184 end
185 185
186 186 # Returns an unsaved copy of the issue
187 187 def copy(attributes=nil, copy_options={})
188 188 copy = self.class.new.copy_from(self, copy_options)
189 189 copy.attributes = attributes if attributes
190 190 copy
191 191 end
192 192
193 193 # Returns true if the issue is a copy
194 194 def copy?
195 195 @copied_from.present?
196 196 end
197 197
198 198 # Moves/copies an issue to a new project and tracker
199 199 # Returns the moved/copied issue on success, false on failure
200 200 def move_to_project(new_project, new_tracker=nil, options={})
201 201 ActiveSupport::Deprecation.warn "Issue#move_to_project is deprecated, use #project= instead."
202 202
203 203 if options[:copy]
204 204 issue = self.copy
205 205 else
206 206 issue = self
207 207 end
208 208
209 209 issue.init_journal(User.current, options[:notes])
210 210
211 211 # Preserve previous behaviour
212 212 # #move_to_project doesn't change tracker automatically
213 213 issue.send :project=, new_project, true
214 214 if new_tracker
215 215 issue.tracker = new_tracker
216 216 end
217 217 # Allow bulk setting of attributes on the issue
218 218 if options[:attributes]
219 219 issue.attributes = options[:attributes]
220 220 end
221 221
222 222 issue.save ? issue : false
223 223 end
224 224
225 225 def status_id=(sid)
226 226 self.status = nil
227 227 result = write_attribute(:status_id, sid)
228 228 @workflow_rule_by_attribute = nil
229 229 result
230 230 end
231 231
232 232 def priority_id=(pid)
233 233 self.priority = nil
234 234 write_attribute(:priority_id, pid)
235 235 end
236 236
237 237 def category_id=(cid)
238 238 self.category = nil
239 239 write_attribute(:category_id, cid)
240 240 end
241 241
242 242 def fixed_version_id=(vid)
243 243 self.fixed_version = nil
244 244 write_attribute(:fixed_version_id, vid)
245 245 end
246 246
247 247 def tracker_id=(tid)
248 248 self.tracker = nil
249 249 result = write_attribute(:tracker_id, tid)
250 250 @custom_field_values = nil
251 251 @workflow_rule_by_attribute = nil
252 252 result
253 253 end
254 254
255 255 def project_id=(project_id)
256 256 if project_id.to_s != self.project_id.to_s
257 257 self.project = (project_id.present? ? Project.find_by_id(project_id) : nil)
258 258 end
259 259 end
260 260
261 261 def project=(project, keep_tracker=false)
262 262 project_was = self.project
263 263 write_attribute(:project_id, project ? project.id : nil)
264 264 association_instance_set('project', project)
265 265 if project_was && project && project_was != project
266 266 @assignable_versions = nil
267 267
268 268 unless keep_tracker || project.trackers.include?(tracker)
269 269 self.tracker = project.trackers.first
270 270 end
271 271 # Reassign to the category with same name if any
272 272 if category
273 273 self.category = project.issue_categories.find_by_name(category.name)
274 274 end
275 275 # Keep the fixed_version if it's still valid in the new_project
276 276 if fixed_version && fixed_version.project != project && !project.shared_versions.include?(fixed_version)
277 277 self.fixed_version = nil
278 278 end
279 279 if parent && parent.project_id != project_id
280 280 self.parent_issue_id = nil
281 281 end
282 282 @custom_field_values = nil
283 283 end
284 284 end
285 285
286 286 def description=(arg)
287 287 if arg.is_a?(String)
288 288 arg = arg.gsub(/(\r\n|\n|\r)/, "\r\n")
289 289 end
290 290 write_attribute(:description, arg)
291 291 end
292 292
293 293 # Overrides assign_attributes so that project and tracker get assigned first
294 294 def assign_attributes_with_project_and_tracker_first(new_attributes, *args)
295 295 return if new_attributes.nil?
296 296 attrs = new_attributes.dup
297 297 attrs.stringify_keys!
298 298
299 299 %w(project project_id tracker tracker_id).each do |attr|
300 300 if attrs.has_key?(attr)
301 301 send "#{attr}=", attrs.delete(attr)
302 302 end
303 303 end
304 304 send :assign_attributes_without_project_and_tracker_first, attrs, *args
305 305 end
306 306 # Do not redefine alias chain on reload (see #4838)
307 307 alias_method_chain(:assign_attributes, :project_and_tracker_first) unless method_defined?(:assign_attributes_without_project_and_tracker_first)
308 308
309 309 def estimated_hours=(h)
310 310 write_attribute :estimated_hours, (h.is_a?(String) ? h.to_hours : h)
311 311 end
312 312
313 313 safe_attributes 'project_id',
314 314 :if => lambda {|issue, user|
315 315 if issue.new_record?
316 316 issue.copy?
317 317 elsif user.allowed_to?(:move_issues, issue.project)
318 318 projects = Issue.allowed_target_projects_on_move(user)
319 319 projects.include?(issue.project) && projects.size > 1
320 320 end
321 321 }
322 322
323 323 safe_attributes 'tracker_id',
324 324 'status_id',
325 325 'category_id',
326 326 'assigned_to_id',
327 327 'priority_id',
328 328 'fixed_version_id',
329 329 'subject',
330 330 'description',
331 331 'start_date',
332 332 'due_date',
333 333 'done_ratio',
334 334 'estimated_hours',
335 335 'custom_field_values',
336 336 'custom_fields',
337 337 'lock_version',
338 338 :if => lambda {|issue, user| issue.new_record? || user.allowed_to?(:edit_issues, issue.project) }
339 339
340 340 safe_attributes 'status_id',
341 341 'assigned_to_id',
342 342 'fixed_version_id',
343 343 'done_ratio',
344 344 'lock_version',
345 345 :if => lambda {|issue, user| issue.new_statuses_allowed_to(user).any? }
346 346
347 347 safe_attributes 'watcher_user_ids',
348 348 :if => lambda {|issue, user| issue.new_record? && user.allowed_to?(:add_issue_watchers, issue.project)}
349 349
350 350 safe_attributes 'is_private',
351 351 :if => lambda {|issue, user|
352 352 user.allowed_to?(:set_issues_private, issue.project) ||
353 353 (issue.author == user && user.allowed_to?(:set_own_issues_private, issue.project))
354 354 }
355 355
356 356 safe_attributes 'parent_issue_id',
357 357 :if => lambda {|issue, user| (issue.new_record? || user.allowed_to?(:edit_issues, issue.project)) &&
358 358 user.allowed_to?(:manage_subtasks, issue.project)}
359 359
360 360 def safe_attribute_names(user=nil)
361 361 names = super
362 362 names -= disabled_core_fields
363 363 names -= read_only_attribute_names(user)
364 364 names
365 365 end
366 366
367 367 # Safely sets attributes
368 368 # Should be called from controllers instead of #attributes=
369 369 # attr_accessible is too rough because we still want things like
370 370 # Issue.new(:project => foo) to work
371 371 def safe_attributes=(attrs, user=User.current)
372 372 return unless attrs.is_a?(Hash)
373 373
374 374 attrs = attrs.dup
375 375
376 376 # Project and Tracker must be set before since new_statuses_allowed_to depends on it.
377 377 if (p = attrs.delete('project_id')) && safe_attribute?('project_id')
378 378 if allowed_target_projects(user).collect(&:id).include?(p.to_i)
379 379 self.project_id = p
380 380 end
381 381 end
382 382
383 383 if (t = attrs.delete('tracker_id')) && safe_attribute?('tracker_id')
384 384 self.tracker_id = t
385 385 end
386 386
387 387 if (s = attrs.delete('status_id')) && safe_attribute?('status_id')
388 388 if new_statuses_allowed_to(user).collect(&:id).include?(s.to_i)
389 389 self.status_id = s
390 390 end
391 391 end
392 392
393 393 attrs = delete_unsafe_attributes(attrs, user)
394 394 return if attrs.empty?
395 395
396 396 unless leaf?
397 397 attrs.reject! {|k,v| %w(priority_id done_ratio start_date due_date estimated_hours).include?(k)}
398 398 end
399 399
400 400 if attrs['parent_issue_id'].present?
401 401 attrs.delete('parent_issue_id') unless Issue.visible(user).exists?(attrs['parent_issue_id'].to_i)
402 402 end
403 403
404 404 if attrs['custom_field_values'].present?
405 405 attrs['custom_field_values'] = attrs['custom_field_values'].reject {|k, v| read_only_attribute_names(user).include? k.to_s}
406 406 end
407 407
408 408 if attrs['custom_fields'].present?
409 409 attrs['custom_fields'] = attrs['custom_fields'].reject {|c| read_only_attribute_names(user).include? c['id'].to_s}
410 410 end
411 411
412 412 # mass-assignment security bypass
413 413 assign_attributes attrs, :without_protection => true
414 414 end
415 415
416 416 def disabled_core_fields
417 417 tracker ? tracker.disabled_core_fields : []
418 418 end
419 419
420 420 # Returns the custom_field_values that can be edited by the given user
421 421 def editable_custom_field_values(user=nil)
422 422 custom_field_values.reject do |value|
423 423 read_only_attribute_names(user).include?(value.custom_field_id.to_s)
424 424 end
425 425 end
426 426
427 427 # Returns the names of attributes that are read-only for user or the current user
428 428 # For users with multiple roles, the read-only fields are the intersection of
429 429 # read-only fields of each role
430 430 # The result is an array of strings where sustom fields are represented with their ids
431 431 #
432 432 # Examples:
433 433 # issue.read_only_attribute_names # => ['due_date', '2']
434 434 # issue.read_only_attribute_names(user) # => []
435 435 def read_only_attribute_names(user=nil)
436 436 workflow_rule_by_attribute(user).reject {|attr, rule| rule != 'readonly'}.keys
437 437 end
438 438
439 439 # Returns the names of required attributes for user or the current user
440 440 # For users with multiple roles, the required fields are the intersection of
441 441 # required fields of each role
442 442 # The result is an array of strings where sustom fields are represented with their ids
443 443 #
444 444 # Examples:
445 445 # issue.required_attribute_names # => ['due_date', '2']
446 446 # issue.required_attribute_names(user) # => []
447 447 def required_attribute_names(user=nil)
448 448 workflow_rule_by_attribute(user).reject {|attr, rule| rule != 'required'}.keys
449 449 end
450 450
451 451 # Returns true if the attribute is required for user
452 452 def required_attribute?(name, user=nil)
453 453 required_attribute_names(user).include?(name.to_s)
454 454 end
455 455
456 456 # Returns a hash of the workflow rule by attribute for the given user
457 457 #
458 458 # Examples:
459 459 # issue.workflow_rule_by_attribute # => {'due_date' => 'required', 'start_date' => 'readonly'}
460 460 def workflow_rule_by_attribute(user=nil)
461 461 return @workflow_rule_by_attribute if @workflow_rule_by_attribute && user.nil?
462 462
463 463 user_real = user || User.current
464 464 roles = user_real.admin ? Role.all : user_real.roles_for_project(project)
465 465 return {} if roles.empty?
466 466
467 467 result = {}
468 468 workflow_permissions = WorkflowPermission.where(:tracker_id => tracker_id, :old_status_id => status_id, :role_id => roles.map(&:id)).all
469 469 if workflow_permissions.any?
470 470 workflow_rules = workflow_permissions.inject({}) do |h, wp|
471 471 h[wp.field_name] ||= []
472 472 h[wp.field_name] << wp.rule
473 473 h
474 474 end
475 475 workflow_rules.each do |attr, rules|
476 476 next if rules.size < roles.size
477 477 uniq_rules = rules.uniq
478 478 if uniq_rules.size == 1
479 479 result[attr] = uniq_rules.first
480 480 else
481 481 result[attr] = 'required'
482 482 end
483 483 end
484 484 end
485 485 @workflow_rule_by_attribute = result if user.nil?
486 486 result
487 487 end
488 488 private :workflow_rule_by_attribute
489 489
490 490 def done_ratio
491 491 if Issue.use_status_for_done_ratio? && status && status.default_done_ratio
492 492 status.default_done_ratio
493 493 else
494 494 read_attribute(:done_ratio)
495 495 end
496 496 end
497 497
498 498 def self.use_status_for_done_ratio?
499 499 Setting.issue_done_ratio == 'issue_status'
500 500 end
501 501
502 502 def self.use_field_for_done_ratio?
503 503 Setting.issue_done_ratio == 'issue_field'
504 504 end
505 505
506 506 def validate_issue
507 507 if self.due_date.nil? && @attributes['due_date'] && !@attributes['due_date'].empty?
508 508 errors.add :due_date, :not_a_date
509 509 end
510 510
511 511 if self.due_date and self.start_date and self.due_date < self.start_date
512 512 errors.add :due_date, :greater_than_start_date
513 513 end
514 514
515 515 if start_date && soonest_start && start_date < soonest_start
516 516 errors.add :start_date, :invalid
517 517 end
518 518
519 519 if fixed_version
520 520 if !assignable_versions.include?(fixed_version)
521 521 errors.add :fixed_version_id, :inclusion
522 522 elsif reopened? && fixed_version.closed?
523 523 errors.add :base, I18n.t(:error_can_not_reopen_issue_on_closed_version)
524 524 end
525 525 end
526 526
527 527 # Checks that the issue can not be added/moved to a disabled tracker
528 528 if project && (tracker_id_changed? || project_id_changed?)
529 529 unless project.trackers.include?(tracker)
530 530 errors.add :tracker_id, :inclusion
531 531 end
532 532 end
533 533
534 534 # Checks parent issue assignment
535 535 if @parent_issue
536 536 if @parent_issue.project_id != project_id
537 537 errors.add :parent_issue_id, :not_same_project
538 538 elsif !new_record?
539 539 # moving an existing issue
540 540 if @parent_issue.root_id != root_id
541 541 # we can always move to another tree
542 542 elsif move_possible?(@parent_issue)
543 543 # move accepted inside tree
544 544 else
545 545 errors.add :parent_issue_id, :not_a_valid_parent
546 546 end
547 547 end
548 548 end
549 549 end
550 550
551 551 # Validates the issue against additional workflow requirements
552 552 def validate_required_fields
553 553 user = new_record? ? author : current_journal.try(:user)
554 554
555 555 required_attribute_names(user).each do |attribute|
556 556 if attribute =~ /^\d+$/
557 557 attribute = attribute.to_i
558 558 v = custom_field_values.detect {|v| v.custom_field_id == attribute }
559 559 if v && v.value.blank?
560 560 errors.add :base, v.custom_field.name + ' ' + l('activerecord.errors.messages.blank')
561 561 end
562 562 else
563 563 if respond_to?(attribute) && send(attribute).blank?
564 564 errors.add attribute, :blank
565 565 end
566 566 end
567 567 end
568 568 end
569 569
570 570 # Set the done_ratio using the status if that setting is set. This will keep the done_ratios
571 571 # even if the user turns off the setting later
572 572 def update_done_ratio_from_issue_status
573 573 if Issue.use_status_for_done_ratio? && status && status.default_done_ratio
574 574 self.done_ratio = status.default_done_ratio
575 575 end
576 576 end
577 577
578 578 def init_journal(user, notes = "")
579 579 @current_journal ||= Journal.new(:journalized => self, :user => user, :notes => notes)
580 580 if new_record?
581 581 @current_journal.notify = false
582 582 else
583 583 @attributes_before_change = attributes.dup
584 584 @custom_values_before_change = {}
585 585 self.custom_field_values.each {|c| @custom_values_before_change.store c.custom_field_id, c.value }
586 586 end
587 587 @current_journal
588 588 end
589 589
590 590 # Returns the id of the last journal or nil
591 591 def last_journal_id
592 592 if new_record?
593 593 nil
594 594 else
595 595 journals.maximum(:id)
596 596 end
597 597 end
598 598
599 599 # Returns a scope for journals that have an id greater than journal_id
600 600 def journals_after(journal_id)
601 601 scope = journals.reorder("#{Journal.table_name}.id ASC")
602 602 if journal_id.present?
603 603 scope = scope.where("#{Journal.table_name}.id > ?", journal_id.to_i)
604 604 end
605 605 scope
606 606 end
607 607
608 608 # Return true if the issue is closed, otherwise false
609 609 def closed?
610 610 self.status.is_closed?
611 611 end
612 612
613 613 # Return true if the issue is being reopened
614 614 def reopened?
615 615 if !new_record? && status_id_changed?
616 616 status_was = IssueStatus.find_by_id(status_id_was)
617 617 status_new = IssueStatus.find_by_id(status_id)
618 618 if status_was && status_new && status_was.is_closed? && !status_new.is_closed?
619 619 return true
620 620 end
621 621 end
622 622 false
623 623 end
624 624
625 625 # Return true if the issue is being closed
626 626 def closing?
627 627 if !new_record? && status_id_changed?
628 628 status_was = IssueStatus.find_by_id(status_id_was)
629 629 status_new = IssueStatus.find_by_id(status_id)
630 630 if status_was && status_new && !status_was.is_closed? && status_new.is_closed?
631 631 return true
632 632 end
633 633 end
634 634 false
635 635 end
636 636
637 637 # Returns true if the issue is overdue
638 638 def overdue?
639 639 !due_date.nil? && (due_date < Date.today) && !status.is_closed?
640 640 end
641 641
642 642 # Is the amount of work done less than it should for the due date
643 643 def behind_schedule?
644 644 return false if start_date.nil? || due_date.nil?
645 645 done_date = start_date + ((due_date - start_date+1)* done_ratio/100).floor
646 646 return done_date <= Date.today
647 647 end
648 648
649 649 # Does this issue have children?
650 650 def children?
651 651 !leaf?
652 652 end
653 653
654 654 # Users the issue can be assigned to
655 655 def assignable_users
656 656 users = project.assignable_users
657 657 users << author if author
658 658 users << assigned_to if assigned_to
659 659 users.uniq.sort
660 660 end
661 661
662 662 # Versions that the issue can be assigned to
663 663 def assignable_versions
664 664 return @assignable_versions if @assignable_versions
665 665
666 666 versions = project.shared_versions.open.all
667 667 if fixed_version
668 668 if fixed_version_id_changed?
669 669 # nothing to do
670 670 elsif project_id_changed?
671 671 if project.shared_versions.include?(fixed_version)
672 672 versions << fixed_version
673 673 end
674 674 else
675 675 versions << fixed_version
676 676 end
677 677 end
678 678 @assignable_versions = versions.uniq.sort
679 679 end
680 680
681 681 # Returns true if this issue is blocked by another issue that is still open
682 682 def blocked?
683 683 !relations_to.detect {|ir| ir.relation_type == 'blocks' && !ir.issue_from.closed?}.nil?
684 684 end
685 685
686 686 # Returns an array of statuses that user is able to apply
687 687 def new_statuses_allowed_to(user=User.current, include_default=false)
688 688 if new_record? && @copied_from
689 689 [IssueStatus.default, @copied_from.status].compact.uniq.sort
690 690 else
691 691 initial_status = nil
692 692 if new_record?
693 693 initial_status = IssueStatus.default
694 694 elsif status_id_was
695 695 initial_status = IssueStatus.find_by_id(status_id_was)
696 696 end
697 697 initial_status ||= status
698 698
699 699 statuses = initial_status.find_new_statuses_allowed_to(
700 700 user.admin ? Role.all : user.roles_for_project(project),
701 701 tracker,
702 702 author == user,
703 703 assigned_to_id_changed? ? assigned_to_id_was == user.id : assigned_to_id == user.id
704 704 )
705 705 statuses << initial_status unless statuses.empty?
706 706 statuses << IssueStatus.default if include_default
707 707 statuses = statuses.compact.uniq.sort
708 708 blocked? ? statuses.reject {|s| s.is_closed?} : statuses
709 709 end
710 710 end
711 711
712 712 def assigned_to_was
713 713 if assigned_to_id_changed? && assigned_to_id_was.present?
714 714 @assigned_to_was ||= User.find_by_id(assigned_to_id_was)
715 715 end
716 716 end
717 717
718 718 # Returns the mail adresses of users that should be notified
719 719 def recipients
720 720 notified = []
721 721 # Author and assignee are always notified unless they have been
722 722 # locked or don't want to be notified
723 723 notified << author if author
724 724 if assigned_to
725 725 notified += (assigned_to.is_a?(Group) ? assigned_to.users : [assigned_to])
726 726 end
727 727 if assigned_to_was
728 728 notified += (assigned_to_was.is_a?(Group) ? assigned_to_was.users : [assigned_to_was])
729 729 end
730 730 notified = notified.select {|u| u.active? && u.notify_about?(self)}
731 731
732 732 notified += project.notified_users
733 733 notified.uniq!
734 734 # Remove users that can not view the issue
735 735 notified.reject! {|user| !visible?(user)}
736 736 notified.collect(&:mail)
737 737 end
738 738
739 739 # Returns the number of hours spent on this issue
740 740 def spent_hours
741 741 @spent_hours ||= time_entries.sum(:hours) || 0
742 742 end
743 743
744 744 # Returns the total number of hours spent on this issue and its descendants
745 745 #
746 746 # Example:
747 747 # spent_hours => 0.0
748 748 # spent_hours => 50.2
749 749 def total_spent_hours
750 750 @total_spent_hours ||= self_and_descendants.sum("#{TimeEntry.table_name}.hours",
751 751 :joins => "LEFT JOIN #{TimeEntry.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id").to_f || 0.0
752 752 end
753 753
754 754 def relations
755 755 @relations ||= (relations_from + relations_to).sort
756 756 end
757 757
758 758 # Preloads relations for a collection of issues
759 759 def self.load_relations(issues)
760 760 if issues.any?
761 761 relations = IssueRelation.all(:conditions => ["issue_from_id IN (:ids) OR issue_to_id IN (:ids)", {:ids => issues.map(&:id)}])
762 762 issues.each do |issue|
763 763 issue.instance_variable_set "@relations", relations.select {|r| r.issue_from_id == issue.id || r.issue_to_id == issue.id}
764 764 end
765 765 end
766 766 end
767 767
768 768 # Preloads visible spent time for a collection of issues
769 769 def self.load_visible_spent_hours(issues, user=User.current)
770 770 if issues.any?
771 771 hours_by_issue_id = TimeEntry.visible(user).sum(:hours, :group => :issue_id)
772 772 issues.each do |issue|
773 773 issue.instance_variable_set "@spent_hours", (hours_by_issue_id[issue.id] || 0)
774 774 end
775 775 end
776 776 end
777 777
778 778 # Finds an issue relation given its id.
779 779 def find_relation(relation_id)
780 780 IssueRelation.find(relation_id, :conditions => ["issue_to_id = ? OR issue_from_id = ?", id, id])
781 781 end
782 782
783 783 def all_dependent_issues(except=[])
784 784 except << self
785 785 dependencies = []
786 786 relations_from.each do |relation|
787 787 if relation.issue_to && !except.include?(relation.issue_to)
788 788 dependencies << relation.issue_to
789 789 dependencies += relation.issue_to.all_dependent_issues(except)
790 790 end
791 791 end
792 792 dependencies
793 793 end
794 794
795 795 # Returns an array of issues that duplicate this one
796 796 def duplicates
797 797 relations_to.select {|r| r.relation_type == IssueRelation::TYPE_DUPLICATES}.collect {|r| r.issue_from}
798 798 end
799 799
800 800 # Returns the due date or the target due date if any
801 801 # Used on gantt chart
802 802 def due_before
803 803 due_date || (fixed_version ? fixed_version.effective_date : nil)
804 804 end
805 805
806 806 # Returns the time scheduled for this issue.
807 807 #
808 808 # Example:
809 809 # Start Date: 2/26/09, End Date: 3/04/09
810 810 # duration => 6
811 811 def duration
812 812 (start_date && due_date) ? due_date - start_date : 0
813 813 end
814 814
815 815 def soonest_start
816 816 @soonest_start ||= (
817 817 relations_to.collect{|relation| relation.successor_soonest_start} +
818 818 ancestors.collect(&:soonest_start)
819 819 ).compact.max
820 820 end
821 821
822 822 def reschedule_after(date)
823 823 return if date.nil?
824 824 if leaf?
825 825 if start_date.nil? || start_date < date
826 826 self.start_date, self.due_date = date, date + duration
827 827 begin
828 828 save
829 829 rescue ActiveRecord::StaleObjectError
830 830 reload
831 831 self.start_date, self.due_date = date, date + duration
832 832 save
833 833 end
834 834 end
835 835 else
836 836 leaves.each do |leaf|
837 837 leaf.reschedule_after(date)
838 838 end
839 839 end
840 840 end
841 841
842 842 def <=>(issue)
843 843 if issue.nil?
844 844 -1
845 845 elsif root_id != issue.root_id
846 846 (root_id || 0) <=> (issue.root_id || 0)
847 847 else
848 848 (lft || 0) <=> (issue.lft || 0)
849 849 end
850 850 end
851 851
852 852 def to_s
853 853 "#{tracker} ##{id}: #{subject}"
854 854 end
855 855
856 856 # Returns a string of css classes that apply to the issue
857 857 def css_classes
858 858 s = "issue status-#{status_id} priority-#{priority_id}"
859 859 s << ' closed' if closed?
860 860 s << ' overdue' if overdue?
861 861 s << ' child' if child?
862 862 s << ' parent' unless leaf?
863 863 s << ' private' if is_private?
864 864 s << ' created-by-me' if User.current.logged? && author_id == User.current.id
865 865 s << ' assigned-to-me' if User.current.logged? && assigned_to_id == User.current.id
866 866 s
867 867 end
868 868
869 869 # Saves an issue and a time_entry from the parameters
870 870 def save_issue_with_child_records(params, existing_time_entry=nil)
871 871 Issue.transaction do
872 872 if params[:time_entry] && (params[:time_entry][:hours].present? || params[:time_entry][:comments].present?) && User.current.allowed_to?(:log_time, project)
873 873 @time_entry = existing_time_entry || TimeEntry.new
874 874 @time_entry.project = project
875 875 @time_entry.issue = self
876 876 @time_entry.user = User.current
877 877 @time_entry.spent_on = User.current.today
878 878 @time_entry.attributes = params[:time_entry]
879 879 self.time_entries << @time_entry
880 880 end
881 881
882 882 # TODO: Rename hook
883 883 Redmine::Hook.call_hook(:controller_issues_edit_before_save, { :params => params, :issue => self, :time_entry => @time_entry, :journal => @current_journal})
884 884 if save
885 885 # TODO: Rename hook
886 886 Redmine::Hook.call_hook(:controller_issues_edit_after_save, { :params => params, :issue => self, :time_entry => @time_entry, :journal => @current_journal})
887 887 else
888 888 raise ActiveRecord::Rollback
889 889 end
890 890 end
891 891 end
892 892
893 893 # Unassigns issues from +version+ if it's no longer shared with issue's project
894 894 def self.update_versions_from_sharing_change(version)
895 895 # Update issues assigned to the version
896 896 update_versions(["#{Issue.table_name}.fixed_version_id = ?", version.id])
897 897 end
898 898
899 899 # Unassigns issues from versions that are no longer shared
900 900 # after +project+ was moved
901 901 def self.update_versions_from_hierarchy_change(project)
902 902 moved_project_ids = project.self_and_descendants.reload.collect(&:id)
903 903 # Update issues of the moved projects and issues assigned to a version of a moved project
904 904 Issue.update_versions(["#{Version.table_name}.project_id IN (?) OR #{Issue.table_name}.project_id IN (?)", moved_project_ids, moved_project_ids])
905 905 end
906 906
907 907 def parent_issue_id=(arg)
908 908 parent_issue_id = arg.blank? ? nil : arg.to_i
909 909 if parent_issue_id && @parent_issue = Issue.find_by_id(parent_issue_id)
910 910 @parent_issue.id
911 911 else
912 912 @parent_issue = nil
913 913 nil
914 914 end
915 915 end
916 916
917 917 def parent_issue_id
918 918 if instance_variable_defined? :@parent_issue
919 919 @parent_issue.nil? ? nil : @parent_issue.id
920 920 else
921 921 parent_id
922 922 end
923 923 end
924 924
925 925 # Extracted from the ReportsController.
926 926 def self.by_tracker(project)
927 927 count_and_group_by(:project => project,
928 928 :field => 'tracker_id',
929 929 :joins => Tracker.table_name)
930 930 end
931 931
932 932 def self.by_version(project)
933 933 count_and_group_by(:project => project,
934 934 :field => 'fixed_version_id',
935 935 :joins => Version.table_name)
936 936 end
937 937
938 938 def self.by_priority(project)
939 939 count_and_group_by(:project => project,
940 940 :field => 'priority_id',
941 941 :joins => IssuePriority.table_name)
942 942 end
943 943
944 944 def self.by_category(project)
945 945 count_and_group_by(:project => project,
946 946 :field => 'category_id',
947 947 :joins => IssueCategory.table_name)
948 948 end
949 949
950 950 def self.by_assigned_to(project)
951 951 count_and_group_by(:project => project,
952 952 :field => 'assigned_to_id',
953 953 :joins => User.table_name)
954 954 end
955 955
956 956 def self.by_author(project)
957 957 count_and_group_by(:project => project,
958 958 :field => 'author_id',
959 959 :joins => User.table_name)
960 960 end
961 961
962 962 def self.by_subproject(project)
963 963 ActiveRecord::Base.connection.select_all("select s.id as status_id,
964 964 s.is_closed as closed,
965 965 #{Issue.table_name}.project_id as project_id,
966 966 count(#{Issue.table_name}.id) as total
967 967 from
968 968 #{Issue.table_name}, #{Project.table_name}, #{IssueStatus.table_name} s
969 969 where
970 970 #{Issue.table_name}.status_id=s.id
971 971 and #{Issue.table_name}.project_id = #{Project.table_name}.id
972 972 and #{visible_condition(User.current, :project => project, :with_subprojects => true)}
973 973 and #{Issue.table_name}.project_id <> #{project.id}
974 974 group by s.id, s.is_closed, #{Issue.table_name}.project_id") if project.descendants.active.any?
975 975 end
976 976 # End ReportsController extraction
977 977
978 978 # Returns an array of projects that user can assign the issue to
979 979 def allowed_target_projects(user=User.current)
980 980 if new_record?
981 981 Project.all(:conditions => Project.allowed_to_condition(user, :add_issues))
982 982 else
983 983 self.class.allowed_target_projects_on_move(user)
984 984 end
985 985 end
986 986
987 987 # Returns an array of projects that user can move issues to
988 988 def self.allowed_target_projects_on_move(user=User.current)
989 989 Project.all(:conditions => Project.allowed_to_condition(user, :move_issues))
990 990 end
991 991
992 992 private
993 993
994 994 def after_project_change
995 995 # Update project_id on related time entries
996 996 TimeEntry.update_all(["project_id = ?", project_id], {:issue_id => id})
997 997
998 998 # Delete issue relations
999 999 unless Setting.cross_project_issue_relations?
1000 1000 relations_from.clear
1001 1001 relations_to.clear
1002 1002 end
1003 1003
1004 1004 # Move subtasks
1005 1005 children.each do |child|
1006 1006 # Change project and keep project
1007 1007 child.send :project=, project, true
1008 1008 unless child.save
1009 1009 raise ActiveRecord::Rollback
1010 1010 end
1011 1011 end
1012 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 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 1028 @copied_from.children.each do |child|
1020 1029 unless child.visible?
1021 1030 # Do not copy subtasks that are not visible to avoid potential disclosure of private data
1022 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 1032 next
1024 1033 end
1025 1034 copy = Issue.new.copy_from(child, @copy_options)
1026 1035 copy.author = author
1027 1036 copy.project = project
1028 1037 copy.parent_issue_id = id
1029 1038 # Children subtasks are copied recursively
1030 1039 unless copy.save
1031 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 1041 end
1033 1042 end
1034 @subtasks_copied = true
1035 1043 end
1044 @after_create_from_copy_handled = true
1036 1045 end
1037 1046
1038 1047 def update_nested_set_attributes
1039 1048 if root_id.nil?
1040 1049 # issue was just created
1041 1050 self.root_id = (@parent_issue.nil? ? id : @parent_issue.root_id)
1042 1051 set_default_left_and_right
1043 1052 Issue.update_all("root_id = #{root_id}, lft = #{lft}, rgt = #{rgt}", ["id = ?", id])
1044 1053 if @parent_issue
1045 1054 move_to_child_of(@parent_issue)
1046 1055 end
1047 1056 reload
1048 1057 elsif parent_issue_id != parent_id
1049 1058 former_parent_id = parent_id
1050 1059 # moving an existing issue
1051 1060 if @parent_issue && @parent_issue.root_id == root_id
1052 1061 # inside the same tree
1053 1062 move_to_child_of(@parent_issue)
1054 1063 else
1055 1064 # to another tree
1056 1065 unless root?
1057 1066 move_to_right_of(root)
1058 1067 reload
1059 1068 end
1060 1069 old_root_id = root_id
1061 1070 self.root_id = (@parent_issue.nil? ? id : @parent_issue.root_id )
1062 1071 target_maxright = nested_set_scope.maximum(right_column_name) || 0
1063 1072 offset = target_maxright + 1 - lft
1064 1073 Issue.update_all("root_id = #{root_id}, lft = lft + #{offset}, rgt = rgt + #{offset}",
1065 1074 ["root_id = ? AND lft >= ? AND rgt <= ? ", old_root_id, lft, rgt])
1066 1075 self[left_column_name] = lft + offset
1067 1076 self[right_column_name] = rgt + offset
1068 1077 if @parent_issue
1069 1078 move_to_child_of(@parent_issue)
1070 1079 end
1071 1080 end
1072 1081 reload
1073 1082 # delete invalid relations of all descendants
1074 1083 self_and_descendants.each do |issue|
1075 1084 issue.relations.each do |relation|
1076 1085 relation.destroy unless relation.valid?
1077 1086 end
1078 1087 end
1079 1088 # update former parent
1080 1089 recalculate_attributes_for(former_parent_id) if former_parent_id
1081 1090 end
1082 1091 remove_instance_variable(:@parent_issue) if instance_variable_defined?(:@parent_issue)
1083 1092 end
1084 1093
1085 1094 def update_parent_attributes
1086 1095 recalculate_attributes_for(parent_id) if parent_id
1087 1096 end
1088 1097
1089 1098 def recalculate_attributes_for(issue_id)
1090 1099 if issue_id && p = Issue.find_by_id(issue_id)
1091 1100 # priority = highest priority of children
1092 1101 if priority_position = p.children.maximum("#{IssuePriority.table_name}.position", :joins => :priority)
1093 1102 p.priority = IssuePriority.find_by_position(priority_position)
1094 1103 end
1095 1104
1096 1105 # start/due dates = lowest/highest dates of children
1097 1106 p.start_date = p.children.minimum(:start_date)
1098 1107 p.due_date = p.children.maximum(:due_date)
1099 1108 if p.start_date && p.due_date && p.due_date < p.start_date
1100 1109 p.start_date, p.due_date = p.due_date, p.start_date
1101 1110 end
1102 1111
1103 1112 # done ratio = weighted average ratio of leaves
1104 1113 unless Issue.use_status_for_done_ratio? && p.status && p.status.default_done_ratio
1105 1114 leaves_count = p.leaves.count
1106 1115 if leaves_count > 0
1107 1116 average = p.leaves.average(:estimated_hours).to_f
1108 1117 if average == 0
1109 1118 average = 1
1110 1119 end
1111 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 1121 progress = done / (average * leaves_count)
1113 1122 p.done_ratio = progress.round
1114 1123 end
1115 1124 end
1116 1125
1117 1126 # estimate = sum of leaves estimates
1118 1127 p.estimated_hours = p.leaves.sum(:estimated_hours).to_f
1119 1128 p.estimated_hours = nil if p.estimated_hours == 0.0
1120 1129
1121 1130 # ancestors will be recursively updated
1122 1131 p.save(:validate => false)
1123 1132 end
1124 1133 end
1125 1134
1126 1135 # Update issues so their versions are not pointing to a
1127 1136 # fixed_version that is not shared with the issue's project
1128 1137 def self.update_versions(conditions=nil)
1129 1138 # Only need to update issues with a fixed_version from
1130 1139 # a different project and that is not systemwide shared
1131 1140 Issue.scoped(:conditions => conditions).all(
1132 1141 :conditions => "#{Issue.table_name}.fixed_version_id IS NOT NULL" +
1133 1142 " AND #{Issue.table_name}.project_id <> #{Version.table_name}.project_id" +
1134 1143 " AND #{Version.table_name}.sharing <> 'system'",
1135 1144 :include => [:project, :fixed_version]
1136 1145 ).each do |issue|
1137 1146 next if issue.project.nil? || issue.fixed_version.nil?
1138 1147 unless issue.project.shared_versions.include?(issue.fixed_version)
1139 1148 issue.init_journal(User.current)
1140 1149 issue.fixed_version = nil
1141 1150 issue.save
1142 1151 end
1143 1152 end
1144 1153 end
1145 1154
1146 1155 # Callback on file attachment
1147 1156 def attachment_added(obj)
1148 1157 if @current_journal && !obj.new_record?
1149 1158 @current_journal.details << JournalDetail.new(:property => 'attachment', :prop_key => obj.id, :value => obj.filename)
1150 1159 end
1151 1160 end
1152 1161
1153 1162 # Callback on attachment deletion
1154 1163 def attachment_removed(obj)
1155 1164 if @current_journal && !obj.new_record?
1156 1165 @current_journal.details << JournalDetail.new(:property => 'attachment', :prop_key => obj.id, :old_value => obj.filename)
1157 1166 @current_journal.save
1158 1167 end
1159 1168 end
1160 1169
1161 1170 # Default assignment based on category
1162 1171 def default_assign
1163 1172 if assigned_to.nil? && category && category.assigned_to
1164 1173 self.assigned_to = category.assigned_to
1165 1174 end
1166 1175 end
1167 1176
1168 1177 # Updates start/due dates of following issues
1169 1178 def reschedule_following_issues
1170 1179 if start_date_changed? || due_date_changed?
1171 1180 relations_from.each do |relation|
1172 1181 relation.set_issue_to_dates
1173 1182 end
1174 1183 end
1175 1184 end
1176 1185
1177 1186 # Closes duplicates if the issue is being closed
1178 1187 def close_duplicates
1179 1188 if closing?
1180 1189 duplicates.each do |duplicate|
1181 1190 # Reload is need in case the duplicate was updated by a previous duplicate
1182 1191 duplicate.reload
1183 1192 # Don't re-close it if it's already closed
1184 1193 next if duplicate.closed?
1185 1194 # Same user and notes
1186 1195 if @current_journal
1187 1196 duplicate.init_journal(@current_journal.user, @current_journal.notes)
1188 1197 end
1189 1198 duplicate.update_attribute :status, self.status
1190 1199 end
1191 1200 end
1192 1201 end
1193 1202
1194 1203 # Make sure updated_on is updated when adding a note
1195 1204 def force_updated_on_change
1196 1205 if @current_journal
1197 1206 self.updated_on = current_time_from_proper_timezone
1198 1207 end
1199 1208 end
1200 1209
1201 1210 # Saves the changes in a Journal
1202 1211 # Called after_save
1203 1212 def create_journal
1204 1213 if @current_journal
1205 1214 # attributes changes
1206 1215 if @attributes_before_change
1207 1216 (Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on)).each {|c|
1208 1217 before = @attributes_before_change[c]
1209 1218 after = send(c)
1210 1219 next if before == after || (before.blank? && after.blank?)
1211 1220 @current_journal.details << JournalDetail.new(:property => 'attr',
1212 1221 :prop_key => c,
1213 1222 :old_value => before,
1214 1223 :value => after)
1215 1224 }
1216 1225 end
1217 1226 if @custom_values_before_change
1218 1227 # custom fields changes
1219 1228 custom_field_values.each {|c|
1220 1229 before = @custom_values_before_change[c.custom_field_id]
1221 1230 after = c.value
1222 1231 next if before == after || (before.blank? && after.blank?)
1223 1232
1224 1233 if before.is_a?(Array) || after.is_a?(Array)
1225 1234 before = [before] unless before.is_a?(Array)
1226 1235 after = [after] unless after.is_a?(Array)
1227 1236
1228 1237 # values removed
1229 1238 (before - after).reject(&:blank?).each do |value|
1230 1239 @current_journal.details << JournalDetail.new(:property => 'cf',
1231 1240 :prop_key => c.custom_field_id,
1232 1241 :old_value => value,
1233 1242 :value => nil)
1234 1243 end
1235 1244 # values added
1236 1245 (after - before).reject(&:blank?).each do |value|
1237 1246 @current_journal.details << JournalDetail.new(:property => 'cf',
1238 1247 :prop_key => c.custom_field_id,
1239 1248 :old_value => nil,
1240 1249 :value => value)
1241 1250 end
1242 1251 else
1243 1252 @current_journal.details << JournalDetail.new(:property => 'cf',
1244 1253 :prop_key => c.custom_field_id,
1245 1254 :old_value => before,
1246 1255 :value => after)
1247 1256 end
1248 1257 }
1249 1258 end
1250 1259 @current_journal.save
1251 1260 # reset current journal
1252 1261 init_journal @current_journal.user, @current_journal.notes
1253 1262 end
1254 1263 end
1255 1264
1256 1265 # Query generator for selecting groups of issue counts for a project
1257 1266 # based on specific criteria
1258 1267 #
1259 1268 # Options
1260 1269 # * project - Project to search in.
1261 1270 # * field - String. Issue field to key off of in the grouping.
1262 1271 # * joins - String. The table name to join against.
1263 1272 def self.count_and_group_by(options)
1264 1273 project = options.delete(:project)
1265 1274 select_field = options.delete(:field)
1266 1275 joins = options.delete(:joins)
1267 1276
1268 1277 where = "#{Issue.table_name}.#{select_field}=j.id"
1269 1278
1270 1279 ActiveRecord::Base.connection.select_all("select s.id as status_id,
1271 1280 s.is_closed as closed,
1272 1281 j.id as #{select_field},
1273 1282 count(#{Issue.table_name}.id) as total
1274 1283 from
1275 1284 #{Issue.table_name}, #{Project.table_name}, #{IssueStatus.table_name} s, #{joins} j
1276 1285 where
1277 1286 #{Issue.table_name}.status_id=s.id
1278 1287 and #{where}
1279 1288 and #{Issue.table_name}.project_id=#{Project.table_name}.id
1280 1289 and #{visible_condition(User.current, :project => project)}
1281 1290 group by s.id, s.is_closed, j.id")
1282 1291 end
1283 1292 end
@@ -1,143 +1,147
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2012 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 class IssueRelation < ActiveRecord::Base
19 19 belongs_to :issue_from, :class_name => 'Issue', :foreign_key => 'issue_from_id'
20 20 belongs_to :issue_to, :class_name => 'Issue', :foreign_key => 'issue_to_id'
21 21
22 22 TYPE_RELATES = "relates"
23 23 TYPE_DUPLICATES = "duplicates"
24 24 TYPE_DUPLICATED = "duplicated"
25 25 TYPE_BLOCKS = "blocks"
26 26 TYPE_BLOCKED = "blocked"
27 27 TYPE_PRECEDES = "precedes"
28 28 TYPE_FOLLOWS = "follows"
29 TYPE_COPIED_TO = "copied_to"
30 TYPE_COPIED_FROM = "copied_from"
29 31
30 32 TYPES = { TYPE_RELATES => { :name => :label_relates_to, :sym_name => :label_relates_to, :order => 1, :sym => TYPE_RELATES },
31 33 TYPE_DUPLICATES => { :name => :label_duplicates, :sym_name => :label_duplicated_by, :order => 2, :sym => TYPE_DUPLICATED },
32 34 TYPE_DUPLICATED => { :name => :label_duplicated_by, :sym_name => :label_duplicates, :order => 3, :sym => TYPE_DUPLICATES, :reverse => TYPE_DUPLICATES },
33 35 TYPE_BLOCKS => { :name => :label_blocks, :sym_name => :label_blocked_by, :order => 4, :sym => TYPE_BLOCKED },
34 36 TYPE_BLOCKED => { :name => :label_blocked_by, :sym_name => :label_blocks, :order => 5, :sym => TYPE_BLOCKS, :reverse => TYPE_BLOCKS },
35 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 41 }.freeze
38 42
39 43 validates_presence_of :issue_from, :issue_to, :relation_type
40 44 validates_inclusion_of :relation_type, :in => TYPES.keys
41 45 validates_numericality_of :delay, :allow_nil => true
42 46 validates_uniqueness_of :issue_to_id, :scope => :issue_from_id
43 47
44 48 validate :validate_issue_relation
45 49
46 50 attr_protected :issue_from_id, :issue_to_id
47 51
48 52 before_save :handle_issue_order
49 53
50 54 def visible?(user=User.current)
51 55 (issue_from.nil? || issue_from.visible?(user)) && (issue_to.nil? || issue_to.visible?(user))
52 56 end
53 57
54 58 def deletable?(user=User.current)
55 59 visible?(user) &&
56 60 ((issue_from.nil? || user.allowed_to?(:manage_issue_relations, issue_from.project)) ||
57 61 (issue_to.nil? || user.allowed_to?(:manage_issue_relations, issue_to.project)))
58 62 end
59 63
60 64 def initialize(attributes=nil, *args)
61 65 super
62 66 if new_record?
63 67 if relation_type.blank?
64 68 self.relation_type = IssueRelation::TYPE_RELATES
65 69 end
66 70 end
67 71 end
68 72
69 73 def validate_issue_relation
70 74 if issue_from && issue_to
71 75 errors.add :issue_to_id, :invalid if issue_from_id == issue_to_id
72 76 errors.add :issue_to_id, :not_same_project unless issue_from.project_id == issue_to.project_id || Setting.cross_project_issue_relations?
73 77 #detect circular dependencies depending wether the relation should be reversed
74 78 if TYPES.has_key?(relation_type) && TYPES[relation_type][:reverse]
75 79 errors.add :base, :circular_dependency if issue_from.all_dependent_issues.include? issue_to
76 80 else
77 81 errors.add :base, :circular_dependency if issue_to.all_dependent_issues.include? issue_from
78 82 end
79 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 84 end
81 85 end
82 86
83 87 def other_issue(issue)
84 88 (self.issue_from_id == issue.id) ? issue_to : issue_from
85 89 end
86 90
87 91 # Returns the relation type for +issue+
88 92 def relation_type_for(issue)
89 93 if TYPES[relation_type]
90 94 if self.issue_from_id == issue.id
91 95 relation_type
92 96 else
93 97 TYPES[relation_type][:sym]
94 98 end
95 99 end
96 100 end
97 101
98 102 def label_for(issue)
99 103 TYPES[relation_type] ? TYPES[relation_type][(self.issue_from_id == issue.id) ? :name : :sym_name] : :unknow
100 104 end
101 105
102 106 def handle_issue_order
103 107 reverse_if_needed
104 108
105 109 if TYPE_PRECEDES == relation_type
106 110 self.delay ||= 0
107 111 else
108 112 self.delay = nil
109 113 end
110 114 set_issue_to_dates
111 115 end
112 116
113 117 def set_issue_to_dates
114 118 soonest_start = self.successor_soonest_start
115 119 if soonest_start && issue_to
116 120 issue_to.reschedule_after(soonest_start)
117 121 end
118 122 end
119 123
120 124 def successor_soonest_start
121 125 if (TYPE_PRECEDES == self.relation_type) && delay && issue_from && (issue_from.start_date || issue_from.due_date)
122 126 (issue_from.due_date || issue_from.start_date) + 1 + delay
123 127 end
124 128 end
125 129
126 130 def <=>(relation)
127 131 TYPES[self.relation_type][:order] <=> TYPES[relation.relation_type][:order]
128 132 end
129 133
130 134 private
131 135
132 136 # Reverses the relation if needed so that it gets stored in the proper way
133 137 # Should not be reversed before validation so that it can be displayed back
134 138 # as entered on new relation form
135 139 def reverse_if_needed
136 140 if TYPES.has_key?(relation_type) && TYPES[relation_type][:reverse]
137 141 issue_tmp = issue_to
138 142 self.issue_to = issue_from
139 143 self.issue_from = issue_tmp
140 144 self.relation_type = TYPES[relation_type][:reverse]
141 145 end
142 146 end
143 147 end
@@ -1,1062 +1,1064
1 1 en:
2 2 # Text direction: Left-to-Right (ltr) or Right-to-Left (rtl)
3 3 direction: ltr
4 4 date:
5 5 formats:
6 6 # Use the strftime parameters for formats.
7 7 # When no format has been given, it uses default.
8 8 # You can provide other formats here if you like!
9 9 default: "%m/%d/%Y"
10 10 short: "%b %d"
11 11 long: "%B %d, %Y"
12 12
13 13 day_names: [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday]
14 14 abbr_day_names: [Sun, Mon, Tue, Wed, Thu, Fri, Sat]
15 15
16 16 # Don't forget the nil at the beginning; there's no such thing as a 0th month
17 17 month_names: [~, January, February, March, April, May, June, July, August, September, October, November, December]
18 18 abbr_month_names: [~, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec]
19 19 # Used in date_select and datime_select.
20 20 order:
21 21 - :year
22 22 - :month
23 23 - :day
24 24
25 25 time:
26 26 formats:
27 27 default: "%m/%d/%Y %I:%M %p"
28 28 time: "%I:%M %p"
29 29 short: "%d %b %H:%M"
30 30 long: "%B %d, %Y %H:%M"
31 31 am: "am"
32 32 pm: "pm"
33 33
34 34 datetime:
35 35 distance_in_words:
36 36 half_a_minute: "half a minute"
37 37 less_than_x_seconds:
38 38 one: "less than 1 second"
39 39 other: "less than %{count} seconds"
40 40 x_seconds:
41 41 one: "1 second"
42 42 other: "%{count} seconds"
43 43 less_than_x_minutes:
44 44 one: "less than a minute"
45 45 other: "less than %{count} minutes"
46 46 x_minutes:
47 47 one: "1 minute"
48 48 other: "%{count} minutes"
49 49 about_x_hours:
50 50 one: "about 1 hour"
51 51 other: "about %{count} hours"
52 52 x_hours:
53 53 one: "1 hour"
54 54 other: "%{count} hours"
55 55 x_days:
56 56 one: "1 day"
57 57 other: "%{count} days"
58 58 about_x_months:
59 59 one: "about 1 month"
60 60 other: "about %{count} months"
61 61 x_months:
62 62 one: "1 month"
63 63 other: "%{count} months"
64 64 about_x_years:
65 65 one: "about 1 year"
66 66 other: "about %{count} years"
67 67 over_x_years:
68 68 one: "over 1 year"
69 69 other: "over %{count} years"
70 70 almost_x_years:
71 71 one: "almost 1 year"
72 72 other: "almost %{count} years"
73 73
74 74 number:
75 75 format:
76 76 separator: "."
77 77 delimiter: ""
78 78 precision: 3
79 79
80 80 human:
81 81 format:
82 82 delimiter: ""
83 83 precision: 3
84 84 storage_units:
85 85 format: "%n %u"
86 86 units:
87 87 byte:
88 88 one: "Byte"
89 89 other: "Bytes"
90 90 kb: "KB"
91 91 mb: "MB"
92 92 gb: "GB"
93 93 tb: "TB"
94 94
95 95 # Used in array.to_sentence.
96 96 support:
97 97 array:
98 98 sentence_connector: "and"
99 99 skip_last_comma: false
100 100
101 101 activerecord:
102 102 errors:
103 103 template:
104 104 header:
105 105 one: "1 error prohibited this %{model} from being saved"
106 106 other: "%{count} errors prohibited this %{model} from being saved"
107 107 messages:
108 108 inclusion: "is not included in the list"
109 109 exclusion: "is reserved"
110 110 invalid: "is invalid"
111 111 confirmation: "doesn't match confirmation"
112 112 accepted: "must be accepted"
113 113 empty: "can't be empty"
114 114 blank: "can't be blank"
115 115 too_long: "is too long (maximum is %{count} characters)"
116 116 too_short: "is too short (minimum is %{count} characters)"
117 117 wrong_length: "is the wrong length (should be %{count} characters)"
118 118 taken: "has already been taken"
119 119 not_a_number: "is not a number"
120 120 not_a_date: "is not a valid date"
121 121 greater_than: "must be greater than %{count}"
122 122 greater_than_or_equal_to: "must be greater than or equal to %{count}"
123 123 equal_to: "must be equal to %{count}"
124 124 less_than: "must be less than %{count}"
125 125 less_than_or_equal_to: "must be less than or equal to %{count}"
126 126 odd: "must be odd"
127 127 even: "must be even"
128 128 greater_than_start_date: "must be greater than start date"
129 129 not_same_project: "doesn't belong to the same project"
130 130 circular_dependency: "This relation would create a circular dependency"
131 131 cant_link_an_issue_with_a_descendant: "An issue cannot be linked to one of its subtasks"
132 132
133 133 actionview_instancetag_blank_option: Please select
134 134
135 135 general_text_No: 'No'
136 136 general_text_Yes: 'Yes'
137 137 general_text_no: 'no'
138 138 general_text_yes: 'yes'
139 139 general_lang_name: 'English'
140 140 general_csv_separator: ','
141 141 general_csv_decimal_separator: '.'
142 142 general_csv_encoding: ISO-8859-1
143 143 general_pdf_encoding: UTF-8
144 144 general_first_day_of_week: '7'
145 145
146 146 notice_account_updated: Account was successfully updated.
147 147 notice_account_invalid_creditentials: Invalid user or password
148 148 notice_account_password_updated: Password was successfully updated.
149 149 notice_account_wrong_password: Wrong password
150 150 notice_account_register_done: Account was successfully created. To activate your account, click on the link that was emailed to you.
151 151 notice_account_unknown_email: Unknown user.
152 152 notice_can_t_change_password: This account uses an external authentication source. Impossible to change the password.
153 153 notice_account_lost_email_sent: An email with instructions to choose a new password has been sent to you.
154 154 notice_account_activated: Your account has been activated. You can now log in.
155 155 notice_successful_create: Successful creation.
156 156 notice_successful_update: Successful update.
157 157 notice_successful_delete: Successful deletion.
158 158 notice_successful_connection: Successful connection.
159 159 notice_file_not_found: The page you were trying to access doesn't exist or has been removed.
160 160 notice_locking_conflict: Data has been updated by another user.
161 161 notice_not_authorized: You are not authorized to access this page.
162 162 notice_not_authorized_archived_project: The project you're trying to access has been archived.
163 163 notice_email_sent: "An email was sent to %{value}"
164 164 notice_email_error: "An error occurred while sending mail (%{value})"
165 165 notice_feeds_access_key_reseted: Your RSS access key was reset.
166 166 notice_api_access_key_reseted: Your API access key was reset.
167 167 notice_failed_to_save_issues: "Failed to save %{count} issue(s) on %{total} selected: %{ids}."
168 168 notice_failed_to_save_time_entries: "Failed to save %{count} time entrie(s) on %{total} selected: %{ids}."
169 169 notice_failed_to_save_members: "Failed to save member(s): %{errors}."
170 170 notice_no_issue_selected: "No issue is selected! Please, check the issues you want to edit."
171 171 notice_account_pending: "Your account was created and is now pending administrator approval."
172 172 notice_default_data_loaded: Default configuration successfully loaded.
173 173 notice_unable_delete_version: Unable to delete version.
174 174 notice_unable_delete_time_entry: Unable to delete time log entry.
175 175 notice_issue_done_ratios_updated: Issue done ratios updated.
176 176 notice_gantt_chart_truncated: "The chart was truncated because it exceeds the maximum number of items that can be displayed (%{max})"
177 177 notice_issue_successful_create: "Issue %{id} created."
178 178 notice_issue_update_conflict: "The issue has been updated by an other user while you were editing it."
179 179 notice_account_deleted: "Your account has been permanently deleted."
180 180 notice_user_successful_create: "User %{id} created."
181 181
182 182 error_can_t_load_default_data: "Default configuration could not be loaded: %{value}"
183 183 error_scm_not_found: "The entry or revision was not found in the repository."
184 184 error_scm_command_failed: "An error occurred when trying to access the repository: %{value}"
185 185 error_scm_annotate: "The entry does not exist or cannot be annotated."
186 186 error_scm_annotate_big_text_file: "The entry cannot be annotated, as it exceeds the maximum text file size."
187 187 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
188 188 error_no_tracker_in_project: 'No tracker is associated to this project. Please check the Project settings.'
189 189 error_no_default_issue_status: 'No default issue status is defined. Please check your configuration (Go to "Administration -> Issue statuses").'
190 190 error_can_not_delete_custom_field: Unable to delete custom field
191 191 error_can_not_delete_tracker: "This tracker contains issues and cannot be deleted."
192 192 error_can_not_remove_role: "This role is in use and cannot be deleted."
193 193 error_can_not_reopen_issue_on_closed_version: 'An issue assigned to a closed version cannot be reopened'
194 194 error_can_not_archive_project: This project cannot be archived
195 195 error_issue_done_ratios_not_updated: "Issue done ratios not updated."
196 196 error_workflow_copy_source: 'Please select a source tracker or role'
197 197 error_workflow_copy_target: 'Please select target tracker(s) and role(s)'
198 198 error_unable_delete_issue_status: 'Unable to delete issue status'
199 199 error_unable_to_connect: "Unable to connect (%{value})"
200 200 error_attachment_too_big: "This file cannot be uploaded because it exceeds the maximum allowed file size (%{max_size})"
201 201 error_session_expired: "Your session has expired. Please login again."
202 202 warning_attachments_not_saved: "%{count} file(s) could not be saved."
203 203
204 204 mail_subject_lost_password: "Your %{value} password"
205 205 mail_body_lost_password: 'To change your password, click on the following link:'
206 206 mail_subject_register: "Your %{value} account activation"
207 207 mail_body_register: 'To activate your account, click on the following link:'
208 208 mail_body_account_information_external: "You can use your %{value} account to log in."
209 209 mail_body_account_information: Your account information
210 210 mail_subject_account_activation_request: "%{value} account activation request"
211 211 mail_body_account_activation_request: "A new user (%{value}) has registered. The account is pending your approval:"
212 212 mail_subject_reminder: "%{count} issue(s) due in the next %{days} days"
213 213 mail_body_reminder: "%{count} issue(s) that are assigned to you are due in the next %{days} days:"
214 214 mail_subject_wiki_content_added: "'%{id}' wiki page has been added"
215 215 mail_body_wiki_content_added: "The '%{id}' wiki page has been added by %{author}."
216 216 mail_subject_wiki_content_updated: "'%{id}' wiki page has been updated"
217 217 mail_body_wiki_content_updated: "The '%{id}' wiki page has been updated by %{author}."
218 218
219 219 gui_validation_error: 1 error
220 220 gui_validation_error_plural: "%{count} errors"
221 221
222 222 field_name: Name
223 223 field_description: Description
224 224 field_summary: Summary
225 225 field_is_required: Required
226 226 field_firstname: First name
227 227 field_lastname: Last name
228 228 field_mail: Email
229 229 field_filename: File
230 230 field_filesize: Size
231 231 field_downloads: Downloads
232 232 field_author: Author
233 233 field_created_on: Created
234 234 field_updated_on: Updated
235 235 field_field_format: Format
236 236 field_is_for_all: For all projects
237 237 field_possible_values: Possible values
238 238 field_regexp: Regular expression
239 239 field_min_length: Minimum length
240 240 field_max_length: Maximum length
241 241 field_value: Value
242 242 field_category: Category
243 243 field_title: Title
244 244 field_project: Project
245 245 field_issue: Issue
246 246 field_status: Status
247 247 field_notes: Notes
248 248 field_is_closed: Issue closed
249 249 field_is_default: Default value
250 250 field_tracker: Tracker
251 251 field_subject: Subject
252 252 field_due_date: Due date
253 253 field_assigned_to: Assignee
254 254 field_priority: Priority
255 255 field_fixed_version: Target version
256 256 field_user: User
257 257 field_principal: Principal
258 258 field_role: Role
259 259 field_homepage: Homepage
260 260 field_is_public: Public
261 261 field_parent: Subproject of
262 262 field_is_in_roadmap: Issues displayed in roadmap
263 263 field_login: Login
264 264 field_mail_notification: Email notifications
265 265 field_admin: Administrator
266 266 field_last_login_on: Last connection
267 267 field_language: Language
268 268 field_effective_date: Date
269 269 field_password: Password
270 270 field_new_password: New password
271 271 field_password_confirmation: Confirmation
272 272 field_version: Version
273 273 field_type: Type
274 274 field_host: Host
275 275 field_port: Port
276 276 field_account: Account
277 277 field_base_dn: Base DN
278 278 field_attr_login: Login attribute
279 279 field_attr_firstname: Firstname attribute
280 280 field_attr_lastname: Lastname attribute
281 281 field_attr_mail: Email attribute
282 282 field_onthefly: On-the-fly user creation
283 283 field_start_date: Start date
284 284 field_done_ratio: "% Done"
285 285 field_auth_source: Authentication mode
286 286 field_hide_mail: Hide my email address
287 287 field_comments: Comment
288 288 field_url: URL
289 289 field_start_page: Start page
290 290 field_subproject: Subproject
291 291 field_hours: Hours
292 292 field_activity: Activity
293 293 field_spent_on: Date
294 294 field_identifier: Identifier
295 295 field_is_filter: Used as a filter
296 296 field_issue_to: Related issue
297 297 field_delay: Delay
298 298 field_assignable: Issues can be assigned to this role
299 299 field_redirect_existing_links: Redirect existing links
300 300 field_estimated_hours: Estimated time
301 301 field_column_names: Columns
302 302 field_time_entries: Log time
303 303 field_time_zone: Time zone
304 304 field_searchable: Searchable
305 305 field_default_value: Default value
306 306 field_comments_sorting: Display comments
307 307 field_parent_title: Parent page
308 308 field_editable: Editable
309 309 field_watcher: Watcher
310 310 field_identity_url: OpenID URL
311 311 field_content: Content
312 312 field_group_by: Group results by
313 313 field_sharing: Sharing
314 314 field_parent_issue: Parent task
315 315 field_member_of_group: "Assignee's group"
316 316 field_assigned_to_role: "Assignee's role"
317 317 field_text: Text field
318 318 field_visible: Visible
319 319 field_warn_on_leaving_unsaved: "Warn me when leaving a page with unsaved text"
320 320 field_issues_visibility: Issues visibility
321 321 field_is_private: Private
322 322 field_commit_logs_encoding: Commit messages encoding
323 323 field_scm_path_encoding: Path encoding
324 324 field_path_to_repository: Path to repository
325 325 field_root_directory: Root directory
326 326 field_cvsroot: CVSROOT
327 327 field_cvs_module: Module
328 328 field_repository_is_default: Main repository
329 329 field_multiple: Multiple values
330 330 field_auth_source_ldap_filter: LDAP filter
331 331 field_core_fields: Standard fields
332 332 field_timeout: "Timeout (in seconds)"
333 333 field_board_parent: Parent forum
334 334
335 335 setting_app_title: Application title
336 336 setting_app_subtitle: Application subtitle
337 337 setting_welcome_text: Welcome text
338 338 setting_default_language: Default language
339 339 setting_login_required: Authentication required
340 340 setting_self_registration: Self-registration
341 341 setting_attachment_max_size: Maximum attachment size
342 342 setting_issues_export_limit: Issues export limit
343 343 setting_mail_from: Emission email address
344 344 setting_bcc_recipients: Blind carbon copy recipients (bcc)
345 345 setting_plain_text_mail: Plain text mail (no HTML)
346 346 setting_host_name: Host name and path
347 347 setting_text_formatting: Text formatting
348 348 setting_wiki_compression: Wiki history compression
349 349 setting_feeds_limit: Maximum number of items in Atom feeds
350 350 setting_default_projects_public: New projects are public by default
351 351 setting_autofetch_changesets: Fetch commits automatically
352 352 setting_sys_api_enabled: Enable WS for repository management
353 353 setting_commit_ref_keywords: Referencing keywords
354 354 setting_commit_fix_keywords: Fixing keywords
355 355 setting_autologin: Autologin
356 356 setting_date_format: Date format
357 357 setting_time_format: Time format
358 358 setting_cross_project_issue_relations: Allow cross-project issue relations
359 359 setting_issue_list_default_columns: Default columns displayed on the issue list
360 360 setting_repositories_encodings: Attachments and repositories encodings
361 361 setting_emails_header: Emails header
362 362 setting_emails_footer: Emails footer
363 363 setting_protocol: Protocol
364 364 setting_per_page_options: Objects per page options
365 365 setting_user_format: Users display format
366 366 setting_activity_days_default: Days displayed on project activity
367 367 setting_display_subprojects_issues: Display subprojects issues on main projects by default
368 368 setting_enabled_scm: Enabled SCM
369 369 setting_mail_handler_body_delimiters: "Truncate emails after one of these lines"
370 370 setting_mail_handler_api_enabled: Enable WS for incoming emails
371 371 setting_mail_handler_api_key: API key
372 372 setting_sequential_project_identifiers: Generate sequential project identifiers
373 373 setting_gravatar_enabled: Use Gravatar user icons
374 374 setting_gravatar_default: Default Gravatar image
375 375 setting_diff_max_lines_displayed: Maximum number of diff lines displayed
376 376 setting_file_max_size_displayed: Maximum size of text files displayed inline
377 377 setting_repository_log_display_limit: Maximum number of revisions displayed on file log
378 378 setting_openid: Allow OpenID login and registration
379 379 setting_password_min_length: Minimum password length
380 380 setting_new_project_user_role_id: Role given to a non-admin user who creates a project
381 381 setting_default_projects_modules: Default enabled modules for new projects
382 382 setting_issue_done_ratio: Calculate the issue done ratio with
383 383 setting_issue_done_ratio_issue_field: Use the issue field
384 384 setting_issue_done_ratio_issue_status: Use the issue status
385 385 setting_start_of_week: Start calendars on
386 386 setting_rest_api_enabled: Enable REST web service
387 387 setting_cache_formatted_text: Cache formatted text
388 388 setting_default_notification_option: Default notification option
389 389 setting_commit_logtime_enabled: Enable time logging
390 390 setting_commit_logtime_activity_id: Activity for logged time
391 391 setting_gantt_items_limit: Maximum number of items displayed on the gantt chart
392 392 setting_issue_group_assignment: Allow issue assignment to groups
393 393 setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
394 394 setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed
395 395 setting_unsubscribe: Allow users to delete their own account
396 396 setting_session_lifetime: Session maximum lifetime
397 397 setting_session_timeout: Session inactivity timeout
398 398 setting_thumbnails_enabled: Display attachment thumbnails
399 399 setting_thumbnails_size: Thumbnails size (in pixels)
400 400
401 401 permission_add_project: Create project
402 402 permission_add_subprojects: Create subprojects
403 403 permission_edit_project: Edit project
404 404 permission_close_project: Close / reopen the project
405 405 permission_select_project_modules: Select project modules
406 406 permission_manage_members: Manage members
407 407 permission_manage_project_activities: Manage project activities
408 408 permission_manage_versions: Manage versions
409 409 permission_manage_categories: Manage issue categories
410 410 permission_view_issues: View Issues
411 411 permission_add_issues: Add issues
412 412 permission_edit_issues: Edit issues
413 413 permission_manage_issue_relations: Manage issue relations
414 414 permission_set_issues_private: Set issues public or private
415 415 permission_set_own_issues_private: Set own issues public or private
416 416 permission_add_issue_notes: Add notes
417 417 permission_edit_issue_notes: Edit notes
418 418 permission_edit_own_issue_notes: Edit own notes
419 419 permission_move_issues: Move issues
420 420 permission_delete_issues: Delete issues
421 421 permission_manage_public_queries: Manage public queries
422 422 permission_save_queries: Save queries
423 423 permission_view_gantt: View gantt chart
424 424 permission_view_calendar: View calendar
425 425 permission_view_issue_watchers: View watchers list
426 426 permission_add_issue_watchers: Add watchers
427 427 permission_delete_issue_watchers: Delete watchers
428 428 permission_log_time: Log spent time
429 429 permission_view_time_entries: View spent time
430 430 permission_edit_time_entries: Edit time logs
431 431 permission_edit_own_time_entries: Edit own time logs
432 432 permission_manage_news: Manage news
433 433 permission_comment_news: Comment news
434 434 permission_manage_documents: Manage documents
435 435 permission_view_documents: View documents
436 436 permission_manage_files: Manage files
437 437 permission_view_files: View files
438 438 permission_manage_wiki: Manage wiki
439 439 permission_rename_wiki_pages: Rename wiki pages
440 440 permission_delete_wiki_pages: Delete wiki pages
441 441 permission_view_wiki_pages: View wiki
442 442 permission_view_wiki_edits: View wiki history
443 443 permission_edit_wiki_pages: Edit wiki pages
444 444 permission_delete_wiki_pages_attachments: Delete attachments
445 445 permission_protect_wiki_pages: Protect wiki pages
446 446 permission_manage_repository: Manage repository
447 447 permission_browse_repository: Browse repository
448 448 permission_view_changesets: View changesets
449 449 permission_commit_access: Commit access
450 450 permission_manage_boards: Manage forums
451 451 permission_view_messages: View messages
452 452 permission_add_messages: Post messages
453 453 permission_edit_messages: Edit messages
454 454 permission_edit_own_messages: Edit own messages
455 455 permission_delete_messages: Delete messages
456 456 permission_delete_own_messages: Delete own messages
457 457 permission_export_wiki_pages: Export wiki pages
458 458 permission_manage_subtasks: Manage subtasks
459 459 permission_manage_related_issues: Manage related issues
460 460
461 461 project_module_issue_tracking: Issue tracking
462 462 project_module_time_tracking: Time tracking
463 463 project_module_news: News
464 464 project_module_documents: Documents
465 465 project_module_files: Files
466 466 project_module_wiki: Wiki
467 467 project_module_repository: Repository
468 468 project_module_boards: Forums
469 469 project_module_calendar: Calendar
470 470 project_module_gantt: Gantt
471 471
472 472 label_user: User
473 473 label_user_plural: Users
474 474 label_user_new: New user
475 475 label_user_anonymous: Anonymous
476 476 label_project: Project
477 477 label_project_new: New project
478 478 label_project_plural: Projects
479 479 label_x_projects:
480 480 zero: no projects
481 481 one: 1 project
482 482 other: "%{count} projects"
483 483 label_project_all: All Projects
484 484 label_project_latest: Latest projects
485 485 label_issue: Issue
486 486 label_issue_new: New issue
487 487 label_issue_plural: Issues
488 488 label_issue_view_all: View all issues
489 489 label_issues_by: "Issues by %{value}"
490 490 label_issue_added: Issue added
491 491 label_issue_updated: Issue updated
492 492 label_issue_note_added: Note added
493 493 label_issue_status_updated: Status updated
494 494 label_issue_priority_updated: Priority updated
495 495 label_document: Document
496 496 label_document_new: New document
497 497 label_document_plural: Documents
498 498 label_document_added: Document added
499 499 label_role: Role
500 500 label_role_plural: Roles
501 501 label_role_new: New role
502 502 label_role_and_permissions: Roles and permissions
503 503 label_role_anonymous: Anonymous
504 504 label_role_non_member: Non member
505 505 label_member: Member
506 506 label_member_new: New member
507 507 label_member_plural: Members
508 508 label_tracker: Tracker
509 509 label_tracker_plural: Trackers
510 510 label_tracker_new: New tracker
511 511 label_workflow: Workflow
512 512 label_issue_status: Issue status
513 513 label_issue_status_plural: Issue statuses
514 514 label_issue_status_new: New status
515 515 label_issue_category: Issue category
516 516 label_issue_category_plural: Issue categories
517 517 label_issue_category_new: New category
518 518 label_custom_field: Custom field
519 519 label_custom_field_plural: Custom fields
520 520 label_custom_field_new: New custom field
521 521 label_enumerations: Enumerations
522 522 label_enumeration_new: New value
523 523 label_information: Information
524 524 label_information_plural: Information
525 525 label_please_login: Please log in
526 526 label_register: Register
527 527 label_login_with_open_id_option: or login with OpenID
528 528 label_password_lost: Lost password
529 529 label_home: Home
530 530 label_my_page: My page
531 531 label_my_account: My account
532 532 label_my_projects: My projects
533 533 label_my_page_block: My page block
534 534 label_administration: Administration
535 535 label_login: Sign in
536 536 label_logout: Sign out
537 537 label_help: Help
538 538 label_reported_issues: Reported issues
539 539 label_assigned_to_me_issues: Issues assigned to me
540 540 label_last_login: Last connection
541 541 label_registered_on: Registered on
542 542 label_activity: Activity
543 543 label_overall_activity: Overall activity
544 544 label_user_activity: "%{value}'s activity"
545 545 label_new: New
546 546 label_logged_as: Logged in as
547 547 label_environment: Environment
548 548 label_authentication: Authentication
549 549 label_auth_source: Authentication mode
550 550 label_auth_source_new: New authentication mode
551 551 label_auth_source_plural: Authentication modes
552 552 label_subproject_plural: Subprojects
553 553 label_subproject_new: New subproject
554 554 label_and_its_subprojects: "%{value} and its subprojects"
555 555 label_min_max_length: Min - Max length
556 556 label_list: List
557 557 label_date: Date
558 558 label_integer: Integer
559 559 label_float: Float
560 560 label_boolean: Boolean
561 561 label_string: Text
562 562 label_text: Long text
563 563 label_attribute: Attribute
564 564 label_attribute_plural: Attributes
565 565 label_download: "%{count} Download"
566 566 label_download_plural: "%{count} Downloads"
567 567 label_no_data: No data to display
568 568 label_change_status: Change status
569 569 label_history: History
570 570 label_attachment: File
571 571 label_attachment_new: New file
572 572 label_attachment_delete: Delete file
573 573 label_attachment_plural: Files
574 574 label_file_added: File added
575 575 label_report: Report
576 576 label_report_plural: Reports
577 577 label_news: News
578 578 label_news_new: Add news
579 579 label_news_plural: News
580 580 label_news_latest: Latest news
581 581 label_news_view_all: View all news
582 582 label_news_added: News added
583 583 label_news_comment_added: Comment added to a news
584 584 label_settings: Settings
585 585 label_overview: Overview
586 586 label_version: Version
587 587 label_version_new: New version
588 588 label_version_plural: Versions
589 589 label_close_versions: Close completed versions
590 590 label_confirmation: Confirmation
591 591 label_export_to: 'Also available in:'
592 592 label_read: Read...
593 593 label_public_projects: Public projects
594 594 label_open_issues: open
595 595 label_open_issues_plural: open
596 596 label_closed_issues: closed
597 597 label_closed_issues_plural: closed
598 598 label_x_open_issues_abbr_on_total:
599 599 zero: 0 open / %{total}
600 600 one: 1 open / %{total}
601 601 other: "%{count} open / %{total}"
602 602 label_x_open_issues_abbr:
603 603 zero: 0 open
604 604 one: 1 open
605 605 other: "%{count} open"
606 606 label_x_closed_issues_abbr:
607 607 zero: 0 closed
608 608 one: 1 closed
609 609 other: "%{count} closed"
610 610 label_x_issues:
611 611 zero: 0 issues
612 612 one: 1 issue
613 613 other: "%{count} issues"
614 614 label_total: Total
615 615 label_permissions: Permissions
616 616 label_current_status: Current status
617 617 label_new_statuses_allowed: New statuses allowed
618 618 label_all: all
619 619 label_none: none
620 620 label_nobody: nobody
621 621 label_next: Next
622 622 label_previous: Previous
623 623 label_used_by: Used by
624 624 label_details: Details
625 625 label_add_note: Add a note
626 626 label_per_page: Per page
627 627 label_calendar: Calendar
628 628 label_months_from: months from
629 629 label_gantt: Gantt
630 630 label_internal: Internal
631 631 label_last_changes: "last %{count} changes"
632 632 label_change_view_all: View all changes
633 633 label_personalize_page: Personalize this page
634 634 label_comment: Comment
635 635 label_comment_plural: Comments
636 636 label_x_comments:
637 637 zero: no comments
638 638 one: 1 comment
639 639 other: "%{count} comments"
640 640 label_comment_add: Add a comment
641 641 label_comment_added: Comment added
642 642 label_comment_delete: Delete comments
643 643 label_query: Custom query
644 644 label_query_plural: Custom queries
645 645 label_query_new: New query
646 646 label_my_queries: My custom queries
647 647 label_filter_add: Add filter
648 648 label_filter_plural: Filters
649 649 label_equals: is
650 650 label_not_equals: is not
651 651 label_in_less_than: in less than
652 652 label_in_more_than: in more than
653 653 label_greater_or_equal: '>='
654 654 label_less_or_equal: '<='
655 655 label_between: between
656 656 label_in: in
657 657 label_today: today
658 658 label_all_time: all time
659 659 label_yesterday: yesterday
660 660 label_this_week: this week
661 661 label_last_week: last week
662 662 label_last_n_days: "last %{count} days"
663 663 label_this_month: this month
664 664 label_last_month: last month
665 665 label_this_year: this year
666 666 label_date_range: Date range
667 667 label_less_than_ago: less than days ago
668 668 label_more_than_ago: more than days ago
669 669 label_ago: days ago
670 670 label_contains: contains
671 671 label_not_contains: doesn't contain
672 672 label_day_plural: days
673 673 label_repository: Repository
674 674 label_repository_new: New repository
675 675 label_repository_plural: Repositories
676 676 label_browse: Browse
677 677 label_modification: "%{count} change"
678 678 label_modification_plural: "%{count} changes"
679 679 label_branch: Branch
680 680 label_tag: Tag
681 681 label_revision: Revision
682 682 label_revision_plural: Revisions
683 683 label_revision_id: "Revision %{value}"
684 684 label_associated_revisions: Associated revisions
685 685 label_added: added
686 686 label_modified: modified
687 687 label_copied: copied
688 688 label_renamed: renamed
689 689 label_deleted: deleted
690 690 label_latest_revision: Latest revision
691 691 label_latest_revision_plural: Latest revisions
692 692 label_view_revisions: View revisions
693 693 label_view_all_revisions: View all revisions
694 694 label_max_size: Maximum size
695 695 label_sort_highest: Move to top
696 696 label_sort_higher: Move up
697 697 label_sort_lower: Move down
698 698 label_sort_lowest: Move to bottom
699 699 label_roadmap: Roadmap
700 700 label_roadmap_due_in: "Due in %{value}"
701 701 label_roadmap_overdue: "%{value} late"
702 702 label_roadmap_no_issues: No issues for this version
703 703 label_search: Search
704 704 label_result_plural: Results
705 705 label_all_words: All words
706 706 label_wiki: Wiki
707 707 label_wiki_edit: Wiki edit
708 708 label_wiki_edit_plural: Wiki edits
709 709 label_wiki_page: Wiki page
710 710 label_wiki_page_plural: Wiki pages
711 711 label_index_by_title: Index by title
712 712 label_index_by_date: Index by date
713 713 label_current_version: Current version
714 714 label_preview: Preview
715 715 label_feed_plural: Feeds
716 716 label_changes_details: Details of all changes
717 717 label_issue_tracking: Issue tracking
718 718 label_spent_time: Spent time
719 719 label_overall_spent_time: Overall spent time
720 720 label_f_hour: "%{value} hour"
721 721 label_f_hour_plural: "%{value} hours"
722 722 label_time_tracking: Time tracking
723 723 label_change_plural: Changes
724 724 label_statistics: Statistics
725 725 label_commits_per_month: Commits per month
726 726 label_commits_per_author: Commits per author
727 727 label_diff: diff
728 728 label_view_diff: View differences
729 729 label_diff_inline: inline
730 730 label_diff_side_by_side: side by side
731 731 label_options: Options
732 732 label_copy_workflow_from: Copy workflow from
733 733 label_permissions_report: Permissions report
734 734 label_watched_issues: Watched issues
735 735 label_related_issues: Related issues
736 736 label_applied_status: Applied status
737 737 label_loading: Loading...
738 738 label_relation_new: New relation
739 739 label_relation_delete: Delete relation
740 740 label_relates_to: related to
741 741 label_duplicates: duplicates
742 742 label_duplicated_by: duplicated by
743 743 label_blocks: blocks
744 744 label_blocked_by: blocked by
745 745 label_precedes: precedes
746 746 label_follows: follows
747 label_copied_to: copied to
748 label_copied_from: copied from
747 749 label_end_to_start: end to start
748 750 label_end_to_end: end to end
749 751 label_start_to_start: start to start
750 752 label_start_to_end: start to end
751 753 label_stay_logged_in: Stay logged in
752 754 label_disabled: disabled
753 755 label_show_completed_versions: Show completed versions
754 756 label_me: me
755 757 label_board: Forum
756 758 label_board_new: New forum
757 759 label_board_plural: Forums
758 760 label_board_locked: Locked
759 761 label_board_sticky: Sticky
760 762 label_topic_plural: Topics
761 763 label_message_plural: Messages
762 764 label_message_last: Last message
763 765 label_message_new: New message
764 766 label_message_posted: Message added
765 767 label_reply_plural: Replies
766 768 label_send_information: Send account information to the user
767 769 label_year: Year
768 770 label_month: Month
769 771 label_week: Week
770 772 label_date_from: From
771 773 label_date_to: To
772 774 label_language_based: Based on user's language
773 775 label_sort_by: "Sort by %{value}"
774 776 label_send_test_email: Send a test email
775 777 label_feeds_access_key: RSS access key
776 778 label_missing_feeds_access_key: Missing a RSS access key
777 779 label_feeds_access_key_created_on: "RSS access key created %{value} ago"
778 780 label_module_plural: Modules
779 781 label_added_time_by: "Added by %{author} %{age} ago"
780 782 label_updated_time_by: "Updated by %{author} %{age} ago"
781 783 label_updated_time: "Updated %{value} ago"
782 784 label_jump_to_a_project: Jump to a project...
783 785 label_file_plural: Files
784 786 label_changeset_plural: Changesets
785 787 label_default_columns: Default columns
786 788 label_no_change_option: (No change)
787 789 label_bulk_edit_selected_issues: Bulk edit selected issues
788 790 label_bulk_edit_selected_time_entries: Bulk edit selected time entries
789 791 label_theme: Theme
790 792 label_default: Default
791 793 label_search_titles_only: Search titles only
792 794 label_user_mail_option_all: "For any event on all my projects"
793 795 label_user_mail_option_selected: "For any event on the selected projects only..."
794 796 label_user_mail_option_none: "No events"
795 797 label_user_mail_option_only_my_events: "Only for things I watch or I'm involved in"
796 798 label_user_mail_option_only_assigned: "Only for things I am assigned to"
797 799 label_user_mail_option_only_owner: "Only for things I am the owner of"
798 800 label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
799 801 label_registration_activation_by_email: account activation by email
800 802 label_registration_manual_activation: manual account activation
801 803 label_registration_automatic_activation: automatic account activation
802 804 label_display_per_page: "Per page: %{value}"
803 805 label_age: Age
804 806 label_change_properties: Change properties
805 807 label_general: General
806 808 label_more: More
807 809 label_scm: SCM
808 810 label_plugins: Plugins
809 811 label_ldap_authentication: LDAP authentication
810 812 label_downloads_abbr: D/L
811 813 label_optional_description: Optional description
812 814 label_add_another_file: Add another file
813 815 label_preferences: Preferences
814 816 label_chronological_order: In chronological order
815 817 label_reverse_chronological_order: In reverse chronological order
816 818 label_planning: Planning
817 819 label_incoming_emails: Incoming emails
818 820 label_generate_key: Generate a key
819 821 label_issue_watchers: Watchers
820 822 label_example: Example
821 823 label_display: Display
822 824 label_sort: Sort
823 825 label_ascending: Ascending
824 826 label_descending: Descending
825 827 label_date_from_to: From %{start} to %{end}
826 828 label_wiki_content_added: Wiki page added
827 829 label_wiki_content_updated: Wiki page updated
828 830 label_group: Group
829 831 label_group_plural: Groups
830 832 label_group_new: New group
831 833 label_time_entry_plural: Spent time
832 834 label_version_sharing_none: Not shared
833 835 label_version_sharing_descendants: With subprojects
834 836 label_version_sharing_hierarchy: With project hierarchy
835 837 label_version_sharing_tree: With project tree
836 838 label_version_sharing_system: With all projects
837 839 label_update_issue_done_ratios: Update issue done ratios
838 840 label_copy_source: Source
839 841 label_copy_target: Target
840 842 label_copy_same_as_target: Same as target
841 843 label_display_used_statuses_only: Only display statuses that are used by this tracker
842 844 label_api_access_key: API access key
843 845 label_missing_api_access_key: Missing an API access key
844 846 label_api_access_key_created_on: "API access key created %{value} ago"
845 847 label_profile: Profile
846 848 label_subtask_plural: Subtasks
847 849 label_project_copy_notifications: Send email notifications during the project copy
848 850 label_principal_search: "Search for user or group:"
849 851 label_user_search: "Search for user:"
850 852 label_additional_workflow_transitions_for_author: Additional transitions allowed when the user is the author
851 853 label_additional_workflow_transitions_for_assignee: Additional transitions allowed when the user is the assignee
852 854 label_issues_visibility_all: All issues
853 855 label_issues_visibility_public: All non private issues
854 856 label_issues_visibility_own: Issues created by or assigned to the user
855 857 label_git_report_last_commit: Report last commit for files and directories
856 858 label_parent_revision: Parent
857 859 label_child_revision: Child
858 860 label_export_options: "%{export_format} export options"
859 861 label_copy_attachments: Copy attachments
860 862 label_copy_subtasks: Copy subtasks
861 863 label_item_position: "%{position} of %{count}"
862 864 label_completed_versions: Completed versions
863 865 label_search_for_watchers: Search for watchers to add
864 866 label_session_expiration: Session expiration
865 867 label_show_closed_projects: View closed projects
866 868 label_status_transitions: Status transitions
867 869 label_fields_permissions: Fields permissions
868 870 label_readonly: Read-only
869 871 label_required: Required
870 872 label_attribute_of_project: "Project's %{name}"
871 873 label_attribute_of_author: "Author's %{name}"
872 874 label_attribute_of_assigned_to: "Assignee's %{name}"
873 875 label_attribute_of_fixed_version: "Target version's %{name}"
874 876
875 877 button_login: Login
876 878 button_submit: Submit
877 879 button_save: Save
878 880 button_check_all: Check all
879 881 button_uncheck_all: Uncheck all
880 882 button_collapse_all: Collapse all
881 883 button_expand_all: Expand all
882 884 button_delete: Delete
883 885 button_create: Create
884 886 button_create_and_continue: Create and continue
885 887 button_test: Test
886 888 button_edit: Edit
887 889 button_edit_associated_wikipage: "Edit associated Wiki page: %{page_title}"
888 890 button_add: Add
889 891 button_change: Change
890 892 button_apply: Apply
891 893 button_clear: Clear
892 894 button_lock: Lock
893 895 button_unlock: Unlock
894 896 button_download: Download
895 897 button_list: List
896 898 button_view: View
897 899 button_move: Move
898 900 button_move_and_follow: Move and follow
899 901 button_back: Back
900 902 button_cancel: Cancel
901 903 button_activate: Activate
902 904 button_sort: Sort
903 905 button_log_time: Log time
904 906 button_rollback: Rollback to this version
905 907 button_watch: Watch
906 908 button_unwatch: Unwatch
907 909 button_reply: Reply
908 910 button_archive: Archive
909 911 button_unarchive: Unarchive
910 912 button_reset: Reset
911 913 button_rename: Rename
912 914 button_change_password: Change password
913 915 button_copy: Copy
914 916 button_copy_and_follow: Copy and follow
915 917 button_annotate: Annotate
916 918 button_update: Update
917 919 button_configure: Configure
918 920 button_quote: Quote
919 921 button_duplicate: Duplicate
920 922 button_show: Show
921 923 button_edit_section: Edit this section
922 924 button_export: Export
923 925 button_delete_my_account: Delete my account
924 926 button_close: Close
925 927 button_reopen: Reopen
926 928
927 929 status_active: active
928 930 status_registered: registered
929 931 status_locked: locked
930 932
931 933 project_status_active: active
932 934 project_status_closed: closed
933 935 project_status_archived: archived
934 936
935 937 version_status_open: open
936 938 version_status_locked: locked
937 939 version_status_closed: closed
938 940
939 941 field_active: Active
940 942
941 943 text_select_mail_notifications: Select actions for which email notifications should be sent.
942 944 text_regexp_info: eg. ^[A-Z0-9]+$
943 945 text_min_max_length_info: 0 means no restriction
944 946 text_project_destroy_confirmation: Are you sure you want to delete this project and related data?
945 947 text_subprojects_destroy_warning: "Its subproject(s): %{value} will be also deleted."
946 948 text_workflow_edit: Select a role and a tracker to edit the workflow
947 949 text_are_you_sure: Are you sure?
948 950 text_are_you_sure_with_children: "Delete issue and all child issues?"
949 951 text_journal_changed: "%{label} changed from %{old} to %{new}"
950 952 text_journal_changed_no_detail: "%{label} updated"
951 953 text_journal_set_to: "%{label} set to %{value}"
952 954 text_journal_deleted: "%{label} deleted (%{old})"
953 955 text_journal_added: "%{label} %{value} added"
954 956 text_tip_issue_begin_day: issue beginning this day
955 957 text_tip_issue_end_day: issue ending this day
956 958 text_tip_issue_begin_end_day: issue beginning and ending this day
957 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 960 text_caracters_maximum: "%{count} characters maximum."
959 961 text_caracters_minimum: "Must be at least %{count} characters long."
960 962 text_length_between: "Length between %{min} and %{max} characters."
961 963 text_tracker_no_workflow: No workflow defined for this tracker
962 964 text_unallowed_characters: Unallowed characters
963 965 text_comma_separated: Multiple values allowed (comma separated).
964 966 text_line_separated: Multiple values allowed (one line for each value).
965 967 text_issues_ref_in_commit_messages: Referencing and fixing issues in commit messages
966 968 text_issue_added: "Issue %{id} has been reported by %{author}."
967 969 text_issue_updated: "Issue %{id} has been updated by %{author}."
968 970 text_wiki_destroy_confirmation: Are you sure you want to delete this wiki and all its content?
969 971 text_issue_category_destroy_question: "Some issues (%{count}) are assigned to this category. What do you want to do?"
970 972 text_issue_category_destroy_assignments: Remove category assignments
971 973 text_issue_category_reassign_to: Reassign issues to this category
972 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 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 976 text_load_default_configuration: Load the default configuration
975 977 text_status_changed_by_changeset: "Applied in changeset %{value}."
976 978 text_time_logged_by_changeset: "Applied in changeset %{value}."
977 979 text_issues_destroy_confirmation: 'Are you sure you want to delete the selected issue(s)?'
978 980 text_issues_destroy_descendants_confirmation: "This will also delete %{count} subtask(s)."
979 981 text_time_entries_destroy_confirmation: 'Are you sure you want to delete the selected time entr(y/ies)?'
980 982 text_select_project_modules: 'Select modules to enable for this project:'
981 983 text_default_administrator_account_changed: Default administrator account changed
982 984 text_file_repository_writable: Attachments directory writable
983 985 text_plugin_assets_writable: Plugin assets directory writable
984 986 text_rmagick_available: RMagick available (optional)
985 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 988 text_destroy_time_entries: Delete reported hours
987 989 text_assign_time_entries_to_project: Assign reported hours to the project
988 990 text_reassign_time_entries: 'Reassign reported hours to this issue:'
989 991 text_user_wrote: "%{value} wrote:"
990 992 text_enumeration_destroy_question: "%{count} objects are assigned to this value."
991 993 text_enumeration_category_reassign_to: 'Reassign them to this value:'
992 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 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 996 text_diff_truncated: '... This diff was truncated because it exceeds the maximum size that can be displayed.'
995 997 text_custom_field_possible_values_info: 'One line for each value'
996 998 text_wiki_page_destroy_question: "This page has %{descendants} child page(s) and descendant(s). What do you want to do?"
997 999 text_wiki_page_nullify_children: "Keep child pages as root pages"
998 1000 text_wiki_page_destroy_children: "Delete child pages and all their descendants"
999 1001 text_wiki_page_reassign_children: "Reassign child pages to this parent page"
1000 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 1003 text_zoom_in: Zoom in
1002 1004 text_zoom_out: Zoom out
1003 1005 text_warn_on_leaving_unsaved: "The current page contains unsaved text that will be lost if you leave this page."
1004 1006 text_scm_path_encoding_note: "Default: UTF-8"
1005 1007 text_git_repository_note: Repository is bare and local (e.g. /gitrepo, c:\gitrepo)
1006 1008 text_mercurial_repository_note: Local repository (e.g. /hgrepo, c:\hgrepo)
1007 1009 text_scm_command: Command
1008 1010 text_scm_command_version: Version
1009 1011 text_scm_config: You can configure your scm commands in config/configuration.yml. Please restart the application after editing it.
1010 1012 text_scm_command_not_available: Scm command is not available. Please check settings on the administration panel.
1011 1013 text_issue_conflict_resolution_overwrite: "Apply my changes anyway (previous notes will be kept but some changes may be overwritten)"
1012 1014 text_issue_conflict_resolution_add_notes: "Add my notes and discard my other changes"
1013 1015 text_issue_conflict_resolution_cancel: "Discard all my changes and redisplay %{link}"
1014 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 1017 text_session_expiration_settings: "Warning: changing these settings may expire the current sessions including yours."
1016 1018 text_project_closed: This project is closed and read-only.
1017 1019
1018 1020 default_role_manager: Manager
1019 1021 default_role_developer: Developer
1020 1022 default_role_reporter: Reporter
1021 1023 default_tracker_bug: Bug
1022 1024 default_tracker_feature: Feature
1023 1025 default_tracker_support: Support
1024 1026 default_issue_status_new: New
1025 1027 default_issue_status_in_progress: In Progress
1026 1028 default_issue_status_resolved: Resolved
1027 1029 default_issue_status_feedback: Feedback
1028 1030 default_issue_status_closed: Closed
1029 1031 default_issue_status_rejected: Rejected
1030 1032 default_doc_category_user: User documentation
1031 1033 default_doc_category_tech: Technical documentation
1032 1034 default_priority_low: Low
1033 1035 default_priority_normal: Normal
1034 1036 default_priority_high: High
1035 1037 default_priority_urgent: Urgent
1036 1038 default_priority_immediate: Immediate
1037 1039 default_activity_design: Design
1038 1040 default_activity_development: Development
1039 1041
1040 1042 enumeration_issue_priorities: Issue priorities
1041 1043 enumeration_doc_categories: Document categories
1042 1044 enumeration_activities: Activities (time tracking)
1043 1045 enumeration_system_activity: System Activity
1044 1046 description_filter: Filter
1045 1047 description_search: Searchfield
1046 1048 description_choose_project: Projects
1047 1049 description_project_scope: Search scope
1048 1050 description_notes: Notes
1049 1051 description_message_content: Message content
1050 1052 description_query_sort_criteria_attribute: Sort attribute
1051 1053 description_query_sort_criteria_direction: Sort direction
1052 1054 description_user_mail_notification: Mail notification settings
1053 1055 description_available_columns: Available Columns
1054 1056 description_selected_columns: Selected Columns
1055 1057 description_all_columns: All Columns
1056 1058 description_issue_category_reassign: Choose issue category
1057 1059 description_wiki_subpages_reassign: Choose new parent page
1058 1060 description_date_range_list: Choose range from list
1059 1061 description_date_range_interval: Choose range by selecting start and end date
1060 1062 description_date_from: Enter start date
1061 1063 description_date_to: Enter end date
1062 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 1 # French translations for Ruby on Rails
2 2 # by Christian Lescuyer (christian@flyingcoders.com)
3 3 # contributor: Sebastien Grosjean - ZenCocoon.com
4 4 # contributor: Thibaut Cuvelier - Developpez.com
5 5
6 6 fr:
7 7 direction: ltr
8 8 date:
9 9 formats:
10 10 default: "%d/%m/%Y"
11 11 short: "%e %b"
12 12 long: "%e %B %Y"
13 13 long_ordinal: "%e %B %Y"
14 14 only_day: "%e"
15 15
16 16 day_names: [dimanche, lundi, mardi, mercredi, jeudi, vendredi, samedi]
17 17 abbr_day_names: [dim, lun, mar, mer, jeu, ven, sam]
18 18 month_names: [~, janvier, fΓ©vrier, mars, avril, mai, juin, juillet, aoΓ»t, septembre, octobre, novembre, dΓ©cembre]
19 19 abbr_month_names: [~, jan., fΓ©v., mar., avr., mai, juin, juil., aoΓ»t, sept., oct., nov., dΓ©c.]
20 20 order:
21 21 - :day
22 22 - :month
23 23 - :year
24 24
25 25 time:
26 26 formats:
27 27 default: "%d/%m/%Y %H:%M"
28 28 time: "%H:%M"
29 29 short: "%d %b %H:%M"
30 30 long: "%A %d %B %Y %H:%M:%S %Z"
31 31 long_ordinal: "%A %d %B %Y %H:%M:%S %Z"
32 32 only_second: "%S"
33 33 am: 'am'
34 34 pm: 'pm'
35 35
36 36 datetime:
37 37 distance_in_words:
38 38 half_a_minute: "30 secondes"
39 39 less_than_x_seconds:
40 40 zero: "moins d'une seconde"
41 41 one: "moins d'uneΒ seconde"
42 42 other: "moins de %{count}Β secondes"
43 43 x_seconds:
44 44 one: "1Β seconde"
45 45 other: "%{count}Β secondes"
46 46 less_than_x_minutes:
47 47 zero: "moins d'une minute"
48 48 one: "moins d'uneΒ minute"
49 49 other: "moins de %{count}Β minutes"
50 50 x_minutes:
51 51 one: "1Β minute"
52 52 other: "%{count}Β minutes"
53 53 about_x_hours:
54 54 one: "environ une heure"
55 55 other: "environ %{count}Β heures"
56 56 x_hours:
57 57 one: "une heure"
58 58 other: "%{count}Β heures"
59 59 x_days:
60 60 one: "unΒ jour"
61 61 other: "%{count}Β jours"
62 62 about_x_months:
63 63 one: "environ un mois"
64 64 other: "environ %{count}Β mois"
65 65 x_months:
66 66 one: "unΒ mois"
67 67 other: "%{count}Β mois"
68 68 about_x_years:
69 69 one: "environ un an"
70 70 other: "environ %{count}Β ans"
71 71 over_x_years:
72 72 one: "plus d'un an"
73 73 other: "plus de %{count}Β ans"
74 74 almost_x_years:
75 75 one: "presqu'un an"
76 76 other: "presque %{count} ans"
77 77 prompts:
78 78 year: "AnnΓ©e"
79 79 month: "Mois"
80 80 day: "Jour"
81 81 hour: "Heure"
82 82 minute: "Minute"
83 83 second: "Seconde"
84 84
85 85 number:
86 86 format:
87 87 precision: 3
88 88 separator: ','
89 89 delimiter: 'Β '
90 90 currency:
91 91 format:
92 92 unit: '€'
93 93 precision: 2
94 94 format: '%nΒ %u'
95 95 human:
96 96 format:
97 97 precision: 3
98 98 storage_units:
99 99 format: "%n %u"
100 100 units:
101 101 byte:
102 102 one: "octet"
103 103 other: "octet"
104 104 kb: "ko"
105 105 mb: "Mo"
106 106 gb: "Go"
107 107 tb: "To"
108 108
109 109 support:
110 110 array:
111 111 sentence_connector: 'et'
112 112 skip_last_comma: true
113 113 word_connector: ", "
114 114 two_words_connector: " et "
115 115 last_word_connector: " et "
116 116
117 117 activerecord:
118 118 errors:
119 119 template:
120 120 header:
121 121 one: "Impossible d'enregistrer %{model} : une erreur"
122 122 other: "Impossible d'enregistrer %{model} : %{count} erreurs."
123 123 body: "Veuillez vΓ©rifier les champs suivantsΒ :"
124 124 messages:
125 125 inclusion: "n'est pas inclus(e) dans la liste"
126 126 exclusion: "n'est pas disponible"
127 127 invalid: "n'est pas valide"
128 128 confirmation: "ne concorde pas avec la confirmation"
129 129 accepted: "doit Γͺtre acceptΓ©(e)"
130 130 empty: "doit Γͺtre renseignΓ©(e)"
131 131 blank: "doit Γͺtre renseignΓ©(e)"
132 132 too_long: "est trop long (pas plus de %{count} caractères)"
133 133 too_short: "est trop court (au moins %{count} caractères)"
134 134 wrong_length: "ne fait pas la bonne longueur (doit comporter %{count} caractères)"
135 135 taken: "est dΓ©jΓ  utilisΓ©"
136 136 not_a_number: "n'est pas un nombre"
137 137 not_a_date: "n'est pas une date valide"
138 138 greater_than: "doit Γͺtre supΓ©rieur Γ  %{count}"
139 139 greater_than_or_equal_to: "doit Γͺtre supΓ©rieur ou Γ©gal Γ  %{count}"
140 140 equal_to: "doit Γͺtre Γ©gal Γ  %{count}"
141 141 less_than: "doit Γͺtre infΓ©rieur Γ  %{count}"
142 142 less_than_or_equal_to: "doit Γͺtre infΓ©rieur ou Γ©gal Γ  %{count}"
143 143 odd: "doit Γͺtre impair"
144 144 even: "doit Γͺtre pair"
145 145 greater_than_start_date: "doit Γͺtre postΓ©rieure Γ  la date de dΓ©but"
146 146 not_same_project: "n'appartient pas au mΓͺme projet"
147 147 circular_dependency: "Cette relation crΓ©erait une dΓ©pendance circulaire"
148 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 150 actionview_instancetag_blank_option: Choisir
151 151
152 152 general_text_No: 'Non'
153 153 general_text_Yes: 'Oui'
154 154 general_text_no: 'non'
155 155 general_text_yes: 'oui'
156 156 general_lang_name: 'FranΓ§ais'
157 157 general_csv_separator: ';'
158 158 general_csv_decimal_separator: ','
159 159 general_csv_encoding: ISO-8859-1
160 160 general_pdf_encoding: UTF-8
161 161 general_first_day_of_week: '1'
162 162
163 163 notice_account_updated: Le compte a été mis à jour avec succès.
164 164 notice_account_invalid_creditentials: Identifiant ou mot de passe invalide.
165 165 notice_account_password_updated: Mot de passe mis à jour avec succès.
166 166 notice_account_wrong_password: Mot de passe incorrect
167 167 notice_account_register_done: Un message contenant les instructions pour activer votre compte vous a Γ©tΓ© envoyΓ©.
168 168 notice_account_unknown_email: Aucun compte ne correspond Γ  cette adresse.
169 169 notice_can_t_change_password: Ce compte utilise une authentification externe. Impossible de changer le mot de passe.
170 170 notice_account_lost_email_sent: Un message contenant les instructions pour choisir un nouveau mot de passe vous a Γ©tΓ© envoyΓ©.
171 171 notice_account_activated: Votre compte a Γ©tΓ© activΓ©. Vous pouvez Γ  prΓ©sent vous connecter.
172 172 notice_successful_create: Création effectuée avec succès.
173 173 notice_successful_update: Mise à jour effectuée avec succès.
174 174 notice_successful_delete: Suppression effectuée avec succès.
175 175 notice_successful_connection: Connexion rΓ©ussie.
176 176 notice_file_not_found: "La page Γ  laquelle vous souhaitez accΓ©der n'existe pas ou a Γ©tΓ© supprimΓ©e."
177 177 notice_locking_conflict: Les donnΓ©es ont Γ©tΓ© mises Γ  jour par un autre utilisateur. Mise Γ  jour impossible.
178 178 notice_not_authorized: "Vous n'Γͺtes pas autorisΓ© Γ  accΓ©der Γ  cette page."
179 179 notice_not_authorized_archived_project: Le projet auquel vous tentez d'accΓ©der a Γ©tΓ© archivΓ©.
180 180 notice_email_sent: "Un email a Γ©tΓ© envoyΓ© Γ  %{value}"
181 181 notice_email_error: "Erreur lors de l'envoi de l'email (%{value})"
182 182 notice_feeds_access_key_reseted: "Votre clé d'accès aux flux RSS a été réinitialisée."
183 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 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 185 notice_no_issue_selected: "Aucune demande sΓ©lectionnΓ©e ! Cochez les demandes que vous voulez mettre Γ  jour."
186 186 notice_account_pending: "Votre compte a été créé et attend l'approbation de l'administrateur."
187 187 notice_default_data_loaded: Paramétrage par défaut chargé avec succès.
188 188 notice_unable_delete_version: Impossible de supprimer cette version.
189 189 notice_issue_done_ratios_updated: L'avancement des demandes a Γ©tΓ© mis Γ  jour.
190 190 notice_api_access_key_reseted: Votre clé d'accès API a été réinitialisée.
191 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 192 notice_issue_successful_create: "Demande %{id} créée."
193 193 notice_issue_update_conflict: "La demande a Γ©tΓ© mise Γ  jour par un autre utilisateur pendant que vous la modifiez."
194 194 notice_account_deleted: "Votre compte a Γ©tΓ© dΓ©finitivement supprimΓ©."
195 195 notice_user_successful_create: "Utilisateur %{id} créé."
196 196
197 197 error_can_t_load_default_data: "Une erreur s'est produite lors du chargement du paramΓ©trage : %{value}"
198 198 error_scm_not_found: "L'entrΓ©e et/ou la rΓ©vision demandΓ©e n'existe pas dans le dΓ©pΓ΄t."
199 199 error_scm_command_failed: "Une erreur s'est produite lors de l'accès au dépôt : %{value}"
200 200 error_scm_annotate: "L'entrΓ©e n'existe pas ou ne peut pas Γͺtre annotΓ©e."
201 201 error_issue_not_found_in_project: "La demande n'existe pas ou n'appartient pas Γ  ce projet"
202 202 error_can_not_reopen_issue_on_closed_version: 'Une demande assignΓ©e Γ  une version fermΓ©e ne peut pas Γͺtre rΓ©ouverte'
203 203 error_can_not_archive_project: "Ce projet ne peut pas Γͺtre archivΓ©"
204 204 error_workflow_copy_source: 'Veuillez sΓ©lectionner un tracker et/ou un rΓ΄le source'
205 205 error_workflow_copy_target: 'Veuillez sΓ©lectionner les trackers et rΓ΄les cibles'
206 206 error_issue_done_ratios_not_updated: L'avancement des demandes n'a pas pu Γͺtre mis Γ  jour.
207 207 error_attachment_too_big: Ce fichier ne peut pas Γͺtre attachΓ© car il excΓ¨de la taille maximale autorisΓ©e (%{max_size})
208 208 error_session_expired: "Votre session a expirΓ©. Veuillez vous reconnecter."
209 209
210 210 warning_attachments_not_saved: "%{count} fichier(s) n'ont pas pu Γͺtre sauvegardΓ©s."
211 211
212 212 mail_subject_lost_password: "Votre mot de passe %{value}"
213 213 mail_body_lost_password: 'Pour changer votre mot de passe, cliquez sur le lien suivant :'
214 214 mail_subject_register: "Activation de votre compte %{value}"
215 215 mail_body_register: 'Pour activer votre compte, cliquez sur le lien suivant :'
216 216 mail_body_account_information_external: "Vous pouvez utiliser votre compte %{value} pour vous connecter."
217 217 mail_body_account_information: Paramètres de connexion de votre compte
218 218 mail_subject_account_activation_request: "Demande d'activation d'un compte %{value}"
219 219 mail_body_account_activation_request: "Un nouvel utilisateur (%{value}) s'est inscrit. Son compte nΓ©cessite votre approbation :"
220 220 mail_subject_reminder: "%{count} demande(s) arrivent Γ  Γ©chΓ©ance (%{days})"
221 221 mail_body_reminder: "%{count} demande(s) qui vous sont assignΓ©es arrivent Γ  Γ©chΓ©ance dans les %{days} prochains jours :"
222 222 mail_subject_wiki_content_added: "Page wiki '%{id}' ajoutΓ©e"
223 223 mail_body_wiki_content_added: "La page wiki '%{id}' a Γ©tΓ© ajoutΓ©e par %{author}."
224 224 mail_subject_wiki_content_updated: "Page wiki '%{id}' mise Γ  jour"
225 225 mail_body_wiki_content_updated: "La page wiki '%{id}' a Γ©tΓ© mise Γ  jour par %{author}."
226 226
227 227 gui_validation_error: 1 erreur
228 228 gui_validation_error_plural: "%{count} erreurs"
229 229
230 230 field_name: Nom
231 231 field_description: Description
232 232 field_summary: RΓ©sumΓ©
233 233 field_is_required: Obligatoire
234 234 field_firstname: PrΓ©nom
235 235 field_lastname: Nom
236 236 field_mail: "Email "
237 237 field_filename: Fichier
238 238 field_filesize: Taille
239 239 field_downloads: TΓ©lΓ©chargements
240 240 field_author: Auteur
241 241 field_created_on: "Créé "
242 242 field_updated_on: "Mis-Γ -jour "
243 243 field_field_format: Format
244 244 field_is_for_all: Pour tous les projets
245 245 field_possible_values: Valeurs possibles
246 246 field_regexp: Expression régulière
247 247 field_min_length: Longueur minimum
248 248 field_max_length: Longueur maximum
249 249 field_value: Valeur
250 250 field_category: CatΓ©gorie
251 251 field_title: Titre
252 252 field_project: Projet
253 253 field_issue: Demande
254 254 field_status: Statut
255 255 field_notes: Notes
256 256 field_is_closed: Demande fermΓ©e
257 257 field_is_default: Valeur par dΓ©faut
258 258 field_tracker: Tracker
259 259 field_subject: Sujet
260 260 field_due_date: EchΓ©ance
261 261 field_assigned_to: AssignΓ© Γ 
262 262 field_priority: PrioritΓ©
263 263 field_fixed_version: Version cible
264 264 field_user: Utilisateur
265 265 field_role: RΓ΄le
266 266 field_homepage: "Site web "
267 267 field_is_public: Public
268 268 field_parent: Sous-projet de
269 269 field_is_in_roadmap: Demandes affichΓ©es dans la roadmap
270 270 field_login: "Identifiant "
271 271 field_mail_notification: Notifications par mail
272 272 field_admin: Administrateur
273 273 field_last_login_on: "Dernière connexion "
274 274 field_language: Langue
275 275 field_effective_date: Date
276 276 field_password: Mot de passe
277 277 field_new_password: Nouveau mot de passe
278 278 field_password_confirmation: Confirmation
279 279 field_version: Version
280 280 field_type: Type
281 281 field_host: HΓ΄te
282 282 field_port: Port
283 283 field_account: Compte
284 284 field_base_dn: Base DN
285 285 field_attr_login: Attribut Identifiant
286 286 field_attr_firstname: Attribut PrΓ©nom
287 287 field_attr_lastname: Attribut Nom
288 288 field_attr_mail: Attribut Email
289 289 field_onthefly: CrΓ©ation des utilisateurs Γ  la volΓ©e
290 290 field_start_date: DΓ©but
291 291 field_done_ratio: "% rΓ©alisΓ©"
292 292 field_auth_source: Mode d'authentification
293 293 field_hide_mail: Cacher mon adresse mail
294 294 field_comments: Commentaire
295 295 field_url: URL
296 296 field_start_page: Page de dΓ©marrage
297 297 field_subproject: Sous-projet
298 298 field_hours: Heures
299 299 field_activity: ActivitΓ©
300 300 field_spent_on: Date
301 301 field_identifier: Identifiant
302 302 field_is_filter: UtilisΓ© comme filtre
303 303 field_issue_to: Demande liΓ©e
304 304 field_delay: Retard
305 305 field_assignable: Demandes assignables Γ  ce rΓ΄le
306 306 field_redirect_existing_links: Rediriger les liens existants
307 307 field_estimated_hours: Temps estimΓ©
308 308 field_column_names: Colonnes
309 309 field_time_zone: Fuseau horaire
310 310 field_searchable: UtilisΓ© pour les recherches
311 311 field_default_value: Valeur par dΓ©faut
312 312 field_comments_sorting: Afficher les commentaires
313 313 field_parent_title: Page parent
314 314 field_editable: Modifiable
315 315 field_watcher: Observateur
316 316 field_identity_url: URL OpenID
317 317 field_content: Contenu
318 318 field_group_by: Grouper par
319 319 field_sharing: Partage
320 320 field_active: Actif
321 321 field_parent_issue: TΓ’che parente
322 322 field_visible: Visible
323 323 field_warn_on_leaving_unsaved: "M'avertir lorsque je quitte une page contenant du texte non sauvegardΓ©"
324 324 field_issues_visibility: VisibilitΓ© des demandes
325 325 field_is_private: PrivΓ©e
326 326 field_commit_logs_encoding: Encodage des messages de commit
327 327 field_repository_is_default: DΓ©pΓ΄t principal
328 328 field_multiple: Valeurs multiples
329 329 field_auth_source_ldap_filter: Filtre LDAP
330 330 field_core_fields: Champs standards
331 331 field_timeout: "Timeout (en secondes)"
332 332 field_board_parent: Forum parent
333 333
334 334 setting_app_title: Titre de l'application
335 335 setting_app_subtitle: Sous-titre de l'application
336 336 setting_welcome_text: Texte d'accueil
337 337 setting_default_language: Langue par dΓ©faut
338 338 setting_login_required: Authentification obligatoire
339 339 setting_self_registration: Inscription des nouveaux utilisateurs
340 340 setting_attachment_max_size: Taille maximale des fichiers
341 341 setting_issues_export_limit: Limite d'exportation des demandes
342 342 setting_mail_from: Adresse d'Γ©mission
343 343 setting_bcc_recipients: Destinataires en copie cachΓ©e (cci)
344 344 setting_plain_text_mail: Mail en texte brut (non HTML)
345 345 setting_host_name: Nom d'hΓ΄te et chemin
346 346 setting_text_formatting: Formatage du texte
347 347 setting_wiki_compression: Compression de l'historique des pages wiki
348 348 setting_feeds_limit: Nombre maximal d'Γ©lΓ©ments dans les flux Atom
349 349 setting_default_projects_public: DΓ©finir les nouveaux projets comme publics par dΓ©faut
350 350 setting_autofetch_changesets: RΓ©cupΓ©ration automatique des commits
351 351 setting_sys_api_enabled: Activer les WS pour la gestion des dΓ©pΓ΄ts
352 352 setting_commit_ref_keywords: Mots-clΓ©s de rΓ©fΓ©rencement
353 353 setting_commit_fix_keywords: Mots-clΓ©s de rΓ©solution
354 354 setting_autologin: DurΓ©e maximale de connexion automatique
355 355 setting_date_format: Format de date
356 356 setting_time_format: Format d'heure
357 357 setting_cross_project_issue_relations: Autoriser les relations entre demandes de diffΓ©rents projets
358 358 setting_issue_list_default_columns: Colonnes affichΓ©es par dΓ©faut sur la liste des demandes
359 359 setting_emails_footer: Pied-de-page des emails
360 360 setting_protocol: Protocole
361 361 setting_per_page_options: Options d'objets affichΓ©s par page
362 362 setting_user_format: Format d'affichage des utilisateurs
363 363 setting_activity_days_default: Nombre de jours affichΓ©s sur l'activitΓ© des projets
364 364 setting_display_subprojects_issues: Afficher par dΓ©faut les demandes des sous-projets sur les projets principaux
365 365 setting_enabled_scm: SCM activΓ©s
366 366 setting_mail_handler_body_delimiters: "Tronquer les emails après l'une de ces lignes"
367 367 setting_mail_handler_api_enabled: "Activer le WS pour la rΓ©ception d'emails"
368 368 setting_mail_handler_api_key: ClΓ© de protection de l'API
369 369 setting_sequential_project_identifiers: GΓ©nΓ©rer des identifiants de projet sΓ©quentiels
370 370 setting_gravatar_enabled: Afficher les Gravatar des utilisateurs
371 371 setting_diff_max_lines_displayed: Nombre maximum de lignes de diff affichΓ©es
372 372 setting_file_max_size_displayed: Taille maximum des fichiers texte affichΓ©s en ligne
373 373 setting_repository_log_display_limit: "Nombre maximum de rΓ©visions affichΓ©es sur l'historique d'un fichier"
374 374 setting_openid: "Autoriser l'authentification et l'enregistrement OpenID"
375 375 setting_password_min_length: Longueur minimum des mots de passe
376 376 setting_new_project_user_role_id: RΓ΄le donnΓ© Γ  un utilisateur non-administrateur qui crΓ©e un projet
377 377 setting_default_projects_modules: Modules activΓ©s par dΓ©faut pour les nouveaux projets
378 378 setting_issue_done_ratio: Calcul de l'avancement des demandes
379 379 setting_issue_done_ratio_issue_status: Utiliser le statut
380 380 setting_issue_done_ratio_issue_field: 'Utiliser le champ % effectuΓ©'
381 381 setting_rest_api_enabled: Activer l'API REST
382 382 setting_gravatar_default: Image Gravatar par dΓ©faut
383 383 setting_start_of_week: Jour de dΓ©but des calendriers
384 384 setting_cache_formatted_text: Mettre en cache le texte formatΓ©
385 385 setting_commit_logtime_enabled: Permettre la saisie de temps
386 386 setting_commit_logtime_activity_id: ActivitΓ© pour le temps saisi
387 387 setting_gantt_items_limit: Nombre maximum d'Γ©lΓ©ments affichΓ©s sur le gantt
388 388 setting_issue_group_assignment: Permettre l'assignement des demandes aux groupes
389 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 390 setting_commit_cross_project_ref: Permettre le rΓ©fΓ©rencement et la rΓ©solution des demandes de tous les autres projets
391 391 setting_unsubscribe: Permettre aux utilisateurs de supprimer leur propre compte
392 392 setting_session_lifetime: DurΓ©e de vie maximale des sessions
393 393 setting_session_timeout: DurΓ©e maximale d'inactivitΓ©
394 394 setting_thumbnails_enabled: Afficher les vignettes des images
395 395 setting_thumbnails_size: Taille des vignettes (en pixels)
396 396
397 397 permission_add_project: CrΓ©er un projet
398 398 permission_add_subprojects: CrΓ©er des sous-projets
399 399 permission_edit_project: Modifier le projet
400 400 permission_close_project: Fermer / rΓ©ouvrir le projet
401 401 permission_select_project_modules: Choisir les modules
402 402 permission_manage_members: GΓ©rer les membres
403 403 permission_manage_versions: GΓ©rer les versions
404 404 permission_manage_categories: GΓ©rer les catΓ©gories de demandes
405 405 permission_view_issues: Voir les demandes
406 406 permission_add_issues: CrΓ©er des demandes
407 407 permission_edit_issues: Modifier les demandes
408 408 permission_manage_issue_relations: GΓ©rer les relations
409 409 permission_set_issues_private: Rendre les demandes publiques ou privΓ©es
410 410 permission_set_own_issues_private: Rendre ses propres demandes publiques ou privΓ©es
411 411 permission_add_issue_notes: Ajouter des notes
412 412 permission_edit_issue_notes: Modifier les notes
413 413 permission_edit_own_issue_notes: Modifier ses propres notes
414 414 permission_move_issues: DΓ©placer les demandes
415 415 permission_delete_issues: Supprimer les demandes
416 416 permission_manage_public_queries: GΓ©rer les requΓͺtes publiques
417 417 permission_save_queries: Sauvegarder les requΓͺtes
418 418 permission_view_gantt: Voir le gantt
419 419 permission_view_calendar: Voir le calendrier
420 420 permission_view_issue_watchers: Voir la liste des observateurs
421 421 permission_add_issue_watchers: Ajouter des observateurs
422 422 permission_delete_issue_watchers: Supprimer des observateurs
423 423 permission_log_time: Saisir le temps passΓ©
424 424 permission_view_time_entries: Voir le temps passΓ©
425 425 permission_edit_time_entries: Modifier les temps passΓ©s
426 426 permission_edit_own_time_entries: Modifier son propre temps passΓ©
427 427 permission_manage_news: GΓ©rer les annonces
428 428 permission_comment_news: Commenter les annonces
429 429 permission_manage_documents: GΓ©rer les documents
430 430 permission_view_documents: Voir les documents
431 431 permission_manage_files: GΓ©rer les fichiers
432 432 permission_view_files: Voir les fichiers
433 433 permission_manage_wiki: GΓ©rer le wiki
434 434 permission_rename_wiki_pages: Renommer les pages
435 435 permission_delete_wiki_pages: Supprimer les pages
436 436 permission_view_wiki_pages: Voir le wiki
437 437 permission_view_wiki_edits: "Voir l'historique des modifications"
438 438 permission_edit_wiki_pages: Modifier les pages
439 439 permission_delete_wiki_pages_attachments: Supprimer les fichiers joints
440 440 permission_protect_wiki_pages: ProtΓ©ger les pages
441 441 permission_manage_repository: GΓ©rer le dΓ©pΓ΄t de sources
442 442 permission_browse_repository: Parcourir les sources
443 443 permission_view_changesets: Voir les rΓ©visions
444 444 permission_commit_access: Droit de commit
445 445 permission_manage_boards: GΓ©rer les forums
446 446 permission_view_messages: Voir les messages
447 447 permission_add_messages: Poster un message
448 448 permission_edit_messages: Modifier les messages
449 449 permission_edit_own_messages: Modifier ses propres messages
450 450 permission_delete_messages: Supprimer les messages
451 451 permission_delete_own_messages: Supprimer ses propres messages
452 452 permission_export_wiki_pages: Exporter les pages
453 453 permission_manage_project_activities: GΓ©rer les activitΓ©s
454 454 permission_manage_subtasks: GΓ©rer les sous-tΓ’ches
455 455 permission_manage_related_issues: GΓ©rer les demandes associΓ©es
456 456
457 457 project_module_issue_tracking: Suivi des demandes
458 458 project_module_time_tracking: Suivi du temps passΓ©
459 459 project_module_news: Publication d'annonces
460 460 project_module_documents: Publication de documents
461 461 project_module_files: Publication de fichiers
462 462 project_module_wiki: Wiki
463 463 project_module_repository: DΓ©pΓ΄t de sources
464 464 project_module_boards: Forums de discussion
465 465
466 466 label_user: Utilisateur
467 467 label_user_plural: Utilisateurs
468 468 label_user_new: Nouvel utilisateur
469 469 label_user_anonymous: Anonyme
470 470 label_project: Projet
471 471 label_project_new: Nouveau projet
472 472 label_project_plural: Projets
473 473 label_x_projects:
474 474 zero: aucun projet
475 475 one: un projet
476 476 other: "%{count} projets"
477 477 label_project_all: Tous les projets
478 478 label_project_latest: Derniers projets
479 479 label_issue: Demande
480 480 label_issue_new: Nouvelle demande
481 481 label_issue_plural: Demandes
482 482 label_issue_view_all: Voir toutes les demandes
483 483 label_issue_added: Demande ajoutΓ©e
484 484 label_issue_updated: Demande mise Γ  jour
485 485 label_issue_note_added: Note ajoutΓ©e
486 486 label_issue_status_updated: Statut changΓ©
487 487 label_issue_priority_updated: PrioritΓ© changΓ©e
488 488 label_issues_by: "Demandes par %{value}"
489 489 label_document: Document
490 490 label_document_new: Nouveau document
491 491 label_document_plural: Documents
492 492 label_document_added: Document ajoutΓ©
493 493 label_role: RΓ΄le
494 494 label_role_plural: RΓ΄les
495 495 label_role_new: Nouveau rΓ΄le
496 496 label_role_and_permissions: RΓ΄les et permissions
497 497 label_role_anonymous: Anonyme
498 498 label_role_non_member: Non membre
499 499 label_member: Membre
500 500 label_member_new: Nouveau membre
501 501 label_member_plural: Membres
502 502 label_tracker: Tracker
503 503 label_tracker_plural: Trackers
504 504 label_tracker_new: Nouveau tracker
505 505 label_workflow: Workflow
506 506 label_issue_status: Statut de demandes
507 507 label_issue_status_plural: Statuts de demandes
508 508 label_issue_status_new: Nouveau statut
509 509 label_issue_category: CatΓ©gorie de demandes
510 510 label_issue_category_plural: CatΓ©gories de demandes
511 511 label_issue_category_new: Nouvelle catΓ©gorie
512 512 label_custom_field: Champ personnalisΓ©
513 513 label_custom_field_plural: Champs personnalisΓ©s
514 514 label_custom_field_new: Nouveau champ personnalisΓ©
515 515 label_enumerations: Listes de valeurs
516 516 label_enumeration_new: Nouvelle valeur
517 517 label_information: Information
518 518 label_information_plural: Informations
519 519 label_please_login: Identification
520 520 label_register: S'enregistrer
521 521 label_login_with_open_id_option: S'authentifier avec OpenID
522 522 label_password_lost: Mot de passe perdu
523 523 label_home: Accueil
524 524 label_my_page: Ma page
525 525 label_my_account: Mon compte
526 526 label_my_projects: Mes projets
527 527 label_my_page_block: Blocs disponibles
528 528 label_administration: Administration
529 529 label_login: Connexion
530 530 label_logout: DΓ©connexion
531 531 label_help: Aide
532 532 label_reported_issues: "Demandes soumises "
533 533 label_assigned_to_me_issues: Demandes qui me sont assignΓ©es
534 534 label_last_login: "Dernière connexion "
535 535 label_registered_on: "Inscrit le "
536 536 label_activity: ActivitΓ©
537 537 label_overall_activity: ActivitΓ© globale
538 538 label_user_activity: "ActivitΓ© de %{value}"
539 539 label_new: Nouveau
540 540 label_logged_as: ConnectΓ© en tant que
541 541 label_environment: Environnement
542 542 label_authentication: Authentification
543 543 label_auth_source: Mode d'authentification
544 544 label_auth_source_new: Nouveau mode d'authentification
545 545 label_auth_source_plural: Modes d'authentification
546 546 label_subproject_plural: Sous-projets
547 547 label_subproject_new: Nouveau sous-projet
548 548 label_and_its_subprojects: "%{value} et ses sous-projets"
549 549 label_min_max_length: Longueurs mini - maxi
550 550 label_list: Liste
551 551 label_date: Date
552 552 label_integer: Entier
553 553 label_float: Nombre dΓ©cimal
554 554 label_boolean: BoolΓ©en
555 555 label_string: Texte
556 556 label_text: Texte long
557 557 label_attribute: Attribut
558 558 label_attribute_plural: Attributs
559 559 label_download: "%{count} tΓ©lΓ©chargement"
560 560 label_download_plural: "%{count} tΓ©lΓ©chargements"
561 561 label_no_data: Aucune donnΓ©e Γ  afficher
562 562 label_change_status: Changer le statut
563 563 label_history: Historique
564 564 label_attachment: Fichier
565 565 label_attachment_new: Nouveau fichier
566 566 label_attachment_delete: Supprimer le fichier
567 567 label_attachment_plural: Fichiers
568 568 label_file_added: Fichier ajoutΓ©
569 569 label_report: Rapport
570 570 label_report_plural: Rapports
571 571 label_news: Annonce
572 572 label_news_new: Nouvelle annonce
573 573 label_news_plural: Annonces
574 574 label_news_latest: Dernières annonces
575 575 label_news_view_all: Voir toutes les annonces
576 576 label_news_added: Annonce ajoutΓ©e
577 577 label_news_comment_added: Commentaire ajoutΓ© Γ  une annonce
578 578 label_settings: Configuration
579 579 label_overview: AperΓ§u
580 580 label_version: Version
581 581 label_version_new: Nouvelle version
582 582 label_version_plural: Versions
583 583 label_confirmation: Confirmation
584 584 label_export_to: 'Formats disponibles :'
585 585 label_read: Lire...
586 586 label_public_projects: Projets publics
587 587 label_open_issues: ouvert
588 588 label_open_issues_plural: ouverts
589 589 label_closed_issues: fermΓ©
590 590 label_closed_issues_plural: fermΓ©s
591 591 label_x_open_issues_abbr_on_total:
592 592 zero: 0 ouverte sur %{total}
593 593 one: 1 ouverte sur %{total}
594 594 other: "%{count} ouvertes sur %{total}"
595 595 label_x_open_issues_abbr:
596 596 zero: 0 ouverte
597 597 one: 1 ouverte
598 598 other: "%{count} ouvertes"
599 599 label_x_closed_issues_abbr:
600 600 zero: 0 fermΓ©e
601 601 one: 1 fermΓ©e
602 602 other: "%{count} fermΓ©es"
603 603 label_x_issues:
604 604 zero: 0 demande
605 605 one: 1 demande
606 606 other: "%{count} demandes"
607 607 label_total: Total
608 608 label_permissions: Permissions
609 609 label_current_status: Statut actuel
610 610 label_new_statuses_allowed: Nouveaux statuts autorisΓ©s
611 611 label_all: tous
612 612 label_none: aucun
613 613 label_nobody: personne
614 614 label_next: Suivant
615 615 label_previous: PrΓ©cΓ©dent
616 616 label_used_by: UtilisΓ© par
617 617 label_details: DΓ©tails
618 618 label_add_note: Ajouter une note
619 619 label_per_page: Par page
620 620 label_calendar: Calendrier
621 621 label_months_from: mois depuis
622 622 label_gantt: Gantt
623 623 label_internal: Interne
624 624 label_last_changes: "%{count} derniers changements"
625 625 label_change_view_all: Voir tous les changements
626 626 label_personalize_page: Personnaliser cette page
627 627 label_comment: Commentaire
628 628 label_comment_plural: Commentaires
629 629 label_x_comments:
630 630 zero: aucun commentaire
631 631 one: un commentaire
632 632 other: "%{count} commentaires"
633 633 label_comment_add: Ajouter un commentaire
634 634 label_comment_added: Commentaire ajoutΓ©
635 635 label_comment_delete: Supprimer les commentaires
636 636 label_query: Rapport personnalisΓ©
637 637 label_query_plural: Rapports personnalisΓ©s
638 638 label_query_new: Nouveau rapport
639 639 label_my_queries: Mes rapports personnalisΓ©s
640 640 label_filter_add: "Ajouter le filtre "
641 641 label_filter_plural: Filtres
642 642 label_equals: Γ©gal
643 643 label_not_equals: diffΓ©rent
644 644 label_in_less_than: dans moins de
645 645 label_in_more_than: dans plus de
646 646 label_in: dans
647 647 label_today: aujourd'hui
648 648 label_all_time: toute la pΓ©riode
649 649 label_yesterday: hier
650 650 label_this_week: cette semaine
651 651 label_last_week: la semaine dernière
652 652 label_last_n_days: "les %{count} derniers jours"
653 653 label_this_month: ce mois-ci
654 654 label_last_month: le mois dernier
655 655 label_this_year: cette annΓ©e
656 656 label_date_range: PΓ©riode
657 657 label_less_than_ago: il y a moins de
658 658 label_more_than_ago: il y a plus de
659 659 label_ago: il y a
660 660 label_contains: contient
661 661 label_not_contains: ne contient pas
662 662 label_day_plural: jours
663 663 label_repository: DΓ©pΓ΄t
664 664 label_repository_new: Nouveau dΓ©pΓ΄t
665 665 label_repository_plural: DΓ©pΓ΄ts
666 666 label_browse: Parcourir
667 667 label_modification: "%{count} modification"
668 668 label_modification_plural: "%{count} modifications"
669 669 label_revision: "RΓ©vision "
670 670 label_revision_plural: RΓ©visions
671 671 label_associated_revisions: RΓ©visions associΓ©es
672 672 label_added: ajoutΓ©
673 673 label_modified: modifiΓ©
674 674 label_copied: copiΓ©
675 675 label_renamed: renommΓ©
676 676 label_deleted: supprimΓ©
677 677 label_latest_revision: Dernière révision
678 678 label_latest_revision_plural: Dernières révisions
679 679 label_view_revisions: Voir les rΓ©visions
680 680 label_max_size: Taille maximale
681 681 label_sort_highest: Remonter en premier
682 682 label_sort_higher: Remonter
683 683 label_sort_lower: Descendre
684 684 label_sort_lowest: Descendre en dernier
685 685 label_roadmap: Roadmap
686 686 label_roadmap_due_in: "Γ‰chΓ©ance dans %{value}"
687 687 label_roadmap_overdue: "En retard de %{value}"
688 688 label_roadmap_no_issues: Aucune demande pour cette version
689 689 label_search: "Recherche "
690 690 label_result_plural: RΓ©sultats
691 691 label_all_words: Tous les mots
692 692 label_wiki: Wiki
693 693 label_wiki_edit: RΓ©vision wiki
694 694 label_wiki_edit_plural: RΓ©visions wiki
695 695 label_wiki_page: Page wiki
696 696 label_wiki_page_plural: Pages wiki
697 697 label_index_by_title: Index par titre
698 698 label_index_by_date: Index par date
699 699 label_current_version: Version actuelle
700 700 label_preview: PrΓ©visualisation
701 701 label_feed_plural: Flux RSS
702 702 label_changes_details: DΓ©tails de tous les changements
703 703 label_issue_tracking: Suivi des demandes
704 704 label_spent_time: Temps passΓ©
705 705 label_f_hour: "%{value} heure"
706 706 label_f_hour_plural: "%{value} heures"
707 707 label_time_tracking: Suivi du temps
708 708 label_change_plural: Changements
709 709 label_statistics: Statistiques
710 710 label_commits_per_month: Commits par mois
711 711 label_commits_per_author: Commits par auteur
712 712 label_view_diff: Voir les diffΓ©rences
713 713 label_diff_inline: en ligne
714 714 label_diff_side_by_side: cΓ΄te Γ  cΓ΄te
715 715 label_options: Options
716 716 label_copy_workflow_from: Copier le workflow de
717 717 label_permissions_report: Synthèse des permissions
718 718 label_watched_issues: Demandes surveillΓ©es
719 719 label_related_issues: Demandes liΓ©es
720 720 label_applied_status: Statut appliquΓ©
721 721 label_loading: Chargement...
722 722 label_relation_new: Nouvelle relation
723 723 label_relation_delete: Supprimer la relation
724 724 label_relates_to: liΓ© Γ 
725 725 label_duplicates: duplique
726 726 label_duplicated_by: dupliquΓ© par
727 727 label_blocks: bloque
728 728 label_blocked_by: bloquΓ© par
729 729 label_precedes: précède
730 730 label_follows: suit
731 label_copied_to: copiΓ© vers
732 label_copied_from: copiΓ© depuis
731 733 label_end_to_start: fin Γ  dΓ©but
732 734 label_end_to_end: fin Γ  fin
733 735 label_start_to_start: dΓ©but Γ  dΓ©but
734 736 label_start_to_end: dΓ©but Γ  fin
735 737 label_stay_logged_in: Rester connectΓ©
736 738 label_disabled: dΓ©sactivΓ©
737 739 label_show_completed_versions: Voir les versions passΓ©es
738 740 label_me: moi
739 741 label_board: Forum
740 742 label_board_new: Nouveau forum
741 743 label_board_plural: Forums
742 744 label_topic_plural: Discussions
743 745 label_message_plural: Messages
744 746 label_message_last: Dernier message
745 747 label_message_new: Nouveau message
746 748 label_message_posted: Message ajoutΓ©
747 749 label_reply_plural: RΓ©ponses
748 750 label_send_information: Envoyer les informations Γ  l'utilisateur
749 751 label_year: AnnΓ©e
750 752 label_month: Mois
751 753 label_week: Semaine
752 754 label_date_from: Du
753 755 label_date_to: Au
754 756 label_language_based: BasΓ© sur la langue de l'utilisateur
755 757 label_sort_by: "Trier par %{value}"
756 758 label_send_test_email: Envoyer un email de test
757 759 label_feeds_access_key_created_on: "Clé d'accès RSS créée il y a %{value}"
758 760 label_module_plural: Modules
759 761 label_added_time_by: "AjoutΓ© par %{author} il y a %{age}"
760 762 label_updated_time_by: "Mis Γ  jour par %{author} il y a %{age}"
761 763 label_updated_time: "Mis Γ  jour il y a %{value}"
762 764 label_jump_to_a_project: Aller Γ  un projet...
763 765 label_file_plural: Fichiers
764 766 label_changeset_plural: RΓ©visions
765 767 label_default_columns: Colonnes par dΓ©faut
766 768 label_no_change_option: (Pas de changement)
767 769 label_bulk_edit_selected_issues: Modifier les demandes sΓ©lectionnΓ©es
768 770 label_theme: Thème
769 771 label_default: DΓ©faut
770 772 label_search_titles_only: Uniquement dans les titres
771 773 label_user_mail_option_all: "Pour tous les Γ©vΓ©nements de tous mes projets"
772 774 label_user_mail_option_selected: "Pour tous les Γ©vΓ©nements des projets sΓ©lectionnΓ©s..."
773 775 label_user_mail_no_self_notified: "Je ne veux pas Γͺtre notifiΓ© des changements que j'effectue"
774 776 label_registration_activation_by_email: activation du compte par email
775 777 label_registration_manual_activation: activation manuelle du compte
776 778 label_registration_automatic_activation: activation automatique du compte
777 779 label_display_per_page: "Par page : %{value}"
778 780 label_age: Γ‚ge
779 781 label_change_properties: Changer les propriΓ©tΓ©s
780 782 label_general: GΓ©nΓ©ral
781 783 label_more: Plus
782 784 label_scm: SCM
783 785 label_plugins: Plugins
784 786 label_ldap_authentication: Authentification LDAP
785 787 label_downloads_abbr: D/L
786 788 label_optional_description: Description facultative
787 789 label_add_another_file: Ajouter un autre fichier
788 790 label_preferences: PrΓ©fΓ©rences
789 791 label_chronological_order: Dans l'ordre chronologique
790 792 label_reverse_chronological_order: Dans l'ordre chronologique inverse
791 793 label_planning: Planning
792 794 label_incoming_emails: Emails entrants
793 795 label_generate_key: GΓ©nΓ©rer une clΓ©
794 796 label_issue_watchers: Observateurs
795 797 label_example: Exemple
796 798 label_display: Affichage
797 799 label_sort: Tri
798 800 label_ascending: Croissant
799 801 label_descending: DΓ©croissant
800 802 label_date_from_to: Du %{start} au %{end}
801 803 label_wiki_content_added: Page wiki ajoutΓ©e
802 804 label_wiki_content_updated: Page wiki mise Γ  jour
803 805 label_group_plural: Groupes
804 806 label_group: Groupe
805 807 label_group_new: Nouveau groupe
806 808 label_time_entry_plural: Temps passΓ©
807 809 label_version_sharing_none: Non partagΓ©
808 810 label_version_sharing_descendants: Avec les sous-projets
809 811 label_version_sharing_hierarchy: Avec toute la hiΓ©rarchie
810 812 label_version_sharing_tree: Avec tout l'arbre
811 813 label_version_sharing_system: Avec tous les projets
812 814 label_copy_source: Source
813 815 label_copy_target: Cible
814 816 label_copy_same_as_target: Comme la cible
815 817 label_update_issue_done_ratios: Mettre Γ  jour l'avancement des demandes
816 818 label_display_used_statuses_only: N'afficher que les statuts utilisΓ©s dans ce tracker
817 819 label_api_access_key: Clé d'accès API
818 820 label_api_access_key_created_on: Clé d'accès API créée il y a %{value}
819 821 label_feeds_access_key: Clé d'accès RSS
820 822 label_missing_api_access_key: Clé d'accès API manquante
821 823 label_missing_feeds_access_key: Clé d'accès RSS manquante
822 824 label_close_versions: Fermer les versions terminΓ©es
823 825 label_revision_id: RΓ©vision %{value}
824 826 label_profile: Profil
825 827 label_subtask_plural: Sous-tΓ’ches
826 828 label_project_copy_notifications: Envoyer les notifications durant la copie du projet
827 829 label_principal_search: "Rechercher un utilisateur ou un groupe :"
828 830 label_user_search: "Rechercher un utilisateur :"
829 831 label_additional_workflow_transitions_for_author: Autorisations supplémentaires lorsque l'utilisateur a créé la demande
830 832 label_additional_workflow_transitions_for_assignee: Autorisations supplΓ©mentaires lorsque la demande est assignΓ©e Γ  l'utilisateur
831 833 label_issues_visibility_all: Toutes les demandes
832 834 label_issues_visibility_public: Toutes les demandes non privΓ©es
833 835 label_issues_visibility_own: Demandes créées par ou assignées à l'utilisateur
834 836 label_export_options: Options d'exportation %{export_format}
835 837 label_copy_attachments: Copier les fichiers
836 838 label_copy_subtasks: Copier les sous-tΓ’ches
837 839 label_item_position: "%{position} sur %{count}"
838 840 label_completed_versions: Versions passΓ©es
839 841 label_session_expiration: Expiration des sessions
840 842 label_show_closed_projects: Voir les projets fermΓ©s
841 843 label_status_transitions: Changements de statut
842 844 label_fields_permissions: Permissions sur les champs
843 845 label_readonly: Lecture
844 846 label_required: Obligatoire
845 847 label_attribute_of_project: "%{name} du projet"
846 848 label_attribute_of_author: "%{name} de l'auteur"
847 849 label_attribute_of_assigned_to: "%{name} de l'assignΓ©"
848 850 label_attribute_of_fixed_version: "%{name} de la version cible"
849 851
850 852 button_login: Connexion
851 853 button_submit: Soumettre
852 854 button_save: Sauvegarder
853 855 button_check_all: Tout cocher
854 856 button_uncheck_all: Tout dΓ©cocher
855 857 button_collapse_all: Plier tout
856 858 button_expand_all: DΓ©plier tout
857 859 button_delete: Supprimer
858 860 button_create: CrΓ©er
859 861 button_create_and_continue: CrΓ©er et continuer
860 862 button_test: Tester
861 863 button_edit: Modifier
862 864 button_add: Ajouter
863 865 button_change: Changer
864 866 button_apply: Appliquer
865 867 button_clear: Effacer
866 868 button_lock: Verrouiller
867 869 button_unlock: DΓ©verrouiller
868 870 button_download: TΓ©lΓ©charger
869 871 button_list: Lister
870 872 button_view: Voir
871 873 button_move: DΓ©placer
872 874 button_move_and_follow: DΓ©placer et suivre
873 875 button_back: Retour
874 876 button_cancel: Annuler
875 877 button_activate: Activer
876 878 button_sort: Trier
877 879 button_log_time: Saisir temps
878 880 button_rollback: Revenir Γ  cette version
879 881 button_watch: Surveiller
880 882 button_unwatch: Ne plus surveiller
881 883 button_reply: RΓ©pondre
882 884 button_archive: Archiver
883 885 button_unarchive: DΓ©sarchiver
884 886 button_reset: RΓ©initialiser
885 887 button_rename: Renommer
886 888 button_change_password: Changer de mot de passe
887 889 button_copy: Copier
888 890 button_copy_and_follow: Copier et suivre
889 891 button_annotate: Annoter
890 892 button_update: Mettre Γ  jour
891 893 button_configure: Configurer
892 894 button_quote: Citer
893 895 button_duplicate: Dupliquer
894 896 button_show: Afficher
895 897 button_edit_section: Modifier cette section
896 898 button_export: Exporter
897 899 button_delete_my_account: Supprimer mon compte
898 900 button_close: Fermer
899 901 button_reopen: RΓ©ouvrir
900 902
901 903 status_active: actif
902 904 status_registered: enregistrΓ©
903 905 status_locked: verrouillΓ©
904 906
905 907 project_status_active: actif
906 908 project_status_closed: fermΓ©
907 909 project_status_archived: archivΓ©
908 910
909 911 version_status_open: ouvert
910 912 version_status_locked: verrouillΓ©
911 913 version_status_closed: fermΓ©
912 914
913 915 text_select_mail_notifications: Actions pour lesquelles une notification par e-mail est envoyΓ©e
914 916 text_regexp_info: ex. ^[A-Z0-9]+$
915 917 text_min_max_length_info: 0 pour aucune restriction
916 918 text_project_destroy_confirmation: Êtes-vous sûr de vouloir supprimer ce projet et toutes ses données ?
917 919 text_subprojects_destroy_warning: "Ses sous-projets : %{value} seront Γ©galement supprimΓ©s."
918 920 text_workflow_edit: SΓ©lectionner un tracker et un rΓ΄le pour Γ©diter le workflow
919 921 text_are_you_sure: Êtes-vous sûr ?
920 922 text_tip_issue_begin_day: tΓ’che commenΓ§ant ce jour
921 923 text_tip_issue_end_day: tΓ’che finissant ce jour
922 924 text_tip_issue_begin_end_day: tΓ’che commenΓ§ant et finissant ce jour
923 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 926 text_caracters_maximum: "%{count} caractères maximum."
925 927 text_caracters_minimum: "%{count} caractères minimum."
926 928 text_length_between: "Longueur comprise entre %{min} et %{max} caractères."
927 929 text_tracker_no_workflow: Aucun worflow n'est dΓ©fini pour ce tracker
928 930 text_unallowed_characters: Caractères non autorisés
929 931 text_comma_separated: Plusieurs valeurs possibles (sΓ©parΓ©es par des virgules).
930 932 text_line_separated: Plusieurs valeurs possibles (une valeur par ligne).
931 933 text_issues_ref_in_commit_messages: RΓ©fΓ©rencement et rΓ©solution des demandes dans les commentaires de commits
932 934 text_issue_added: "La demande %{id} a Γ©tΓ© soumise par %{author}."
933 935 text_issue_updated: "La demande %{id} a Γ©tΓ© mise Γ  jour par %{author}."
934 936 text_wiki_destroy_confirmation: Etes-vous sΓ»r de vouloir supprimer ce wiki et tout son contenu ?
935 937 text_issue_category_destroy_question: "%{count} demandes sont affectΓ©es Γ  cette catΓ©gorie. Que voulez-vous faire ?"
936 938 text_issue_category_destroy_assignments: N'affecter les demandes Γ  aucune autre catΓ©gorie
937 939 text_issue_category_reassign_to: RΓ©affecter les demandes Γ  cette catΓ©gorie
938 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 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 942 text_load_default_configuration: Charger le paramΓ©trage par dΓ©faut
941 943 text_status_changed_by_changeset: "AppliquΓ© par commit %{value}."
942 944 text_time_logged_by_changeset: "AppliquΓ© par commit %{value}"
943 945 text_issues_destroy_confirmation: 'Êtes-vous sûr de vouloir supprimer la ou les demandes(s) selectionnée(s) ?'
944 946 text_issues_destroy_descendants_confirmation: "Cela entrainera Γ©galement la suppression de %{count} sous-tΓ’che(s)."
945 947 text_select_project_modules: 'SΓ©lectionner les modules Γ  activer pour ce projet :'
946 948 text_default_administrator_account_changed: Compte administrateur par dΓ©faut changΓ©
947 949 text_file_repository_writable: RΓ©pertoire de stockage des fichiers accessible en Γ©criture
948 950 text_plugin_assets_writable: RΓ©pertoire public des plugins accessible en Γ©criture
949 951 text_rmagick_available: Bibliothèque RMagick présente (optionnelle)
950 952 text_destroy_time_entries_question: "%{hours} heures ont Γ©tΓ© enregistrΓ©es sur les demandes Γ  supprimer. Que voulez-vous faire ?"
951 953 text_destroy_time_entries: Supprimer les heures
952 954 text_assign_time_entries_to_project: Reporter les heures sur le projet
953 955 text_reassign_time_entries: 'Reporter les heures sur cette demande:'
954 956 text_user_wrote: "%{value} a Γ©crit :"
955 957 text_enumeration_destroy_question: "Cette valeur est affectΓ©e Γ  %{count} objets."
956 958 text_enumeration_category_reassign_to: 'RΓ©affecter les objets Γ  cette valeur:'
957 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 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 961 text_diff_truncated: '... Ce diffΓ©rentiel a Γ©tΓ© tronquΓ© car il excΓ¨de la taille maximale pouvant Γͺtre affichΓ©e.'
960 962 text_custom_field_possible_values_info: 'Une ligne par valeur'
961 963 text_wiki_page_destroy_question: "Cette page possède %{descendants} sous-page(s) et descendante(s). Que voulez-vous faire ?"
962 964 text_wiki_page_nullify_children: "Conserver les sous-pages en tant que pages racines"
963 965 text_wiki_page_destroy_children: "Supprimer les sous-pages et toutes leurs descedantes"
964 966 text_wiki_page_reassign_children: "RΓ©affecter les sous-pages Γ  cette page"
965 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 968 text_warn_on_leaving_unsaved: "Cette page contient du texte non sauvegardΓ© qui sera perdu si vous quittez la page."
967 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 970 text_issue_conflict_resolution_add_notes: "Ajouter mes notes et ignorer mes autres changements"
969 971 text_issue_conflict_resolution_cancel: "Annuler ma mise Γ  jour et rΓ©afficher %{link}"
970 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 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 974 text_project_closed: Ce projet est fermΓ© et accessible en lecture seule.
973 975
974 976 default_role_manager: "Manager "
975 977 default_role_developer: "DΓ©veloppeur "
976 978 default_role_reporter: "Rapporteur "
977 979 default_tracker_bug: Anomalie
978 980 default_tracker_feature: Evolution
979 981 default_tracker_support: Assistance
980 982 default_issue_status_new: Nouveau
981 983 default_issue_status_in_progress: En cours
982 984 default_issue_status_resolved: RΓ©solu
983 985 default_issue_status_feedback: Commentaire
984 986 default_issue_status_closed: FermΓ©
985 987 default_issue_status_rejected: RejetΓ©
986 988 default_doc_category_user: Documentation utilisateur
987 989 default_doc_category_tech: Documentation technique
988 990 default_priority_low: Bas
989 991 default_priority_normal: Normal
990 992 default_priority_high: Haut
991 993 default_priority_urgent: Urgent
992 994 default_priority_immediate: ImmΓ©diat
993 995 default_activity_design: Conception
994 996 default_activity_development: DΓ©veloppement
995 997
996 998 enumeration_issue_priorities: PrioritΓ©s des demandes
997 999 enumeration_doc_categories: CatΓ©gories des documents
998 1000 enumeration_activities: ActivitΓ©s (suivi du temps)
999 1001 label_greater_or_equal: ">="
1000 1002 label_less_or_equal: "<="
1001 1003 label_between: entre
1002 1004 label_view_all_revisions: Voir toutes les rΓ©visions
1003 1005 label_tag: Tag
1004 1006 label_branch: Branche
1005 1007 error_no_tracker_in_project: "Aucun tracker n'est associΓ© Γ  ce projet. VΓ©rifier la configuration du projet."
1006 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 1009 text_journal_changed: "%{label} changΓ© de %{old} Γ  %{new}"
1008 1010 text_journal_changed_no_detail: "%{label} mis Γ  jour"
1009 1011 text_journal_set_to: "%{label} mis Γ  %{value}"
1010 1012 text_journal_deleted: "%{label} %{old} supprimΓ©"
1011 1013 text_journal_added: "%{label} %{value} ajoutΓ©"
1012 1014 enumeration_system_activity: Activité système
1013 1015 label_board_sticky: Sticky
1014 1016 label_board_locked: VerrouillΓ©
1015 1017 error_unable_delete_issue_status: Impossible de supprimer le statut de demande
1016 1018 error_can_not_delete_custom_field: Impossible de supprimer le champ personnalisΓ©
1017 1019 error_unable_to_connect: Connexion impossible (%{value})
1018 1020 error_can_not_remove_role: Ce rΓ΄le est utilisΓ© et ne peut pas Γͺtre supprimΓ©.
1019 1021 error_can_not_delete_tracker: Ce tracker contient des demandes et ne peut pas Γͺtre supprimΓ©.
1020 1022 field_principal: Principal
1021 1023 notice_failed_to_save_members: "Erreur lors de la sauvegarde des membres: %{errors}."
1022 1024 text_zoom_out: Zoom arrière
1023 1025 text_zoom_in: Zoom avant
1024 1026 notice_unable_delete_time_entry: Impossible de supprimer le temps passΓ©.
1025 1027 label_overall_spent_time: Temps passΓ© global
1026 1028 field_time_entries: Temps passΓ©
1027 1029 project_module_gantt: Gantt
1028 1030 project_module_calendar: Calendrier
1029 1031 button_edit_associated_wikipage: "Modifier la page wiki associΓ©e: %{page_title}"
1030 1032 text_are_you_sure_with_children: Supprimer la demande et toutes ses sous-demandes ?
1031 1033 field_text: Champ texte
1032 1034 label_user_mail_option_only_owner: Seulement pour ce que j'ai créé
1033 1035 setting_default_notification_option: Option de notification par dΓ©faut
1034 1036 label_user_mail_option_only_my_events: Seulement pour ce que je surveille
1035 1037 label_user_mail_option_only_assigned: Seulement pour ce qui m'est assignΓ©
1036 1038 label_user_mail_option_none: Aucune notification
1037 1039 field_member_of_group: Groupe de l'assignΓ©
1038 1040 field_assigned_to_role: RΓ΄le de l'assignΓ©
1039 1041 setting_emails_header: En-tΓͺte des emails
1040 1042 label_bulk_edit_selected_time_entries: Modifier les temps passΓ©s sΓ©lectionnΓ©s
1041 1043 text_time_entries_destroy_confirmation: "Etes-vous sΓ»r de vouloir supprimer les temps passΓ©s sΓ©lectionnΓ©s ?"
1042 1044 field_scm_path_encoding: Encodage des chemins
1043 1045 text_scm_path_encoding_note: "DΓ©faut : UTF-8"
1044 1046 field_path_to_repository: Chemin du dΓ©pΓ΄t
1045 1047 field_root_directory: RΓ©pertoire racine
1046 1048 field_cvs_module: Module
1047 1049 field_cvsroot: CVSROOT
1048 1050 text_mercurial_repository_note: "DΓ©pΓ΄t local (exemples : /hgrepo, c:\\hgrepo)"
1049 1051 text_scm_command: Commande
1050 1052 text_scm_command_version: Version
1051 1053 label_git_report_last_commit: Afficher le dernier commit des fichiers et rΓ©pertoires
1052 1054 text_scm_config: Vous pouvez configurer les commandes des SCM dans config/configuration.yml. Redémarrer l'application après modification.
1053 1055 text_scm_command_not_available: Ce SCM n'est pas disponible. Vérifier les paramètres dans la section administration.
1054 1056 label_diff: diff
1055 1057 text_git_repository_note: Repository is bare and local (e.g. /gitrepo, c:\gitrepo)
1056 1058 description_query_sort_criteria_direction: Ordre de tri
1057 1059 description_project_scope: Périmètre de recherche
1058 1060 description_filter: Filtre
1059 1061 description_user_mail_notification: Option de notification
1060 1062 description_date_from: Date de dΓ©but
1061 1063 description_message_content: Contenu du message
1062 1064 description_available_columns: Colonnes disponibles
1063 1065 description_all_columns: Toutes les colonnes
1064 1066 description_date_range_interval: Choisir une pΓ©riode
1065 1067 description_issue_category_reassign: Choisir une catΓ©gorie
1066 1068 description_search: Champ de recherche
1067 1069 description_notes: Notes
1068 1070 description_date_range_list: Choisir une pΓ©riode prΓ©dΓ©finie
1069 1071 description_choose_project: Projets
1070 1072 description_date_to: Date de fin
1071 1073 description_query_sort_criteria_attribute: Critère de tri
1072 1074 description_wiki_subpages_reassign: Choisir une nouvelle page parent
1073 1075 description_selected_columns: Colonnes sΓ©lectionnΓ©es
1074 1076 label_parent_revision: Parent
1075 1077 label_child_revision: Enfant
1076 1078 error_scm_annotate_big_text_file: Cette entrΓ©e ne peut pas Γͺtre annotΓ©e car elle excΓ¨de la taille maximale.
1077 1079 setting_repositories_encodings: Encodages des fichiers et des dΓ©pΓ΄ts
1078 1080 label_search_for_watchers: Rechercher des observateurs
1079 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 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2012 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../test_helper', __FILE__)
19 19 require 'issues_controller'
20 20
21 21 class IssuesControllerTest < ActionController::TestCase
22 22 fixtures :projects,
23 23 :users,
24 24 :roles,
25 25 :members,
26 26 :member_roles,
27 27 :issues,
28 28 :issue_statuses,
29 29 :versions,
30 30 :trackers,
31 31 :projects_trackers,
32 32 :issue_categories,
33 33 :enabled_modules,
34 34 :enumerations,
35 35 :attachments,
36 36 :workflows,
37 37 :custom_fields,
38 38 :custom_values,
39 39 :custom_fields_projects,
40 40 :custom_fields_trackers,
41 41 :time_entries,
42 42 :journals,
43 43 :journal_details,
44 44 :queries,
45 45 :repositories,
46 46 :changesets
47 47
48 48 include Redmine::I18n
49 49
50 50 def setup
51 51 @controller = IssuesController.new
52 52 @request = ActionController::TestRequest.new
53 53 @response = ActionController::TestResponse.new
54 54 User.current = nil
55 55 end
56 56
57 57 def test_index
58 58 with_settings :default_language => "en" do
59 59 get :index
60 60 assert_response :success
61 61 assert_template 'index'
62 62 assert_not_nil assigns(:issues)
63 63 assert_nil assigns(:project)
64 64 assert_tag :tag => 'a', :content => /Can&#x27;t print recipes/
65 65 assert_tag :tag => 'a', :content => /Subproject issue/
66 66 # private projects hidden
67 67 assert_no_tag :tag => 'a', :content => /Issue of a private subproject/
68 68 assert_no_tag :tag => 'a', :content => /Issue on project 2/
69 69 # project column
70 70 assert_tag :tag => 'th', :content => /Project/
71 71 end
72 72 end
73 73
74 74 def test_index_should_not_list_issues_when_module_disabled
75 75 EnabledModule.delete_all("name = 'issue_tracking' AND project_id = 1")
76 76 get :index
77 77 assert_response :success
78 78 assert_template 'index'
79 79 assert_not_nil assigns(:issues)
80 80 assert_nil assigns(:project)
81 81 assert_no_tag :tag => 'a', :content => /Can&#x27;t print recipes/
82 82 assert_tag :tag => 'a', :content => /Subproject issue/
83 83 end
84 84
85 85 def test_index_should_list_visible_issues_only
86 86 get :index, :per_page => 100
87 87 assert_response :success
88 88 assert_not_nil assigns(:issues)
89 89 assert_nil assigns(:issues).detect {|issue| !issue.visible?}
90 90 end
91 91
92 92 def test_index_with_project
93 93 Setting.display_subprojects_issues = 0
94 94 get :index, :project_id => 1
95 95 assert_response :success
96 96 assert_template 'index'
97 97 assert_not_nil assigns(:issues)
98 98 assert_tag :tag => 'a', :content => /Can&#x27;t print recipes/
99 99 assert_no_tag :tag => 'a', :content => /Subproject issue/
100 100 end
101 101
102 102 def test_index_with_project_and_subprojects
103 103 Setting.display_subprojects_issues = 1
104 104 get :index, :project_id => 1
105 105 assert_response :success
106 106 assert_template 'index'
107 107 assert_not_nil assigns(:issues)
108 108 assert_tag :tag => 'a', :content => /Can&#x27;t print recipes/
109 109 assert_tag :tag => 'a', :content => /Subproject issue/
110 110 assert_no_tag :tag => 'a', :content => /Issue of a private subproject/
111 111 end
112 112
113 113 def test_index_with_project_and_subprojects_should_show_private_subprojects
114 114 @request.session[:user_id] = 2
115 115 Setting.display_subprojects_issues = 1
116 116 get :index, :project_id => 1
117 117 assert_response :success
118 118 assert_template 'index'
119 119 assert_not_nil assigns(:issues)
120 120 assert_tag :tag => 'a', :content => /Can&#x27;t print recipes/
121 121 assert_tag :tag => 'a', :content => /Subproject issue/
122 122 assert_tag :tag => 'a', :content => /Issue of a private subproject/
123 123 end
124 124
125 125 def test_index_with_project_and_default_filter
126 126 get :index, :project_id => 1, :set_filter => 1
127 127 assert_response :success
128 128 assert_template 'index'
129 129 assert_not_nil assigns(:issues)
130 130
131 131 query = assigns(:query)
132 132 assert_not_nil query
133 133 # default filter
134 134 assert_equal({'status_id' => {:operator => 'o', :values => ['']}}, query.filters)
135 135 end
136 136
137 137 def test_index_with_project_and_filter
138 138 get :index, :project_id => 1, :set_filter => 1,
139 139 :f => ['tracker_id'],
140 140 :op => {'tracker_id' => '='},
141 141 :v => {'tracker_id' => ['1']}
142 142 assert_response :success
143 143 assert_template 'index'
144 144 assert_not_nil assigns(:issues)
145 145
146 146 query = assigns(:query)
147 147 assert_not_nil query
148 148 assert_equal({'tracker_id' => {:operator => '=', :values => ['1']}}, query.filters)
149 149 end
150 150
151 151 def test_index_with_short_filters
152 152 to_test = {
153 153 'status_id' => {
154 154 'o' => { :op => 'o', :values => [''] },
155 155 'c' => { :op => 'c', :values => [''] },
156 156 '7' => { :op => '=', :values => ['7'] },
157 157 '7|3|4' => { :op => '=', :values => ['7', '3', '4'] },
158 158 '=7' => { :op => '=', :values => ['7'] },
159 159 '!3' => { :op => '!', :values => ['3'] },
160 160 '!7|3|4' => { :op => '!', :values => ['7', '3', '4'] }},
161 161 'subject' => {
162 162 'This is a subject' => { :op => '=', :values => ['This is a subject'] },
163 163 'o' => { :op => '=', :values => ['o'] },
164 164 '~This is part of a subject' => { :op => '~', :values => ['This is part of a subject'] },
165 165 '!~This is part of a subject' => { :op => '!~', :values => ['This is part of a subject'] }},
166 166 'tracker_id' => {
167 167 '3' => { :op => '=', :values => ['3'] },
168 168 '=3' => { :op => '=', :values => ['3'] }},
169 169 'start_date' => {
170 170 '2011-10-12' => { :op => '=', :values => ['2011-10-12'] },
171 171 '=2011-10-12' => { :op => '=', :values => ['2011-10-12'] },
172 172 '>=2011-10-12' => { :op => '>=', :values => ['2011-10-12'] },
173 173 '<=2011-10-12' => { :op => '<=', :values => ['2011-10-12'] },
174 174 '><2011-10-01|2011-10-30' => { :op => '><', :values => ['2011-10-01', '2011-10-30'] },
175 175 '<t+2' => { :op => '<t+', :values => ['2'] },
176 176 '>t+2' => { :op => '>t+', :values => ['2'] },
177 177 't+2' => { :op => 't+', :values => ['2'] },
178 178 't' => { :op => 't', :values => [''] },
179 179 'w' => { :op => 'w', :values => [''] },
180 180 '>t-2' => { :op => '>t-', :values => ['2'] },
181 181 '<t-2' => { :op => '<t-', :values => ['2'] },
182 182 't-2' => { :op => 't-', :values => ['2'] }},
183 183 'created_on' => {
184 184 '>=2011-10-12' => { :op => '>=', :values => ['2011-10-12'] },
185 185 '<t-2' => { :op => '<t-', :values => ['2'] },
186 186 '>t-2' => { :op => '>t-', :values => ['2'] },
187 187 't-2' => { :op => 't-', :values => ['2'] }},
188 188 'cf_1' => {
189 189 'c' => { :op => '=', :values => ['c'] },
190 190 '!c' => { :op => '!', :values => ['c'] },
191 191 '!*' => { :op => '!*', :values => [''] },
192 192 '*' => { :op => '*', :values => [''] }},
193 193 'estimated_hours' => {
194 194 '=13.4' => { :op => '=', :values => ['13.4'] },
195 195 '>=45' => { :op => '>=', :values => ['45'] },
196 196 '<=125' => { :op => '<=', :values => ['125'] },
197 197 '><10.5|20.5' => { :op => '><', :values => ['10.5', '20.5'] },
198 198 '!*' => { :op => '!*', :values => [''] },
199 199 '*' => { :op => '*', :values => [''] }}
200 200 }
201 201
202 202 default_filter = { 'status_id' => {:operator => 'o', :values => [''] }}
203 203
204 204 to_test.each do |field, expression_and_expected|
205 205 expression_and_expected.each do |filter_expression, expected|
206 206
207 207 get :index, :set_filter => 1, field => filter_expression
208 208
209 209 assert_response :success
210 210 assert_template 'index'
211 211 assert_not_nil assigns(:issues)
212 212
213 213 query = assigns(:query)
214 214 assert_not_nil query
215 215 assert query.has_filter?(field)
216 216 assert_equal(default_filter.merge({field => {:operator => expected[:op], :values => expected[:values]}}), query.filters)
217 217 end
218 218 end
219 219 end
220 220
221 221 def test_index_with_project_and_empty_filters
222 222 get :index, :project_id => 1, :set_filter => 1, :fields => ['']
223 223 assert_response :success
224 224 assert_template 'index'
225 225 assert_not_nil assigns(:issues)
226 226
227 227 query = assigns(:query)
228 228 assert_not_nil query
229 229 # no filter
230 230 assert_equal({}, query.filters)
231 231 end
232 232
233 233 def test_index_with_project_custom_field_filter
234 234 field = ProjectCustomField.create!(:name => 'Client', :is_filter => true, :field_format => 'string')
235 235 CustomValue.create!(:custom_field => field, :customized => Project.find(3), :value => 'Foo')
236 236 CustomValue.create!(:custom_field => field, :customized => Project.find(5), :value => 'Foo')
237 237 filter_name = "project.cf_#{field.id}"
238 238 @request.session[:user_id] = 1
239 239
240 240 get :index, :set_filter => 1,
241 241 :f => [filter_name],
242 242 :op => {filter_name => '='},
243 243 :v => {filter_name => ['Foo']}
244 244 assert_response :success
245 245 assert_template 'index'
246 246 assert_equal [3, 5], assigns(:issues).map(&:project_id).uniq.sort
247 247 end
248 248
249 249 def test_index_with_query
250 250 get :index, :project_id => 1, :query_id => 5
251 251 assert_response :success
252 252 assert_template 'index'
253 253 assert_not_nil assigns(:issues)
254 254 assert_nil assigns(:issue_count_by_group)
255 255 end
256 256
257 257 def test_index_with_query_grouped_by_tracker
258 258 get :index, :project_id => 1, :query_id => 6
259 259 assert_response :success
260 260 assert_template 'index'
261 261 assert_not_nil assigns(:issues)
262 262 assert_not_nil assigns(:issue_count_by_group)
263 263 end
264 264
265 265 def test_index_with_query_grouped_by_list_custom_field
266 266 get :index, :project_id => 1, :query_id => 9
267 267 assert_response :success
268 268 assert_template 'index'
269 269 assert_not_nil assigns(:issues)
270 270 assert_not_nil assigns(:issue_count_by_group)
271 271 end
272 272
273 273 def test_index_with_query_grouped_by_user_custom_field
274 274 cf = IssueCustomField.create!(:name => 'User', :is_for_all => true, :tracker_ids => [1,2,3], :field_format => 'user')
275 275 CustomValue.create!(:custom_field => cf, :customized => Issue.find(1), :value => '2')
276 276 CustomValue.create!(:custom_field => cf, :customized => Issue.find(2), :value => '3')
277 277 CustomValue.create!(:custom_field => cf, :customized => Issue.find(3), :value => '3')
278 278 CustomValue.create!(:custom_field => cf, :customized => Issue.find(5), :value => '')
279 279
280 280 get :index, :project_id => 1, :set_filter => 1, :group_by => "cf_#{cf.id}"
281 281 assert_response :success
282 282
283 283 assert_select 'tr.group', 3
284 284 assert_select 'tr.group' do
285 285 assert_select 'a', :text => 'John Smith'
286 286 assert_select 'span.count', :text => '(1)'
287 287 end
288 288 assert_select 'tr.group' do
289 289 assert_select 'a', :text => 'Dave Lopper'
290 290 assert_select 'span.count', :text => '(2)'
291 291 end
292 292 end
293 293
294 294 def test_index_with_query_id_and_project_id_should_set_session_query
295 295 get :index, :project_id => 1, :query_id => 4
296 296 assert_response :success
297 297 assert_kind_of Hash, session[:query]
298 298 assert_equal 4, session[:query][:id]
299 299 assert_equal 1, session[:query][:project_id]
300 300 end
301 301
302 302 def test_index_with_invalid_query_id_should_respond_404
303 303 get :index, :project_id => 1, :query_id => 999
304 304 assert_response 404
305 305 end
306 306
307 307 def test_index_with_cross_project_query_in_session_should_show_project_issues
308 308 q = Query.create!(:name => "test", :user_id => 2, :is_public => false, :project => nil)
309 309 @request.session[:query] = {:id => q.id, :project_id => 1}
310 310
311 311 with_settings :display_subprojects_issues => '0' do
312 312 get :index, :project_id => 1
313 313 end
314 314 assert_response :success
315 315 assert_not_nil assigns(:query)
316 316 assert_equal q.id, assigns(:query).id
317 317 assert_equal 1, assigns(:query).project_id
318 318 assert_equal [1], assigns(:issues).map(&:project_id).uniq
319 319 end
320 320
321 321 def test_private_query_should_not_be_available_to_other_users
322 322 q = Query.create!(:name => "private", :user => User.find(2), :is_public => false, :project => nil)
323 323 @request.session[:user_id] = 3
324 324
325 325 get :index, :query_id => q.id
326 326 assert_response 403
327 327 end
328 328
329 329 def test_private_query_should_be_available_to_its_user
330 330 q = Query.create!(:name => "private", :user => User.find(2), :is_public => false, :project => nil)
331 331 @request.session[:user_id] = 2
332 332
333 333 get :index, :query_id => q.id
334 334 assert_response :success
335 335 end
336 336
337 337 def test_public_query_should_be_available_to_other_users
338 338 q = Query.create!(:name => "private", :user => User.find(2), :is_public => true, :project => nil)
339 339 @request.session[:user_id] = 3
340 340
341 341 get :index, :query_id => q.id
342 342 assert_response :success
343 343 end
344 344
345 345 def test_index_should_omit_page_param_in_export_links
346 346 get :index, :page => 2
347 347 assert_response :success
348 348 assert_select 'a.atom[href=/issues.atom]'
349 349 assert_select 'a.csv[href=/issues.csv]'
350 350 assert_select 'a.pdf[href=/issues.pdf]'
351 351 assert_select 'form#csv-export-form[action=/issues.csv]'
352 352 end
353 353
354 354 def test_index_csv
355 355 get :index, :format => 'csv'
356 356 assert_response :success
357 357 assert_not_nil assigns(:issues)
358 358 assert_equal 'text/csv; header=present', @response.content_type
359 359 assert @response.body.starts_with?("#,")
360 360 lines = @response.body.chomp.split("\n")
361 361 assert_equal assigns(:query).columns.size + 1, lines[0].split(',').size
362 362 end
363 363
364 364 def test_index_csv_with_project
365 365 get :index, :project_id => 1, :format => 'csv'
366 366 assert_response :success
367 367 assert_not_nil assigns(:issues)
368 368 assert_equal 'text/csv; header=present', @response.content_type
369 369 end
370 370
371 371 def test_index_csv_with_description
372 372 get :index, :format => 'csv', :description => '1'
373 373 assert_response :success
374 374 assert_not_nil assigns(:issues)
375 375 assert_equal 'text/csv; header=present', @response.content_type
376 376 assert @response.body.starts_with?("#,")
377 377 lines = @response.body.chomp.split("\n")
378 378 assert_equal assigns(:query).columns.size + 2, lines[0].split(',').size
379 379 end
380 380
381 381 def test_index_csv_with_spent_time_column
382 382 issue = Issue.create!(:project_id => 1, :tracker_id => 1, :subject => 'test_index_csv_with_spent_time_column', :author_id => 2)
383 383 TimeEntry.create!(:project => issue.project, :issue => issue, :hours => 7.33, :user => User.find(2), :spent_on => Date.today)
384 384
385 385 get :index, :format => 'csv', :set_filter => '1', :c => %w(subject spent_hours)
386 386 assert_response :success
387 387 assert_equal 'text/csv; header=present', @response.content_type
388 388 lines = @response.body.chomp.split("\n")
389 389 assert_include "#{issue.id},#{issue.subject},7.33", lines
390 390 end
391 391
392 392 def test_index_csv_with_all_columns
393 393 get :index, :format => 'csv', :columns => 'all'
394 394 assert_response :success
395 395 assert_not_nil assigns(:issues)
396 396 assert_equal 'text/csv; header=present', @response.content_type
397 397 assert @response.body.starts_with?("#,")
398 398 lines = @response.body.chomp.split("\n")
399 399 assert_equal assigns(:query).available_columns.size + 1, lines[0].split(',').size
400 400 end
401 401
402 402 def test_index_csv_with_multi_column_field
403 403 CustomField.find(1).update_attribute :multiple, true
404 404 issue = Issue.find(1)
405 405 issue.custom_field_values = {1 => ['MySQL', 'Oracle']}
406 406 issue.save!
407 407
408 408 get :index, :format => 'csv', :columns => 'all'
409 409 assert_response :success
410 410 lines = @response.body.chomp.split("\n")
411 411 assert lines.detect {|line| line.include?('"MySQL, Oracle"')}
412 412 end
413 413
414 414 def test_index_csv_big_5
415 415 with_settings :default_language => "zh-TW" do
416 416 str_utf8 = "\xe4\xb8\x80\xe6\x9c\x88"
417 417 str_big5 = "\xa4@\xa4\xeb"
418 418 if str_utf8.respond_to?(:force_encoding)
419 419 str_utf8.force_encoding('UTF-8')
420 420 str_big5.force_encoding('Big5')
421 421 end
422 422 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
423 423 :status_id => 1, :priority => IssuePriority.all.first,
424 424 :subject => str_utf8)
425 425 assert issue.save
426 426
427 427 get :index, :project_id => 1,
428 428 :f => ['subject'],
429 429 :op => '=', :values => [str_utf8],
430 430 :format => 'csv'
431 431 assert_equal 'text/csv; header=present', @response.content_type
432 432 lines = @response.body.chomp.split("\n")
433 433 s1 = "\xaa\xac\xbaA"
434 434 if str_utf8.respond_to?(:force_encoding)
435 435 s1.force_encoding('Big5')
436 436 end
437 437 assert lines[0].include?(s1)
438 438 assert lines[1].include?(str_big5)
439 439 end
440 440 end
441 441
442 442 def test_index_csv_cannot_convert_should_be_replaced_big_5
443 443 with_settings :default_language => "zh-TW" do
444 444 str_utf8 = "\xe4\xbb\xa5\xe5\x86\x85"
445 445 if str_utf8.respond_to?(:force_encoding)
446 446 str_utf8.force_encoding('UTF-8')
447 447 end
448 448 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
449 449 :status_id => 1, :priority => IssuePriority.all.first,
450 450 :subject => str_utf8)
451 451 assert issue.save
452 452
453 453 get :index, :project_id => 1,
454 454 :f => ['subject'],
455 455 :op => '=', :values => [str_utf8],
456 456 :c => ['status', 'subject'],
457 457 :format => 'csv',
458 458 :set_filter => 1
459 459 assert_equal 'text/csv; header=present', @response.content_type
460 460 lines = @response.body.chomp.split("\n")
461 461 s1 = "\xaa\xac\xbaA" # status
462 462 if str_utf8.respond_to?(:force_encoding)
463 463 s1.force_encoding('Big5')
464 464 end
465 465 assert lines[0].include?(s1)
466 466 s2 = lines[1].split(",")[2]
467 467 if s1.respond_to?(:force_encoding)
468 468 s3 = "\xa5H?" # subject
469 469 s3.force_encoding('Big5')
470 470 assert_equal s3, s2
471 471 elsif RUBY_PLATFORM == 'java'
472 472 assert_equal "??", s2
473 473 else
474 474 assert_equal "\xa5H???", s2
475 475 end
476 476 end
477 477 end
478 478
479 479 def test_index_csv_tw
480 480 with_settings :default_language => "zh-TW" do
481 481 str1 = "test_index_csv_tw"
482 482 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
483 483 :status_id => 1, :priority => IssuePriority.all.first,
484 484 :subject => str1, :estimated_hours => '1234.5')
485 485 assert issue.save
486 486 assert_equal 1234.5, issue.estimated_hours
487 487
488 488 get :index, :project_id => 1,
489 489 :f => ['subject'],
490 490 :op => '=', :values => [str1],
491 491 :c => ['estimated_hours', 'subject'],
492 492 :format => 'csv',
493 493 :set_filter => 1
494 494 assert_equal 'text/csv; header=present', @response.content_type
495 495 lines = @response.body.chomp.split("\n")
496 496 assert_equal "#{issue.id},1234.50,#{str1}", lines[1]
497 497
498 498 str_tw = "Traditional Chinese (\xe7\xb9\x81\xe9\xab\x94\xe4\xb8\xad\xe6\x96\x87)"
499 499 if str_tw.respond_to?(:force_encoding)
500 500 str_tw.force_encoding('UTF-8')
501 501 end
502 502 assert_equal str_tw, l(:general_lang_name)
503 503 assert_equal ',', l(:general_csv_separator)
504 504 assert_equal '.', l(:general_csv_decimal_separator)
505 505 end
506 506 end
507 507
508 508 def test_index_csv_fr
509 509 with_settings :default_language => "fr" do
510 510 str1 = "test_index_csv_fr"
511 511 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
512 512 :status_id => 1, :priority => IssuePriority.all.first,
513 513 :subject => str1, :estimated_hours => '1234.5')
514 514 assert issue.save
515 515 assert_equal 1234.5, issue.estimated_hours
516 516
517 517 get :index, :project_id => 1,
518 518 :f => ['subject'],
519 519 :op => '=', :values => [str1],
520 520 :c => ['estimated_hours', 'subject'],
521 521 :format => 'csv',
522 522 :set_filter => 1
523 523 assert_equal 'text/csv; header=present', @response.content_type
524 524 lines = @response.body.chomp.split("\n")
525 525 assert_equal "#{issue.id};1234,50;#{str1}", lines[1]
526 526
527 527 str_fr = "Fran\xc3\xa7ais"
528 528 if str_fr.respond_to?(:force_encoding)
529 529 str_fr.force_encoding('UTF-8')
530 530 end
531 531 assert_equal str_fr, l(:general_lang_name)
532 532 assert_equal ';', l(:general_csv_separator)
533 533 assert_equal ',', l(:general_csv_decimal_separator)
534 534 end
535 535 end
536 536
537 537 def test_index_pdf
538 538 ["en", "zh", "zh-TW", "ja", "ko"].each do |lang|
539 539 with_settings :default_language => lang do
540 540
541 541 get :index
542 542 assert_response :success
543 543 assert_template 'index'
544 544
545 545 if lang == "ja"
546 546 if RUBY_PLATFORM != 'java'
547 547 assert_equal "CP932", l(:general_pdf_encoding)
548 548 end
549 549 if RUBY_PLATFORM == 'java' && l(:general_pdf_encoding) == "CP932"
550 550 next
551 551 end
552 552 end
553 553
554 554 get :index, :format => 'pdf'
555 555 assert_response :success
556 556 assert_not_nil assigns(:issues)
557 557 assert_equal 'application/pdf', @response.content_type
558 558
559 559 get :index, :project_id => 1, :format => 'pdf'
560 560 assert_response :success
561 561 assert_not_nil assigns(:issues)
562 562 assert_equal 'application/pdf', @response.content_type
563 563
564 564 get :index, :project_id => 1, :query_id => 6, :format => 'pdf'
565 565 assert_response :success
566 566 assert_not_nil assigns(:issues)
567 567 assert_equal 'application/pdf', @response.content_type
568 568 end
569 569 end
570 570 end
571 571
572 572 def test_index_pdf_with_query_grouped_by_list_custom_field
573 573 get :index, :project_id => 1, :query_id => 9, :format => 'pdf'
574 574 assert_response :success
575 575 assert_not_nil assigns(:issues)
576 576 assert_not_nil assigns(:issue_count_by_group)
577 577 assert_equal 'application/pdf', @response.content_type
578 578 end
579 579
580 580 def test_index_atom
581 581 get :index, :project_id => 'ecookbook', :format => 'atom'
582 582 assert_response :success
583 583 assert_template 'common/feed'
584 584
585 585 assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil },
586 586 :attributes => {:rel => 'self', :href => 'http://test.host/projects/ecookbook/issues.atom'}
587 587 assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil },
588 588 :attributes => {:rel => 'alternate', :href => 'http://test.host/projects/ecookbook/issues'}
589 589
590 590 assert_tag :tag => 'entry', :child => {
591 591 :tag => 'link',
592 592 :attributes => {:href => 'http://test.host/issues/1'}}
593 593 end
594 594
595 595 def test_index_sort
596 596 get :index, :sort => 'tracker,id:desc'
597 597 assert_response :success
598 598
599 599 sort_params = @request.session['issues_index_sort']
600 600 assert sort_params.is_a?(String)
601 601 assert_equal 'tracker,id:desc', sort_params
602 602
603 603 issues = assigns(:issues)
604 604 assert_not_nil issues
605 605 assert !issues.empty?
606 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 607 end
608 608
609 609 def test_index_sort_by_field_not_included_in_columns
610 610 Setting.issue_list_default_columns = %w(subject author)
611 611 get :index, :sort => 'tracker'
612 612 end
613 613
614 614 def test_index_sort_by_assigned_to
615 615 get :index, :sort => 'assigned_to'
616 616 assert_response :success
617 617 assignees = assigns(:issues).collect(&:assigned_to).compact
618 618 assert_equal assignees.sort, assignees
619 619 end
620 620
621 621 def test_index_sort_by_assigned_to_desc
622 622 get :index, :sort => 'assigned_to:desc'
623 623 assert_response :success
624 624 assignees = assigns(:issues).collect(&:assigned_to).compact
625 625 assert_equal assignees.sort.reverse, assignees
626 626 end
627 627
628 628 def test_index_group_by_assigned_to
629 629 get :index, :group_by => 'assigned_to', :sort => 'priority'
630 630 assert_response :success
631 631 end
632 632
633 633 def test_index_sort_by_author
634 634 get :index, :sort => 'author'
635 635 assert_response :success
636 636 authors = assigns(:issues).collect(&:author)
637 637 assert_equal authors.sort, authors
638 638 end
639 639
640 640 def test_index_sort_by_author_desc
641 641 get :index, :sort => 'author:desc'
642 642 assert_response :success
643 643 authors = assigns(:issues).collect(&:author)
644 644 assert_equal authors.sort.reverse, authors
645 645 end
646 646
647 647 def test_index_group_by_author
648 648 get :index, :group_by => 'author', :sort => 'priority'
649 649 assert_response :success
650 650 end
651 651
652 652 def test_index_sort_by_spent_hours
653 653 get :index, :sort => 'spent_hours:desc'
654 654 assert_response :success
655 655 hours = assigns(:issues).collect(&:spent_hours)
656 656 assert_equal hours.sort.reverse, hours
657 657 end
658 658
659 659 def test_index_sort_by_user_custom_field
660 660 cf = IssueCustomField.create!(:name => 'User', :is_for_all => true, :tracker_ids => [1,2,3], :field_format => 'user')
661 661 CustomValue.create!(:custom_field => cf, :customized => Issue.find(1), :value => '2')
662 662 CustomValue.create!(:custom_field => cf, :customized => Issue.find(2), :value => '3')
663 663 CustomValue.create!(:custom_field => cf, :customized => Issue.find(3), :value => '3')
664 664 CustomValue.create!(:custom_field => cf, :customized => Issue.find(5), :value => '')
665 665
666 666 get :index, :project_id => 1, :set_filter => 1, :sort => "cf_#{cf.id},id"
667 667 assert_response :success
668 668
669 669 assert_equal [2, 3, 1], assigns(:issues).select {|issue| issue.custom_field_value(cf).present?}.map(&:id)
670 670 end
671 671
672 672 def test_index_with_columns
673 673 columns = ['tracker', 'subject', 'assigned_to']
674 674 get :index, :set_filter => 1, :c => columns
675 675 assert_response :success
676 676
677 677 # query should use specified columns
678 678 query = assigns(:query)
679 679 assert_kind_of Query, query
680 680 assert_equal columns, query.column_names.map(&:to_s)
681 681
682 682 # columns should be stored in session
683 683 assert_kind_of Hash, session[:query]
684 684 assert_kind_of Array, session[:query][:column_names]
685 685 assert_equal columns, session[:query][:column_names].map(&:to_s)
686 686
687 687 # ensure only these columns are kept in the selected columns list
688 688 assert_tag :tag => 'select', :attributes => { :id => 'selected_columns' },
689 689 :children => { :count => 3 }
690 690 assert_no_tag :tag => 'option', :attributes => { :value => 'project' },
691 691 :parent => { :tag => 'select', :attributes => { :id => "selected_columns" } }
692 692 end
693 693
694 694 def test_index_without_project_should_implicitly_add_project_column_to_default_columns
695 695 Setting.issue_list_default_columns = ['tracker', 'subject', 'assigned_to']
696 696 get :index, :set_filter => 1
697 697
698 698 # query should use specified columns
699 699 query = assigns(:query)
700 700 assert_kind_of Query, query
701 701 assert_equal [:project, :tracker, :subject, :assigned_to], query.columns.map(&:name)
702 702 end
703 703
704 704 def test_index_without_project_and_explicit_default_columns_should_not_add_project_column
705 705 Setting.issue_list_default_columns = ['tracker', 'subject', 'assigned_to']
706 706 columns = ['tracker', 'subject', 'assigned_to']
707 707 get :index, :set_filter => 1, :c => columns
708 708
709 709 # query should use specified columns
710 710 query = assigns(:query)
711 711 assert_kind_of Query, query
712 712 assert_equal columns.map(&:to_sym), query.columns.map(&:name)
713 713 end
714 714
715 715 def test_index_with_custom_field_column
716 716 columns = %w(tracker subject cf_2)
717 717 get :index, :set_filter => 1, :c => columns
718 718 assert_response :success
719 719
720 720 # query should use specified columns
721 721 query = assigns(:query)
722 722 assert_kind_of Query, query
723 723 assert_equal columns, query.column_names.map(&:to_s)
724 724
725 725 assert_tag :td,
726 726 :attributes => {:class => 'cf_2 string'},
727 727 :ancestor => {:tag => 'table', :attributes => {:class => /issues/}}
728 728 end
729 729
730 730 def test_index_with_multi_custom_field_column
731 731 field = CustomField.find(1)
732 732 field.update_attribute :multiple, true
733 733 issue = Issue.find(1)
734 734 issue.custom_field_values = {1 => ['MySQL', 'Oracle']}
735 735 issue.save!
736 736
737 737 get :index, :set_filter => 1, :c => %w(tracker subject cf_1)
738 738 assert_response :success
739 739
740 740 assert_tag :td,
741 741 :attributes => {:class => /cf_1/},
742 742 :content => 'MySQL, Oracle'
743 743 end
744 744
745 745 def test_index_with_multi_user_custom_field_column
746 746 field = IssueCustomField.create!(:name => 'Multi user', :field_format => 'user', :multiple => true,
747 747 :tracker_ids => [1], :is_for_all => true)
748 748 issue = Issue.find(1)
749 749 issue.custom_field_values = {field.id => ['2', '3']}
750 750 issue.save!
751 751
752 752 get :index, :set_filter => 1, :c => ['tracker', 'subject', "cf_#{field.id}"]
753 753 assert_response :success
754 754
755 755 assert_tag :td,
756 756 :attributes => {:class => /cf_#{field.id}/},
757 757 :child => {:tag => 'a', :content => 'John Smith'}
758 758 end
759 759
760 760 def test_index_with_date_column
761 761 Issue.find(1).update_attribute :start_date, '1987-08-24'
762 762
763 763 with_settings :date_format => '%d/%m/%Y' do
764 764 get :index, :set_filter => 1, :c => %w(start_date)
765 765 assert_tag 'td', :attributes => {:class => /start_date/}, :content => '24/08/1987'
766 766 end
767 767 end
768 768
769 769 def test_index_with_done_ratio
770 770 Issue.find(1).update_attribute :done_ratio, 40
771 771
772 772 get :index, :set_filter => 1, :c => %w(done_ratio)
773 773 assert_tag 'td', :attributes => {:class => /done_ratio/},
774 774 :child => {:tag => 'table', :attributes => {:class => 'progress'},
775 775 :descendant => {:tag => 'td', :attributes => {:class => 'closed', :style => 'width: 40%;'}}
776 776 }
777 777 end
778 778
779 779 def test_index_with_spent_hours_column
780 780 get :index, :set_filter => 1, :c => %w(subject spent_hours)
781 781
782 782 assert_tag 'tr', :attributes => {:id => 'issue-3'},
783 783 :child => {
784 784 :tag => 'td', :attributes => {:class => /spent_hours/}, :content => '1.00'
785 785 }
786 786 end
787 787
788 788 def test_index_should_not_show_spent_hours_column_without_permission
789 789 Role.anonymous.remove_permission! :view_time_entries
790 790 get :index, :set_filter => 1, :c => %w(subject spent_hours)
791 791
792 792 assert_no_tag 'td', :attributes => {:class => /spent_hours/}
793 793 end
794 794
795 795 def test_index_with_fixed_version
796 796 get :index, :set_filter => 1, :c => %w(fixed_version)
797 797 assert_tag 'td', :attributes => {:class => /fixed_version/},
798 798 :child => {:tag => 'a', :content => '1.0', :attributes => {:href => '/versions/2'}}
799 799 end
800 800
801 801 def test_index_send_html_if_query_is_invalid
802 802 get :index, :f => ['start_date'], :op => {:start_date => '='}
803 803 assert_equal 'text/html', @response.content_type
804 804 assert_template 'index'
805 805 end
806 806
807 807 def test_index_send_nothing_if_query_is_invalid
808 808 get :index, :f => ['start_date'], :op => {:start_date => '='}, :format => 'csv'
809 809 assert_equal 'text/csv', @response.content_type
810 810 assert @response.body.blank?
811 811 end
812 812
813 813 def test_show_by_anonymous
814 814 get :show, :id => 1
815 815 assert_response :success
816 816 assert_template 'show'
817 817 assert_not_nil assigns(:issue)
818 818 assert_equal Issue.find(1), assigns(:issue)
819 819
820 820 # anonymous role is allowed to add a note
821 821 assert_tag :tag => 'form',
822 822 :descendant => { :tag => 'fieldset',
823 823 :child => { :tag => 'legend',
824 824 :content => /Notes/ } }
825 825 assert_tag :tag => 'title',
826 826 :content => "Bug #1: Can&#x27;t print recipes - eCookbook - Redmine"
827 827 end
828 828
829 829 def test_show_by_manager
830 830 @request.session[:user_id] = 2
831 831 get :show, :id => 1
832 832 assert_response :success
833 833
834 834 assert_tag :tag => 'a',
835 835 :content => /Quote/
836 836
837 837 assert_tag :tag => 'form',
838 838 :descendant => { :tag => 'fieldset',
839 839 :child => { :tag => 'legend',
840 840 :content => /Change properties/ } },
841 841 :descendant => { :tag => 'fieldset',
842 842 :child => { :tag => 'legend',
843 843 :content => /Log time/ } },
844 844 :descendant => { :tag => 'fieldset',
845 845 :child => { :tag => 'legend',
846 846 :content => /Notes/ } }
847 847 end
848 848
849 849 def test_show_should_display_update_form
850 850 @request.session[:user_id] = 2
851 851 get :show, :id => 1
852 852 assert_response :success
853 853
854 854 assert_tag 'form', :attributes => {:id => 'issue-form'}
855 855 assert_tag 'input', :attributes => {:name => 'issue[is_private]'}
856 856 assert_tag 'select', :attributes => {:name => 'issue[project_id]'}
857 857 assert_tag 'select', :attributes => {:name => 'issue[tracker_id]'}
858 858 assert_tag 'input', :attributes => {:name => 'issue[subject]'}
859 859 assert_tag 'textarea', :attributes => {:name => 'issue[description]'}
860 860 assert_tag 'select', :attributes => {:name => 'issue[status_id]'}
861 861 assert_tag 'select', :attributes => {:name => 'issue[priority_id]'}
862 862 assert_tag 'select', :attributes => {:name => 'issue[assigned_to_id]'}
863 863 assert_tag 'select', :attributes => {:name => 'issue[category_id]'}
864 864 assert_tag 'select', :attributes => {:name => 'issue[fixed_version_id]'}
865 865 assert_tag 'input', :attributes => {:name => 'issue[parent_issue_id]'}
866 866 assert_tag 'input', :attributes => {:name => 'issue[start_date]'}
867 867 assert_tag 'input', :attributes => {:name => 'issue[due_date]'}
868 868 assert_tag 'select', :attributes => {:name => 'issue[done_ratio]'}
869 869 assert_tag 'input', :attributes => { :name => 'issue[custom_field_values][2]' }
870 870 assert_no_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]'}
871 871 assert_tag 'textarea', :attributes => {:name => 'notes'}
872 872 end
873 873
874 874 def test_show_should_display_update_form_with_minimal_permissions
875 875 Role.find(1).update_attribute :permissions, [:view_issues, :add_issue_notes]
876 876 WorkflowTransition.delete_all :role_id => 1
877 877
878 878 @request.session[:user_id] = 2
879 879 get :show, :id => 1
880 880 assert_response :success
881 881
882 882 assert_tag 'form', :attributes => {:id => 'issue-form'}
883 883 assert_no_tag 'input', :attributes => {:name => 'issue[is_private]'}
884 884 assert_no_tag 'select', :attributes => {:name => 'issue[project_id]'}
885 885 assert_no_tag 'select', :attributes => {:name => 'issue[tracker_id]'}
886 886 assert_no_tag 'input', :attributes => {:name => 'issue[subject]'}
887 887 assert_no_tag 'textarea', :attributes => {:name => 'issue[description]'}
888 888 assert_no_tag 'select', :attributes => {:name => 'issue[status_id]'}
889 889 assert_no_tag 'select', :attributes => {:name => 'issue[priority_id]'}
890 890 assert_no_tag 'select', :attributes => {:name => 'issue[assigned_to_id]'}
891 891 assert_no_tag 'select', :attributes => {:name => 'issue[category_id]'}
892 892 assert_no_tag 'select', :attributes => {:name => 'issue[fixed_version_id]'}
893 893 assert_no_tag 'input', :attributes => {:name => 'issue[parent_issue_id]'}
894 894 assert_no_tag 'input', :attributes => {:name => 'issue[start_date]'}
895 895 assert_no_tag 'input', :attributes => {:name => 'issue[due_date]'}
896 896 assert_no_tag 'select', :attributes => {:name => 'issue[done_ratio]'}
897 897 assert_no_tag 'input', :attributes => { :name => 'issue[custom_field_values][2]' }
898 898 assert_no_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]'}
899 899 assert_tag 'textarea', :attributes => {:name => 'notes'}
900 900 end
901 901
902 902 def test_show_should_display_update_form_with_workflow_permissions
903 903 Role.find(1).update_attribute :permissions, [:view_issues, :add_issue_notes]
904 904
905 905 @request.session[:user_id] = 2
906 906 get :show, :id => 1
907 907 assert_response :success
908 908
909 909 assert_tag 'form', :attributes => {:id => 'issue-form'}
910 910 assert_no_tag 'input', :attributes => {:name => 'issue[is_private]'}
911 911 assert_no_tag 'select', :attributes => {:name => 'issue[project_id]'}
912 912 assert_no_tag 'select', :attributes => {:name => 'issue[tracker_id]'}
913 913 assert_no_tag 'input', :attributes => {:name => 'issue[subject]'}
914 914 assert_no_tag 'textarea', :attributes => {:name => 'issue[description]'}
915 915 assert_tag 'select', :attributes => {:name => 'issue[status_id]'}
916 916 assert_no_tag 'select', :attributes => {:name => 'issue[priority_id]'}
917 917 assert_tag 'select', :attributes => {:name => 'issue[assigned_to_id]'}
918 918 assert_no_tag 'select', :attributes => {:name => 'issue[category_id]'}
919 919 assert_tag 'select', :attributes => {:name => 'issue[fixed_version_id]'}
920 920 assert_no_tag 'input', :attributes => {:name => 'issue[parent_issue_id]'}
921 921 assert_no_tag 'input', :attributes => {:name => 'issue[start_date]'}
922 922 assert_no_tag 'input', :attributes => {:name => 'issue[due_date]'}
923 923 assert_tag 'select', :attributes => {:name => 'issue[done_ratio]'}
924 924 assert_no_tag 'input', :attributes => { :name => 'issue[custom_field_values][2]' }
925 925 assert_no_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]'}
926 926 assert_tag 'textarea', :attributes => {:name => 'notes'}
927 927 end
928 928
929 929 def test_show_should_not_display_update_form_without_permissions
930 930 Role.find(1).update_attribute :permissions, [:view_issues]
931 931
932 932 @request.session[:user_id] = 2
933 933 get :show, :id => 1
934 934 assert_response :success
935 935
936 936 assert_no_tag 'form', :attributes => {:id => 'issue-form'}
937 937 end
938 938
939 939 def test_update_form_should_not_display_inactive_enumerations
940 940 @request.session[:user_id] = 2
941 941 get :show, :id => 1
942 942 assert_response :success
943 943
944 944 assert ! IssuePriority.find(15).active?
945 945 assert_no_tag :option, :attributes => {:value => '15'},
946 946 :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} }
947 947 end
948 948
949 949 def test_update_form_should_allow_attachment_upload
950 950 @request.session[:user_id] = 2
951 951 get :show, :id => 1
952 952
953 953 assert_tag :tag => 'form',
954 954 :attributes => {:id => 'issue-form', :method => 'post', :enctype => 'multipart/form-data'},
955 955 :descendant => {
956 956 :tag => 'input',
957 957 :attributes => {:type => 'file', :name => 'attachments[1][file]'}
958 958 }
959 959 end
960 960
961 961 def test_show_should_deny_anonymous_access_without_permission
962 962 Role.anonymous.remove_permission!(:view_issues)
963 963 get :show, :id => 1
964 964 assert_response :redirect
965 965 end
966 966
967 967 def test_show_should_deny_anonymous_access_to_private_issue
968 968 Issue.update_all(["is_private = ?", true], "id = 1")
969 969 get :show, :id => 1
970 970 assert_response :redirect
971 971 end
972 972
973 973 def test_show_should_deny_non_member_access_without_permission
974 974 Role.non_member.remove_permission!(:view_issues)
975 975 @request.session[:user_id] = 9
976 976 get :show, :id => 1
977 977 assert_response 403
978 978 end
979 979
980 980 def test_show_should_deny_non_member_access_to_private_issue
981 981 Issue.update_all(["is_private = ?", true], "id = 1")
982 982 @request.session[:user_id] = 9
983 983 get :show, :id => 1
984 984 assert_response 403
985 985 end
986 986
987 987 def test_show_should_deny_member_access_without_permission
988 988 Role.find(1).remove_permission!(:view_issues)
989 989 @request.session[:user_id] = 2
990 990 get :show, :id => 1
991 991 assert_response 403
992 992 end
993 993
994 994 def test_show_should_deny_member_access_to_private_issue_without_permission
995 995 Issue.update_all(["is_private = ?", true], "id = 1")
996 996 @request.session[:user_id] = 3
997 997 get :show, :id => 1
998 998 assert_response 403
999 999 end
1000 1000
1001 1001 def test_show_should_allow_author_access_to_private_issue
1002 1002 Issue.update_all(["is_private = ?, author_id = 3", true], "id = 1")
1003 1003 @request.session[:user_id] = 3
1004 1004 get :show, :id => 1
1005 1005 assert_response :success
1006 1006 end
1007 1007
1008 1008 def test_show_should_allow_assignee_access_to_private_issue
1009 1009 Issue.update_all(["is_private = ?, assigned_to_id = 3", true], "id = 1")
1010 1010 @request.session[:user_id] = 3
1011 1011 get :show, :id => 1
1012 1012 assert_response :success
1013 1013 end
1014 1014
1015 1015 def test_show_should_allow_member_access_to_private_issue_with_permission
1016 1016 Issue.update_all(["is_private = ?", true], "id = 1")
1017 1017 User.find(3).roles_for_project(Project.find(1)).first.update_attribute :issues_visibility, 'all'
1018 1018 @request.session[:user_id] = 3
1019 1019 get :show, :id => 1
1020 1020 assert_response :success
1021 1021 end
1022 1022
1023 1023 def test_show_should_not_disclose_relations_to_invisible_issues
1024 1024 Setting.cross_project_issue_relations = '1'
1025 1025 IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(2), :relation_type => 'relates')
1026 1026 # Relation to a private project issue
1027 1027 IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(4), :relation_type => 'relates')
1028 1028
1029 1029 get :show, :id => 1
1030 1030 assert_response :success
1031 1031
1032 1032 assert_tag :div, :attributes => { :id => 'relations' },
1033 1033 :descendant => { :tag => 'a', :content => /#2$/ }
1034 1034 assert_no_tag :div, :attributes => { :id => 'relations' },
1035 1035 :descendant => { :tag => 'a', :content => /#4$/ }
1036 1036 end
1037 1037
1038 1038 def test_show_should_list_subtasks
1039 1039 Issue.create!(:project_id => 1, :author_id => 1, :tracker_id => 1, :parent_issue_id => 1, :subject => 'Child Issue')
1040 1040
1041 1041 get :show, :id => 1
1042 1042 assert_response :success
1043 1043 assert_tag 'div', :attributes => {:id => 'issue_tree'},
1044 1044 :descendant => {:tag => 'td', :content => /Child Issue/, :attributes => {:class => /subject/}}
1045 1045 end
1046 1046
1047 1047 def test_show_should_list_parents
1048 1048 issue = Issue.create!(:project_id => 1, :author_id => 1, :tracker_id => 1, :parent_issue_id => 1, :subject => 'Child Issue')
1049 1049
1050 1050 get :show, :id => issue.id
1051 1051 assert_response :success
1052 1052 assert_tag 'div', :attributes => {:class => 'subject'},
1053 1053 :descendant => {:tag => 'h3', :content => 'Child Issue'}
1054 1054 assert_tag 'div', :attributes => {:class => 'subject'},
1055 1055 :descendant => {:tag => 'a', :attributes => {:href => '/issues/1'}}
1056 1056 end
1057 1057
1058 1058 def test_show_should_not_display_prev_next_links_without_query_in_session
1059 1059 get :show, :id => 1
1060 1060 assert_response :success
1061 1061 assert_nil assigns(:prev_issue_id)
1062 1062 assert_nil assigns(:next_issue_id)
1063 1063
1064 1064 assert_no_tag 'div', :attributes => {:class => /next-prev-links/}
1065 1065 end
1066 1066
1067 1067 def test_show_should_display_prev_next_links_with_query_in_session
1068 1068 @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => nil}
1069 1069 @request.session['issues_index_sort'] = 'id'
1070 1070
1071 1071 with_settings :display_subprojects_issues => '0' do
1072 1072 get :show, :id => 3
1073 1073 end
1074 1074
1075 1075 assert_response :success
1076 1076 # Previous and next issues for all projects
1077 1077 assert_equal 2, assigns(:prev_issue_id)
1078 1078 assert_equal 5, assigns(:next_issue_id)
1079 1079
1080 1080 assert_tag 'div', :attributes => {:class => /next-prev-links/}
1081 1081 assert_tag 'a', :attributes => {:href => '/issues/2'}, :content => /Previous/
1082 1082 assert_tag 'a', :attributes => {:href => '/issues/5'}, :content => /Next/
1083 1083
1084 1084 count = Issue.open.visible.count
1085 1085 assert_tag 'span', :attributes => {:class => 'position'}, :content => "3 of #{count}"
1086 1086 end
1087 1087
1088 1088 def test_show_should_display_prev_next_links_with_saved_query_in_session
1089 1089 query = Query.create!(:name => 'test', :is_public => true, :user_id => 1,
1090 1090 :filters => {'status_id' => {:values => ['5'], :operator => '='}},
1091 1091 :sort_criteria => [['id', 'asc']])
1092 1092 @request.session[:query] = {:id => query.id, :project_id => nil}
1093 1093
1094 1094 get :show, :id => 11
1095 1095
1096 1096 assert_response :success
1097 1097 assert_equal query, assigns(:query)
1098 1098 # Previous and next issues for all projects
1099 1099 assert_equal 8, assigns(:prev_issue_id)
1100 1100 assert_equal 12, assigns(:next_issue_id)
1101 1101
1102 1102 assert_tag 'a', :attributes => {:href => '/issues/8'}, :content => /Previous/
1103 1103 assert_tag 'a', :attributes => {:href => '/issues/12'}, :content => /Next/
1104 1104 end
1105 1105
1106 1106 def test_show_should_display_prev_next_links_with_query_and_sort_on_association
1107 1107 @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => nil}
1108 1108
1109 1109 %w(project tracker status priority author assigned_to category fixed_version).each do |assoc_sort|
1110 1110 @request.session['issues_index_sort'] = assoc_sort
1111 1111
1112 1112 get :show, :id => 3
1113 1113 assert_response :success, "Wrong response status for #{assoc_sort} sort"
1114 1114
1115 1115 assert_tag 'div', :attributes => {:class => /next-prev-links/}, :content => /Previous/
1116 1116 assert_tag 'div', :attributes => {:class => /next-prev-links/}, :content => /Next/
1117 1117 end
1118 1118 end
1119 1119
1120 1120 def test_show_should_display_prev_next_links_with_project_query_in_session
1121 1121 @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => 1}
1122 1122 @request.session['issues_index_sort'] = 'id'
1123 1123
1124 1124 with_settings :display_subprojects_issues => '0' do
1125 1125 get :show, :id => 3
1126 1126 end
1127 1127
1128 1128 assert_response :success
1129 1129 # Previous and next issues inside project
1130 1130 assert_equal 2, assigns(:prev_issue_id)
1131 1131 assert_equal 7, assigns(:next_issue_id)
1132 1132
1133 1133 assert_tag 'a', :attributes => {:href => '/issues/2'}, :content => /Previous/
1134 1134 assert_tag 'a', :attributes => {:href => '/issues/7'}, :content => /Next/
1135 1135 end
1136 1136
1137 1137 def test_show_should_not_display_prev_link_for_first_issue
1138 1138 @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => 1}
1139 1139 @request.session['issues_index_sort'] = 'id'
1140 1140
1141 1141 with_settings :display_subprojects_issues => '0' do
1142 1142 get :show, :id => 1
1143 1143 end
1144 1144
1145 1145 assert_response :success
1146 1146 assert_nil assigns(:prev_issue_id)
1147 1147 assert_equal 2, assigns(:next_issue_id)
1148 1148
1149 1149 assert_no_tag 'a', :content => /Previous/
1150 1150 assert_tag 'a', :attributes => {:href => '/issues/2'}, :content => /Next/
1151 1151 end
1152 1152
1153 1153 def test_show_should_not_display_prev_next_links_for_issue_not_in_query_results
1154 1154 @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'c'}}, :project_id => 1}
1155 1155 @request.session['issues_index_sort'] = 'id'
1156 1156
1157 1157 get :show, :id => 1
1158 1158
1159 1159 assert_response :success
1160 1160 assert_nil assigns(:prev_issue_id)
1161 1161 assert_nil assigns(:next_issue_id)
1162 1162
1163 1163 assert_no_tag 'a', :content => /Previous/
1164 1164 assert_no_tag 'a', :content => /Next/
1165 1165 end
1166 1166
1167 1167 def test_show_show_should_display_prev_next_links_with_query_sort_by_user_custom_field
1168 1168 cf = IssueCustomField.create!(:name => 'User', :is_for_all => true, :tracker_ids => [1,2,3], :field_format => 'user')
1169 1169 CustomValue.create!(:custom_field => cf, :customized => Issue.find(1), :value => '2')
1170 1170 CustomValue.create!(:custom_field => cf, :customized => Issue.find(2), :value => '3')
1171 1171 CustomValue.create!(:custom_field => cf, :customized => Issue.find(3), :value => '3')
1172 1172 CustomValue.create!(:custom_field => cf, :customized => Issue.find(5), :value => '')
1173 1173
1174 1174 query = Query.create!(:name => 'test', :is_public => true, :user_id => 1, :filters => {},
1175 1175 :sort_criteria => [["cf_#{cf.id}", 'asc'], ['id', 'asc']])
1176 1176 @request.session[:query] = {:id => query.id, :project_id => nil}
1177 1177
1178 1178 get :show, :id => 3
1179 1179 assert_response :success
1180 1180
1181 1181 assert_equal 2, assigns(:prev_issue_id)
1182 1182 assert_equal 1, assigns(:next_issue_id)
1183 1183 end
1184 1184
1185 1185 def test_show_should_display_link_to_the_assignee
1186 1186 get :show, :id => 2
1187 1187 assert_response :success
1188 1188 assert_select '.assigned-to' do
1189 1189 assert_select 'a[href=/users/3]'
1190 1190 end
1191 1191 end
1192 1192
1193 1193 def test_show_should_display_visible_changesets_from_other_projects
1194 1194 project = Project.find(2)
1195 1195 issue = project.issues.first
1196 1196 issue.changeset_ids = [102]
1197 1197 issue.save!
1198 1198 project.disable_module! :repository
1199 1199
1200 1200 @request.session[:user_id] = 2
1201 1201 get :show, :id => issue.id
1202 1202 assert_tag 'a', :attributes => {:href => "/projects/ecookbook/repository/revisions/3"}
1203 1203 end
1204 1204
1205 1205 def test_show_should_display_watchers
1206 1206 @request.session[:user_id] = 2
1207 1207 Issue.find(1).add_watcher User.find(2)
1208 1208
1209 1209 get :show, :id => 1
1210 1210 assert_select 'div#watchers ul' do
1211 1211 assert_select 'li' do
1212 1212 assert_select 'a[href=/users/2]'
1213 1213 assert_select 'a img[alt=Delete]'
1214 1214 end
1215 1215 end
1216 1216 end
1217 1217
1218 1218 def test_show_should_display_watchers_with_gravatars
1219 1219 @request.session[:user_id] = 2
1220 1220 Issue.find(1).add_watcher User.find(2)
1221 1221
1222 1222 with_settings :gravatar_enabled => '1' do
1223 1223 get :show, :id => 1
1224 1224 end
1225 1225
1226 1226 assert_select 'div#watchers ul' do
1227 1227 assert_select 'li' do
1228 1228 assert_select 'img.gravatar'
1229 1229 assert_select 'a[href=/users/2]'
1230 1230 assert_select 'a img[alt=Delete]'
1231 1231 end
1232 1232 end
1233 1233 end
1234 1234
1235 1235 def test_show_with_thumbnails_enabled_should_display_thumbnails
1236 1236 @request.session[:user_id] = 2
1237 1237
1238 1238 with_settings :thumbnails_enabled => '1' do
1239 1239 get :show, :id => 14
1240 1240 assert_response :success
1241 1241 end
1242 1242
1243 1243 assert_select 'div.thumbnails' do
1244 1244 assert_select 'a[href=/attachments/16/testfile.png]' do
1245 1245 assert_select 'img[src=/attachments/thumbnail/16]'
1246 1246 end
1247 1247 end
1248 1248 end
1249 1249
1250 1250 def test_show_with_thumbnails_disabled_should_not_display_thumbnails
1251 1251 @request.session[:user_id] = 2
1252 1252
1253 1253 with_settings :thumbnails_enabled => '0' do
1254 1254 get :show, :id => 14
1255 1255 assert_response :success
1256 1256 end
1257 1257
1258 1258 assert_select 'div.thumbnails', 0
1259 1259 end
1260 1260
1261 1261 def test_show_with_multi_custom_field
1262 1262 field = CustomField.find(1)
1263 1263 field.update_attribute :multiple, true
1264 1264 issue = Issue.find(1)
1265 1265 issue.custom_field_values = {1 => ['MySQL', 'Oracle']}
1266 1266 issue.save!
1267 1267
1268 1268 get :show, :id => 1
1269 1269 assert_response :success
1270 1270
1271 1271 assert_tag :td, :content => 'MySQL, Oracle'
1272 1272 end
1273 1273
1274 1274 def test_show_with_multi_user_custom_field
1275 1275 field = IssueCustomField.create!(:name => 'Multi user', :field_format => 'user', :multiple => true,
1276 1276 :tracker_ids => [1], :is_for_all => true)
1277 1277 issue = Issue.find(1)
1278 1278 issue.custom_field_values = {field.id => ['2', '3']}
1279 1279 issue.save!
1280 1280
1281 1281 get :show, :id => 1
1282 1282 assert_response :success
1283 1283
1284 1284 # TODO: should display links
1285 1285 assert_tag :td, :content => 'Dave Lopper, John Smith'
1286 1286 end
1287 1287
1288 1288 def test_show_atom
1289 1289 get :show, :id => 2, :format => 'atom'
1290 1290 assert_response :success
1291 1291 assert_template 'journals/index'
1292 1292 # Inline image
1293 1293 assert_select 'content', :text => Regexp.new(Regexp.quote('http://test.host/attachments/download/10'))
1294 1294 end
1295 1295
1296 1296 def test_show_export_to_pdf
1297 1297 get :show, :id => 3, :format => 'pdf'
1298 1298 assert_response :success
1299 1299 assert_equal 'application/pdf', @response.content_type
1300 1300 assert @response.body.starts_with?('%PDF')
1301 1301 assert_not_nil assigns(:issue)
1302 1302 end
1303 1303
1304 1304 def test_show_export_to_pdf_with_ancestors
1305 1305 issue = Issue.generate!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => 1)
1306 1306
1307 1307 get :show, :id => issue.id, :format => 'pdf'
1308 1308 assert_response :success
1309 1309 assert_equal 'application/pdf', @response.content_type
1310 1310 assert @response.body.starts_with?('%PDF')
1311 1311 end
1312 1312
1313 1313 def test_show_export_to_pdf_with_descendants
1314 1314 c1 = Issue.generate!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => 1)
1315 1315 c2 = Issue.generate!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => 1)
1316 1316 c3 = Issue.generate!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => c1.id)
1317 1317
1318 1318 get :show, :id => 1, :format => 'pdf'
1319 1319 assert_response :success
1320 1320 assert_equal 'application/pdf', @response.content_type
1321 1321 assert @response.body.starts_with?('%PDF')
1322 1322 end
1323 1323
1324 1324 def test_show_export_to_pdf_with_journals
1325 1325 get :show, :id => 1, :format => 'pdf'
1326 1326 assert_response :success
1327 1327 assert_equal 'application/pdf', @response.content_type
1328 1328 assert @response.body.starts_with?('%PDF')
1329 1329 end
1330 1330
1331 1331 def test_show_export_to_pdf_with_changesets
1332 1332 Issue.find(3).changesets = Changeset.find_all_by_id(100, 101, 102)
1333 1333
1334 1334 get :show, :id => 3, :format => 'pdf'
1335 1335 assert_response :success
1336 1336 assert_equal 'application/pdf', @response.content_type
1337 1337 assert @response.body.starts_with?('%PDF')
1338 1338 end
1339 1339
1340 1340 def test_get_new
1341 1341 @request.session[:user_id] = 2
1342 1342 get :new, :project_id => 1, :tracker_id => 1
1343 1343 assert_response :success
1344 1344 assert_template 'new'
1345 1345
1346 1346 assert_tag 'input', :attributes => {:name => 'issue[is_private]'}
1347 1347 assert_no_tag 'select', :attributes => {:name => 'issue[project_id]'}
1348 1348 assert_tag 'select', :attributes => {:name => 'issue[tracker_id]'}
1349 1349 assert_tag 'input', :attributes => {:name => 'issue[subject]'}
1350 1350 assert_tag 'textarea', :attributes => {:name => 'issue[description]'}
1351 1351 assert_tag 'select', :attributes => {:name => 'issue[status_id]'}
1352 1352 assert_tag 'select', :attributes => {:name => 'issue[priority_id]'}
1353 1353 assert_tag 'select', :attributes => {:name => 'issue[assigned_to_id]'}
1354 1354 assert_tag 'select', :attributes => {:name => 'issue[category_id]'}
1355 1355 assert_tag 'select', :attributes => {:name => 'issue[fixed_version_id]'}
1356 1356 assert_tag 'input', :attributes => {:name => 'issue[parent_issue_id]'}
1357 1357 assert_tag 'input', :attributes => {:name => 'issue[start_date]'}
1358 1358 assert_tag 'input', :attributes => {:name => 'issue[due_date]'}
1359 1359 assert_tag 'select', :attributes => {:name => 'issue[done_ratio]'}
1360 1360 assert_tag 'input', :attributes => { :name => 'issue[custom_field_values][2]', :value => 'Default string' }
1361 1361 assert_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]'}
1362 1362
1363 1363 # Be sure we don't display inactive IssuePriorities
1364 1364 assert ! IssuePriority.find(15).active?
1365 1365 assert_no_tag :option, :attributes => {:value => '15'},
1366 1366 :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} }
1367 1367 end
1368 1368
1369 1369 def test_get_new_with_minimal_permissions
1370 1370 Role.find(1).update_attribute :permissions, [:add_issues]
1371 1371 WorkflowTransition.delete_all :role_id => 1
1372 1372
1373 1373 @request.session[:user_id] = 2
1374 1374 get :new, :project_id => 1, :tracker_id => 1
1375 1375 assert_response :success
1376 1376 assert_template 'new'
1377 1377
1378 1378 assert_no_tag 'input', :attributes => {:name => 'issue[is_private]'}
1379 1379 assert_no_tag 'select', :attributes => {:name => 'issue[project_id]'}
1380 1380 assert_tag 'select', :attributes => {:name => 'issue[tracker_id]'}
1381 1381 assert_tag 'input', :attributes => {:name => 'issue[subject]'}
1382 1382 assert_tag 'textarea', :attributes => {:name => 'issue[description]'}
1383 1383 assert_tag 'select', :attributes => {:name => 'issue[status_id]'}
1384 1384 assert_tag 'select', :attributes => {:name => 'issue[priority_id]'}
1385 1385 assert_tag 'select', :attributes => {:name => 'issue[assigned_to_id]'}
1386 1386 assert_tag 'select', :attributes => {:name => 'issue[category_id]'}
1387 1387 assert_tag 'select', :attributes => {:name => 'issue[fixed_version_id]'}
1388 1388 assert_no_tag 'input', :attributes => {:name => 'issue[parent_issue_id]'}
1389 1389 assert_tag 'input', :attributes => {:name => 'issue[start_date]'}
1390 1390 assert_tag 'input', :attributes => {:name => 'issue[due_date]'}
1391 1391 assert_tag 'select', :attributes => {:name => 'issue[done_ratio]'}
1392 1392 assert_tag 'input', :attributes => { :name => 'issue[custom_field_values][2]', :value => 'Default string' }
1393 1393 assert_no_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]'}
1394 1394 end
1395 1395
1396 1396 def test_get_new_with_list_custom_field
1397 1397 @request.session[:user_id] = 2
1398 1398 get :new, :project_id => 1, :tracker_id => 1
1399 1399 assert_response :success
1400 1400 assert_template 'new'
1401 1401
1402 1402 assert_tag 'select',
1403 1403 :attributes => {:name => 'issue[custom_field_values][1]', :class => 'list_cf'},
1404 1404 :children => {:count => 4},
1405 1405 :child => {:tag => 'option', :attributes => {:value => 'MySQL'}, :content => 'MySQL'}
1406 1406 end
1407 1407
1408 1408 def test_get_new_with_multi_custom_field
1409 1409 field = IssueCustomField.find(1)
1410 1410 field.update_attribute :multiple, true
1411 1411
1412 1412 @request.session[:user_id] = 2
1413 1413 get :new, :project_id => 1, :tracker_id => 1
1414 1414 assert_response :success
1415 1415 assert_template 'new'
1416 1416
1417 1417 assert_tag 'select',
1418 1418 :attributes => {:name => 'issue[custom_field_values][1][]', :multiple => 'multiple'},
1419 1419 :children => {:count => 3},
1420 1420 :child => {:tag => 'option', :attributes => {:value => 'MySQL'}, :content => 'MySQL'}
1421 1421 assert_tag 'input',
1422 1422 :attributes => {:name => 'issue[custom_field_values][1][]', :value => ''}
1423 1423 end
1424 1424
1425 1425 def test_get_new_with_multi_user_custom_field
1426 1426 field = IssueCustomField.create!(:name => 'Multi user', :field_format => 'user', :multiple => true,
1427 1427 :tracker_ids => [1], :is_for_all => true)
1428 1428
1429 1429 @request.session[:user_id] = 2
1430 1430 get :new, :project_id => 1, :tracker_id => 1
1431 1431 assert_response :success
1432 1432 assert_template 'new'
1433 1433
1434 1434 assert_tag 'select',
1435 1435 :attributes => {:name => "issue[custom_field_values][#{field.id}][]", :multiple => 'multiple'},
1436 1436 :children => {:count => Project.find(1).users.count},
1437 1437 :child => {:tag => 'option', :attributes => {:value => '2'}, :content => 'John Smith'}
1438 1438 assert_tag 'input',
1439 1439 :attributes => {:name => "issue[custom_field_values][#{field.id}][]", :value => ''}
1440 1440 end
1441 1441
1442 1442 def test_get_new_with_date_custom_field
1443 1443 field = IssueCustomField.create!(:name => 'Date', :field_format => 'date', :tracker_ids => [1], :is_for_all => true)
1444 1444
1445 1445 @request.session[:user_id] = 2
1446 1446 get :new, :project_id => 1, :tracker_id => 1
1447 1447 assert_response :success
1448 1448
1449 1449 assert_select 'input[name=?]', "issue[custom_field_values][#{field.id}]"
1450 1450 end
1451 1451
1452 1452 def test_get_new_with_text_custom_field
1453 1453 field = IssueCustomField.create!(:name => 'Text', :field_format => 'text', :tracker_ids => [1], :is_for_all => true)
1454 1454
1455 1455 @request.session[:user_id] = 2
1456 1456 get :new, :project_id => 1, :tracker_id => 1
1457 1457 assert_response :success
1458 1458
1459 1459 assert_select 'textarea[name=?]', "issue[custom_field_values][#{field.id}]"
1460 1460 end
1461 1461
1462 1462 def test_get_new_without_default_start_date_is_creation_date
1463 1463 Setting.default_issue_start_date_to_creation_date = 0
1464 1464
1465 1465 @request.session[:user_id] = 2
1466 1466 get :new, :project_id => 1, :tracker_id => 1
1467 1467 assert_response :success
1468 1468 assert_template 'new'
1469 1469
1470 1470 assert_tag :tag => 'input', :attributes => { :name => 'issue[start_date]',
1471 1471 :value => nil }
1472 1472 end
1473 1473
1474 1474 def test_get_new_with_default_start_date_is_creation_date
1475 1475 Setting.default_issue_start_date_to_creation_date = 1
1476 1476
1477 1477 @request.session[:user_id] = 2
1478 1478 get :new, :project_id => 1, :tracker_id => 1
1479 1479 assert_response :success
1480 1480 assert_template 'new'
1481 1481
1482 1482 assert_tag :tag => 'input', :attributes => { :name => 'issue[start_date]',
1483 1483 :value => Date.today.to_s }
1484 1484 end
1485 1485
1486 1486 def test_get_new_form_should_allow_attachment_upload
1487 1487 @request.session[:user_id] = 2
1488 1488 get :new, :project_id => 1, :tracker_id => 1
1489 1489
1490 1490 assert_select 'form[id=issue-form][method=post][enctype=multipart/form-data]' do
1491 1491 assert_select 'input[name=?][type=file]', 'attachments[1][file]'
1492 1492 assert_select 'input[name=?][maxlength=255]', 'attachments[1][description]'
1493 1493 end
1494 1494 end
1495 1495
1496 1496 def test_get_new_should_prefill_the_form_from_params
1497 1497 @request.session[:user_id] = 2
1498 1498 get :new, :project_id => 1,
1499 1499 :issue => {:tracker_id => 3, :description => 'Prefilled', :custom_field_values => {'2' => 'Custom field value'}}
1500 1500
1501 1501 issue = assigns(:issue)
1502 1502 assert_equal 3, issue.tracker_id
1503 1503 assert_equal 'Prefilled', issue.description
1504 1504 assert_equal 'Custom field value', issue.custom_field_value(2)
1505 1505
1506 1506 assert_tag 'select',
1507 1507 :attributes => {:name => 'issue[tracker_id]'},
1508 1508 :child => {:tag => 'option', :attributes => {:value => '3', :selected => 'selected'}}
1509 1509 assert_tag 'textarea',
1510 1510 :attributes => {:name => 'issue[description]'}, :content => "\nPrefilled"
1511 1511 assert_tag 'input',
1512 1512 :attributes => {:name => 'issue[custom_field_values][2]', :value => 'Custom field value'}
1513 1513 end
1514 1514
1515 1515 def test_get_new_should_mark_required_fields
1516 1516 cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1517 1517 cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1518 1518 WorkflowPermission.delete_all
1519 1519 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'required')
1520 1520 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'required')
1521 1521 @request.session[:user_id] = 2
1522 1522
1523 1523 get :new, :project_id => 1
1524 1524 assert_response :success
1525 1525 assert_template 'new'
1526 1526
1527 1527 assert_select 'label[for=issue_start_date]' do
1528 1528 assert_select 'span[class=required]', 0
1529 1529 end
1530 1530 assert_select 'label[for=issue_due_date]' do
1531 1531 assert_select 'span[class=required]'
1532 1532 end
1533 1533 assert_select 'label[for=?]', "issue_custom_field_values_#{cf1.id}" do
1534 1534 assert_select 'span[class=required]', 0
1535 1535 end
1536 1536 assert_select 'label[for=?]', "issue_custom_field_values_#{cf2.id}" do
1537 1537 assert_select 'span[class=required]'
1538 1538 end
1539 1539 end
1540 1540
1541 1541 def test_get_new_should_not_display_readonly_fields
1542 1542 cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1543 1543 cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1544 1544 WorkflowPermission.delete_all
1545 1545 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
1546 1546 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'readonly')
1547 1547 @request.session[:user_id] = 2
1548 1548
1549 1549 get :new, :project_id => 1
1550 1550 assert_response :success
1551 1551 assert_template 'new'
1552 1552
1553 1553 assert_select 'input[name=?]', 'issue[start_date]'
1554 1554 assert_select 'input[name=?]', 'issue[due_date]', 0
1555 1555 assert_select 'input[name=?]', "issue[custom_field_values][#{cf1.id}]"
1556 1556 assert_select 'input[name=?]', "issue[custom_field_values][#{cf2.id}]", 0
1557 1557 end
1558 1558
1559 1559 def test_get_new_without_tracker_id
1560 1560 @request.session[:user_id] = 2
1561 1561 get :new, :project_id => 1
1562 1562 assert_response :success
1563 1563 assert_template 'new'
1564 1564
1565 1565 issue = assigns(:issue)
1566 1566 assert_not_nil issue
1567 1567 assert_equal Project.find(1).trackers.first, issue.tracker
1568 1568 end
1569 1569
1570 1570 def test_get_new_with_no_default_status_should_display_an_error
1571 1571 @request.session[:user_id] = 2
1572 1572 IssueStatus.delete_all
1573 1573
1574 1574 get :new, :project_id => 1
1575 1575 assert_response 500
1576 1576 assert_error_tag :content => /No default issue/
1577 1577 end
1578 1578
1579 1579 def test_get_new_with_no_tracker_should_display_an_error
1580 1580 @request.session[:user_id] = 2
1581 1581 Tracker.delete_all
1582 1582
1583 1583 get :new, :project_id => 1
1584 1584 assert_response 500
1585 1585 assert_error_tag :content => /No tracker/
1586 1586 end
1587 1587
1588 1588 def test_update_new_form
1589 1589 @request.session[:user_id] = 2
1590 1590 xhr :post, :new, :project_id => 1,
1591 1591 :issue => {:tracker_id => 2,
1592 1592 :subject => 'This is the test_new issue',
1593 1593 :description => 'This is the description',
1594 1594 :priority_id => 5}
1595 1595 assert_response :success
1596 1596 assert_template 'update_form'
1597 1597 assert_template 'form'
1598 1598 assert_equal 'text/javascript', response.content_type
1599 1599
1600 1600 issue = assigns(:issue)
1601 1601 assert_kind_of Issue, issue
1602 1602 assert_equal 1, issue.project_id
1603 1603 assert_equal 2, issue.tracker_id
1604 1604 assert_equal 'This is the test_new issue', issue.subject
1605 1605 end
1606 1606
1607 1607 def test_update_new_form_should_propose_transitions_based_on_initial_status
1608 1608 @request.session[:user_id] = 2
1609 1609 WorkflowTransition.delete_all
1610 1610 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2)
1611 1611 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5)
1612 1612 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4)
1613 1613
1614 1614 xhr :post, :new, :project_id => 1,
1615 1615 :issue => {:tracker_id => 1,
1616 1616 :status_id => 5,
1617 1617 :subject => 'This is an issue'}
1618 1618
1619 1619 assert_equal 5, assigns(:issue).status_id
1620 1620 assert_equal [1,2,5], assigns(:allowed_statuses).map(&:id).sort
1621 1621 end
1622 1622
1623 1623 def test_post_create
1624 1624 @request.session[:user_id] = 2
1625 1625 assert_difference 'Issue.count' do
1626 1626 post :create, :project_id => 1,
1627 1627 :issue => {:tracker_id => 3,
1628 1628 :status_id => 2,
1629 1629 :subject => 'This is the test_new issue',
1630 1630 :description => 'This is the description',
1631 1631 :priority_id => 5,
1632 1632 :start_date => '2010-11-07',
1633 1633 :estimated_hours => '',
1634 1634 :custom_field_values => {'2' => 'Value for field 2'}}
1635 1635 end
1636 1636 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
1637 1637
1638 1638 issue = Issue.find_by_subject('This is the test_new issue')
1639 1639 assert_not_nil issue
1640 1640 assert_equal 2, issue.author_id
1641 1641 assert_equal 3, issue.tracker_id
1642 1642 assert_equal 2, issue.status_id
1643 1643 assert_equal Date.parse('2010-11-07'), issue.start_date
1644 1644 assert_nil issue.estimated_hours
1645 1645 v = issue.custom_values.find(:first, :conditions => {:custom_field_id => 2})
1646 1646 assert_not_nil v
1647 1647 assert_equal 'Value for field 2', v.value
1648 1648 end
1649 1649
1650 1650 def test_post_new_with_group_assignment
1651 1651 group = Group.find(11)
1652 1652 project = Project.find(1)
1653 1653 project.members << Member.new(:principal => group, :roles => [Role.givable.first])
1654 1654
1655 1655 with_settings :issue_group_assignment => '1' do
1656 1656 @request.session[:user_id] = 2
1657 1657 assert_difference 'Issue.count' do
1658 1658 post :create, :project_id => project.id,
1659 1659 :issue => {:tracker_id => 3,
1660 1660 :status_id => 1,
1661 1661 :subject => 'This is the test_new_with_group_assignment issue',
1662 1662 :assigned_to_id => group.id}
1663 1663 end
1664 1664 end
1665 1665 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
1666 1666
1667 1667 issue = Issue.find_by_subject('This is the test_new_with_group_assignment issue')
1668 1668 assert_not_nil issue
1669 1669 assert_equal group, issue.assigned_to
1670 1670 end
1671 1671
1672 1672 def test_post_create_without_start_date_and_default_start_date_is_not_creation_date
1673 1673 Setting.default_issue_start_date_to_creation_date = 0
1674 1674
1675 1675 @request.session[:user_id] = 2
1676 1676 assert_difference 'Issue.count' do
1677 1677 post :create, :project_id => 1,
1678 1678 :issue => {:tracker_id => 3,
1679 1679 :status_id => 2,
1680 1680 :subject => 'This is the test_new issue',
1681 1681 :description => 'This is the description',
1682 1682 :priority_id => 5,
1683 1683 :estimated_hours => '',
1684 1684 :custom_field_values => {'2' => 'Value for field 2'}}
1685 1685 end
1686 1686 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
1687 1687
1688 1688 issue = Issue.find_by_subject('This is the test_new issue')
1689 1689 assert_not_nil issue
1690 1690 assert_nil issue.start_date
1691 1691 end
1692 1692
1693 1693 def test_post_create_without_start_date_and_default_start_date_is_creation_date
1694 1694 Setting.default_issue_start_date_to_creation_date = 1
1695 1695
1696 1696 @request.session[:user_id] = 2
1697 1697 assert_difference 'Issue.count' do
1698 1698 post :create, :project_id => 1,
1699 1699 :issue => {:tracker_id => 3,
1700 1700 :status_id => 2,
1701 1701 :subject => 'This is the test_new issue',
1702 1702 :description => 'This is the description',
1703 1703 :priority_id => 5,
1704 1704 :estimated_hours => '',
1705 1705 :custom_field_values => {'2' => 'Value for field 2'}}
1706 1706 end
1707 1707 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
1708 1708
1709 1709 issue = Issue.find_by_subject('This is the test_new issue')
1710 1710 assert_not_nil issue
1711 1711 assert_equal Date.today, issue.start_date
1712 1712 end
1713 1713
1714 1714 def test_post_create_and_continue
1715 1715 @request.session[:user_id] = 2
1716 1716 assert_difference 'Issue.count' do
1717 1717 post :create, :project_id => 1,
1718 1718 :issue => {:tracker_id => 3, :subject => 'This is first issue', :priority_id => 5},
1719 1719 :continue => ''
1720 1720 end
1721 1721
1722 1722 issue = Issue.first(:order => 'id DESC')
1723 1723 assert_redirected_to :controller => 'issues', :action => 'new', :project_id => 'ecookbook', :issue => {:tracker_id => 3}
1724 1724 assert_not_nil flash[:notice], "flash was not set"
1725 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 1726 end
1727 1727
1728 1728 def test_post_create_without_custom_fields_param
1729 1729 @request.session[:user_id] = 2
1730 1730 assert_difference 'Issue.count' do
1731 1731 post :create, :project_id => 1,
1732 1732 :issue => {:tracker_id => 1,
1733 1733 :subject => 'This is the test_new issue',
1734 1734 :description => 'This is the description',
1735 1735 :priority_id => 5}
1736 1736 end
1737 1737 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
1738 1738 end
1739 1739
1740 1740 def test_post_create_with_multi_custom_field
1741 1741 field = IssueCustomField.find_by_name('Database')
1742 1742 field.update_attribute(:multiple, true)
1743 1743
1744 1744 @request.session[:user_id] = 2
1745 1745 assert_difference 'Issue.count' do
1746 1746 post :create, :project_id => 1,
1747 1747 :issue => {:tracker_id => 1,
1748 1748 :subject => 'This is the test_new issue',
1749 1749 :description => 'This is the description',
1750 1750 :priority_id => 5,
1751 1751 :custom_field_values => {'1' => ['', 'MySQL', 'Oracle']}}
1752 1752 end
1753 1753 assert_response 302
1754 1754 issue = Issue.first(:order => 'id DESC')
1755 1755 assert_equal ['MySQL', 'Oracle'], issue.custom_field_value(1).sort
1756 1756 end
1757 1757
1758 1758 def test_post_create_with_empty_multi_custom_field
1759 1759 field = IssueCustomField.find_by_name('Database')
1760 1760 field.update_attribute(:multiple, true)
1761 1761
1762 1762 @request.session[:user_id] = 2
1763 1763 assert_difference 'Issue.count' do
1764 1764 post :create, :project_id => 1,
1765 1765 :issue => {:tracker_id => 1,
1766 1766 :subject => 'This is the test_new issue',
1767 1767 :description => 'This is the description',
1768 1768 :priority_id => 5,
1769 1769 :custom_field_values => {'1' => ['']}}
1770 1770 end
1771 1771 assert_response 302
1772 1772 issue = Issue.first(:order => 'id DESC')
1773 1773 assert_equal [''], issue.custom_field_value(1).sort
1774 1774 end
1775 1775
1776 1776 def test_post_create_with_multi_user_custom_field
1777 1777 field = IssueCustomField.create!(:name => 'Multi user', :field_format => 'user', :multiple => true,
1778 1778 :tracker_ids => [1], :is_for_all => true)
1779 1779
1780 1780 @request.session[:user_id] = 2
1781 1781 assert_difference 'Issue.count' do
1782 1782 post :create, :project_id => 1,
1783 1783 :issue => {:tracker_id => 1,
1784 1784 :subject => 'This is the test_new issue',
1785 1785 :description => 'This is the description',
1786 1786 :priority_id => 5,
1787 1787 :custom_field_values => {field.id.to_s => ['', '2', '3']}}
1788 1788 end
1789 1789 assert_response 302
1790 1790 issue = Issue.first(:order => 'id DESC')
1791 1791 assert_equal ['2', '3'], issue.custom_field_value(field).sort
1792 1792 end
1793 1793
1794 1794 def test_post_create_with_required_custom_field_and_without_custom_fields_param
1795 1795 field = IssueCustomField.find_by_name('Database')
1796 1796 field.update_attribute(:is_required, true)
1797 1797
1798 1798 @request.session[:user_id] = 2
1799 1799 assert_no_difference 'Issue.count' do
1800 1800 post :create, :project_id => 1,
1801 1801 :issue => {:tracker_id => 1,
1802 1802 :subject => 'This is the test_new issue',
1803 1803 :description => 'This is the description',
1804 1804 :priority_id => 5}
1805 1805 end
1806 1806 assert_response :success
1807 1807 assert_template 'new'
1808 1808 issue = assigns(:issue)
1809 1809 assert_not_nil issue
1810 1810 assert_error_tag :content => /Database can&#x27;t be blank/
1811 1811 end
1812 1812
1813 1813 def test_create_should_validate_required_fields
1814 1814 cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1815 1815 cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1816 1816 WorkflowPermission.delete_all
1817 1817 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => 'due_date', :rule => 'required')
1818 1818 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'required')
1819 1819 @request.session[:user_id] = 2
1820 1820
1821 1821 assert_no_difference 'Issue.count' do
1822 1822 post :create, :project_id => 1, :issue => {
1823 1823 :tracker_id => 2,
1824 1824 :status_id => 1,
1825 1825 :subject => 'Test',
1826 1826 :start_date => '',
1827 1827 :due_date => '',
1828 1828 :custom_field_values => {cf1.id.to_s => '', cf2.id.to_s => ''}
1829 1829 }
1830 1830 assert_response :success
1831 1831 assert_template 'new'
1832 1832 end
1833 1833
1834 1834 assert_error_tag :content => /Due date can&#x27;t be blank/i
1835 1835 assert_error_tag :content => /Bar can&#x27;t be blank/i
1836 1836 end
1837 1837
1838 1838 def test_create_should_ignore_readonly_fields
1839 1839 cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1840 1840 cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1841 1841 WorkflowPermission.delete_all
1842 1842 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
1843 1843 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'readonly')
1844 1844 @request.session[:user_id] = 2
1845 1845
1846 1846 assert_difference 'Issue.count' do
1847 1847 post :create, :project_id => 1, :issue => {
1848 1848 :tracker_id => 2,
1849 1849 :status_id => 1,
1850 1850 :subject => 'Test',
1851 1851 :start_date => '2012-07-14',
1852 1852 :due_date => '2012-07-16',
1853 1853 :custom_field_values => {cf1.id.to_s => 'value1', cf2.id.to_s => 'value2'}
1854 1854 }
1855 1855 assert_response 302
1856 1856 end
1857 1857
1858 1858 issue = Issue.first(:order => 'id DESC')
1859 1859 assert_equal Date.parse('2012-07-14'), issue.start_date
1860 1860 assert_nil issue.due_date
1861 1861 assert_equal 'value1', issue.custom_field_value(cf1)
1862 1862 assert_nil issue.custom_field_value(cf2)
1863 1863 end
1864 1864
1865 1865 def test_post_create_with_watchers
1866 1866 @request.session[:user_id] = 2
1867 1867 ActionMailer::Base.deliveries.clear
1868 1868
1869 1869 assert_difference 'Watcher.count', 2 do
1870 1870 post :create, :project_id => 1,
1871 1871 :issue => {:tracker_id => 1,
1872 1872 :subject => 'This is a new issue with watchers',
1873 1873 :description => 'This is the description',
1874 1874 :priority_id => 5,
1875 1875 :watcher_user_ids => ['2', '3']}
1876 1876 end
1877 1877 issue = Issue.find_by_subject('This is a new issue with watchers')
1878 1878 assert_not_nil issue
1879 1879 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
1880 1880
1881 1881 # Watchers added
1882 1882 assert_equal [2, 3], issue.watcher_user_ids.sort
1883 1883 assert issue.watched_by?(User.find(3))
1884 1884 # Watchers notified
1885 1885 mail = ActionMailer::Base.deliveries.last
1886 1886 assert_not_nil mail
1887 1887 assert [mail.bcc, mail.cc].flatten.include?(User.find(3).mail)
1888 1888 end
1889 1889
1890 1890 def test_post_create_subissue
1891 1891 @request.session[:user_id] = 2
1892 1892
1893 1893 assert_difference 'Issue.count' do
1894 1894 post :create, :project_id => 1,
1895 1895 :issue => {:tracker_id => 1,
1896 1896 :subject => 'This is a child issue',
1897 1897 :parent_issue_id => 2}
1898 1898 end
1899 1899 issue = Issue.find_by_subject('This is a child issue')
1900 1900 assert_not_nil issue
1901 1901 assert_equal Issue.find(2), issue.parent
1902 1902 end
1903 1903
1904 1904 def test_post_create_subissue_with_non_numeric_parent_id
1905 1905 @request.session[:user_id] = 2
1906 1906
1907 1907 assert_difference 'Issue.count' do
1908 1908 post :create, :project_id => 1,
1909 1909 :issue => {:tracker_id => 1,
1910 1910 :subject => 'This is a child issue',
1911 1911 :parent_issue_id => 'ABC'}
1912 1912 end
1913 1913 issue = Issue.find_by_subject('This is a child issue')
1914 1914 assert_not_nil issue
1915 1915 assert_nil issue.parent
1916 1916 end
1917 1917
1918 1918 def test_post_create_private
1919 1919 @request.session[:user_id] = 2
1920 1920
1921 1921 assert_difference 'Issue.count' do
1922 1922 post :create, :project_id => 1,
1923 1923 :issue => {:tracker_id => 1,
1924 1924 :subject => 'This is a private issue',
1925 1925 :is_private => '1'}
1926 1926 end
1927 1927 issue = Issue.first(:order => 'id DESC')
1928 1928 assert issue.is_private?
1929 1929 end
1930 1930
1931 1931 def test_post_create_private_with_set_own_issues_private_permission
1932 1932 role = Role.find(1)
1933 1933 role.remove_permission! :set_issues_private
1934 1934 role.add_permission! :set_own_issues_private
1935 1935
1936 1936 @request.session[:user_id] = 2
1937 1937
1938 1938 assert_difference 'Issue.count' do
1939 1939 post :create, :project_id => 1,
1940 1940 :issue => {:tracker_id => 1,
1941 1941 :subject => 'This is a private issue',
1942 1942 :is_private => '1'}
1943 1943 end
1944 1944 issue = Issue.first(:order => 'id DESC')
1945 1945 assert issue.is_private?
1946 1946 end
1947 1947
1948 1948 def test_post_create_should_send_a_notification
1949 1949 ActionMailer::Base.deliveries.clear
1950 1950 @request.session[:user_id] = 2
1951 1951 assert_difference 'Issue.count' do
1952 1952 post :create, :project_id => 1,
1953 1953 :issue => {:tracker_id => 3,
1954 1954 :subject => 'This is the test_new issue',
1955 1955 :description => 'This is the description',
1956 1956 :priority_id => 5,
1957 1957 :estimated_hours => '',
1958 1958 :custom_field_values => {'2' => 'Value for field 2'}}
1959 1959 end
1960 1960 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
1961 1961
1962 1962 assert_equal 1, ActionMailer::Base.deliveries.size
1963 1963 end
1964 1964
1965 1965 def test_post_create_should_preserve_fields_values_on_validation_failure
1966 1966 @request.session[:user_id] = 2
1967 1967 post :create, :project_id => 1,
1968 1968 :issue => {:tracker_id => 1,
1969 1969 # empty subject
1970 1970 :subject => '',
1971 1971 :description => 'This is a description',
1972 1972 :priority_id => 6,
1973 1973 :custom_field_values => {'1' => 'Oracle', '2' => 'Value for field 2'}}
1974 1974 assert_response :success
1975 1975 assert_template 'new'
1976 1976
1977 1977 assert_tag :textarea, :attributes => { :name => 'issue[description]' },
1978 1978 :content => "\nThis is a description"
1979 1979 assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
1980 1980 :child => { :tag => 'option', :attributes => { :selected => 'selected',
1981 1981 :value => '6' },
1982 1982 :content => 'High' }
1983 1983 # Custom fields
1984 1984 assert_tag :select, :attributes => { :name => 'issue[custom_field_values][1]' },
1985 1985 :child => { :tag => 'option', :attributes => { :selected => 'selected',
1986 1986 :value => 'Oracle' },
1987 1987 :content => 'Oracle' }
1988 1988 assert_tag :input, :attributes => { :name => 'issue[custom_field_values][2]',
1989 1989 :value => 'Value for field 2'}
1990 1990 end
1991 1991
1992 1992 def test_post_create_with_failure_should_preserve_watchers
1993 1993 assert !User.find(8).member_of?(Project.find(1))
1994 1994
1995 1995 @request.session[:user_id] = 2
1996 1996 post :create, :project_id => 1,
1997 1997 :issue => {:tracker_id => 1,
1998 1998 :watcher_user_ids => ['3', '8']}
1999 1999 assert_response :success
2000 2000 assert_template 'new'
2001 2001
2002 2002 assert_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]', :value => '2', :checked => nil}
2003 2003 assert_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]', :value => '3', :checked => 'checked'}
2004 2004 assert_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]', :value => '8', :checked => 'checked'}
2005 2005 end
2006 2006
2007 2007 def test_post_create_should_ignore_non_safe_attributes
2008 2008 @request.session[:user_id] = 2
2009 2009 assert_nothing_raised do
2010 2010 post :create, :project_id => 1, :issue => { :tracker => "A param can not be a Tracker" }
2011 2011 end
2012 2012 end
2013 2013
2014 2014 def test_post_create_with_attachment
2015 2015 set_tmp_attachments_directory
2016 2016 @request.session[:user_id] = 2
2017 2017
2018 2018 assert_difference 'Issue.count' do
2019 2019 assert_difference 'Attachment.count' do
2020 2020 post :create, :project_id => 1,
2021 2021 :issue => { :tracker_id => '1', :subject => 'With attachment' },
2022 2022 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
2023 2023 end
2024 2024 end
2025 2025
2026 2026 issue = Issue.first(:order => 'id DESC')
2027 2027 attachment = Attachment.first(:order => 'id DESC')
2028 2028
2029 2029 assert_equal issue, attachment.container
2030 2030 assert_equal 2, attachment.author_id
2031 2031 assert_equal 'testfile.txt', attachment.filename
2032 2032 assert_equal 'text/plain', attachment.content_type
2033 2033 assert_equal 'test file', attachment.description
2034 2034 assert_equal 59, attachment.filesize
2035 2035 assert File.exists?(attachment.diskfile)
2036 2036 assert_equal 59, File.size(attachment.diskfile)
2037 2037 end
2038 2038
2039 2039 def test_post_create_with_failure_should_save_attachments
2040 2040 set_tmp_attachments_directory
2041 2041 @request.session[:user_id] = 2
2042 2042
2043 2043 assert_no_difference 'Issue.count' do
2044 2044 assert_difference 'Attachment.count' do
2045 2045 post :create, :project_id => 1,
2046 2046 :issue => { :tracker_id => '1', :subject => '' },
2047 2047 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
2048 2048 assert_response :success
2049 2049 assert_template 'new'
2050 2050 end
2051 2051 end
2052 2052
2053 2053 attachment = Attachment.first(:order => 'id DESC')
2054 2054 assert_equal 'testfile.txt', attachment.filename
2055 2055 assert File.exists?(attachment.diskfile)
2056 2056 assert_nil attachment.container
2057 2057
2058 2058 assert_tag 'input', :attributes => {:name => 'attachments[p0][token]', :value => attachment.token}
2059 2059 assert_tag 'span', :content => /testfile.txt/
2060 2060 end
2061 2061
2062 2062 def test_post_create_with_failure_should_keep_saved_attachments
2063 2063 set_tmp_attachments_directory
2064 2064 attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2)
2065 2065 @request.session[:user_id] = 2
2066 2066
2067 2067 assert_no_difference 'Issue.count' do
2068 2068 assert_no_difference 'Attachment.count' do
2069 2069 post :create, :project_id => 1,
2070 2070 :issue => { :tracker_id => '1', :subject => '' },
2071 2071 :attachments => {'p0' => {'token' => attachment.token}}
2072 2072 assert_response :success
2073 2073 assert_template 'new'
2074 2074 end
2075 2075 end
2076 2076
2077 2077 assert_tag 'input', :attributes => {:name => 'attachments[p0][token]', :value => attachment.token}
2078 2078 assert_tag 'span', :content => /testfile.txt/
2079 2079 end
2080 2080
2081 2081 def test_post_create_should_attach_saved_attachments
2082 2082 set_tmp_attachments_directory
2083 2083 attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2)
2084 2084 @request.session[:user_id] = 2
2085 2085
2086 2086 assert_difference 'Issue.count' do
2087 2087 assert_no_difference 'Attachment.count' do
2088 2088 post :create, :project_id => 1,
2089 2089 :issue => { :tracker_id => '1', :subject => 'Saved attachments' },
2090 2090 :attachments => {'p0' => {'token' => attachment.token}}
2091 2091 assert_response 302
2092 2092 end
2093 2093 end
2094 2094
2095 2095 issue = Issue.first(:order => 'id DESC')
2096 2096 assert_equal 1, issue.attachments.count
2097 2097
2098 2098 attachment.reload
2099 2099 assert_equal issue, attachment.container
2100 2100 end
2101 2101
2102 2102 context "without workflow privilege" do
2103 2103 setup do
2104 2104 WorkflowTransition.delete_all(["role_id = ?", Role.anonymous.id])
2105 2105 Role.anonymous.add_permission! :add_issues, :add_issue_notes
2106 2106 end
2107 2107
2108 2108 context "#new" do
2109 2109 should "propose default status only" do
2110 2110 get :new, :project_id => 1
2111 2111 assert_response :success
2112 2112 assert_template 'new'
2113 2113 assert_tag :tag => 'select',
2114 2114 :attributes => {:name => 'issue[status_id]'},
2115 2115 :children => {:count => 1},
2116 2116 :child => {:tag => 'option', :attributes => {:value => IssueStatus.default.id.to_s}}
2117 2117 end
2118 2118
2119 2119 should "accept default status" do
2120 2120 assert_difference 'Issue.count' do
2121 2121 post :create, :project_id => 1,
2122 2122 :issue => {:tracker_id => 1,
2123 2123 :subject => 'This is an issue',
2124 2124 :status_id => 1}
2125 2125 end
2126 2126 issue = Issue.last(:order => 'id')
2127 2127 assert_equal IssueStatus.default, issue.status
2128 2128 end
2129 2129
2130 2130 should "ignore unauthorized status" do
2131 2131 assert_difference 'Issue.count' do
2132 2132 post :create, :project_id => 1,
2133 2133 :issue => {:tracker_id => 1,
2134 2134 :subject => 'This is an issue',
2135 2135 :status_id => 3}
2136 2136 end
2137 2137 issue = Issue.last(:order => 'id')
2138 2138 assert_equal IssueStatus.default, issue.status
2139 2139 end
2140 2140 end
2141 2141
2142 2142 context "#update" do
2143 2143 should "ignore status change" do
2144 2144 assert_difference 'Journal.count' do
2145 2145 put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 3}
2146 2146 end
2147 2147 assert_equal 1, Issue.find(1).status_id
2148 2148 end
2149 2149
2150 2150 should "ignore attributes changes" do
2151 2151 assert_difference 'Journal.count' do
2152 2152 put :update, :id => 1, :notes => 'just trying', :issue => {:subject => 'changed', :assigned_to_id => 2}
2153 2153 end
2154 2154 issue = Issue.find(1)
2155 2155 assert_equal "Can't print recipes", issue.subject
2156 2156 assert_nil issue.assigned_to
2157 2157 end
2158 2158 end
2159 2159 end
2160 2160
2161 2161 context "with workflow privilege" do
2162 2162 setup do
2163 2163 WorkflowTransition.delete_all(["role_id = ?", Role.anonymous.id])
2164 2164 WorkflowTransition.create!(:role => Role.anonymous, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3)
2165 2165 WorkflowTransition.create!(:role => Role.anonymous, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4)
2166 2166 Role.anonymous.add_permission! :add_issues, :add_issue_notes
2167 2167 end
2168 2168
2169 2169 context "#update" do
2170 2170 should "accept authorized status" do
2171 2171 assert_difference 'Journal.count' do
2172 2172 put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 3}
2173 2173 end
2174 2174 assert_equal 3, Issue.find(1).status_id
2175 2175 end
2176 2176
2177 2177 should "ignore unauthorized status" do
2178 2178 assert_difference 'Journal.count' do
2179 2179 put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 2}
2180 2180 end
2181 2181 assert_equal 1, Issue.find(1).status_id
2182 2182 end
2183 2183
2184 2184 should "accept authorized attributes changes" do
2185 2185 assert_difference 'Journal.count' do
2186 2186 put :update, :id => 1, :notes => 'just trying', :issue => {:assigned_to_id => 2}
2187 2187 end
2188 2188 issue = Issue.find(1)
2189 2189 assert_equal 2, issue.assigned_to_id
2190 2190 end
2191 2191
2192 2192 should "ignore unauthorized attributes changes" do
2193 2193 assert_difference 'Journal.count' do
2194 2194 put :update, :id => 1, :notes => 'just trying', :issue => {:subject => 'changed'}
2195 2195 end
2196 2196 issue = Issue.find(1)
2197 2197 assert_equal "Can't print recipes", issue.subject
2198 2198 end
2199 2199 end
2200 2200
2201 2201 context "and :edit_issues permission" do
2202 2202 setup do
2203 2203 Role.anonymous.add_permission! :add_issues, :edit_issues
2204 2204 end
2205 2205
2206 2206 should "accept authorized status" do
2207 2207 assert_difference 'Journal.count' do
2208 2208 put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 3}
2209 2209 end
2210 2210 assert_equal 3, Issue.find(1).status_id
2211 2211 end
2212 2212
2213 2213 should "ignore unauthorized status" do
2214 2214 assert_difference 'Journal.count' do
2215 2215 put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 2}
2216 2216 end
2217 2217 assert_equal 1, Issue.find(1).status_id
2218 2218 end
2219 2219
2220 2220 should "accept authorized attributes changes" do
2221 2221 assert_difference 'Journal.count' do
2222 2222 put :update, :id => 1, :notes => 'just trying', :issue => {:subject => 'changed', :assigned_to_id => 2}
2223 2223 end
2224 2224 issue = Issue.find(1)
2225 2225 assert_equal "changed", issue.subject
2226 2226 assert_equal 2, issue.assigned_to_id
2227 2227 end
2228 2228 end
2229 2229 end
2230 2230
2231 2231 def test_new_as_copy
2232 2232 @request.session[:user_id] = 2
2233 2233 get :new, :project_id => 1, :copy_from => 1
2234 2234
2235 2235 assert_response :success
2236 2236 assert_template 'new'
2237 2237
2238 2238 assert_not_nil assigns(:issue)
2239 2239 orig = Issue.find(1)
2240 2240 assert_equal 1, assigns(:issue).project_id
2241 2241 assert_equal orig.subject, assigns(:issue).subject
2242 2242 assert assigns(:issue).copy?
2243 2243
2244 2244 assert_tag 'form', :attributes => {:id => 'issue-form', :action => '/projects/ecookbook/issues'}
2245 2245 assert_tag 'select', :attributes => {:name => 'issue[project_id]'}
2246 2246 assert_tag 'select', :attributes => {:name => 'issue[project_id]'},
2247 2247 :child => {:tag => 'option', :attributes => {:value => '1', :selected => 'selected'}, :content => 'eCookbook'}
2248 2248 assert_tag 'select', :attributes => {:name => 'issue[project_id]'},
2249 2249 :child => {:tag => 'option', :attributes => {:value => '2', :selected => nil}, :content => 'OnlineStore'}
2250 2250 assert_tag 'input', :attributes => {:name => 'copy_from', :value => '1'}
2251 2251 end
2252 2252
2253 2253 def test_new_as_copy_with_attachments_should_show_copy_attachments_checkbox
2254 2254 @request.session[:user_id] = 2
2255 2255 issue = Issue.find(3)
2256 2256 assert issue.attachments.count > 0
2257 2257 get :new, :project_id => 1, :copy_from => 3
2258 2258
2259 2259 assert_tag 'input', :attributes => {:name => 'copy_attachments', :type => 'checkbox', :checked => 'checked', :value => '1'}
2260 2260 end
2261 2261
2262 2262 def test_new_as_copy_without_attachments_should_not_show_copy_attachments_checkbox
2263 2263 @request.session[:user_id] = 2
2264 2264 issue = Issue.find(3)
2265 2265 issue.attachments.delete_all
2266 2266 get :new, :project_id => 1, :copy_from => 3
2267 2267
2268 2268 assert_no_tag 'input', :attributes => {:name => 'copy_attachments', :type => 'checkbox', :checked => 'checked', :value => '1'}
2269 2269 end
2270 2270
2271 2271 def test_new_as_copy_with_subtasks_should_show_copy_subtasks_checkbox
2272 2272 @request.session[:user_id] = 2
2273 2273 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
2274 2274 get :new, :project_id => 1, :copy_from => issue.id
2275 2275
2276 2276 assert_select 'input[type=checkbox][name=copy_subtasks][checked=checked][value=1]'
2277 2277 end
2278 2278
2279 2279 def test_new_as_copy_with_invalid_issue_should_respond_with_404
2280 2280 @request.session[:user_id] = 2
2281 2281 get :new, :project_id => 1, :copy_from => 99999
2282 2282 assert_response 404
2283 2283 end
2284 2284
2285 2285 def test_create_as_copy_on_different_project
2286 2286 @request.session[:user_id] = 2
2287 2287 assert_difference 'Issue.count' do
2288 2288 post :create, :project_id => 1, :copy_from => 1,
2289 2289 :issue => {:project_id => '2', :tracker_id => '3', :status_id => '1', :subject => 'Copy'}
2290 2290
2291 2291 assert_not_nil assigns(:issue)
2292 2292 assert assigns(:issue).copy?
2293 2293 end
2294 2294 issue = Issue.first(:order => 'id DESC')
2295 2295 assert_redirected_to "/issues/#{issue.id}"
2296 2296
2297 2297 assert_equal 2, issue.project_id
2298 2298 assert_equal 3, issue.tracker_id
2299 2299 assert_equal 'Copy', issue.subject
2300 2300 end
2301 2301
2302 2302 def test_create_as_copy_should_copy_attachments
2303 2303 @request.session[:user_id] = 2
2304 2304 issue = Issue.find(3)
2305 2305 count = issue.attachments.count
2306 2306 assert count > 0
2307 2307
2308 2308 assert_difference 'Issue.count' do
2309 2309 assert_difference 'Attachment.count', count do
2310 2310 assert_no_difference 'Journal.count' do
2311 2311 post :create, :project_id => 1, :copy_from => 3,
2312 2312 :issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with attachments'},
2313 2313 :copy_attachments => '1'
2314 2314 end
2315 2315 end
2316 2316 end
2317 2317 copy = Issue.first(:order => 'id DESC')
2318 2318 assert_equal count, copy.attachments.count
2319 2319 assert_equal issue.attachments.map(&:filename).sort, copy.attachments.map(&:filename).sort
2320 2320 end
2321 2321
2322 2322 def test_create_as_copy_without_copy_attachments_option_should_not_copy_attachments
2323 2323 @request.session[:user_id] = 2
2324 2324 issue = Issue.find(3)
2325 2325 count = issue.attachments.count
2326 2326 assert count > 0
2327 2327
2328 2328 assert_difference 'Issue.count' do
2329 2329 assert_no_difference 'Attachment.count' do
2330 2330 assert_no_difference 'Journal.count' do
2331 2331 post :create, :project_id => 1, :copy_from => 3,
2332 2332 :issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with attachments'}
2333 2333 end
2334 2334 end
2335 2335 end
2336 2336 copy = Issue.first(:order => 'id DESC')
2337 2337 assert_equal 0, copy.attachments.count
2338 2338 end
2339 2339
2340 2340 def test_create_as_copy_with_attachments_should_add_new_files
2341 2341 @request.session[:user_id] = 2
2342 2342 issue = Issue.find(3)
2343 2343 count = issue.attachments.count
2344 2344 assert count > 0
2345 2345
2346 2346 assert_difference 'Issue.count' do
2347 2347 assert_difference 'Attachment.count', count + 1 do
2348 2348 assert_no_difference 'Journal.count' do
2349 2349 post :create, :project_id => 1, :copy_from => 3,
2350 2350 :issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with attachments'},
2351 2351 :copy_attachments => '1',
2352 2352 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
2353 2353 end
2354 2354 end
2355 2355 end
2356 2356 copy = Issue.first(:order => 'id DESC')
2357 2357 assert_equal count + 1, copy.attachments.count
2358 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 2373 def test_create_as_copy_should_copy_subtasks
2361 2374 @request.session[:user_id] = 2
2362 2375 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
2363 2376 count = issue.descendants.count
2364 2377
2365 2378 assert_difference 'Issue.count', count+1 do
2366 2379 assert_no_difference 'Journal.count' do
2367 2380 post :create, :project_id => 1, :copy_from => issue.id,
2368 2381 :issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with subtasks'},
2369 2382 :copy_subtasks => '1'
2370 2383 end
2371 2384 end
2372 2385 copy = Issue.where(:parent_id => nil).first(:order => 'id DESC')
2373 2386 assert_equal count, copy.descendants.count
2374 2387 assert_equal issue.descendants.map(&:subject).sort, copy.descendants.map(&:subject).sort
2375 2388 end
2376 2389
2377 2390 def test_create_as_copy_without_copy_subtasks_option_should_not_copy_subtasks
2378 2391 @request.session[:user_id] = 2
2379 2392 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
2380 2393
2381 2394 assert_difference 'Issue.count', 1 do
2382 2395 assert_no_difference 'Journal.count' do
2383 2396 post :create, :project_id => 1, :copy_from => 3,
2384 2397 :issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with subtasks'}
2385 2398 end
2386 2399 end
2387 2400 copy = Issue.where(:parent_id => nil).first(:order => 'id DESC')
2388 2401 assert_equal 0, copy.descendants.count
2389 2402 end
2390 2403
2391 2404 def test_create_as_copy_with_failure
2392 2405 @request.session[:user_id] = 2
2393 2406 post :create, :project_id => 1, :copy_from => 1,
2394 2407 :issue => {:project_id => '2', :tracker_id => '3', :status_id => '1', :subject => ''}
2395 2408
2396 2409 assert_response :success
2397 2410 assert_template 'new'
2398 2411
2399 2412 assert_not_nil assigns(:issue)
2400 2413 assert assigns(:issue).copy?
2401 2414
2402 2415 assert_tag 'form', :attributes => {:id => 'issue-form', :action => '/projects/ecookbook/issues'}
2403 2416 assert_tag 'select', :attributes => {:name => 'issue[project_id]'}
2404 2417 assert_tag 'select', :attributes => {:name => 'issue[project_id]'},
2405 2418 :child => {:tag => 'option', :attributes => {:value => '1', :selected => nil}, :content => 'eCookbook'}
2406 2419 assert_tag 'select', :attributes => {:name => 'issue[project_id]'},
2407 2420 :child => {:tag => 'option', :attributes => {:value => '2', :selected => 'selected'}, :content => 'OnlineStore'}
2408 2421 assert_tag 'input', :attributes => {:name => 'copy_from', :value => '1'}
2409 2422 end
2410 2423
2411 2424 def test_create_as_copy_on_project_without_permission_should_ignore_target_project
2412 2425 @request.session[:user_id] = 2
2413 2426 assert !User.find(2).member_of?(Project.find(4))
2414 2427
2415 2428 assert_difference 'Issue.count' do
2416 2429 post :create, :project_id => 1, :copy_from => 1,
2417 2430 :issue => {:project_id => '4', :tracker_id => '3', :status_id => '1', :subject => 'Copy'}
2418 2431 end
2419 2432 issue = Issue.first(:order => 'id DESC')
2420 2433 assert_equal 1, issue.project_id
2421 2434 end
2422 2435
2423 2436 def test_get_edit
2424 2437 @request.session[:user_id] = 2
2425 2438 get :edit, :id => 1
2426 2439 assert_response :success
2427 2440 assert_template 'edit'
2428 2441 assert_not_nil assigns(:issue)
2429 2442 assert_equal Issue.find(1), assigns(:issue)
2430 2443
2431 2444 # Be sure we don't display inactive IssuePriorities
2432 2445 assert ! IssuePriority.find(15).active?
2433 2446 assert_no_tag :option, :attributes => {:value => '15'},
2434 2447 :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} }
2435 2448 end
2436 2449
2437 2450 def test_get_edit_should_display_the_time_entry_form_with_log_time_permission
2438 2451 @request.session[:user_id] = 2
2439 2452 Role.find_by_name('Manager').update_attribute :permissions, [:view_issues, :edit_issues, :log_time]
2440 2453
2441 2454 get :edit, :id => 1
2442 2455 assert_tag 'input', :attributes => {:name => 'time_entry[hours]'}
2443 2456 end
2444 2457
2445 2458 def test_get_edit_should_not_display_the_time_entry_form_without_log_time_permission
2446 2459 @request.session[:user_id] = 2
2447 2460 Role.find_by_name('Manager').remove_permission! :log_time
2448 2461
2449 2462 get :edit, :id => 1
2450 2463 assert_no_tag 'input', :attributes => {:name => 'time_entry[hours]'}
2451 2464 end
2452 2465
2453 2466 def test_get_edit_with_params
2454 2467 @request.session[:user_id] = 2
2455 2468 get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 },
2456 2469 :time_entry => { :hours => '2.5', :comments => 'test_get_edit_with_params', :activity_id => TimeEntryActivity.first.id }
2457 2470 assert_response :success
2458 2471 assert_template 'edit'
2459 2472
2460 2473 issue = assigns(:issue)
2461 2474 assert_not_nil issue
2462 2475
2463 2476 assert_equal 5, issue.status_id
2464 2477 assert_tag :select, :attributes => { :name => 'issue[status_id]' },
2465 2478 :child => { :tag => 'option',
2466 2479 :content => 'Closed',
2467 2480 :attributes => { :selected => 'selected' } }
2468 2481
2469 2482 assert_equal 7, issue.priority_id
2470 2483 assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
2471 2484 :child => { :tag => 'option',
2472 2485 :content => 'Urgent',
2473 2486 :attributes => { :selected => 'selected' } }
2474 2487
2475 2488 assert_tag :input, :attributes => { :name => 'time_entry[hours]', :value => '2.5' }
2476 2489 assert_tag :select, :attributes => { :name => 'time_entry[activity_id]' },
2477 2490 :child => { :tag => 'option',
2478 2491 :attributes => { :selected => 'selected', :value => TimeEntryActivity.first.id } }
2479 2492 assert_tag :input, :attributes => { :name => 'time_entry[comments]', :value => 'test_get_edit_with_params' }
2480 2493 end
2481 2494
2482 2495 def test_get_edit_with_multi_custom_field
2483 2496 field = CustomField.find(1)
2484 2497 field.update_attribute :multiple, true
2485 2498 issue = Issue.find(1)
2486 2499 issue.custom_field_values = {1 => ['MySQL', 'Oracle']}
2487 2500 issue.save!
2488 2501
2489 2502 @request.session[:user_id] = 2
2490 2503 get :edit, :id => 1
2491 2504 assert_response :success
2492 2505 assert_template 'edit'
2493 2506
2494 2507 assert_tag 'select', :attributes => {:name => 'issue[custom_field_values][1][]', :multiple => 'multiple'}
2495 2508 assert_tag 'select', :attributes => {:name => 'issue[custom_field_values][1][]'},
2496 2509 :child => {:tag => 'option', :attributes => {:value => 'MySQL', :selected => 'selected'}}
2497 2510 assert_tag 'select', :attributes => {:name => 'issue[custom_field_values][1][]'},
2498 2511 :child => {:tag => 'option', :attributes => {:value => 'PostgreSQL', :selected => nil}}
2499 2512 assert_tag 'select', :attributes => {:name => 'issue[custom_field_values][1][]'},
2500 2513 :child => {:tag => 'option', :attributes => {:value => 'Oracle', :selected => 'selected'}}
2501 2514 end
2502 2515
2503 2516 def test_update_edit_form
2504 2517 @request.session[:user_id] = 2
2505 2518 xhr :put, :new, :project_id => 1,
2506 2519 :id => 1,
2507 2520 :issue => {:tracker_id => 2,
2508 2521 :subject => 'This is the test_new issue',
2509 2522 :description => 'This is the description',
2510 2523 :priority_id => 5}
2511 2524 assert_response :success
2512 2525 assert_equal 'text/javascript', response.content_type
2513 2526 assert_template 'update_form'
2514 2527 assert_template 'form'
2515 2528
2516 2529 issue = assigns(:issue)
2517 2530 assert_kind_of Issue, issue
2518 2531 assert_equal 1, issue.id
2519 2532 assert_equal 1, issue.project_id
2520 2533 assert_equal 2, issue.tracker_id
2521 2534 assert_equal 'This is the test_new issue', issue.subject
2522 2535 end
2523 2536
2524 2537 def test_update_edit_form_should_propose_transitions_based_on_initial_status
2525 2538 @request.session[:user_id] = 2
2526 2539 WorkflowTransition.delete_all
2527 2540 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 1)
2528 2541 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 5)
2529 2542 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 5, :new_status_id => 4)
2530 2543
2531 2544 xhr :put, :new, :project_id => 1,
2532 2545 :id => 2,
2533 2546 :issue => {:tracker_id => 2,
2534 2547 :status_id => 5,
2535 2548 :subject => 'This is an issue'}
2536 2549
2537 2550 assert_equal 5, assigns(:issue).status_id
2538 2551 assert_equal [1,2,5], assigns(:allowed_statuses).map(&:id).sort
2539 2552 end
2540 2553
2541 2554 def test_update_edit_form_with_project_change
2542 2555 @request.session[:user_id] = 2
2543 2556 xhr :put, :new, :project_id => 1,
2544 2557 :id => 1,
2545 2558 :issue => {:project_id => 2,
2546 2559 :tracker_id => 2,
2547 2560 :subject => 'This is the test_new issue',
2548 2561 :description => 'This is the description',
2549 2562 :priority_id => 5}
2550 2563 assert_response :success
2551 2564 assert_template 'form'
2552 2565
2553 2566 issue = assigns(:issue)
2554 2567 assert_kind_of Issue, issue
2555 2568 assert_equal 1, issue.id
2556 2569 assert_equal 2, issue.project_id
2557 2570 assert_equal 2, issue.tracker_id
2558 2571 assert_equal 'This is the test_new issue', issue.subject
2559 2572 end
2560 2573
2561 2574 def test_put_update_without_custom_fields_param
2562 2575 @request.session[:user_id] = 2
2563 2576 ActionMailer::Base.deliveries.clear
2564 2577
2565 2578 issue = Issue.find(1)
2566 2579 assert_equal '125', issue.custom_value_for(2).value
2567 2580 old_subject = issue.subject
2568 2581 new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
2569 2582
2570 2583 assert_difference('Journal.count') do
2571 2584 assert_difference('JournalDetail.count', 2) do
2572 2585 put :update, :id => 1, :issue => {:subject => new_subject,
2573 2586 :priority_id => '6',
2574 2587 :category_id => '1' # no change
2575 2588 }
2576 2589 end
2577 2590 end
2578 2591 assert_redirected_to :action => 'show', :id => '1'
2579 2592 issue.reload
2580 2593 assert_equal new_subject, issue.subject
2581 2594 # Make sure custom fields were not cleared
2582 2595 assert_equal '125', issue.custom_value_for(2).value
2583 2596
2584 2597 mail = ActionMailer::Base.deliveries.last
2585 2598 assert_not_nil mail
2586 2599 assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
2587 2600 assert_mail_body_match "Subject changed from #{old_subject} to #{new_subject}", mail
2588 2601 end
2589 2602
2590 2603 def test_put_update_with_project_change
2591 2604 @request.session[:user_id] = 2
2592 2605 ActionMailer::Base.deliveries.clear
2593 2606
2594 2607 assert_difference('Journal.count') do
2595 2608 assert_difference('JournalDetail.count', 3) do
2596 2609 put :update, :id => 1, :issue => {:project_id => '2',
2597 2610 :tracker_id => '1', # no change
2598 2611 :priority_id => '6',
2599 2612 :category_id => '3'
2600 2613 }
2601 2614 end
2602 2615 end
2603 2616 assert_redirected_to :action => 'show', :id => '1'
2604 2617 issue = Issue.find(1)
2605 2618 assert_equal 2, issue.project_id
2606 2619 assert_equal 1, issue.tracker_id
2607 2620 assert_equal 6, issue.priority_id
2608 2621 assert_equal 3, issue.category_id
2609 2622
2610 2623 mail = ActionMailer::Base.deliveries.last
2611 2624 assert_not_nil mail
2612 2625 assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
2613 2626 assert_mail_body_match "Project changed from eCookbook to OnlineStore", mail
2614 2627 end
2615 2628
2616 2629 def test_put_update_with_tracker_change
2617 2630 @request.session[:user_id] = 2
2618 2631 ActionMailer::Base.deliveries.clear
2619 2632
2620 2633 assert_difference('Journal.count') do
2621 2634 assert_difference('JournalDetail.count', 2) do
2622 2635 put :update, :id => 1, :issue => {:project_id => '1',
2623 2636 :tracker_id => '2',
2624 2637 :priority_id => '6'
2625 2638 }
2626 2639 end
2627 2640 end
2628 2641 assert_redirected_to :action => 'show', :id => '1'
2629 2642 issue = Issue.find(1)
2630 2643 assert_equal 1, issue.project_id
2631 2644 assert_equal 2, issue.tracker_id
2632 2645 assert_equal 6, issue.priority_id
2633 2646 assert_equal 1, issue.category_id
2634 2647
2635 2648 mail = ActionMailer::Base.deliveries.last
2636 2649 assert_not_nil mail
2637 2650 assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
2638 2651 assert_mail_body_match "Tracker changed from Bug to Feature request", mail
2639 2652 end
2640 2653
2641 2654 def test_put_update_with_custom_field_change
2642 2655 @request.session[:user_id] = 2
2643 2656 issue = Issue.find(1)
2644 2657 assert_equal '125', issue.custom_value_for(2).value
2645 2658
2646 2659 assert_difference('Journal.count') do
2647 2660 assert_difference('JournalDetail.count', 3) do
2648 2661 put :update, :id => 1, :issue => {:subject => 'Custom field change',
2649 2662 :priority_id => '6',
2650 2663 :category_id => '1', # no change
2651 2664 :custom_field_values => { '2' => 'New custom value' }
2652 2665 }
2653 2666 end
2654 2667 end
2655 2668 assert_redirected_to :action => 'show', :id => '1'
2656 2669 issue.reload
2657 2670 assert_equal 'New custom value', issue.custom_value_for(2).value
2658 2671
2659 2672 mail = ActionMailer::Base.deliveries.last
2660 2673 assert_not_nil mail
2661 2674 assert_mail_body_match "Searchable field changed from 125 to New custom value", mail
2662 2675 end
2663 2676
2664 2677 def test_put_update_with_multi_custom_field_change
2665 2678 field = CustomField.find(1)
2666 2679 field.update_attribute :multiple, true
2667 2680 issue = Issue.find(1)
2668 2681 issue.custom_field_values = {1 => ['MySQL', 'Oracle']}
2669 2682 issue.save!
2670 2683
2671 2684 @request.session[:user_id] = 2
2672 2685 assert_difference('Journal.count') do
2673 2686 assert_difference('JournalDetail.count', 3) do
2674 2687 put :update, :id => 1,
2675 2688 :issue => {
2676 2689 :subject => 'Custom field change',
2677 2690 :custom_field_values => { '1' => ['', 'Oracle', 'PostgreSQL'] }
2678 2691 }
2679 2692 end
2680 2693 end
2681 2694 assert_redirected_to :action => 'show', :id => '1'
2682 2695 assert_equal ['Oracle', 'PostgreSQL'], Issue.find(1).custom_field_value(1).sort
2683 2696 end
2684 2697
2685 2698 def test_put_update_with_status_and_assignee_change
2686 2699 issue = Issue.find(1)
2687 2700 assert_equal 1, issue.status_id
2688 2701 @request.session[:user_id] = 2
2689 2702 assert_difference('TimeEntry.count', 0) do
2690 2703 put :update,
2691 2704 :id => 1,
2692 2705 :issue => { :status_id => 2, :assigned_to_id => 3 },
2693 2706 :notes => 'Assigned to dlopper',
2694 2707 :time_entry => { :hours => '', :comments => '', :activity_id => TimeEntryActivity.first }
2695 2708 end
2696 2709 assert_redirected_to :action => 'show', :id => '1'
2697 2710 issue.reload
2698 2711 assert_equal 2, issue.status_id
2699 2712 j = Journal.find(:first, :order => 'id DESC')
2700 2713 assert_equal 'Assigned to dlopper', j.notes
2701 2714 assert_equal 2, j.details.size
2702 2715
2703 2716 mail = ActionMailer::Base.deliveries.last
2704 2717 assert_mail_body_match "Status changed from New to Assigned", mail
2705 2718 # subject should contain the new status
2706 2719 assert mail.subject.include?("(#{ IssueStatus.find(2).name })")
2707 2720 end
2708 2721
2709 2722 def test_put_update_with_note_only
2710 2723 notes = 'Note added by IssuesControllerTest#test_update_with_note_only'
2711 2724 # anonymous user
2712 2725 put :update,
2713 2726 :id => 1,
2714 2727 :notes => notes
2715 2728 assert_redirected_to :action => 'show', :id => '1'
2716 2729 j = Journal.find(:first, :order => 'id DESC')
2717 2730 assert_equal notes, j.notes
2718 2731 assert_equal 0, j.details.size
2719 2732 assert_equal User.anonymous, j.user
2720 2733
2721 2734 mail = ActionMailer::Base.deliveries.last
2722 2735 assert_mail_body_match notes, mail
2723 2736 end
2724 2737
2725 2738 def test_put_update_with_note_and_spent_time
2726 2739 @request.session[:user_id] = 2
2727 2740 spent_hours_before = Issue.find(1).spent_hours
2728 2741 assert_difference('TimeEntry.count') do
2729 2742 put :update,
2730 2743 :id => 1,
2731 2744 :notes => '2.5 hours added',
2732 2745 :time_entry => { :hours => '2.5', :comments => 'test_put_update_with_note_and_spent_time', :activity_id => TimeEntryActivity.first.id }
2733 2746 end
2734 2747 assert_redirected_to :action => 'show', :id => '1'
2735 2748
2736 2749 issue = Issue.find(1)
2737 2750
2738 2751 j = Journal.find(:first, :order => 'id DESC')
2739 2752 assert_equal '2.5 hours added', j.notes
2740 2753 assert_equal 0, j.details.size
2741 2754
2742 2755 t = issue.time_entries.find_by_comments('test_put_update_with_note_and_spent_time')
2743 2756 assert_not_nil t
2744 2757 assert_equal 2.5, t.hours
2745 2758 assert_equal spent_hours_before + 2.5, issue.spent_hours
2746 2759 end
2747 2760
2748 2761 def test_put_update_with_attachment_only
2749 2762 set_tmp_attachments_directory
2750 2763
2751 2764 # Delete all fixtured journals, a race condition can occur causing the wrong
2752 2765 # journal to get fetched in the next find.
2753 2766 Journal.delete_all
2754 2767
2755 2768 # anonymous user
2756 2769 assert_difference 'Attachment.count' do
2757 2770 put :update, :id => 1,
2758 2771 :notes => '',
2759 2772 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
2760 2773 end
2761 2774
2762 2775 assert_redirected_to :action => 'show', :id => '1'
2763 2776 j = Issue.find(1).journals.find(:first, :order => 'id DESC')
2764 2777 assert j.notes.blank?
2765 2778 assert_equal 1, j.details.size
2766 2779 assert_equal 'testfile.txt', j.details.first.value
2767 2780 assert_equal User.anonymous, j.user
2768 2781
2769 2782 attachment = Attachment.first(:order => 'id DESC')
2770 2783 assert_equal Issue.find(1), attachment.container
2771 2784 assert_equal User.anonymous, attachment.author
2772 2785 assert_equal 'testfile.txt', attachment.filename
2773 2786 assert_equal 'text/plain', attachment.content_type
2774 2787 assert_equal 'test file', attachment.description
2775 2788 assert_equal 59, attachment.filesize
2776 2789 assert File.exists?(attachment.diskfile)
2777 2790 assert_equal 59, File.size(attachment.diskfile)
2778 2791
2779 2792 mail = ActionMailer::Base.deliveries.last
2780 2793 assert_mail_body_match 'testfile.txt', mail
2781 2794 end
2782 2795
2783 2796 def test_put_update_with_failure_should_save_attachments
2784 2797 set_tmp_attachments_directory
2785 2798 @request.session[:user_id] = 2
2786 2799
2787 2800 assert_no_difference 'Journal.count' do
2788 2801 assert_difference 'Attachment.count' do
2789 2802 put :update, :id => 1,
2790 2803 :issue => { :subject => '' },
2791 2804 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
2792 2805 assert_response :success
2793 2806 assert_template 'edit'
2794 2807 end
2795 2808 end
2796 2809
2797 2810 attachment = Attachment.first(:order => 'id DESC')
2798 2811 assert_equal 'testfile.txt', attachment.filename
2799 2812 assert File.exists?(attachment.diskfile)
2800 2813 assert_nil attachment.container
2801 2814
2802 2815 assert_tag 'input', :attributes => {:name => 'attachments[p0][token]', :value => attachment.token}
2803 2816 assert_tag 'span', :content => /testfile.txt/
2804 2817 end
2805 2818
2806 2819 def test_put_update_with_failure_should_keep_saved_attachments
2807 2820 set_tmp_attachments_directory
2808 2821 attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2)
2809 2822 @request.session[:user_id] = 2
2810 2823
2811 2824 assert_no_difference 'Journal.count' do
2812 2825 assert_no_difference 'Attachment.count' do
2813 2826 put :update, :id => 1,
2814 2827 :issue => { :subject => '' },
2815 2828 :attachments => {'p0' => {'token' => attachment.token}}
2816 2829 assert_response :success
2817 2830 assert_template 'edit'
2818 2831 end
2819 2832 end
2820 2833
2821 2834 assert_tag 'input', :attributes => {:name => 'attachments[p0][token]', :value => attachment.token}
2822 2835 assert_tag 'span', :content => /testfile.txt/
2823 2836 end
2824 2837
2825 2838 def test_put_update_should_attach_saved_attachments
2826 2839 set_tmp_attachments_directory
2827 2840 attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2)
2828 2841 @request.session[:user_id] = 2
2829 2842
2830 2843 assert_difference 'Journal.count' do
2831 2844 assert_difference 'JournalDetail.count' do
2832 2845 assert_no_difference 'Attachment.count' do
2833 2846 put :update, :id => 1,
2834 2847 :notes => 'Attachment added',
2835 2848 :attachments => {'p0' => {'token' => attachment.token}}
2836 2849 assert_redirected_to '/issues/1'
2837 2850 end
2838 2851 end
2839 2852 end
2840 2853
2841 2854 attachment.reload
2842 2855 assert_equal Issue.find(1), attachment.container
2843 2856
2844 2857 journal = Journal.first(:order => 'id DESC')
2845 2858 assert_equal 1, journal.details.size
2846 2859 assert_equal 'testfile.txt', journal.details.first.value
2847 2860 end
2848 2861
2849 2862 def test_put_update_with_attachment_that_fails_to_save
2850 2863 set_tmp_attachments_directory
2851 2864
2852 2865 # Delete all fixtured journals, a race condition can occur causing the wrong
2853 2866 # journal to get fetched in the next find.
2854 2867 Journal.delete_all
2855 2868
2856 2869 # Mock out the unsaved attachment
2857 2870 Attachment.any_instance.stubs(:create).returns(Attachment.new)
2858 2871
2859 2872 # anonymous user
2860 2873 put :update,
2861 2874 :id => 1,
2862 2875 :notes => '',
2863 2876 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
2864 2877 assert_redirected_to :action => 'show', :id => '1'
2865 2878 assert_equal '1 file(s) could not be saved.', flash[:warning]
2866 2879 end
2867 2880
2868 2881 def test_put_update_with_no_change
2869 2882 issue = Issue.find(1)
2870 2883 issue.journals.clear
2871 2884 ActionMailer::Base.deliveries.clear
2872 2885
2873 2886 put :update,
2874 2887 :id => 1,
2875 2888 :notes => ''
2876 2889 assert_redirected_to :action => 'show', :id => '1'
2877 2890
2878 2891 issue.reload
2879 2892 assert issue.journals.empty?
2880 2893 # No email should be sent
2881 2894 assert ActionMailer::Base.deliveries.empty?
2882 2895 end
2883 2896
2884 2897 def test_put_update_should_send_a_notification
2885 2898 @request.session[:user_id] = 2
2886 2899 ActionMailer::Base.deliveries.clear
2887 2900 issue = Issue.find(1)
2888 2901 old_subject = issue.subject
2889 2902 new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
2890 2903
2891 2904 put :update, :id => 1, :issue => {:subject => new_subject,
2892 2905 :priority_id => '6',
2893 2906 :category_id => '1' # no change
2894 2907 }
2895 2908 assert_equal 1, ActionMailer::Base.deliveries.size
2896 2909 end
2897 2910
2898 2911 def test_put_update_with_invalid_spent_time_hours_only
2899 2912 @request.session[:user_id] = 2
2900 2913 notes = 'Note added by IssuesControllerTest#test_post_edit_with_invalid_spent_time'
2901 2914
2902 2915 assert_no_difference('Journal.count') do
2903 2916 put :update,
2904 2917 :id => 1,
2905 2918 :notes => notes,
2906 2919 :time_entry => {"comments"=>"", "activity_id"=>"", "hours"=>"2z"}
2907 2920 end
2908 2921 assert_response :success
2909 2922 assert_template 'edit'
2910 2923
2911 2924 assert_error_tag :descendant => {:content => /Activity can&#x27;t be blank/}
2912 2925 assert_tag :textarea, :attributes => { :name => 'notes' }, :content => "\n"+notes
2913 2926 assert_tag :input, :attributes => { :name => 'time_entry[hours]', :value => "2z" }
2914 2927 end
2915 2928
2916 2929 def test_put_update_with_invalid_spent_time_comments_only
2917 2930 @request.session[:user_id] = 2
2918 2931 notes = 'Note added by IssuesControllerTest#test_post_edit_with_invalid_spent_time'
2919 2932
2920 2933 assert_no_difference('Journal.count') do
2921 2934 put :update,
2922 2935 :id => 1,
2923 2936 :notes => notes,
2924 2937 :time_entry => {"comments"=>"this is my comment", "activity_id"=>"", "hours"=>""}
2925 2938 end
2926 2939 assert_response :success
2927 2940 assert_template 'edit'
2928 2941
2929 2942 assert_error_tag :descendant => {:content => /Activity can&#x27;t be blank/}
2930 2943 assert_error_tag :descendant => {:content => /Hours can&#x27;t be blank/}
2931 2944 assert_tag :textarea, :attributes => { :name => 'notes' }, :content => "\n"+notes
2932 2945 assert_tag :input, :attributes => { :name => 'time_entry[comments]', :value => "this is my comment" }
2933 2946 end
2934 2947
2935 2948 def test_put_update_should_allow_fixed_version_to_be_set_to_a_subproject
2936 2949 issue = Issue.find(2)
2937 2950 @request.session[:user_id] = 2
2938 2951
2939 2952 put :update,
2940 2953 :id => issue.id,
2941 2954 :issue => {
2942 2955 :fixed_version_id => 4
2943 2956 }
2944 2957
2945 2958 assert_response :redirect
2946 2959 issue.reload
2947 2960 assert_equal 4, issue.fixed_version_id
2948 2961 assert_not_equal issue.project_id, issue.fixed_version.project_id
2949 2962 end
2950 2963
2951 2964 def test_put_update_should_redirect_back_using_the_back_url_parameter
2952 2965 issue = Issue.find(2)
2953 2966 @request.session[:user_id] = 2
2954 2967
2955 2968 put :update,
2956 2969 :id => issue.id,
2957 2970 :issue => {
2958 2971 :fixed_version_id => 4
2959 2972 },
2960 2973 :back_url => '/issues'
2961 2974
2962 2975 assert_response :redirect
2963 2976 assert_redirected_to '/issues'
2964 2977 end
2965 2978
2966 2979 def test_put_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host
2967 2980 issue = Issue.find(2)
2968 2981 @request.session[:user_id] = 2
2969 2982
2970 2983 put :update,
2971 2984 :id => issue.id,
2972 2985 :issue => {
2973 2986 :fixed_version_id => 4
2974 2987 },
2975 2988 :back_url => 'http://google.com'
2976 2989
2977 2990 assert_response :redirect
2978 2991 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue.id
2979 2992 end
2980 2993
2981 2994 def test_get_bulk_edit
2982 2995 @request.session[:user_id] = 2
2983 2996 get :bulk_edit, :ids => [1, 2]
2984 2997 assert_response :success
2985 2998 assert_template 'bulk_edit'
2986 2999
2987 3000 assert_tag :select, :attributes => {:name => 'issue[project_id]'}
2988 3001 assert_tag :input, :attributes => {:name => 'issue[parent_issue_id]'}
2989 3002
2990 3003 # Project specific custom field, date type
2991 3004 field = CustomField.find(9)
2992 3005 assert !field.is_for_all?
2993 3006 assert_equal 'date', field.field_format
2994 3007 assert_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'}
2995 3008
2996 3009 # System wide custom field
2997 3010 assert CustomField.find(1).is_for_all?
2998 3011 assert_tag :select, :attributes => {:name => 'issue[custom_field_values][1]'}
2999 3012
3000 3013 # Be sure we don't display inactive IssuePriorities
3001 3014 assert ! IssuePriority.find(15).active?
3002 3015 assert_no_tag :option, :attributes => {:value => '15'},
3003 3016 :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} }
3004 3017 end
3005 3018
3006 3019 def test_get_bulk_edit_on_different_projects
3007 3020 @request.session[:user_id] = 2
3008 3021 get :bulk_edit, :ids => [1, 2, 6]
3009 3022 assert_response :success
3010 3023 assert_template 'bulk_edit'
3011 3024
3012 3025 # Can not set issues from different projects as children of an issue
3013 3026 assert_no_tag :input, :attributes => {:name => 'issue[parent_issue_id]'}
3014 3027
3015 3028 # Project specific custom field, date type
3016 3029 field = CustomField.find(9)
3017 3030 assert !field.is_for_all?
3018 3031 assert !field.project_ids.include?(Issue.find(6).project_id)
3019 3032 assert_no_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'}
3020 3033 end
3021 3034
3022 3035 def test_get_bulk_edit_with_user_custom_field
3023 3036 field = IssueCustomField.create!(:name => 'Tester', :field_format => 'user', :is_for_all => true)
3024 3037
3025 3038 @request.session[:user_id] = 2
3026 3039 get :bulk_edit, :ids => [1, 2]
3027 3040 assert_response :success
3028 3041 assert_template 'bulk_edit'
3029 3042
3030 3043 assert_tag :select,
3031 3044 :attributes => {:name => "issue[custom_field_values][#{field.id}]", :class => 'user_cf'},
3032 3045 :children => {
3033 3046 :only => {:tag => 'option'},
3034 3047 :count => Project.find(1).users.count + 2 # "no change" + "none" options
3035 3048 }
3036 3049 end
3037 3050
3038 3051 def test_get_bulk_edit_with_version_custom_field
3039 3052 field = IssueCustomField.create!(:name => 'Affected version', :field_format => 'version', :is_for_all => true)
3040 3053
3041 3054 @request.session[:user_id] = 2
3042 3055 get :bulk_edit, :ids => [1, 2]
3043 3056 assert_response :success
3044 3057 assert_template 'bulk_edit'
3045 3058
3046 3059 assert_tag :select,
3047 3060 :attributes => {:name => "issue[custom_field_values][#{field.id}]"},
3048 3061 :children => {
3049 3062 :only => {:tag => 'option'},
3050 3063 :count => Project.find(1).shared_versions.count + 2 # "no change" + "none" options
3051 3064 }
3052 3065 end
3053 3066
3054 3067 def test_get_bulk_edit_with_multi_custom_field
3055 3068 field = CustomField.find(1)
3056 3069 field.update_attribute :multiple, true
3057 3070
3058 3071 @request.session[:user_id] = 2
3059 3072 get :bulk_edit, :ids => [1, 2]
3060 3073 assert_response :success
3061 3074 assert_template 'bulk_edit'
3062 3075
3063 3076 assert_tag :select,
3064 3077 :attributes => {:name => "issue[custom_field_values][1][]"},
3065 3078 :children => {
3066 3079 :only => {:tag => 'option'},
3067 3080 :count => field.possible_values.size + 1 # "none" options
3068 3081 }
3069 3082 end
3070 3083
3071 3084 def test_bulk_edit_should_only_propose_statuses_allowed_for_all_issues
3072 3085 WorkflowTransition.delete_all
3073 3086 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 1)
3074 3087 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3)
3075 3088 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4)
3076 3089 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 1)
3077 3090 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 3)
3078 3091 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 5)
3079 3092 @request.session[:user_id] = 2
3080 3093 get :bulk_edit, :ids => [1, 2]
3081 3094
3082 3095 assert_response :success
3083 3096 statuses = assigns(:available_statuses)
3084 3097 assert_not_nil statuses
3085 3098 assert_equal [1, 3], statuses.map(&:id).sort
3086 3099
3087 3100 assert_tag 'select', :attributes => {:name => 'issue[status_id]'},
3088 3101 :children => {:count => 3} # 2 statuses + "no change" option
3089 3102 end
3090 3103
3091 3104 def test_bulk_edit_should_propose_target_project_open_shared_versions
3092 3105 @request.session[:user_id] = 2
3093 3106 post :bulk_edit, :ids => [1, 2, 6], :issue => {:project_id => 1}
3094 3107 assert_response :success
3095 3108 assert_template 'bulk_edit'
3096 3109 assert_equal Project.find(1).shared_versions.open.all.sort, assigns(:versions).sort
3097 3110 assert_tag 'select',
3098 3111 :attributes => {:name => 'issue[fixed_version_id]'},
3099 3112 :descendant => {:tag => 'option', :content => '2.0'}
3100 3113 end
3101 3114
3102 3115 def test_bulk_edit_should_propose_target_project_categories
3103 3116 @request.session[:user_id] = 2
3104 3117 post :bulk_edit, :ids => [1, 2, 6], :issue => {:project_id => 1}
3105 3118 assert_response :success
3106 3119 assert_template 'bulk_edit'
3107 3120 assert_equal Project.find(1).issue_categories.sort, assigns(:categories).sort
3108 3121 assert_tag 'select',
3109 3122 :attributes => {:name => 'issue[category_id]'},
3110 3123 :descendant => {:tag => 'option', :content => 'Recipes'}
3111 3124 end
3112 3125
3113 3126 def test_bulk_update
3114 3127 @request.session[:user_id] = 2
3115 3128 # update issues priority
3116 3129 post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing',
3117 3130 :issue => {:priority_id => 7,
3118 3131 :assigned_to_id => '',
3119 3132 :custom_field_values => {'2' => ''}}
3120 3133
3121 3134 assert_response 302
3122 3135 # check that the issues were updated
3123 3136 assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id}
3124 3137
3125 3138 issue = Issue.find(1)
3126 3139 journal = issue.journals.find(:first, :order => 'created_on DESC')
3127 3140 assert_equal '125', issue.custom_value_for(2).value
3128 3141 assert_equal 'Bulk editing', journal.notes
3129 3142 assert_equal 1, journal.details.size
3130 3143 end
3131 3144
3132 3145 def test_bulk_update_with_group_assignee
3133 3146 group = Group.find(11)
3134 3147 project = Project.find(1)
3135 3148 project.members << Member.new(:principal => group, :roles => [Role.givable.first])
3136 3149
3137 3150 @request.session[:user_id] = 2
3138 3151 # update issues assignee
3139 3152 post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing',
3140 3153 :issue => {:priority_id => '',
3141 3154 :assigned_to_id => group.id,
3142 3155 :custom_field_values => {'2' => ''}}
3143 3156
3144 3157 assert_response 302
3145 3158 assert_equal [group, group], Issue.find_all_by_id([1, 2]).collect {|i| i.assigned_to}
3146 3159 end
3147 3160
3148 3161 def test_bulk_update_on_different_projects
3149 3162 @request.session[:user_id] = 2
3150 3163 # update issues priority
3151 3164 post :bulk_update, :ids => [1, 2, 6], :notes => 'Bulk editing',
3152 3165 :issue => {:priority_id => 7,
3153 3166 :assigned_to_id => '',
3154 3167 :custom_field_values => {'2' => ''}}
3155 3168
3156 3169 assert_response 302
3157 3170 # check that the issues were updated
3158 3171 assert_equal [7, 7, 7], Issue.find([1,2,6]).map(&:priority_id)
3159 3172
3160 3173 issue = Issue.find(1)
3161 3174 journal = issue.journals.find(:first, :order => 'created_on DESC')
3162 3175 assert_equal '125', issue.custom_value_for(2).value
3163 3176 assert_equal 'Bulk editing', journal.notes
3164 3177 assert_equal 1, journal.details.size
3165 3178 end
3166 3179
3167 3180 def test_bulk_update_on_different_projects_without_rights
3168 3181 @request.session[:user_id] = 3
3169 3182 user = User.find(3)
3170 3183 action = { :controller => "issues", :action => "bulk_update" }
3171 3184 assert user.allowed_to?(action, Issue.find(1).project)
3172 3185 assert ! user.allowed_to?(action, Issue.find(6).project)
3173 3186 post :bulk_update, :ids => [1, 6], :notes => 'Bulk should fail',
3174 3187 :issue => {:priority_id => 7,
3175 3188 :assigned_to_id => '',
3176 3189 :custom_field_values => {'2' => ''}}
3177 3190 assert_response 403
3178 3191 assert_not_equal "Bulk should fail", Journal.last.notes
3179 3192 end
3180 3193
3181 3194 def test_bullk_update_should_send_a_notification
3182 3195 @request.session[:user_id] = 2
3183 3196 ActionMailer::Base.deliveries.clear
3184 3197 post(:bulk_update,
3185 3198 {
3186 3199 :ids => [1, 2],
3187 3200 :notes => 'Bulk editing',
3188 3201 :issue => {
3189 3202 :priority_id => 7,
3190 3203 :assigned_to_id => '',
3191 3204 :custom_field_values => {'2' => ''}
3192 3205 }
3193 3206 })
3194 3207
3195 3208 assert_response 302
3196 3209 assert_equal 2, ActionMailer::Base.deliveries.size
3197 3210 end
3198 3211
3199 3212 def test_bulk_update_project
3200 3213 @request.session[:user_id] = 2
3201 3214 post :bulk_update, :ids => [1, 2], :issue => {:project_id => '2'}
3202 3215 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
3203 3216 # Issues moved to project 2
3204 3217 assert_equal 2, Issue.find(1).project_id
3205 3218 assert_equal 2, Issue.find(2).project_id
3206 3219 # No tracker change
3207 3220 assert_equal 1, Issue.find(1).tracker_id
3208 3221 assert_equal 2, Issue.find(2).tracker_id
3209 3222 end
3210 3223
3211 3224 def test_bulk_update_project_on_single_issue_should_follow_when_needed
3212 3225 @request.session[:user_id] = 2
3213 3226 post :bulk_update, :id => 1, :issue => {:project_id => '2'}, :follow => '1'
3214 3227 assert_redirected_to '/issues/1'
3215 3228 end
3216 3229
3217 3230 def test_bulk_update_project_on_multiple_issues_should_follow_when_needed
3218 3231 @request.session[:user_id] = 2
3219 3232 post :bulk_update, :id => [1, 2], :issue => {:project_id => '2'}, :follow => '1'
3220 3233 assert_redirected_to '/projects/onlinestore/issues'
3221 3234 end
3222 3235
3223 3236 def test_bulk_update_tracker
3224 3237 @request.session[:user_id] = 2
3225 3238 post :bulk_update, :ids => [1, 2], :issue => {:tracker_id => '2'}
3226 3239 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
3227 3240 assert_equal 2, Issue.find(1).tracker_id
3228 3241 assert_equal 2, Issue.find(2).tracker_id
3229 3242 end
3230 3243
3231 3244 def test_bulk_update_status
3232 3245 @request.session[:user_id] = 2
3233 3246 # update issues priority
3234 3247 post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing status',
3235 3248 :issue => {:priority_id => '',
3236 3249 :assigned_to_id => '',
3237 3250 :status_id => '5'}
3238 3251
3239 3252 assert_response 302
3240 3253 issue = Issue.find(1)
3241 3254 assert issue.closed?
3242 3255 end
3243 3256
3244 3257 def test_bulk_update_priority
3245 3258 @request.session[:user_id] = 2
3246 3259 post :bulk_update, :ids => [1, 2], :issue => {:priority_id => 6}
3247 3260
3248 3261 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
3249 3262 assert_equal 6, Issue.find(1).priority_id
3250 3263 assert_equal 6, Issue.find(2).priority_id
3251 3264 end
3252 3265
3253 3266 def test_bulk_update_with_notes
3254 3267 @request.session[:user_id] = 2
3255 3268 post :bulk_update, :ids => [1, 2], :notes => 'Moving two issues'
3256 3269
3257 3270 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
3258 3271 assert_equal 'Moving two issues', Issue.find(1).journals.sort_by(&:id).last.notes
3259 3272 assert_equal 'Moving two issues', Issue.find(2).journals.sort_by(&:id).last.notes
3260 3273 end
3261 3274
3262 3275 def test_bulk_update_parent_id
3263 3276 @request.session[:user_id] = 2
3264 3277 post :bulk_update, :ids => [1, 3],
3265 3278 :notes => 'Bulk editing parent',
3266 3279 :issue => {:priority_id => '', :assigned_to_id => '', :status_id => '', :parent_issue_id => '2'}
3267 3280
3268 3281 assert_response 302
3269 3282 parent = Issue.find(2)
3270 3283 assert_equal parent.id, Issue.find(1).parent_id
3271 3284 assert_equal parent.id, Issue.find(3).parent_id
3272 3285 assert_equal [1, 3], parent.children.collect(&:id).sort
3273 3286 end
3274 3287
3275 3288 def test_bulk_update_custom_field
3276 3289 @request.session[:user_id] = 2
3277 3290 # update issues priority
3278 3291 post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing custom field',
3279 3292 :issue => {:priority_id => '',
3280 3293 :assigned_to_id => '',
3281 3294 :custom_field_values => {'2' => '777'}}
3282 3295
3283 3296 assert_response 302
3284 3297
3285 3298 issue = Issue.find(1)
3286 3299 journal = issue.journals.find(:first, :order => 'created_on DESC')
3287 3300 assert_equal '777', issue.custom_value_for(2).value
3288 3301 assert_equal 1, journal.details.size
3289 3302 assert_equal '125', journal.details.first.old_value
3290 3303 assert_equal '777', journal.details.first.value
3291 3304 end
3292 3305
3293 3306 def test_bulk_update_custom_field_to_blank
3294 3307 @request.session[:user_id] = 2
3295 3308 post :bulk_update, :ids => [1, 3], :notes => 'Bulk editing custom field',
3296 3309 :issue => {:priority_id => '',
3297 3310 :assigned_to_id => '',
3298 3311 :custom_field_values => {'1' => '__none__'}}
3299 3312 assert_response 302
3300 3313 assert_equal '', Issue.find(1).custom_field_value(1)
3301 3314 assert_equal '', Issue.find(3).custom_field_value(1)
3302 3315 end
3303 3316
3304 3317 def test_bulk_update_multi_custom_field
3305 3318 field = CustomField.find(1)
3306 3319 field.update_attribute :multiple, true
3307 3320
3308 3321 @request.session[:user_id] = 2
3309 3322 post :bulk_update, :ids => [1, 2, 3], :notes => 'Bulk editing multi custom field',
3310 3323 :issue => {:priority_id => '',
3311 3324 :assigned_to_id => '',
3312 3325 :custom_field_values => {'1' => ['MySQL', 'Oracle']}}
3313 3326
3314 3327 assert_response 302
3315 3328
3316 3329 assert_equal ['MySQL', 'Oracle'], Issue.find(1).custom_field_value(1).sort
3317 3330 assert_equal ['MySQL', 'Oracle'], Issue.find(3).custom_field_value(1).sort
3318 3331 # the custom field is not associated with the issue tracker
3319 3332 assert_nil Issue.find(2).custom_field_value(1)
3320 3333 end
3321 3334
3322 3335 def test_bulk_update_multi_custom_field_to_blank
3323 3336 field = CustomField.find(1)
3324 3337 field.update_attribute :multiple, true
3325 3338
3326 3339 @request.session[:user_id] = 2
3327 3340 post :bulk_update, :ids => [1, 3], :notes => 'Bulk editing multi custom field',
3328 3341 :issue => {:priority_id => '',
3329 3342 :assigned_to_id => '',
3330 3343 :custom_field_values => {'1' => ['__none__']}}
3331 3344 assert_response 302
3332 3345 assert_equal [''], Issue.find(1).custom_field_value(1)
3333 3346 assert_equal [''], Issue.find(3).custom_field_value(1)
3334 3347 end
3335 3348
3336 3349 def test_bulk_update_unassign
3337 3350 assert_not_nil Issue.find(2).assigned_to
3338 3351 @request.session[:user_id] = 2
3339 3352 # unassign issues
3340 3353 post :bulk_update, :ids => [1, 2], :notes => 'Bulk unassigning', :issue => {:assigned_to_id => 'none'}
3341 3354 assert_response 302
3342 3355 # check that the issues were updated
3343 3356 assert_nil Issue.find(2).assigned_to
3344 3357 end
3345 3358
3346 3359 def test_post_bulk_update_should_allow_fixed_version_to_be_set_to_a_subproject
3347 3360 @request.session[:user_id] = 2
3348 3361
3349 3362 post :bulk_update, :ids => [1,2], :issue => {:fixed_version_id => 4}
3350 3363
3351 3364 assert_response :redirect
3352 3365 issues = Issue.find([1,2])
3353 3366 issues.each do |issue|
3354 3367 assert_equal 4, issue.fixed_version_id
3355 3368 assert_not_equal issue.project_id, issue.fixed_version.project_id
3356 3369 end
3357 3370 end
3358 3371
3359 3372 def test_post_bulk_update_should_redirect_back_using_the_back_url_parameter
3360 3373 @request.session[:user_id] = 2
3361 3374 post :bulk_update, :ids => [1,2], :back_url => '/issues'
3362 3375
3363 3376 assert_response :redirect
3364 3377 assert_redirected_to '/issues'
3365 3378 end
3366 3379
3367 3380 def test_post_bulk_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host
3368 3381 @request.session[:user_id] = 2
3369 3382 post :bulk_update, :ids => [1,2], :back_url => 'http://google.com'
3370 3383
3371 3384 assert_response :redirect
3372 3385 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => Project.find(1).identifier
3373 3386 end
3374 3387
3375 3388 def test_bulk_update_with_failure_should_set_flash
3376 3389 @request.session[:user_id] = 2
3377 3390 Issue.update_all("subject = ''", "id = 2") # Make it invalid
3378 3391 post :bulk_update, :ids => [1, 2], :issue => {:priority_id => 6}
3379 3392
3380 3393 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
3381 3394 assert_equal 'Failed to save 1 issue(s) on 2 selected: #2.', flash[:error]
3382 3395 end
3383 3396
3384 3397 def test_get_bulk_copy
3385 3398 @request.session[:user_id] = 2
3386 3399 get :bulk_edit, :ids => [1, 2, 3], :copy => '1'
3387 3400 assert_response :success
3388 3401 assert_template 'bulk_edit'
3389 3402
3390 3403 issues = assigns(:issues)
3391 3404 assert_not_nil issues
3392 3405 assert_equal [1, 2, 3], issues.map(&:id).sort
3393 3406
3394 3407 assert_select 'input[name=copy_attachments]'
3395 3408 end
3396 3409
3397 3410 def test_bulk_copy_to_another_project
3398 3411 @request.session[:user_id] = 2
3399 3412 assert_difference 'Issue.count', 2 do
3400 3413 assert_no_difference 'Project.find(1).issues.count' do
3401 3414 post :bulk_update, :ids => [1, 2], :issue => {:project_id => '2'}, :copy => '1'
3402 3415 end
3403 3416 end
3404 3417 assert_redirected_to '/projects/ecookbook/issues'
3405 3418
3406 3419 copies = Issue.all(:order => 'id DESC', :limit => issues.size)
3407 3420 copies.each do |copy|
3408 3421 assert_equal 2, copy.project_id
3409 3422 end
3410 3423 end
3411 3424
3412 3425 def test_bulk_copy_should_allow_not_changing_the_issue_attributes
3413 3426 @request.session[:user_id] = 2
3414 3427 issues = [
3415 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 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 3432 assert_difference 'Issue.count', issues.size do
3420 3433 post :bulk_update, :ids => issues.map(&:id), :copy => '1',
3421 3434 :issue => {
3422 3435 :project_id => '', :tracker_id => '', :assigned_to_id => '',
3423 3436 :status_id => '', :start_date => '', :due_date => ''
3424 3437 }
3425 3438 end
3426 3439
3427 3440 copies = Issue.all(:order => 'id DESC', :limit => issues.size)
3428 3441 issues.each do |orig|
3429 3442 copy = copies.detect {|c| c.subject == orig.subject}
3430 3443 assert_not_nil copy
3431 3444 assert_equal orig.project_id, copy.project_id
3432 3445 assert_equal orig.tracker_id, copy.tracker_id
3433 3446 assert_equal orig.status_id, copy.status_id
3434 3447 assert_equal orig.assigned_to_id, copy.assigned_to_id
3435 3448 assert_equal orig.priority_id, copy.priority_id
3436 3449 end
3437 3450 end
3438 3451
3439 3452 def test_bulk_copy_should_allow_changing_the_issue_attributes
3440 3453 # Fixes random test failure with Mysql
3441 3454 # where Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2})
3442 3455 # doesn't return the expected results
3443 3456 Issue.delete_all("project_id=2")
3444 3457
3445 3458 @request.session[:user_id] = 2
3446 3459 assert_difference 'Issue.count', 2 do
3447 3460 assert_no_difference 'Project.find(1).issues.count' do
3448 3461 post :bulk_update, :ids => [1, 2], :copy => '1',
3449 3462 :issue => {
3450 3463 :project_id => '2', :tracker_id => '', :assigned_to_id => '4',
3451 3464 :status_id => '1', :start_date => '2009-12-01', :due_date => '2009-12-31'
3452 3465 }
3453 3466 end
3454 3467 end
3455 3468
3456 3469 copied_issues = Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2})
3457 3470 assert_equal 2, copied_issues.size
3458 3471 copied_issues.each do |issue|
3459 3472 assert_equal 2, issue.project_id, "Project is incorrect"
3460 3473 assert_equal 4, issue.assigned_to_id, "Assigned to is incorrect"
3461 3474 assert_equal 1, issue.status_id, "Status is incorrect"
3462 3475 assert_equal '2009-12-01', issue.start_date.to_s, "Start date is incorrect"
3463 3476 assert_equal '2009-12-31', issue.due_date.to_s, "Due date is incorrect"
3464 3477 end
3465 3478 end
3466 3479
3467 3480 def test_bulk_copy_should_allow_adding_a_note
3468 3481 @request.session[:user_id] = 2
3469 3482 assert_difference 'Issue.count', 1 do
3470 3483 post :bulk_update, :ids => [1], :copy => '1',
3471 3484 :notes => 'Copying one issue',
3472 3485 :issue => {
3473 3486 :project_id => '', :tracker_id => '', :assigned_to_id => '4',
3474 3487 :status_id => '3', :start_date => '2009-12-01', :due_date => '2009-12-31'
3475 3488 }
3476 3489 end
3477 3490
3478 3491 issue = Issue.first(:order => 'id DESC')
3479 3492 assert_equal 1, issue.journals.size
3480 3493 journal = issue.journals.first
3481 3494 assert_equal 0, journal.details.size
3482 3495 assert_equal 'Copying one issue', journal.notes
3483 3496 end
3484 3497
3485 3498 def test_bulk_copy_should_allow_not_copying_the_attachments
3486 3499 attachment_count = Issue.find(3).attachments.size
3487 3500 assert attachment_count > 0
3488 3501 @request.session[:user_id] = 2
3489 3502
3490 3503 assert_difference 'Issue.count', 1 do
3491 3504 assert_no_difference 'Attachment.count' do
3492 3505 post :bulk_update, :ids => [3], :copy => '1',
3493 3506 :issue => {
3494 3507 :project_id => ''
3495 3508 }
3496 3509 end
3497 3510 end
3498 3511 end
3499 3512
3500 3513 def test_bulk_copy_should_allow_copying_the_attachments
3501 3514 attachment_count = Issue.find(3).attachments.size
3502 3515 assert attachment_count > 0
3503 3516 @request.session[:user_id] = 2
3504 3517
3505 3518 assert_difference 'Issue.count', 1 do
3506 3519 assert_difference 'Attachment.count', attachment_count do
3507 3520 post :bulk_update, :ids => [3], :copy => '1', :copy_attachments => '1',
3508 3521 :issue => {
3509 3522 :project_id => ''
3510 3523 }
3511 3524 end
3512 3525 end
3513 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 3541 def test_bulk_copy_should_allow_not_copying_the_subtasks
3516 3542 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
3517 3543 @request.session[:user_id] = 2
3518 3544
3519 3545 assert_difference 'Issue.count', 1 do
3520 3546 post :bulk_update, :ids => [issue.id], :copy => '1',
3521 3547 :issue => {
3522 3548 :project_id => ''
3523 3549 }
3524 3550 end
3525 3551 end
3526 3552
3527 3553 def test_bulk_copy_should_allow_copying_the_subtasks
3528 3554 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
3529 3555 count = issue.descendants.count
3530 3556 @request.session[:user_id] = 2
3531 3557
3532 3558 assert_difference 'Issue.count', count+1 do
3533 3559 post :bulk_update, :ids => [issue.id], :copy => '1', :copy_subtasks => '1',
3534 3560 :issue => {
3535 3561 :project_id => ''
3536 3562 }
3537 3563 end
3538 3564 copy = Issue.where(:parent_id => nil).order("id DESC").first
3539 3565 assert_equal count, copy.descendants.count
3540 3566 end
3541 3567
3542 3568 def test_bulk_copy_should_not_copy_selected_subtasks_twice
3543 3569 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
3544 3570 count = issue.descendants.count
3545 3571 @request.session[:user_id] = 2
3546 3572
3547 3573 assert_difference 'Issue.count', count+1 do
3548 3574 post :bulk_update, :ids => issue.self_and_descendants.map(&:id), :copy => '1', :copy_subtasks => '1',
3549 3575 :issue => {
3550 3576 :project_id => ''
3551 3577 }
3552 3578 end
3553 3579 copy = Issue.where(:parent_id => nil).order("id DESC").first
3554 3580 assert_equal count, copy.descendants.count
3555 3581 end
3556 3582
3557 3583 def test_bulk_copy_to_another_project_should_follow_when_needed
3558 3584 @request.session[:user_id] = 2
3559 3585 post :bulk_update, :ids => [1], :copy => '1', :issue => {:project_id => 2}, :follow => '1'
3560 3586 issue = Issue.first(:order => 'id DESC')
3561 3587 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
3562 3588 end
3563 3589
3564 3590 def test_destroy_issue_with_no_time_entries
3565 3591 assert_nil TimeEntry.find_by_issue_id(2)
3566 3592 @request.session[:user_id] = 2
3567 3593
3568 3594 assert_difference 'Issue.count', -1 do
3569 3595 delete :destroy, :id => 2
3570 3596 end
3571 3597 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
3572 3598 assert_nil Issue.find_by_id(2)
3573 3599 end
3574 3600
3575 3601 def test_destroy_issues_with_time_entries
3576 3602 @request.session[:user_id] = 2
3577 3603
3578 3604 assert_no_difference 'Issue.count' do
3579 3605 delete :destroy, :ids => [1, 3]
3580 3606 end
3581 3607 assert_response :success
3582 3608 assert_template 'destroy'
3583 3609 assert_not_nil assigns(:hours)
3584 3610 assert Issue.find_by_id(1) && Issue.find_by_id(3)
3585 3611 assert_tag 'form',
3586 3612 :descendant => {:tag => 'input', :attributes => {:name => '_method', :value => 'delete'}}
3587 3613 end
3588 3614
3589 3615 def test_destroy_issues_and_destroy_time_entries
3590 3616 @request.session[:user_id] = 2
3591 3617
3592 3618 assert_difference 'Issue.count', -2 do
3593 3619 assert_difference 'TimeEntry.count', -3 do
3594 3620 delete :destroy, :ids => [1, 3], :todo => 'destroy'
3595 3621 end
3596 3622 end
3597 3623 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
3598 3624 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
3599 3625 assert_nil TimeEntry.find_by_id([1, 2])
3600 3626 end
3601 3627
3602 3628 def test_destroy_issues_and_assign_time_entries_to_project
3603 3629 @request.session[:user_id] = 2
3604 3630
3605 3631 assert_difference 'Issue.count', -2 do
3606 3632 assert_no_difference 'TimeEntry.count' do
3607 3633 delete :destroy, :ids => [1, 3], :todo => 'nullify'
3608 3634 end
3609 3635 end
3610 3636 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
3611 3637 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
3612 3638 assert_nil TimeEntry.find(1).issue_id
3613 3639 assert_nil TimeEntry.find(2).issue_id
3614 3640 end
3615 3641
3616 3642 def test_destroy_issues_and_reassign_time_entries_to_another_issue
3617 3643 @request.session[:user_id] = 2
3618 3644
3619 3645 assert_difference 'Issue.count', -2 do
3620 3646 assert_no_difference 'TimeEntry.count' do
3621 3647 delete :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2
3622 3648 end
3623 3649 end
3624 3650 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
3625 3651 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
3626 3652 assert_equal 2, TimeEntry.find(1).issue_id
3627 3653 assert_equal 2, TimeEntry.find(2).issue_id
3628 3654 end
3629 3655
3630 3656 def test_destroy_issues_from_different_projects
3631 3657 @request.session[:user_id] = 2
3632 3658
3633 3659 assert_difference 'Issue.count', -3 do
3634 3660 delete :destroy, :ids => [1, 2, 6], :todo => 'destroy'
3635 3661 end
3636 3662 assert_redirected_to :controller => 'issues', :action => 'index'
3637 3663 assert !(Issue.find_by_id(1) || Issue.find_by_id(2) || Issue.find_by_id(6))
3638 3664 end
3639 3665
3640 3666 def test_destroy_parent_and_child_issues
3641 3667 parent = Issue.create!(:project_id => 1, :author_id => 1, :tracker_id => 1, :subject => 'Parent Issue')
3642 3668 child = Issue.create!(:project_id => 1, :author_id => 1, :tracker_id => 1, :subject => 'Child Issue', :parent_issue_id => parent.id)
3643 3669 assert child.is_descendant_of?(parent.reload)
3644 3670
3645 3671 @request.session[:user_id] = 2
3646 3672 assert_difference 'Issue.count', -2 do
3647 3673 delete :destroy, :ids => [parent.id, child.id], :todo => 'destroy'
3648 3674 end
3649 3675 assert_response 302
3650 3676 end
3651 3677
3652 3678 def test_default_search_scope
3653 3679 get :index
3654 3680 assert_tag :div, :attributes => {:id => 'quick-search'},
3655 3681 :child => {:tag => 'form',
3656 3682 :child => {:tag => 'input', :attributes => {:name => 'issues', :type => 'hidden', :value => '1'}}}
3657 3683 end
3658 3684 end
@@ -1,1579 +1,1592
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2012 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../test_helper', __FILE__)
19 19
20 20 class IssueTest < ActiveSupport::TestCase
21 21 fixtures :projects, :users, :members, :member_roles, :roles,
22 22 :groups_users,
23 23 :trackers, :projects_trackers,
24 24 :enabled_modules,
25 25 :versions,
26 26 :issue_statuses, :issue_categories, :issue_relations, :workflows,
27 27 :enumerations,
28 28 :issues, :journals, :journal_details,
29 29 :custom_fields, :custom_fields_projects, :custom_fields_trackers, :custom_values,
30 30 :time_entries
31 31
32 32 include Redmine::I18n
33 33
34 34 def teardown
35 35 User.current = nil
36 36 end
37 37
38 38 def test_create
39 39 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
40 40 :status_id => 1, :priority => IssuePriority.all.first,
41 41 :subject => 'test_create',
42 42 :description => 'IssueTest#test_create', :estimated_hours => '1:30')
43 43 assert issue.save
44 44 issue.reload
45 45 assert_equal 1.5, issue.estimated_hours
46 46 end
47 47
48 48 def test_create_minimal
49 49 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
50 50 :status_id => 1, :priority => IssuePriority.all.first,
51 51 :subject => 'test_create')
52 52 assert issue.save
53 53 assert issue.description.nil?
54 54 assert_nil issue.estimated_hours
55 55 end
56 56
57 57 def test_create_with_required_custom_field
58 58 set_language_if_valid 'en'
59 59 field = IssueCustomField.find_by_name('Database')
60 60 field.update_attribute(:is_required, true)
61 61
62 62 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1,
63 63 :status_id => 1, :subject => 'test_create',
64 64 :description => 'IssueTest#test_create_with_required_custom_field')
65 65 assert issue.available_custom_fields.include?(field)
66 66 # No value for the custom field
67 67 assert !issue.save
68 68 assert_equal ["Database can't be blank"], issue.errors.full_messages
69 69 # Blank value
70 70 issue.custom_field_values = { field.id => '' }
71 71 assert !issue.save
72 72 assert_equal ["Database can't be blank"], issue.errors.full_messages
73 73 # Invalid value
74 74 issue.custom_field_values = { field.id => 'SQLServer' }
75 75 assert !issue.save
76 76 assert_equal ["Database is not included in the list"], issue.errors.full_messages
77 77 # Valid value
78 78 issue.custom_field_values = { field.id => 'PostgreSQL' }
79 79 assert issue.save
80 80 issue.reload
81 81 assert_equal 'PostgreSQL', issue.custom_value_for(field).value
82 82 end
83 83
84 84 def test_create_with_group_assignment
85 85 with_settings :issue_group_assignment => '1' do
86 86 assert Issue.new(:project_id => 2, :tracker_id => 1, :author_id => 1,
87 87 :subject => 'Group assignment',
88 88 :assigned_to_id => 11).save
89 89 issue = Issue.first(:order => 'id DESC')
90 90 assert_kind_of Group, issue.assigned_to
91 91 assert_equal Group.find(11), issue.assigned_to
92 92 end
93 93 end
94 94
95 95 def assert_visibility_match(user, issues)
96 96 assert_equal issues.collect(&:id).sort, Issue.all.select {|issue| issue.visible?(user)}.collect(&:id).sort
97 97 end
98 98
99 99 def test_visible_scope_for_anonymous
100 100 # Anonymous user should see issues of public projects only
101 101 issues = Issue.visible(User.anonymous).all
102 102 assert issues.any?
103 103 assert_nil issues.detect {|issue| !issue.project.is_public?}
104 104 assert_nil issues.detect {|issue| issue.is_private?}
105 105 assert_visibility_match User.anonymous, issues
106 106 end
107 107
108 108 def test_visible_scope_for_anonymous_without_view_issues_permissions
109 109 # Anonymous user should not see issues without permission
110 110 Role.anonymous.remove_permission!(:view_issues)
111 111 issues = Issue.visible(User.anonymous).all
112 112 assert issues.empty?
113 113 assert_visibility_match User.anonymous, issues
114 114 end
115 115
116 116 def test_anonymous_should_not_see_private_issues_with_issues_visibility_set_to_default
117 117 assert Role.anonymous.update_attribute(:issues_visibility, 'default')
118 118 issue = Issue.generate_for_project!(Project.find(1), :author => User.anonymous, :assigned_to => User.anonymous, :is_private => true)
119 119 assert_nil Issue.where(:id => issue.id).visible(User.anonymous).first
120 120 assert !issue.visible?(User.anonymous)
121 121 end
122 122
123 123 def test_anonymous_should_not_see_private_issues_with_issues_visibility_set_to_own
124 124 assert Role.anonymous.update_attribute(:issues_visibility, 'own')
125 125 issue = Issue.generate_for_project!(Project.find(1), :author => User.anonymous, :assigned_to => User.anonymous, :is_private => true)
126 126 assert_nil Issue.where(:id => issue.id).visible(User.anonymous).first
127 127 assert !issue.visible?(User.anonymous)
128 128 end
129 129
130 130 def test_visible_scope_for_non_member
131 131 user = User.find(9)
132 132 assert user.projects.empty?
133 133 # Non member user should see issues of public projects only
134 134 issues = Issue.visible(user).all
135 135 assert issues.any?
136 136 assert_nil issues.detect {|issue| !issue.project.is_public?}
137 137 assert_nil issues.detect {|issue| issue.is_private?}
138 138 assert_visibility_match user, issues
139 139 end
140 140
141 141 def test_visible_scope_for_non_member_with_own_issues_visibility
142 142 Role.non_member.update_attribute :issues_visibility, 'own'
143 143 Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 9, :subject => 'Issue by non member')
144 144 user = User.find(9)
145 145
146 146 issues = Issue.visible(user).all
147 147 assert issues.any?
148 148 assert_nil issues.detect {|issue| issue.author != user}
149 149 assert_visibility_match user, issues
150 150 end
151 151
152 152 def test_visible_scope_for_non_member_without_view_issues_permissions
153 153 # Non member user should not see issues without permission
154 154 Role.non_member.remove_permission!(:view_issues)
155 155 user = User.find(9)
156 156 assert user.projects.empty?
157 157 issues = Issue.visible(user).all
158 158 assert issues.empty?
159 159 assert_visibility_match user, issues
160 160 end
161 161
162 162 def test_visible_scope_for_member
163 163 user = User.find(9)
164 164 # User should see issues of projects for which he has view_issues permissions only
165 165 Role.non_member.remove_permission!(:view_issues)
166 166 Member.create!(:principal => user, :project_id => 3, :role_ids => [2])
167 167 issues = Issue.visible(user).all
168 168 assert issues.any?
169 169 assert_nil issues.detect {|issue| issue.project_id != 3}
170 170 assert_nil issues.detect {|issue| issue.is_private?}
171 171 assert_visibility_match user, issues
172 172 end
173 173
174 174 def test_visible_scope_for_member_with_groups_should_return_assigned_issues
175 175 user = User.find(8)
176 176 assert user.groups.any?
177 177 Member.create!(:principal => user.groups.first, :project_id => 1, :role_ids => [2])
178 178 Role.non_member.remove_permission!(:view_issues)
179 179
180 180 issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3,
181 181 :status_id => 1, :priority => IssuePriority.all.first,
182 182 :subject => 'Assignment test',
183 183 :assigned_to => user.groups.first,
184 184 :is_private => true)
185 185
186 186 Role.find(2).update_attribute :issues_visibility, 'default'
187 187 issues = Issue.visible(User.find(8)).all
188 188 assert issues.any?
189 189 assert issues.include?(issue)
190 190
191 191 Role.find(2).update_attribute :issues_visibility, 'own'
192 192 issues = Issue.visible(User.find(8)).all
193 193 assert issues.any?
194 194 assert issues.include?(issue)
195 195 end
196 196
197 197 def test_visible_scope_for_admin
198 198 user = User.find(1)
199 199 user.members.each(&:destroy)
200 200 assert user.projects.empty?
201 201 issues = Issue.visible(user).all
202 202 assert issues.any?
203 203 # Admin should see issues on private projects that he does not belong to
204 204 assert issues.detect {|issue| !issue.project.is_public?}
205 205 # Admin should see private issues of other users
206 206 assert issues.detect {|issue| issue.is_private? && issue.author != user}
207 207 assert_visibility_match user, issues
208 208 end
209 209
210 210 def test_visible_scope_with_project
211 211 project = Project.find(1)
212 212 issues = Issue.visible(User.find(2), :project => project).all
213 213 projects = issues.collect(&:project).uniq
214 214 assert_equal 1, projects.size
215 215 assert_equal project, projects.first
216 216 end
217 217
218 218 def test_visible_scope_with_project_and_subprojects
219 219 project = Project.find(1)
220 220 issues = Issue.visible(User.find(2), :project => project, :with_subprojects => true).all
221 221 projects = issues.collect(&:project).uniq
222 222 assert projects.size > 1
223 223 assert_equal [], projects.select {|p| !p.is_or_is_descendant_of?(project)}
224 224 end
225 225
226 226 def test_visible_and_nested_set_scopes
227 227 assert_equal 0, Issue.find(1).descendants.visible.all.size
228 228 end
229 229
230 230 def test_open_scope
231 231 issues = Issue.open.all
232 232 assert_nil issues.detect(&:closed?)
233 233 end
234 234
235 235 def test_open_scope_with_arg
236 236 issues = Issue.open(false).all
237 237 assert_equal issues, issues.select(&:closed?)
238 238 end
239 239
240 240 def test_errors_full_messages_should_include_custom_fields_errors
241 241 field = IssueCustomField.find_by_name('Database')
242 242
243 243 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1,
244 244 :status_id => 1, :subject => 'test_create',
245 245 :description => 'IssueTest#test_create_with_required_custom_field')
246 246 assert issue.available_custom_fields.include?(field)
247 247 # Invalid value
248 248 issue.custom_field_values = { field.id => 'SQLServer' }
249 249
250 250 assert !issue.valid?
251 251 assert_equal 1, issue.errors.full_messages.size
252 252 assert_equal "Database #{I18n.translate('activerecord.errors.messages.inclusion')}",
253 253 issue.errors.full_messages.first
254 254 end
255 255
256 256 def test_update_issue_with_required_custom_field
257 257 field = IssueCustomField.find_by_name('Database')
258 258 field.update_attribute(:is_required, true)
259 259
260 260 issue = Issue.find(1)
261 261 assert_nil issue.custom_value_for(field)
262 262 assert issue.available_custom_fields.include?(field)
263 263 # No change to custom values, issue can be saved
264 264 assert issue.save
265 265 # Blank value
266 266 issue.custom_field_values = { field.id => '' }
267 267 assert !issue.save
268 268 # Valid value
269 269 issue.custom_field_values = { field.id => 'PostgreSQL' }
270 270 assert issue.save
271 271 issue.reload
272 272 assert_equal 'PostgreSQL', issue.custom_value_for(field).value
273 273 end
274 274
275 275 def test_should_not_update_attributes_if_custom_fields_validation_fails
276 276 issue = Issue.find(1)
277 277 field = IssueCustomField.find_by_name('Database')
278 278 assert issue.available_custom_fields.include?(field)
279 279
280 280 issue.custom_field_values = { field.id => 'Invalid' }
281 281 issue.subject = 'Should be not be saved'
282 282 assert !issue.save
283 283
284 284 issue.reload
285 285 assert_equal "Can't print recipes", issue.subject
286 286 end
287 287
288 288 def test_should_not_recreate_custom_values_objects_on_update
289 289 field = IssueCustomField.find_by_name('Database')
290 290
291 291 issue = Issue.find(1)
292 292 issue.custom_field_values = { field.id => 'PostgreSQL' }
293 293 assert issue.save
294 294 custom_value = issue.custom_value_for(field)
295 295 issue.reload
296 296 issue.custom_field_values = { field.id => 'MySQL' }
297 297 assert issue.save
298 298 issue.reload
299 299 assert_equal custom_value.id, issue.custom_value_for(field).id
300 300 end
301 301
302 302 def test_should_not_update_custom_fields_on_changing_tracker_with_different_custom_fields
303 303 issue = Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :subject => 'Test', :custom_field_values => {'2' => 'Test'})
304 304 assert !Tracker.find(2).custom_field_ids.include?(2)
305 305
306 306 issue = Issue.find(issue.id)
307 307 issue.attributes = {:tracker_id => 2, :custom_field_values => {'1' => ''}}
308 308
309 309 issue = Issue.find(issue.id)
310 310 custom_value = issue.custom_value_for(2)
311 311 assert_not_nil custom_value
312 312 assert_equal 'Test', custom_value.value
313 313 end
314 314
315 315 def test_assigning_tracker_id_should_reload_custom_fields_values
316 316 issue = Issue.new(:project => Project.find(1))
317 317 assert issue.custom_field_values.empty?
318 318 issue.tracker_id = 1
319 319 assert issue.custom_field_values.any?
320 320 end
321 321
322 322 def test_assigning_attributes_should_assign_project_and_tracker_first
323 323 seq = sequence('seq')
324 324 issue = Issue.new
325 325 issue.expects(:project_id=).in_sequence(seq)
326 326 issue.expects(:tracker_id=).in_sequence(seq)
327 327 issue.expects(:subject=).in_sequence(seq)
328 328 issue.attributes = {:tracker_id => 2, :project_id => 1, :subject => 'Test'}
329 329 end
330 330
331 331 def test_assigning_tracker_and_custom_fields_should_assign_custom_fields
332 332 attributes = ActiveSupport::OrderedHash.new
333 333 attributes['custom_field_values'] = { '1' => 'MySQL' }
334 334 attributes['tracker_id'] = '1'
335 335 issue = Issue.new(:project => Project.find(1))
336 336 issue.attributes = attributes
337 337 assert_equal 'MySQL', issue.custom_field_value(1)
338 338 end
339 339
340 340 def test_should_update_issue_with_disabled_tracker
341 341 p = Project.find(1)
342 342 issue = Issue.find(1)
343 343
344 344 p.trackers.delete(issue.tracker)
345 345 assert !p.trackers.include?(issue.tracker)
346 346
347 347 issue.reload
348 348 issue.subject = 'New subject'
349 349 assert issue.save
350 350 end
351 351
352 352 def test_should_not_set_a_disabled_tracker
353 353 p = Project.find(1)
354 354 p.trackers.delete(Tracker.find(2))
355 355
356 356 issue = Issue.find(1)
357 357 issue.tracker_id = 2
358 358 issue.subject = 'New subject'
359 359 assert !issue.save
360 360 assert_not_nil issue.errors[:tracker_id]
361 361 end
362 362
363 363 def test_category_based_assignment
364 364 issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3,
365 365 :status_id => 1, :priority => IssuePriority.all.first,
366 366 :subject => 'Assignment test',
367 367 :description => 'Assignment test', :category_id => 1)
368 368 assert_equal IssueCategory.find(1).assigned_to, issue.assigned_to
369 369 end
370 370
371 371 def test_new_statuses_allowed_to
372 372 WorkflowTransition.delete_all
373 373
374 374 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2, :author => false, :assignee => false)
375 375 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3, :author => true, :assignee => false)
376 376 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4, :author => false, :assignee => true)
377 377 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5, :author => true, :assignee => true)
378 378 status = IssueStatus.find(1)
379 379 role = Role.find(1)
380 380 tracker = Tracker.find(1)
381 381 user = User.find(2)
382 382
383 383 issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :author_id => 1)
384 384 assert_equal [1, 2], issue.new_statuses_allowed_to(user).map(&:id)
385 385
386 386 issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :author => user)
387 387 assert_equal [1, 2, 3, 5], issue.new_statuses_allowed_to(user).map(&:id)
388 388
389 389 issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :author_id => 1, :assigned_to => user)
390 390 assert_equal [1, 2, 4, 5], issue.new_statuses_allowed_to(user).map(&:id)
391 391
392 392 issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :author => user, :assigned_to => user)
393 393 assert_equal [1, 2, 3, 4, 5], issue.new_statuses_allowed_to(user).map(&:id)
394 394 end
395 395
396 396 def test_new_statuses_allowed_to_should_return_all_transitions_for_admin
397 397 admin = User.find(1)
398 398 issue = Issue.find(1)
399 399 assert !admin.member_of?(issue.project)
400 400 expected_statuses = [issue.status] + WorkflowTransition.find_all_by_old_status_id(issue.status_id).map(&:new_status).uniq.sort
401 401
402 402 assert_equal expected_statuses, issue.new_statuses_allowed_to(admin)
403 403 end
404 404
405 405 def test_new_statuses_allowed_to_should_return_default_and_current_status_when_copying
406 406 issue = Issue.find(1).copy
407 407 assert_equal [1], issue.new_statuses_allowed_to(User.find(2)).map(&:id)
408 408
409 409 issue = Issue.find(2).copy
410 410 assert_equal [1, 2], issue.new_statuses_allowed_to(User.find(2)).map(&:id)
411 411 end
412 412
413 413 def test_safe_attributes_names_should_not_include_disabled_field
414 414 tracker = Tracker.new(:core_fields => %w(assigned_to_id fixed_version_id))
415 415
416 416 issue = Issue.new(:tracker => tracker)
417 417 assert_include 'tracker_id', issue.safe_attribute_names
418 418 assert_include 'status_id', issue.safe_attribute_names
419 419 assert_include 'subject', issue.safe_attribute_names
420 420 assert_include 'description', issue.safe_attribute_names
421 421 assert_include 'custom_field_values', issue.safe_attribute_names
422 422 assert_include 'custom_fields', issue.safe_attribute_names
423 423 assert_include 'lock_version', issue.safe_attribute_names
424 424
425 425 tracker.core_fields.each do |field|
426 426 assert_include field, issue.safe_attribute_names
427 427 end
428 428
429 429 tracker.disabled_core_fields.each do |field|
430 430 assert_not_include field, issue.safe_attribute_names
431 431 end
432 432 end
433 433
434 434 def test_safe_attributes_should_ignore_disabled_fields
435 435 tracker = Tracker.find(1)
436 436 tracker.core_fields = %w(assigned_to_id due_date)
437 437 tracker.save!
438 438
439 439 issue = Issue.new(:tracker => tracker)
440 440 issue.safe_attributes = {'start_date' => '2012-07-14', 'due_date' => '2012-07-14'}
441 441 assert_nil issue.start_date
442 442 assert_equal Date.parse('2012-07-14'), issue.due_date
443 443 end
444 444
445 445 def test_safe_attributes_should_accept_target_tracker_enabled_fields
446 446 source = Tracker.find(1)
447 447 source.core_fields = []
448 448 source.save!
449 449 target = Tracker.find(2)
450 450 target.core_fields = %w(assigned_to_id due_date)
451 451 target.save!
452 452
453 453 issue = Issue.new(:tracker => source)
454 454 issue.safe_attributes = {'tracker_id' => 2, 'due_date' => '2012-07-14'}
455 455 assert_equal target, issue.tracker
456 456 assert_equal Date.parse('2012-07-14'), issue.due_date
457 457 end
458 458
459 459 def test_safe_attributes_should_not_include_readonly_fields
460 460 WorkflowPermission.delete_all
461 461 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
462 462 user = User.find(2)
463 463
464 464 issue = Issue.new(:project_id => 1, :tracker_id => 1)
465 465 assert_equal %w(due_date), issue.read_only_attribute_names(user)
466 466 assert_not_include 'due_date', issue.safe_attribute_names(user)
467 467
468 468 issue.send :safe_attributes=, {'start_date' => '2012-07-14', 'due_date' => '2012-07-14'}, user
469 469 assert_equal Date.parse('2012-07-14'), issue.start_date
470 470 assert_nil issue.due_date
471 471 end
472 472
473 473 def test_safe_attributes_should_not_include_readonly_custom_fields
474 474 cf1 = IssueCustomField.create!(:name => 'Writable field', :field_format => 'string', :is_for_all => true, :tracker_ids => [1])
475 475 cf2 = IssueCustomField.create!(:name => 'Readonly field', :field_format => 'string', :is_for_all => true, :tracker_ids => [1])
476 476
477 477 WorkflowPermission.delete_all
478 478 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'readonly')
479 479 user = User.find(2)
480 480
481 481 issue = Issue.new(:project_id => 1, :tracker_id => 1)
482 482 assert_equal [cf2.id.to_s], issue.read_only_attribute_names(user)
483 483 assert_not_include cf2.id.to_s, issue.safe_attribute_names(user)
484 484
485 485 issue.send :safe_attributes=, {'custom_field_values' => {cf1.id.to_s => 'value1', cf2.id.to_s => 'value2'}}, user
486 486 assert_equal 'value1', issue.custom_field_value(cf1)
487 487 assert_nil issue.custom_field_value(cf2)
488 488
489 489 issue.send :safe_attributes=, {'custom_fields' => [{'id' => cf1.id.to_s, 'value' => 'valuea'}, {'id' => cf2.id.to_s, 'value' => 'valueb'}]}, user
490 490 assert_equal 'valuea', issue.custom_field_value(cf1)
491 491 assert_nil issue.custom_field_value(cf2)
492 492 end
493 493
494 494 def test_editable_custom_field_values_should_return_non_readonly_custom_values
495 495 cf1 = IssueCustomField.create!(:name => 'Writable field', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
496 496 cf2 = IssueCustomField.create!(:name => 'Readonly field', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
497 497
498 498 WorkflowPermission.delete_all
499 499 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'readonly')
500 500 user = User.find(2)
501 501
502 502 issue = Issue.new(:project_id => 1, :tracker_id => 1)
503 503 values = issue.editable_custom_field_values(user)
504 504 assert values.detect {|value| value.custom_field == cf1}
505 505 assert_nil values.detect {|value| value.custom_field == cf2}
506 506
507 507 issue.tracker_id = 2
508 508 values = issue.editable_custom_field_values(user)
509 509 assert values.detect {|value| value.custom_field == cf1}
510 510 assert values.detect {|value| value.custom_field == cf2}
511 511 end
512 512
513 513 def test_safe_attributes_should_accept_target_tracker_writable_fields
514 514 WorkflowPermission.delete_all
515 515 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
516 516 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => 'start_date', :rule => 'readonly')
517 517 user = User.find(2)
518 518
519 519 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1)
520 520
521 521 issue.send :safe_attributes=, {'start_date' => '2012-07-12', 'due_date' => '2012-07-14'}, user
522 522 assert_equal Date.parse('2012-07-12'), issue.start_date
523 523 assert_nil issue.due_date
524 524
525 525 issue.send :safe_attributes=, {'start_date' => '2012-07-15', 'due_date' => '2012-07-16', 'tracker_id' => 2}, user
526 526 assert_equal Date.parse('2012-07-12'), issue.start_date
527 527 assert_equal Date.parse('2012-07-16'), issue.due_date
528 528 end
529 529
530 530 def test_safe_attributes_should_accept_target_status_writable_fields
531 531 WorkflowPermission.delete_all
532 532 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
533 533 WorkflowPermission.create!(:old_status_id => 2, :tracker_id => 1, :role_id => 1, :field_name => 'start_date', :rule => 'readonly')
534 534 user = User.find(2)
535 535
536 536 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1)
537 537
538 538 issue.send :safe_attributes=, {'start_date' => '2012-07-12', 'due_date' => '2012-07-14'}, user
539 539 assert_equal Date.parse('2012-07-12'), issue.start_date
540 540 assert_nil issue.due_date
541 541
542 542 issue.send :safe_attributes=, {'start_date' => '2012-07-15', 'due_date' => '2012-07-16', 'status_id' => 2}, user
543 543 assert_equal Date.parse('2012-07-12'), issue.start_date
544 544 assert_equal Date.parse('2012-07-16'), issue.due_date
545 545 end
546 546
547 547 def test_required_attributes_should_be_validated
548 548 cf = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
549 549
550 550 WorkflowPermission.delete_all
551 551 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'required')
552 552 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'category_id', :rule => 'required')
553 553 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => cf.id.to_s, :rule => 'required')
554 554
555 555 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => 'start_date', :rule => 'required')
556 556 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => cf.id.to_s, :rule => 'required')
557 557 user = User.find(2)
558 558
559 559 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1, :subject => 'Required fields', :author => user)
560 560 assert_equal [cf.id.to_s, "category_id", "due_date"], issue.required_attribute_names(user).sort
561 561 assert !issue.save, "Issue was saved"
562 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 564 issue.tracker_id = 2
565 565 assert_equal [cf.id.to_s, "start_date"], issue.required_attribute_names(user).sort
566 566 assert !issue.save, "Issue was saved"
567 567 assert_equal ["Foo can't be blank", "Start date can't be blank"], issue.errors.full_messages.sort
568 568
569 569 issue.start_date = Date.today
570 570 issue.custom_field_values = {cf.id.to_s => 'bar'}
571 571 assert issue.save
572 572 end
573 573
574 574 def test_required_attribute_names_for_multiple_roles_should_intersect_rules
575 575 WorkflowPermission.delete_all
576 576 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'required')
577 577 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'start_date', :rule => 'required')
578 578 user = User.find(2)
579 579 member = Member.find(1)
580 580 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1)
581 581
582 582 assert_equal %w(due_date start_date), issue.required_attribute_names(user).sort
583 583
584 584 member.role_ids = [1, 2]
585 585 member.save!
586 586 assert_equal [], issue.required_attribute_names(user.reload)
587 587
588 588 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 2, :field_name => 'due_date', :rule => 'required')
589 589 assert_equal %w(due_date), issue.required_attribute_names(user)
590 590
591 591 member.role_ids = [1, 2, 3]
592 592 member.save!
593 593 assert_equal [], issue.required_attribute_names(user.reload)
594 594
595 595 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 2, :field_name => 'due_date', :rule => 'readonly')
596 596 # required + readonly => required
597 597 assert_equal %w(due_date), issue.required_attribute_names(user)
598 598 end
599 599
600 600 def test_read_only_attribute_names_for_multiple_roles_should_intersect_rules
601 601 WorkflowPermission.delete_all
602 602 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
603 603 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'start_date', :rule => 'readonly')
604 604 user = User.find(2)
605 605 member = Member.find(1)
606 606 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1)
607 607
608 608 assert_equal %w(due_date start_date), issue.read_only_attribute_names(user).sort
609 609
610 610 member.role_ids = [1, 2]
611 611 member.save!
612 612 assert_equal [], issue.read_only_attribute_names(user.reload)
613 613
614 614 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 2, :field_name => 'due_date', :rule => 'readonly')
615 615 assert_equal %w(due_date), issue.read_only_attribute_names(user)
616 616 end
617 617
618 618 def test_copy
619 619 issue = Issue.new.copy_from(1)
620 620 assert issue.copy?
621 621 assert issue.save
622 622 issue.reload
623 623 orig = Issue.find(1)
624 624 assert_equal orig.subject, issue.subject
625 625 assert_equal orig.tracker, issue.tracker
626 626 assert_equal "125", issue.custom_value_for(2).value
627 627 end
628 628
629 629 def test_copy_should_copy_status
630 630 orig = Issue.find(8)
631 631 assert orig.status != IssueStatus.default
632 632
633 633 issue = Issue.new.copy_from(orig)
634 634 assert issue.save
635 635 issue.reload
636 636 assert_equal orig.status, issue.status
637 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 652 def test_copy_should_copy_subtasks
640 653 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
641 654
642 655 copy = issue.reload.copy
643 656 copy.author = User.find(7)
644 657 assert_difference 'Issue.count', 1+issue.descendants.count do
645 658 assert copy.save
646 659 end
647 660 copy.reload
648 661 assert_equal %w(Child1 Child2), copy.children.map(&:subject).sort
649 662 child_copy = copy.children.detect {|c| c.subject == 'Child1'}
650 663 assert_equal %w(Child11), child_copy.children.map(&:subject).sort
651 664 assert_equal copy.author, child_copy.author
652 665 end
653 666
654 667 def test_copy_should_copy_subtasks_to_target_project
655 668 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
656 669
657 670 copy = issue.copy(:project_id => 3)
658 671 assert_difference 'Issue.count', 1+issue.descendants.count do
659 672 assert copy.save
660 673 end
661 674 assert_equal [3], copy.reload.descendants.map(&:project_id).uniq
662 675 end
663 676
664 677 def test_copy_should_not_copy_subtasks_twice_when_saving_twice
665 678 issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
666 679
667 680 copy = issue.reload.copy
668 681 assert_difference 'Issue.count', 1+issue.descendants.count do
669 682 assert copy.save
670 683 assert copy.save
671 684 end
672 685 end
673 686
674 687 def test_should_not_call_after_project_change_on_creation
675 688 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1, :subject => 'Test', :author_id => 1)
676 689 issue.expects(:after_project_change).never
677 690 issue.save!
678 691 end
679 692
680 693 def test_should_not_call_after_project_change_on_update
681 694 issue = Issue.find(1)
682 695 issue.project = Project.find(1)
683 696 issue.subject = 'No project change'
684 697 issue.expects(:after_project_change).never
685 698 issue.save!
686 699 end
687 700
688 701 def test_should_call_after_project_change_on_project_change
689 702 issue = Issue.find(1)
690 703 issue.project = Project.find(2)
691 704 issue.expects(:after_project_change).once
692 705 issue.save!
693 706 end
694 707
695 708 def test_adding_journal_should_update_timestamp
696 709 issue = Issue.find(1)
697 710 updated_on_was = issue.updated_on
698 711
699 712 issue.init_journal(User.first, "Adding notes")
700 713 assert_difference 'Journal.count' do
701 714 assert issue.save
702 715 end
703 716 issue.reload
704 717
705 718 assert_not_equal updated_on_was, issue.updated_on
706 719 end
707 720
708 721 def test_should_close_duplicates
709 722 # Create 3 issues
710 723 project = Project.find(1)
711 724 issue1 = Issue.generate_for_project!(project)
712 725 issue2 = Issue.generate_for_project!(project)
713 726 issue3 = Issue.generate_for_project!(project)
714 727
715 728 # 2 is a dupe of 1
716 729 IssueRelation.create!(:issue_from => issue2, :issue_to => issue1, :relation_type => IssueRelation::TYPE_DUPLICATES)
717 730 # And 3 is a dupe of 2
718 731 IssueRelation.create!(:issue_from => issue3, :issue_to => issue2, :relation_type => IssueRelation::TYPE_DUPLICATES)
719 732 # And 3 is a dupe of 1 (circular duplicates)
720 733 IssueRelation.create!(:issue_from => issue3, :issue_to => issue1, :relation_type => IssueRelation::TYPE_DUPLICATES)
721 734
722 735 assert issue1.reload.duplicates.include?(issue2)
723 736
724 737 # Closing issue 1
725 738 issue1.init_journal(User.find(:first), "Closing issue1")
726 739 issue1.status = IssueStatus.find :first, :conditions => {:is_closed => true}
727 740 assert issue1.save
728 741 # 2 and 3 should be also closed
729 742 assert issue2.reload.closed?
730 743 assert issue3.reload.closed?
731 744 end
732 745
733 746 def test_should_not_close_duplicated_issue
734 747 project = Project.find(1)
735 748 issue1 = Issue.generate_for_project!(project)
736 749 issue2 = Issue.generate_for_project!(project)
737 750
738 751 # 2 is a dupe of 1
739 752 IssueRelation.create(:issue_from => issue2, :issue_to => issue1, :relation_type => IssueRelation::TYPE_DUPLICATES)
740 753 # 2 is a dup of 1 but 1 is not a duplicate of 2
741 754 assert !issue2.reload.duplicates.include?(issue1)
742 755
743 756 # Closing issue 2
744 757 issue2.init_journal(User.find(:first), "Closing issue2")
745 758 issue2.status = IssueStatus.find :first, :conditions => {:is_closed => true}
746 759 assert issue2.save
747 760 # 1 should not be also closed
748 761 assert !issue1.reload.closed?
749 762 end
750 763
751 764 def test_assignable_versions
752 765 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 1, :subject => 'New issue')
753 766 assert_equal ['open'], issue.assignable_versions.collect(&:status).uniq
754 767 end
755 768
756 769 def test_should_not_be_able_to_assign_a_new_issue_to_a_closed_version
757 770 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 1, :subject => 'New issue')
758 771 assert !issue.save
759 772 assert_not_nil issue.errors[:fixed_version_id]
760 773 end
761 774
762 775 def test_should_not_be_able_to_assign_a_new_issue_to_a_locked_version
763 776 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 2, :subject => 'New issue')
764 777 assert !issue.save
765 778 assert_not_nil issue.errors[:fixed_version_id]
766 779 end
767 780
768 781 def test_should_be_able_to_assign_a_new_issue_to_an_open_version
769 782 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 3, :subject => 'New issue')
770 783 assert issue.save
771 784 end
772 785
773 786 def test_should_be_able_to_update_an_issue_assigned_to_a_closed_version
774 787 issue = Issue.find(11)
775 788 assert_equal 'closed', issue.fixed_version.status
776 789 issue.subject = 'Subject changed'
777 790 assert issue.save
778 791 end
779 792
780 793 def test_should_not_be_able_to_reopen_an_issue_assigned_to_a_closed_version
781 794 issue = Issue.find(11)
782 795 issue.status_id = 1
783 796 assert !issue.save
784 797 assert_not_nil issue.errors[:base]
785 798 end
786 799
787 800 def test_should_be_able_to_reopen_and_reassign_an_issue_assigned_to_a_closed_version
788 801 issue = Issue.find(11)
789 802 issue.status_id = 1
790 803 issue.fixed_version_id = 3
791 804 assert issue.save
792 805 end
793 806
794 807 def test_should_be_able_to_reopen_an_issue_assigned_to_a_locked_version
795 808 issue = Issue.find(12)
796 809 assert_equal 'locked', issue.fixed_version.status
797 810 issue.status_id = 1
798 811 assert issue.save
799 812 end
800 813
801 814 def test_should_not_be_able_to_keep_unshared_version_when_changing_project
802 815 issue = Issue.find(2)
803 816 assert_equal 2, issue.fixed_version_id
804 817 issue.project_id = 3
805 818 assert_nil issue.fixed_version_id
806 819 issue.fixed_version_id = 2
807 820 assert !issue.save
808 821 assert_include 'Target version is not included in the list', issue.errors.full_messages
809 822 end
810 823
811 824 def test_should_keep_shared_version_when_changing_project
812 825 Version.find(2).update_attribute :sharing, 'tree'
813 826
814 827 issue = Issue.find(2)
815 828 assert_equal 2, issue.fixed_version_id
816 829 issue.project_id = 3
817 830 assert_equal 2, issue.fixed_version_id
818 831 assert issue.save
819 832 end
820 833
821 834 def test_allowed_target_projects_on_move_should_include_projects_with_issue_tracking_enabled
822 835 assert_include Project.find(2), Issue.allowed_target_projects_on_move(User.find(2))
823 836 end
824 837
825 838 def test_allowed_target_projects_on_move_should_not_include_projects_with_issue_tracking_disabled
826 839 Project.find(2).disable_module! :issue_tracking
827 840 assert_not_include Project.find(2), Issue.allowed_target_projects_on_move(User.find(2))
828 841 end
829 842
830 843 def test_move_to_another_project_with_same_category
831 844 issue = Issue.find(1)
832 845 issue.project = Project.find(2)
833 846 assert issue.save
834 847 issue.reload
835 848 assert_equal 2, issue.project_id
836 849 # Category changes
837 850 assert_equal 4, issue.category_id
838 851 # Make sure time entries were move to the target project
839 852 assert_equal 2, issue.time_entries.first.project_id
840 853 end
841 854
842 855 def test_move_to_another_project_without_same_category
843 856 issue = Issue.find(2)
844 857 issue.project = Project.find(2)
845 858 assert issue.save
846 859 issue.reload
847 860 assert_equal 2, issue.project_id
848 861 # Category cleared
849 862 assert_nil issue.category_id
850 863 end
851 864
852 865 def test_move_to_another_project_should_clear_fixed_version_when_not_shared
853 866 issue = Issue.find(1)
854 867 issue.update_attribute(:fixed_version_id, 1)
855 868 issue.project = Project.find(2)
856 869 assert issue.save
857 870 issue.reload
858 871 assert_equal 2, issue.project_id
859 872 # Cleared fixed_version
860 873 assert_equal nil, issue.fixed_version
861 874 end
862 875
863 876 def test_move_to_another_project_should_keep_fixed_version_when_shared_with_the_target_project
864 877 issue = Issue.find(1)
865 878 issue.update_attribute(:fixed_version_id, 4)
866 879 issue.project = Project.find(5)
867 880 assert issue.save
868 881 issue.reload
869 882 assert_equal 5, issue.project_id
870 883 # Keep fixed_version
871 884 assert_equal 4, issue.fixed_version_id
872 885 end
873 886
874 887 def test_move_to_another_project_should_clear_fixed_version_when_not_shared_with_the_target_project
875 888 issue = Issue.find(1)
876 889 issue.update_attribute(:fixed_version_id, 1)
877 890 issue.project = Project.find(5)
878 891 assert issue.save
879 892 issue.reload
880 893 assert_equal 5, issue.project_id
881 894 # Cleared fixed_version
882 895 assert_equal nil, issue.fixed_version
883 896 end
884 897
885 898 def test_move_to_another_project_should_keep_fixed_version_when_shared_systemwide
886 899 issue = Issue.find(1)
887 900 issue.update_attribute(:fixed_version_id, 7)
888 901 issue.project = Project.find(2)
889 902 assert issue.save
890 903 issue.reload
891 904 assert_equal 2, issue.project_id
892 905 # Keep fixed_version
893 906 assert_equal 7, issue.fixed_version_id
894 907 end
895 908
896 909 def test_move_to_another_project_with_disabled_tracker
897 910 issue = Issue.find(1)
898 911 target = Project.find(2)
899 912 target.tracker_ids = [3]
900 913 target.save
901 914 issue.project = target
902 915 assert issue.save
903 916 issue.reload
904 917 assert_equal 2, issue.project_id
905 918 assert_equal 3, issue.tracker_id
906 919 end
907 920
908 921 def test_copy_to_the_same_project
909 922 issue = Issue.find(1)
910 923 copy = issue.copy
911 924 assert_difference 'Issue.count' do
912 925 copy.save!
913 926 end
914 927 assert_kind_of Issue, copy
915 928 assert_equal issue.project, copy.project
916 929 assert_equal "125", copy.custom_value_for(2).value
917 930 end
918 931
919 932 def test_copy_to_another_project_and_tracker
920 933 issue = Issue.find(1)
921 934 copy = issue.copy(:project_id => 3, :tracker_id => 2)
922 935 assert_difference 'Issue.count' do
923 936 copy.save!
924 937 end
925 938 copy.reload
926 939 assert_kind_of Issue, copy
927 940 assert_equal Project.find(3), copy.project
928 941 assert_equal Tracker.find(2), copy.tracker
929 942 # Custom field #2 is not associated with target tracker
930 943 assert_nil copy.custom_value_for(2)
931 944 end
932 945
933 946 context "#copy" do
934 947 setup do
935 948 @issue = Issue.find(1)
936 949 end
937 950
938 951 should "not create a journal" do
939 952 copy = @issue.copy(:project_id => 3, :tracker_id => 2, :assigned_to_id => 3)
940 953 copy.save!
941 954 assert_equal 0, copy.reload.journals.size
942 955 end
943 956
944 957 should "allow assigned_to changes" do
945 958 copy = @issue.copy(:project_id => 3, :tracker_id => 2, :assigned_to_id => 3)
946 959 assert_equal 3, copy.assigned_to_id
947 960 end
948 961
949 962 should "allow status changes" do
950 963 copy = @issue.copy(:project_id => 3, :tracker_id => 2, :status_id => 2)
951 964 assert_equal 2, copy.status_id
952 965 end
953 966
954 967 should "allow start date changes" do
955 968 date = Date.today
956 969 copy = @issue.copy(:project_id => 3, :tracker_id => 2, :start_date => date)
957 970 assert_equal date, copy.start_date
958 971 end
959 972
960 973 should "allow due date changes" do
961 974 date = Date.today
962 975 copy = @issue.copy(:project_id => 3, :tracker_id => 2, :due_date => date)
963 976 assert_equal date, copy.due_date
964 977 end
965 978
966 979 should "set current user as author" do
967 980 User.current = User.find(9)
968 981 copy = @issue.copy(:project_id => 3, :tracker_id => 2)
969 982 assert_equal User.current, copy.author
970 983 end
971 984
972 985 should "create a journal with notes" do
973 986 date = Date.today
974 987 notes = "Notes added when copying"
975 988 copy = @issue.copy(:project_id => 3, :tracker_id => 2, :start_date => date)
976 989 copy.init_journal(User.current, notes)
977 990 copy.save!
978 991
979 992 assert_equal 1, copy.journals.size
980 993 journal = copy.journals.first
981 994 assert_equal 0, journal.details.size
982 995 assert_equal notes, journal.notes
983 996 end
984 997 end
985 998
986 999 def test_recipients_should_include_previous_assignee
987 1000 user = User.find(3)
988 1001 user.members.update_all ["mail_notification = ?", false]
989 1002 user.update_attribute :mail_notification, 'only_assigned'
990 1003
991 1004 issue = Issue.find(2)
992 1005 issue.assigned_to = nil
993 1006 assert_include user.mail, issue.recipients
994 1007 issue.save!
995 1008 assert !issue.recipients.include?(user.mail)
996 1009 end
997 1010
998 1011 def test_recipients_should_not_include_users_that_cannot_view_the_issue
999 1012 issue = Issue.find(12)
1000 1013 assert issue.recipients.include?(issue.author.mail)
1001 1014 # copy the issue to a private project
1002 1015 copy = issue.copy(:project_id => 5, :tracker_id => 2)
1003 1016 # author is not a member of project anymore
1004 1017 assert !copy.recipients.include?(copy.author.mail)
1005 1018 end
1006 1019
1007 1020 def test_recipients_should_include_the_assigned_group_members
1008 1021 group_member = User.generate!
1009 1022 group = Group.generate!
1010 1023 group.users << group_member
1011 1024
1012 1025 issue = Issue.find(12)
1013 1026 issue.assigned_to = group
1014 1027 assert issue.recipients.include?(group_member.mail)
1015 1028 end
1016 1029
1017 1030 def test_watcher_recipients_should_not_include_users_that_cannot_view_the_issue
1018 1031 user = User.find(3)
1019 1032 issue = Issue.find(9)
1020 1033 Watcher.create!(:user => user, :watchable => issue)
1021 1034 assert issue.watched_by?(user)
1022 1035 assert !issue.watcher_recipients.include?(user.mail)
1023 1036 end
1024 1037
1025 1038 def test_issue_destroy
1026 1039 Issue.find(1).destroy
1027 1040 assert_nil Issue.find_by_id(1)
1028 1041 assert_nil TimeEntry.find_by_issue_id(1)
1029 1042 end
1030 1043
1031 1044 def test_destroying_a_deleted_issue_should_not_raise_an_error
1032 1045 issue = Issue.find(1)
1033 1046 Issue.find(1).destroy
1034 1047
1035 1048 assert_nothing_raised do
1036 1049 assert_no_difference 'Issue.count' do
1037 1050 issue.destroy
1038 1051 end
1039 1052 assert issue.destroyed?
1040 1053 end
1041 1054 end
1042 1055
1043 1056 def test_destroying_a_stale_issue_should_not_raise_an_error
1044 1057 issue = Issue.find(1)
1045 1058 Issue.find(1).update_attribute :subject, "Updated"
1046 1059
1047 1060 assert_nothing_raised do
1048 1061 assert_difference 'Issue.count', -1 do
1049 1062 issue.destroy
1050 1063 end
1051 1064 assert issue.destroyed?
1052 1065 end
1053 1066 end
1054 1067
1055 1068 def test_blocked
1056 1069 blocked_issue = Issue.find(9)
1057 1070 blocking_issue = Issue.find(10)
1058 1071
1059 1072 assert blocked_issue.blocked?
1060 1073 assert !blocking_issue.blocked?
1061 1074 end
1062 1075
1063 1076 def test_blocked_issues_dont_allow_closed_statuses
1064 1077 blocked_issue = Issue.find(9)
1065 1078
1066 1079 allowed_statuses = blocked_issue.new_statuses_allowed_to(users(:users_002))
1067 1080 assert !allowed_statuses.empty?
1068 1081 closed_statuses = allowed_statuses.select {|st| st.is_closed?}
1069 1082 assert closed_statuses.empty?
1070 1083 end
1071 1084
1072 1085 def test_unblocked_issues_allow_closed_statuses
1073 1086 blocking_issue = Issue.find(10)
1074 1087
1075 1088 allowed_statuses = blocking_issue.new_statuses_allowed_to(users(:users_002))
1076 1089 assert !allowed_statuses.empty?
1077 1090 closed_statuses = allowed_statuses.select {|st| st.is_closed?}
1078 1091 assert !closed_statuses.empty?
1079 1092 end
1080 1093
1081 1094 def test_rescheduling_an_issue_should_reschedule_following_issue
1082 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 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 1097 IssueRelation.create!(:issue_from => issue1, :issue_to => issue2, :relation_type => IssueRelation::TYPE_PRECEDES)
1085 1098 assert_equal issue1.due_date + 1, issue2.reload.start_date
1086 1099
1087 1100 issue1.due_date = Date.today + 5
1088 1101 issue1.save!
1089 1102 assert_equal issue1.due_date + 1, issue2.reload.start_date
1090 1103 end
1091 1104
1092 1105 def test_rescheduling_a_stale_issue_should_not_raise_an_error
1093 1106 stale = Issue.find(1)
1094 1107 issue = Issue.find(1)
1095 1108 issue.subject = "Updated"
1096 1109 issue.save!
1097 1110
1098 1111 date = 10.days.from_now.to_date
1099 1112 assert_nothing_raised do
1100 1113 stale.reschedule_after(date)
1101 1114 end
1102 1115 assert_equal date, stale.reload.start_date
1103 1116 end
1104 1117
1105 1118 def test_overdue
1106 1119 assert Issue.new(:due_date => 1.day.ago.to_date).overdue?
1107 1120 assert !Issue.new(:due_date => Date.today).overdue?
1108 1121 assert !Issue.new(:due_date => 1.day.from_now.to_date).overdue?
1109 1122 assert !Issue.new(:due_date => nil).overdue?
1110 1123 assert !Issue.new(:due_date => 1.day.ago.to_date, :status => IssueStatus.find(:first, :conditions => {:is_closed => true})).overdue?
1111 1124 end
1112 1125
1113 1126 context "#behind_schedule?" do
1114 1127 should "be false if the issue has no start_date" do
1115 1128 assert !Issue.new(:start_date => nil, :due_date => 1.day.from_now.to_date, :done_ratio => 0).behind_schedule?
1116 1129 end
1117 1130
1118 1131 should "be false if the issue has no end_date" do
1119 1132 assert !Issue.new(:start_date => 1.day.from_now.to_date, :due_date => nil, :done_ratio => 0).behind_schedule?
1120 1133 end
1121 1134
1122 1135 should "be false if the issue has more done than it's calendar time" do
1123 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 1137 end
1125 1138
1126 1139 should "be true if the issue hasn't been started at all" do
1127 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 1141 end
1129 1142
1130 1143 should "be true if the issue has used more calendar time than it's done ratio" do
1131 1144 assert Issue.new(:start_date => 100.days.ago.to_date, :due_date => Date.today, :done_ratio => 90).behind_schedule?
1132 1145 end
1133 1146 end
1134 1147
1135 1148 context "#assignable_users" do
1136 1149 should "be Users" do
1137 1150 assert_kind_of User, Issue.find(1).assignable_users.first
1138 1151 end
1139 1152
1140 1153 should "include the issue author" do
1141 1154 project = Project.find(1)
1142 1155 non_project_member = User.generate!
1143 1156 issue = Issue.generate_for_project!(project, :author => non_project_member)
1144 1157
1145 1158 assert issue.assignable_users.include?(non_project_member)
1146 1159 end
1147 1160
1148 1161 should "include the current assignee" do
1149 1162 project = Project.find(1)
1150 1163 user = User.generate!
1151 1164 issue = Issue.generate_for_project!(project, :assigned_to => user)
1152 1165 user.lock!
1153 1166
1154 1167 assert Issue.find(issue.id).assignable_users.include?(user)
1155 1168 end
1156 1169
1157 1170 should "not show the issue author twice" do
1158 1171 assignable_user_ids = Issue.find(1).assignable_users.collect(&:id)
1159 1172 assert_equal 2, assignable_user_ids.length
1160 1173
1161 1174 assignable_user_ids.each do |user_id|
1162 1175 assert_equal 1, assignable_user_ids.select {|i| i == user_id}.length, "User #{user_id} appears more or less than once"
1163 1176 end
1164 1177 end
1165 1178
1166 1179 context "with issue_group_assignment" do
1167 1180 should "include groups" do
1168 1181 issue = Issue.new(:project => Project.find(2))
1169 1182
1170 1183 with_settings :issue_group_assignment => '1' do
1171 1184 assert_equal %w(Group User), issue.assignable_users.map {|a| a.class.name}.uniq.sort
1172 1185 assert issue.assignable_users.include?(Group.find(11))
1173 1186 end
1174 1187 end
1175 1188 end
1176 1189
1177 1190 context "without issue_group_assignment" do
1178 1191 should "not include groups" do
1179 1192 issue = Issue.new(:project => Project.find(2))
1180 1193
1181 1194 with_settings :issue_group_assignment => '0' do
1182 1195 assert_equal %w(User), issue.assignable_users.map {|a| a.class.name}.uniq.sort
1183 1196 assert !issue.assignable_users.include?(Group.find(11))
1184 1197 end
1185 1198 end
1186 1199 end
1187 1200 end
1188 1201
1189 1202 def test_create_should_send_email_notification
1190 1203 ActionMailer::Base.deliveries.clear
1191 1204 issue = Issue.new(:project_id => 1, :tracker_id => 1,
1192 1205 :author_id => 3, :status_id => 1,
1193 1206 :priority => IssuePriority.all.first,
1194 1207 :subject => 'test_create', :estimated_hours => '1:30')
1195 1208
1196 1209 assert issue.save
1197 1210 assert_equal 1, ActionMailer::Base.deliveries.size
1198 1211 end
1199 1212
1200 1213 def test_stale_issue_should_not_send_email_notification
1201 1214 ActionMailer::Base.deliveries.clear
1202 1215 issue = Issue.find(1)
1203 1216 stale = Issue.find(1)
1204 1217
1205 1218 issue.init_journal(User.find(1))
1206 1219 issue.subject = 'Subjet update'
1207 1220 assert issue.save
1208 1221 assert_equal 1, ActionMailer::Base.deliveries.size
1209 1222 ActionMailer::Base.deliveries.clear
1210 1223
1211 1224 stale.init_journal(User.find(1))
1212 1225 stale.subject = 'Another subjet update'
1213 1226 assert_raise ActiveRecord::StaleObjectError do
1214 1227 stale.save
1215 1228 end
1216 1229 assert ActionMailer::Base.deliveries.empty?
1217 1230 end
1218 1231
1219 1232 def test_journalized_description
1220 1233 IssueCustomField.delete_all
1221 1234
1222 1235 i = Issue.first
1223 1236 old_description = i.description
1224 1237 new_description = "This is the new description"
1225 1238
1226 1239 i.init_journal(User.find(2))
1227 1240 i.description = new_description
1228 1241 assert_difference 'Journal.count', 1 do
1229 1242 assert_difference 'JournalDetail.count', 1 do
1230 1243 i.save!
1231 1244 end
1232 1245 end
1233 1246
1234 1247 detail = JournalDetail.first(:order => 'id DESC')
1235 1248 assert_equal i, detail.journal.journalized
1236 1249 assert_equal 'attr', detail.property
1237 1250 assert_equal 'description', detail.prop_key
1238 1251 assert_equal old_description, detail.old_value
1239 1252 assert_equal new_description, detail.value
1240 1253 end
1241 1254
1242 1255 def test_blank_descriptions_should_not_be_journalized
1243 1256 IssueCustomField.delete_all
1244 1257 Issue.update_all("description = NULL", "id=1")
1245 1258
1246 1259 i = Issue.find(1)
1247 1260 i.init_journal(User.find(2))
1248 1261 i.subject = "blank description"
1249 1262 i.description = "\r\n"
1250 1263
1251 1264 assert_difference 'Journal.count', 1 do
1252 1265 assert_difference 'JournalDetail.count', 1 do
1253 1266 i.save!
1254 1267 end
1255 1268 end
1256 1269 end
1257 1270
1258 1271 def test_journalized_multi_custom_field
1259 1272 field = IssueCustomField.create!(:name => 'filter', :field_format => 'list', :is_filter => true, :is_for_all => true,
1260 1273 :tracker_ids => [1], :possible_values => ['value1', 'value2', 'value3'], :multiple => true)
1261 1274
1262 1275 issue = Issue.create!(:project_id => 1, :tracker_id => 1, :subject => 'Test', :author_id => 1)
1263 1276
1264 1277 assert_difference 'Journal.count' do
1265 1278 assert_difference 'JournalDetail.count' do
1266 1279 issue.init_journal(User.first)
1267 1280 issue.custom_field_values = {field.id => ['value1']}
1268 1281 issue.save!
1269 1282 end
1270 1283 assert_difference 'JournalDetail.count' do
1271 1284 issue.init_journal(User.first)
1272 1285 issue.custom_field_values = {field.id => ['value1', 'value2']}
1273 1286 issue.save!
1274 1287 end
1275 1288 assert_difference 'JournalDetail.count', 2 do
1276 1289 issue.init_journal(User.first)
1277 1290 issue.custom_field_values = {field.id => ['value3', 'value2']}
1278 1291 issue.save!
1279 1292 end
1280 1293 assert_difference 'JournalDetail.count', 2 do
1281 1294 issue.init_journal(User.first)
1282 1295 issue.custom_field_values = {field.id => nil}
1283 1296 issue.save!
1284 1297 end
1285 1298 end
1286 1299 end
1287 1300
1288 1301 def test_description_eol_should_be_normalized
1289 1302 i = Issue.new(:description => "CR \r LF \n CRLF \r\n")
1290 1303 assert_equal "CR \r\n LF \r\n CRLF \r\n", i.description
1291 1304 end
1292 1305
1293 1306 def test_saving_twice_should_not_duplicate_journal_details
1294 1307 i = Issue.find(:first)
1295 1308 i.init_journal(User.find(2), 'Some notes')
1296 1309 # initial changes
1297 1310 i.subject = 'New subject'
1298 1311 i.done_ratio = i.done_ratio + 10
1299 1312 assert_difference 'Journal.count' do
1300 1313 assert i.save
1301 1314 end
1302 1315 # 1 more change
1303 1316 i.priority = IssuePriority.find(:first, :conditions => ["id <> ?", i.priority_id])
1304 1317 assert_no_difference 'Journal.count' do
1305 1318 assert_difference 'JournalDetail.count', 1 do
1306 1319 i.save
1307 1320 end
1308 1321 end
1309 1322 # no more change
1310 1323 assert_no_difference 'Journal.count' do
1311 1324 assert_no_difference 'JournalDetail.count' do
1312 1325 i.save
1313 1326 end
1314 1327 end
1315 1328 end
1316 1329
1317 1330 def test_all_dependent_issues
1318 1331 IssueRelation.delete_all
1319 1332 assert IssueRelation.create!(:issue_from => Issue.find(1),
1320 1333 :issue_to => Issue.find(2),
1321 1334 :relation_type => IssueRelation::TYPE_PRECEDES)
1322 1335 assert IssueRelation.create!(:issue_from => Issue.find(2),
1323 1336 :issue_to => Issue.find(3),
1324 1337 :relation_type => IssueRelation::TYPE_PRECEDES)
1325 1338 assert IssueRelation.create!(:issue_from => Issue.find(3),
1326 1339 :issue_to => Issue.find(8),
1327 1340 :relation_type => IssueRelation::TYPE_PRECEDES)
1328 1341
1329 1342 assert_equal [2, 3, 8], Issue.find(1).all_dependent_issues.collect(&:id).sort
1330 1343 end
1331 1344
1332 1345 def test_all_dependent_issues_with_persistent_circular_dependency
1333 1346 IssueRelation.delete_all
1334 1347 assert IssueRelation.create!(:issue_from => Issue.find(1),
1335 1348 :issue_to => Issue.find(2),
1336 1349 :relation_type => IssueRelation::TYPE_PRECEDES)
1337 1350 assert IssueRelation.create!(:issue_from => Issue.find(2),
1338 1351 :issue_to => Issue.find(3),
1339 1352 :relation_type => IssueRelation::TYPE_PRECEDES)
1340 1353
1341 1354 r = IssueRelation.create!(:issue_from => Issue.find(3),
1342 1355 :issue_to => Issue.find(7),
1343 1356 :relation_type => IssueRelation::TYPE_PRECEDES)
1344 1357 IssueRelation.update_all("issue_to_id = 1", ["id = ?", r.id])
1345 1358
1346 1359 assert_equal [2, 3], Issue.find(1).all_dependent_issues.collect(&:id).sort
1347 1360 end
1348 1361
1349 1362 def test_all_dependent_issues_with_persistent_multiple_circular_dependencies
1350 1363 IssueRelation.delete_all
1351 1364 assert IssueRelation.create!(:issue_from => Issue.find(1),
1352 1365 :issue_to => Issue.find(2),
1353 1366 :relation_type => IssueRelation::TYPE_RELATES)
1354 1367 assert IssueRelation.create!(:issue_from => Issue.find(2),
1355 1368 :issue_to => Issue.find(3),
1356 1369 :relation_type => IssueRelation::TYPE_RELATES)
1357 1370 assert IssueRelation.create!(:issue_from => Issue.find(3),
1358 1371 :issue_to => Issue.find(8),
1359 1372 :relation_type => IssueRelation::TYPE_RELATES)
1360 1373
1361 1374 r = IssueRelation.create!(:issue_from => Issue.find(8),
1362 1375 :issue_to => Issue.find(7),
1363 1376 :relation_type => IssueRelation::TYPE_RELATES)
1364 1377 IssueRelation.update_all("issue_to_id = 2", ["id = ?", r.id])
1365 1378
1366 1379 r = IssueRelation.create!(:issue_from => Issue.find(3),
1367 1380 :issue_to => Issue.find(7),
1368 1381 :relation_type => IssueRelation::TYPE_RELATES)
1369 1382 IssueRelation.update_all("issue_to_id = 1", ["id = ?", r.id])
1370 1383
1371 1384 assert_equal [2, 3, 8], Issue.find(1).all_dependent_issues.collect(&:id).sort
1372 1385 end
1373 1386
1374 1387 context "#done_ratio" do
1375 1388 setup do
1376 1389 @issue = Issue.find(1)
1377 1390 @issue_status = IssueStatus.find(1)
1378 1391 @issue_status.update_attribute(:default_done_ratio, 50)
1379 1392 @issue2 = Issue.find(2)
1380 1393 @issue_status2 = IssueStatus.find(2)
1381 1394 @issue_status2.update_attribute(:default_done_ratio, 0)
1382 1395 end
1383 1396
1384 1397 teardown do
1385 1398 Setting.issue_done_ratio = 'issue_field'
1386 1399 end
1387 1400
1388 1401 context "with Setting.issue_done_ratio using the issue_field" do
1389 1402 setup do
1390 1403 Setting.issue_done_ratio = 'issue_field'
1391 1404 end
1392 1405
1393 1406 should "read the issue's field" do
1394 1407 assert_equal 0, @issue.done_ratio
1395 1408 assert_equal 30, @issue2.done_ratio
1396 1409 end
1397 1410 end
1398 1411
1399 1412 context "with Setting.issue_done_ratio using the issue_status" do
1400 1413 setup do
1401 1414 Setting.issue_done_ratio = 'issue_status'
1402 1415 end
1403 1416
1404 1417 should "read the Issue Status's default done ratio" do
1405 1418 assert_equal 50, @issue.done_ratio
1406 1419 assert_equal 0, @issue2.done_ratio
1407 1420 end
1408 1421 end
1409 1422 end
1410 1423
1411 1424 context "#update_done_ratio_from_issue_status" do
1412 1425 setup do
1413 1426 @issue = Issue.find(1)
1414 1427 @issue_status = IssueStatus.find(1)
1415 1428 @issue_status.update_attribute(:default_done_ratio, 50)
1416 1429 @issue2 = Issue.find(2)
1417 1430 @issue_status2 = IssueStatus.find(2)
1418 1431 @issue_status2.update_attribute(:default_done_ratio, 0)
1419 1432 end
1420 1433
1421 1434 context "with Setting.issue_done_ratio using the issue_field" do
1422 1435 setup do
1423 1436 Setting.issue_done_ratio = 'issue_field'
1424 1437 end
1425 1438
1426 1439 should "not change the issue" do
1427 1440 @issue.update_done_ratio_from_issue_status
1428 1441 @issue2.update_done_ratio_from_issue_status
1429 1442
1430 1443 assert_equal 0, @issue.read_attribute(:done_ratio)
1431 1444 assert_equal 30, @issue2.read_attribute(:done_ratio)
1432 1445 end
1433 1446 end
1434 1447
1435 1448 context "with Setting.issue_done_ratio using the issue_status" do
1436 1449 setup do
1437 1450 Setting.issue_done_ratio = 'issue_status'
1438 1451 end
1439 1452
1440 1453 should "change the issue's done ratio" do
1441 1454 @issue.update_done_ratio_from_issue_status
1442 1455 @issue2.update_done_ratio_from_issue_status
1443 1456
1444 1457 assert_equal 50, @issue.read_attribute(:done_ratio)
1445 1458 assert_equal 0, @issue2.read_attribute(:done_ratio)
1446 1459 end
1447 1460 end
1448 1461 end
1449 1462
1450 1463 test "#by_tracker" do
1451 1464 User.current = User.anonymous
1452 1465 groups = Issue.by_tracker(Project.find(1))
1453 1466 assert_equal 3, groups.size
1454 1467 assert_equal 7, groups.inject(0) {|sum, group| sum + group['total'].to_i}
1455 1468 end
1456 1469
1457 1470 test "#by_version" do
1458 1471 User.current = User.anonymous
1459 1472 groups = Issue.by_version(Project.find(1))
1460 1473 assert_equal 3, groups.size
1461 1474 assert_equal 3, groups.inject(0) {|sum, group| sum + group['total'].to_i}
1462 1475 end
1463 1476
1464 1477 test "#by_priority" do
1465 1478 User.current = User.anonymous
1466 1479 groups = Issue.by_priority(Project.find(1))
1467 1480 assert_equal 4, groups.size
1468 1481 assert_equal 7, groups.inject(0) {|sum, group| sum + group['total'].to_i}
1469 1482 end
1470 1483
1471 1484 test "#by_category" do
1472 1485 User.current = User.anonymous
1473 1486 groups = Issue.by_category(Project.find(1))
1474 1487 assert_equal 2, groups.size
1475 1488 assert_equal 3, groups.inject(0) {|sum, group| sum + group['total'].to_i}
1476 1489 end
1477 1490
1478 1491 test "#by_assigned_to" do
1479 1492 User.current = User.anonymous
1480 1493 groups = Issue.by_assigned_to(Project.find(1))
1481 1494 assert_equal 2, groups.size
1482 1495 assert_equal 2, groups.inject(0) {|sum, group| sum + group['total'].to_i}
1483 1496 end
1484 1497
1485 1498 test "#by_author" do
1486 1499 User.current = User.anonymous
1487 1500 groups = Issue.by_author(Project.find(1))
1488 1501 assert_equal 4, groups.size
1489 1502 assert_equal 7, groups.inject(0) {|sum, group| sum + group['total'].to_i}
1490 1503 end
1491 1504
1492 1505 test "#by_subproject" do
1493 1506 User.current = User.anonymous
1494 1507 groups = Issue.by_subproject(Project.find(1))
1495 1508 # Private descendant not visible
1496 1509 assert_equal 1, groups.size
1497 1510 assert_equal 2, groups.inject(0) {|sum, group| sum + group['total'].to_i}
1498 1511 end
1499 1512
1500 1513 def test_recently_updated_scope
1501 1514 #should return the last updated issue
1502 1515 assert_equal Issue.reorder("updated_on DESC").first, Issue.recently_updated.limit(1).first
1503 1516 end
1504 1517
1505 1518 def test_on_active_projects_scope
1506 1519 assert Project.find(2).archive
1507 1520
1508 1521 before = Issue.on_active_project.length
1509 1522 # test inclusion to results
1510 1523 issue = Issue.generate_for_project!(Project.find(1), :tracker => Project.find(2).trackers.first)
1511 1524 assert_equal before + 1, Issue.on_active_project.length
1512 1525
1513 1526 # Move to an archived project
1514 1527 issue.project = Project.find(2)
1515 1528 assert issue.save
1516 1529 assert_equal before, Issue.on_active_project.length
1517 1530 end
1518 1531
1519 1532 context "Issue#recipients" do
1520 1533 setup do
1521 1534 @project = Project.find(1)
1522 1535 @author = User.generate!
1523 1536 @assignee = User.generate!
1524 1537 @issue = Issue.generate_for_project!(@project, :assigned_to => @assignee, :author => @author)
1525 1538 end
1526 1539
1527 1540 should "include project recipients" do
1528 1541 assert @project.recipients.present?
1529 1542 @project.recipients.each do |project_recipient|
1530 1543 assert @issue.recipients.include?(project_recipient)
1531 1544 end
1532 1545 end
1533 1546
1534 1547 should "include the author if the author is active" do
1535 1548 assert @issue.author, "No author set for Issue"
1536 1549 assert @issue.recipients.include?(@issue.author.mail)
1537 1550 end
1538 1551
1539 1552 should "include the assigned to user if the assigned to user is active" do
1540 1553 assert @issue.assigned_to, "No assigned_to set for Issue"
1541 1554 assert @issue.recipients.include?(@issue.assigned_to.mail)
1542 1555 end
1543 1556
1544 1557 should "not include users who opt out of all email" do
1545 1558 @author.update_attribute(:mail_notification, :none)
1546 1559
1547 1560 assert !@issue.recipients.include?(@issue.author.mail)
1548 1561 end
1549 1562
1550 1563 should "not include the issue author if they are only notified of assigned issues" do
1551 1564 @author.update_attribute(:mail_notification, :only_assigned)
1552 1565
1553 1566 assert !@issue.recipients.include?(@issue.author.mail)
1554 1567 end
1555 1568
1556 1569 should "not include the assigned user if they are only notified of owned issues" do
1557 1570 @assignee.update_attribute(:mail_notification, :only_owner)
1558 1571
1559 1572 assert !@issue.recipients.include?(@issue.assigned_to.mail)
1560 1573 end
1561 1574 end
1562 1575
1563 1576 def test_last_journal_id_with_journals_should_return_the_journal_id
1564 1577 assert_equal 2, Issue.find(1).last_journal_id
1565 1578 end
1566 1579
1567 1580 def test_last_journal_id_without_journals_should_return_nil
1568 1581 assert_nil Issue.find(3).last_journal_id
1569 1582 end
1570 1583
1571 1584 def test_journals_after_should_return_journals_with_greater_id
1572 1585 assert_equal [Journal.find(2)], Issue.find(1).journals_after('1')
1573 1586 assert_equal [], Issue.find(1).journals_after('2')
1574 1587 end
1575 1588
1576 1589 def test_journals_after_with_blank_arg_should_return_all_journals
1577 1590 assert_equal [Journal.find(1), Journal.find(2)], Issue.find(1).journals_after('')
1578 1591 end
1579 1592 end
General Comments 0
You need to be logged in to leave comments. Login now