##// END OF EJS Templates
Default target version for new issues (#1828)....
Jean-Philippe Lang -
r14404:9178d4748f19
parent child
Show More

The requested changes are too big and content was truncated. Show full diff

@@ -0,0 +1,12
1 class AddProjectsDefaultVersionId < ActiveRecord::Migration
2 def self.up
3 # Don't try to add the column if redmine_default_version plugin was used
4 unless column_exists?(:projects, :default_version_id, :integer)
5 add_column :projects, :default_version_id, :integer, :default => nil
6 end
7 end
8
9 def self.down
10 remove_column :projects, :default_version_id
11 end
12 end
@@ -1,115 +1,123
1 1 # encoding: utf-8
2 2 #
3 3 # Redmine - project management software
4 4 # Copyright (C) 2006-2015 Jean-Philippe Lang
5 5 #
6 6 # This program is free software; you can redistribute it and/or
7 7 # modify it under the terms of the GNU General Public License
8 8 # as published by the Free Software Foundation; either version 2
9 9 # of the License, or (at your option) any later version.
10 10 #
11 11 # This program is distributed in the hope that it will be useful,
12 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 14 # GNU General Public License for more details.
15 15 #
16 16 # You should have received a copy of the GNU General Public License
17 17 # along with this program; if not, write to the Free Software
18 18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 19
20 20 module ProjectsHelper
21 21 def project_settings_tabs
22 22 tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural},
23 23 {:name => 'modules', :action => :select_project_modules, :partial => 'projects/settings/modules', :label => :label_module_plural},
24 24 {:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural},
25 25 {:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural},
26 26 {:name => 'categories', :action => :manage_categories, :partial => 'projects/settings/issue_categories', :label => :label_issue_category_plural},
27 27 {:name => 'wiki', :action => :manage_wiki, :partial => 'projects/settings/wiki', :label => :label_wiki},
28 28 {:name => 'repositories', :action => :manage_repository, :partial => 'projects/settings/repositories', :label => :label_repository_plural},
29 29 {:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural},
30 30 {:name => 'activities', :action => :manage_project_activities, :partial => 'projects/settings/activities', :label => :enumeration_activities}
31 31 ]
32 32 tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)}
33 33 end
34 34
35 35 def parent_project_select_tag(project)
36 36 selected = project.parent
37 37 # retrieve the requested parent project
38 38 parent_id = (params[:project] && params[:project][:parent_id]) || params[:parent_id]
39 39 if parent_id
40 40 selected = (parent_id.blank? ? nil : Project.find(parent_id))
41 41 end
42 42
43 43 options = ''
44 44 options << "<option value=''>&nbsp;</option>" if project.allowed_parents.include?(nil)
45 45 options << project_tree_options_for_select(project.allowed_parents.compact, :selected => selected)
46 46 content_tag('select', options.html_safe, :name => 'project[parent_id]', :id => 'project_parent_id')
47 47 end
48 48
49 49 def render_project_action_links
50 50 links = []
51 51 if User.current.allowed_to?(:add_project, nil, :global => true)
52 52 links << link_to(l(:label_project_new), new_project_path, :class => 'icon icon-add')
53 53 end
54 54 if User.current.allowed_to?(:view_issues, nil, :global => true)
55 55 links << link_to(l(:label_issue_view_all), issues_path)
56 56 end
57 57 if User.current.allowed_to?(:view_time_entries, nil, :global => true)
58 58 links << link_to(l(:label_overall_spent_time), time_entries_path)
59 59 end
60 60 links << link_to(l(:label_overall_activity), activity_path)
61 61 links.join(" | ").html_safe
62 62 end
63 63
64 64 # Renders the projects index
65 65 def render_project_hierarchy(projects)
66 66 render_project_nested_lists(projects) do |project|
67 67 s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")
68 68 if project.description.present?
69 69 s << content_tag('div', textilizable(project.short_description, :project => project), :class => 'wiki description')
70 70 end
71 71 s
72 72 end
73 73 end
74 74
75 75 # Returns a set of options for a select field, grouped by project.
76 76 def version_options_for_select(versions, selected=nil)
77 77 grouped = Hash.new {|h,k| h[k] = []}
78 78 versions.each do |version|
79 79 grouped[version.project.name] << [version.name, version.id]
80 80 end
81 81
82 82 selected = selected.is_a?(Version) ? selected.id : selected
83 83 if grouped.keys.size > 1
84 84 grouped_options_for_select(grouped, selected)
85 85 else
86 86 options_for_select((grouped.values.first || []), selected)
87 87 end
88 88 end
89 89
90 def project_default_version_options(project)
91 versions = project.shared_versions.open.to_a
92 if project.default_version && !versions.include?(project.default_version)
93 versions << project.default_version
94 end
95 version_options_for_select(versions, project.default_version)
96 end
97
90 98 def format_version_sharing(sharing)
91 99 sharing = 'none' unless Version::VERSION_SHARINGS.include?(sharing)
92 100 l("label_version_sharing_#{sharing}")
93 101 end
94 102
95 103 def render_api_includes(project, api)
96 104 api.array :trackers do
97 105 project.trackers.each do |tracker|
98 106 api.tracker(:id => tracker.id, :name => tracker.name)
99 107 end
100 108 end if include_in_api_response?('trackers')
101 109
102 110 api.array :issue_categories do
103 111 project.issue_categories.each do |category|
104 112 api.issue_category(:id => category.id, :name => category.name)
105 113 end
106 114 end if include_in_api_response?('issue_categories')
107 115
108 116 api.array :enabled_modules do
109 117 project.enabled_modules.each do |enabled_module|
110 118 api.enabled_module(:id => enabled_module.id, :name => enabled_module.name)
111 119 end
112 120 end if include_in_api_response?('enabled_modules')
113 121
114 122 end
115 123 end
@@ -1,1680 +1,1689
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2015 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 include Redmine::Utils::DateCalculation
21 21 include Redmine::I18n
22 22 before_save :set_parent_id
23 23 include Redmine::NestedSet::IssueNestedSet
24 24
25 25 belongs_to :project
26 26 belongs_to :tracker
27 27 belongs_to :status, :class_name => 'IssueStatus'
28 28 belongs_to :author, :class_name => 'User'
29 29 belongs_to :assigned_to, :class_name => 'Principal'
30 30 belongs_to :fixed_version, :class_name => 'Version'
31 31 belongs_to :priority, :class_name => 'IssuePriority'
32 32 belongs_to :category, :class_name => 'IssueCategory'
33 33
34 34 has_many :journals, :as => :journalized, :dependent => :destroy, :inverse_of => :journalized
35 35 has_many :visible_journals,
36 36 lambda {where(["(#{Journal.table_name}.private_notes = ? OR (#{Project.allowed_to_condition(User.current, :view_private_notes)}))", false])},
37 37 :class_name => 'Journal',
38 38 :as => :journalized
39 39
40 40 has_many :time_entries, :dependent => :destroy
41 41 has_and_belongs_to_many :changesets, lambda {order("#{Changeset.table_name}.committed_on ASC, #{Changeset.table_name}.id ASC")}
42 42
43 43 has_many :relations_from, :class_name => 'IssueRelation', :foreign_key => 'issue_from_id', :dependent => :delete_all
44 44 has_many :relations_to, :class_name => 'IssueRelation', :foreign_key => 'issue_to_id', :dependent => :delete_all
45 45
46 46 acts_as_attachable :after_add => :attachment_added, :after_remove => :attachment_removed
47 47 acts_as_customizable
48 48 acts_as_watchable
49 49 acts_as_searchable :columns => ['subject', "#{table_name}.description"],
50 50 :preload => [:project, :status, :tracker],
51 51 :scope => lambda {|options| options[:open_issues] ? self.open : self.all}
52 52
53 53 acts_as_event :title => Proc.new {|o| "#{o.tracker.name} ##{o.id} (#{o.status}): #{o.subject}"},
54 54 :url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.id}},
55 55 :type => Proc.new {|o| 'issue' + (o.closed? ? ' closed' : '') }
56 56
57 57 acts_as_activity_provider :scope => preload(:project, :author, :tracker),
58 58 :author_key => :author_id
59 59
60 60 DONE_RATIO_OPTIONS = %w(issue_field issue_status)
61 61
62 62 attr_reader :current_journal
63 63 delegate :notes, :notes=, :private_notes, :private_notes=, :to => :current_journal, :allow_nil => true
64 64
65 65 validates_presence_of :subject, :project, :tracker
66 66 validates_presence_of :priority, :if => Proc.new {|issue| issue.new_record? || issue.priority_id_changed?}
67 67 validates_presence_of :status, :if => Proc.new {|issue| issue.new_record? || issue.status_id_changed?}
68 68 validates_presence_of :author, :if => Proc.new {|issue| issue.new_record? || issue.author_id_changed?}
69 69
70 70 validates_length_of :subject, :maximum => 255
71 71 validates_inclusion_of :done_ratio, :in => 0..100
72 72 validates :estimated_hours, :numericality => {:greater_than_or_equal_to => 0, :allow_nil => true, :message => :invalid}
73 73 validates :start_date, :date => true
74 74 validates :due_date, :date => true
75 75 validate :validate_issue, :validate_required_fields
76 76 attr_protected :id
77 77
78 78 scope :visible, lambda {|*args|
79 79 joins(:project).
80 80 where(Issue.visible_condition(args.shift || User.current, *args))
81 81 }
82 82
83 83 scope :open, lambda {|*args|
84 84 is_closed = args.size > 0 ? !args.first : false
85 85 joins(:status).
86 86 where("#{IssueStatus.table_name}.is_closed = ?", is_closed)
87 87 }
88 88
89 89 scope :recently_updated, lambda { order("#{Issue.table_name}.updated_on DESC") }
90 90 scope :on_active_project, lambda {
91 91 joins(:project).
92 92 where("#{Project.table_name}.status = ?", Project::STATUS_ACTIVE)
93 93 }
94 94 scope :fixed_version, lambda {|versions|
95 95 ids = [versions].flatten.compact.map {|v| v.is_a?(Version) ? v.id : v}
96 96 ids.any? ? where(:fixed_version_id => ids) : where('1=0')
97 97 }
98 98 scope :assigned_to, lambda {|arg|
99 99 arg = Array(arg).uniq
100 100 ids = arg.map {|p| p.is_a?(Principal) ? p.id : p}
101 101 ids += arg.select {|p| p.is_a?(User)}.map(&:group_ids).flatten.uniq
102 102 ids.compact!
103 103 ids.any? ? where(:assigned_to_id => ids) : none
104 104 }
105 105
106 106 before_validation :clear_disabled_fields
107 107 before_create :default_assign
108 108 before_save :close_duplicates, :update_done_ratio_from_issue_status,
109 109 :force_updated_on_change, :update_closed_on, :set_assigned_to_was
110 110 after_save {|issue| issue.send :after_project_change if !issue.id_changed? && issue.project_id_changed?}
111 111 after_save :reschedule_following_issues, :update_nested_set_attributes,
112 112 :update_parent_attributes, :create_journal
113 113 # Should be after_create but would be called before previous after_save callbacks
114 114 after_save :after_create_from_copy
115 115 after_destroy :update_parent_attributes
116 116 after_create :send_notification
117 117 # Keep it at the end of after_save callbacks
118 118 after_save :clear_assigned_to_was
119 119
120 120 # Returns a SQL conditions string used to find all issues visible by the specified user
121 121 def self.visible_condition(user, options={})
122 122 Project.allowed_to_condition(user, :view_issues, options) do |role, user|
123 123 if user.id && user.logged?
124 124 case role.issues_visibility
125 125 when 'all'
126 126 nil
127 127 when 'default'
128 128 user_ids = [user.id] + user.groups.map(&:id).compact
129 129 "(#{table_name}.is_private = #{connection.quoted_false} OR #{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
130 130 when 'own'
131 131 user_ids = [user.id] + user.groups.map(&:id).compact
132 132 "(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
133 133 else
134 134 '1=0'
135 135 end
136 136 else
137 137 "(#{table_name}.is_private = #{connection.quoted_false})"
138 138 end
139 139 end
140 140 end
141 141
142 142 # Returns true if usr or current user is allowed to view the issue
143 143 def visible?(usr=nil)
144 144 (usr || User.current).allowed_to?(:view_issues, self.project) do |role, user|
145 145 if user.logged?
146 146 case role.issues_visibility
147 147 when 'all'
148 148 true
149 149 when 'default'
150 150 !self.is_private? || (self.author == user || user.is_or_belongs_to?(assigned_to))
151 151 when 'own'
152 152 self.author == user || user.is_or_belongs_to?(assigned_to)
153 153 else
154 154 false
155 155 end
156 156 else
157 157 !self.is_private?
158 158 end
159 159 end
160 160 end
161 161
162 162 # Returns true if user or current user is allowed to edit or add a note to the issue
163 163 def editable?(user=User.current)
164 164 attributes_editable?(user) || user.allowed_to?(:add_issue_notes, project)
165 165 end
166 166
167 167 # Returns true if user or current user is allowed to edit the issue
168 168 def attributes_editable?(user=User.current)
169 169 user.allowed_to?(:edit_issues, project)
170 170 end
171 171
172 172 def initialize(attributes=nil, *args)
173 173 super
174 174 if new_record?
175 175 # set default values for new records only
176 176 self.priority ||= IssuePriority.default
177 177 self.watcher_user_ids = []
178 178 end
179 179 end
180 180
181 181 def create_or_update
182 182 super
183 183 ensure
184 184 @status_was = nil
185 185 end
186 186 private :create_or_update
187 187
188 188 # AR#Persistence#destroy would raise and RecordNotFound exception
189 189 # if the issue was already deleted or updated (non matching lock_version).
190 190 # This is a problem when bulk deleting issues or deleting a project
191 191 # (because an issue may already be deleted if its parent was deleted
192 192 # first).
193 193 # The issue is reloaded by the nested_set before being deleted so
194 194 # the lock_version condition should not be an issue but we handle it.
195 195 def destroy
196 196 super
197 197 rescue ActiveRecord::StaleObjectError, ActiveRecord::RecordNotFound
198 198 # Stale or already deleted
199 199 begin
200 200 reload
201 201 rescue ActiveRecord::RecordNotFound
202 202 # The issue was actually already deleted
203 203 @destroyed = true
204 204 return freeze
205 205 end
206 206 # The issue was stale, retry to destroy
207 207 super
208 208 end
209 209
210 210 alias :base_reload :reload
211 211 def reload(*args)
212 212 @workflow_rule_by_attribute = nil
213 213 @assignable_versions = nil
214 214 @relations = nil
215 215 @spent_hours = nil
216 216 @total_spent_hours = nil
217 217 @total_estimated_hours = nil
218 218 base_reload(*args)
219 219 end
220 220
221 221 # Overrides Redmine::Acts::Customizable::InstanceMethods#available_custom_fields
222 222 def available_custom_fields
223 223 (project && tracker) ? (project.all_issue_custom_fields & tracker.custom_fields) : []
224 224 end
225 225
226 226 def visible_custom_field_values(user=nil)
227 227 user_real = user || User.current
228 228 custom_field_values.select do |value|
229 229 value.custom_field.visible_by?(project, user_real)
230 230 end
231 231 end
232 232
233 233 # Copies attributes from another issue, arg can be an id or an Issue
234 234 def copy_from(arg, options={})
235 235 issue = arg.is_a?(Issue) ? arg : Issue.visible.find(arg)
236 236 self.attributes = issue.attributes.dup.except("id", "root_id", "parent_id", "lft", "rgt", "created_on", "updated_on")
237 237 self.custom_field_values = issue.custom_field_values.inject({}) {|h,v| h[v.custom_field_id] = v.value; h}
238 238 self.status = issue.status
239 239 self.author = User.current
240 240 unless options[:attachments] == false
241 241 self.attachments = issue.attachments.map do |attachement|
242 242 attachement.copy(:container => self)
243 243 end
244 244 end
245 245 @copied_from = issue
246 246 @copy_options = options
247 247 self
248 248 end
249 249
250 250 # Returns an unsaved copy of the issue
251 251 def copy(attributes=nil, copy_options={})
252 252 copy = self.class.new.copy_from(self, copy_options)
253 253 copy.attributes = attributes if attributes
254 254 copy
255 255 end
256 256
257 257 # Returns true if the issue is a copy
258 258 def copy?
259 259 @copied_from.present?
260 260 end
261 261
262 262 def status_id=(status_id)
263 263 if status_id.to_s != self.status_id.to_s
264 264 self.status = (status_id.present? ? IssueStatus.find_by_id(status_id) : nil)
265 265 end
266 266 self.status_id
267 267 end
268 268
269 269 # Sets the status.
270 270 def status=(status)
271 271 if status != self.status
272 272 @workflow_rule_by_attribute = nil
273 273 end
274 274 association(:status).writer(status)
275 275 end
276 276
277 277 def priority_id=(pid)
278 278 self.priority = nil
279 279 write_attribute(:priority_id, pid)
280 280 end
281 281
282 282 def category_id=(cid)
283 283 self.category = nil
284 284 write_attribute(:category_id, cid)
285 285 end
286 286
287 287 def fixed_version_id=(vid)
288 288 self.fixed_version = nil
289 289 write_attribute(:fixed_version_id, vid)
290 290 end
291 291
292 292 def tracker_id=(tracker_id)
293 293 if tracker_id.to_s != self.tracker_id.to_s
294 294 self.tracker = (tracker_id.present? ? Tracker.find_by_id(tracker_id) : nil)
295 295 end
296 296 self.tracker_id
297 297 end
298 298
299 299 # Sets the tracker.
300 300 # This will set the status to the default status of the new tracker if:
301 301 # * the status was the default for the previous tracker
302 302 # * or if the status was not part of the new tracker statuses
303 303 # * or the status was nil
304 304 def tracker=(tracker)
305 305 if tracker != self.tracker
306 306 if status == default_status
307 307 self.status = nil
308 308 elsif status && tracker && !tracker.issue_status_ids.include?(status.id)
309 309 self.status = nil
310 310 end
311 311 @custom_field_values = nil
312 312 @workflow_rule_by_attribute = nil
313 313 end
314 314 association(:tracker).writer(tracker)
315 315 self.status ||= default_status
316 316 self.tracker
317 317 end
318 318
319 319 def project_id=(project_id)
320 320 if project_id.to_s != self.project_id.to_s
321 321 self.project = (project_id.present? ? Project.find_by_id(project_id) : nil)
322 322 end
323 323 self.project_id
324 324 end
325 325
326 326 # Sets the project.
327 327 # Unless keep_tracker argument is set to true, this will change the tracker
328 328 # to the first tracker of the new project if the previous tracker is not part
329 329 # of the new project trackers.
330 # This will clear the fixed_version is it's no longer valid for the new project.
331 # This will clear the parent issue if it's no longer valid for the new project.
332 # This will set the category to the category with the same name in the new
333 # project if it exists, or clear it if it doesn't.
330 # This will:
331 # * clear the fixed_version is it's no longer valid for the new project.
332 # * clear the parent issue if it's no longer valid for the new project.
333 # * set the category to the category with the same name in the new
334 # project if it exists, or clear it if it doesn't.
335 # * for new issue, set the fixed_version to the project default version
336 # if it's a valid fixed_version.
334 337 def project=(project, keep_tracker=false)
335 338 project_was = self.project
336 339 association(:project).writer(project)
337 340 if project_was && project && project_was != project
338 341 @assignable_versions = nil
339 342
340 343 unless keep_tracker || project.trackers.include?(tracker)
341 344 self.tracker = project.trackers.first
342 345 end
343 346 # Reassign to the category with same name if any
344 347 if category
345 348 self.category = project.issue_categories.find_by_name(category.name)
346 349 end
347 350 # Keep the fixed_version if it's still valid in the new_project
348 351 if fixed_version && fixed_version.project != project && !project.shared_versions.include?(fixed_version)
349 352 self.fixed_version = nil
350 353 end
351 354 # Clear the parent task if it's no longer valid
352 355 unless valid_parent_project?
353 356 self.parent_issue_id = nil
354 357 end
355 358 @custom_field_values = nil
356 359 @workflow_rule_by_attribute = nil
357 360 end
361 # Set fixed_version to the project default version if it's valid
362 if new_record? && fixed_version.nil? && project && project.default_version_id?
363 if project.shared_versions.open.exists?(project.default_version_id)
364 self.fixed_version_id = project.default_version_id
365 end
366 end
358 367 self.project
359 368 end
360 369
361 370 def description=(arg)
362 371 if arg.is_a?(String)
363 372 arg = arg.gsub(/(\r\n|\n|\r)/, "\r\n")
364 373 end
365 374 write_attribute(:description, arg)
366 375 end
367 376
368 377 # Overrides assign_attributes so that project and tracker get assigned first
369 378 def assign_attributes_with_project_and_tracker_first(new_attributes, *args)
370 379 return if new_attributes.nil?
371 380 attrs = new_attributes.dup
372 381 attrs.stringify_keys!
373 382
374 383 %w(project project_id tracker tracker_id).each do |attr|
375 384 if attrs.has_key?(attr)
376 385 send "#{attr}=", attrs.delete(attr)
377 386 end
378 387 end
379 388 send :assign_attributes_without_project_and_tracker_first, attrs, *args
380 389 end
381 390 # Do not redefine alias chain on reload (see #4838)
382 391 alias_method_chain(:assign_attributes, :project_and_tracker_first) unless method_defined?(:assign_attributes_without_project_and_tracker_first)
383 392
384 393 def attributes=(new_attributes)
385 394 assign_attributes new_attributes
386 395 end
387 396
388 397 def estimated_hours=(h)
389 398 write_attribute :estimated_hours, (h.is_a?(String) ? h.to_hours : h)
390 399 end
391 400
392 401 safe_attributes 'project_id',
393 402 'tracker_id',
394 403 'status_id',
395 404 'category_id',
396 405 'assigned_to_id',
397 406 'priority_id',
398 407 'fixed_version_id',
399 408 'subject',
400 409 'description',
401 410 'start_date',
402 411 'due_date',
403 412 'done_ratio',
404 413 'estimated_hours',
405 414 'custom_field_values',
406 415 'custom_fields',
407 416 'lock_version',
408 417 'notes',
409 418 :if => lambda {|issue, user| issue.new_record? || user.allowed_to?(:edit_issues, issue.project) }
410 419
411 420 safe_attributes 'notes',
412 421 :if => lambda {|issue, user| user.allowed_to?(:add_issue_notes, issue.project)}
413 422
414 423 safe_attributes 'private_notes',
415 424 :if => lambda {|issue, user| !issue.new_record? && user.allowed_to?(:set_notes_private, issue.project)}
416 425
417 426 safe_attributes 'watcher_user_ids',
418 427 :if => lambda {|issue, user| issue.new_record? && user.allowed_to?(:add_issue_watchers, issue.project)}
419 428
420 429 safe_attributes 'is_private',
421 430 :if => lambda {|issue, user|
422 431 user.allowed_to?(:set_issues_private, issue.project) ||
423 432 (issue.author_id == user.id && user.allowed_to?(:set_own_issues_private, issue.project))
424 433 }
425 434
426 435 safe_attributes 'parent_issue_id',
427 436 :if => lambda {|issue, user| (issue.new_record? || user.allowed_to?(:edit_issues, issue.project)) &&
428 437 user.allowed_to?(:manage_subtasks, issue.project)}
429 438
430 439 def safe_attribute_names(user=nil)
431 440 names = super
432 441 names -= disabled_core_fields
433 442 names -= read_only_attribute_names(user)
434 443 if new_record?
435 444 # Make sure that project_id can always be set for new issues
436 445 names |= %w(project_id)
437 446 end
438 447 if dates_derived?
439 448 names -= %w(start_date due_date)
440 449 end
441 450 if priority_derived?
442 451 names -= %w(priority_id)
443 452 end
444 453 if done_ratio_derived?
445 454 names -= %w(done_ratio)
446 455 end
447 456 names
448 457 end
449 458
450 459 # Safely sets attributes
451 460 # Should be called from controllers instead of #attributes=
452 461 # attr_accessible is too rough because we still want things like
453 462 # Issue.new(:project => foo) to work
454 463 def safe_attributes=(attrs, user=User.current)
455 464 return unless attrs.is_a?(Hash)
456 465
457 466 attrs = attrs.deep_dup
458 467
459 468 # Project and Tracker must be set before since new_statuses_allowed_to depends on it.
460 469 if (p = attrs.delete('project_id')) && safe_attribute?('project_id')
461 470 if allowed_target_projects(user).where(:id => p.to_i).exists?
462 471 self.project_id = p
463 472 end
464 473
465 474 if project_id_changed? && attrs['category_id'].to_s == category_id_was.to_s
466 475 # Discard submitted category on previous project
467 476 attrs.delete('category_id')
468 477 end
469 478 end
470 479
471 480 if (t = attrs.delete('tracker_id')) && safe_attribute?('tracker_id')
472 481 self.tracker_id = t
473 482 end
474 483 if project
475 484 # Set the default tracker to accept custom field values
476 485 # even if tracker is not specified
477 486 self.tracker ||= project.trackers.first
478 487 end
479 488
480 489 statuses_allowed = new_statuses_allowed_to(user)
481 490 if (s = attrs.delete('status_id')) && safe_attribute?('status_id')
482 491 if statuses_allowed.collect(&:id).include?(s.to_i)
483 492 self.status_id = s
484 493 end
485 494 end
486 495 if new_record? && !statuses_allowed.include?(status)
487 496 self.status = statuses_allowed.first || default_status
488 497 end
489 498
490 499 attrs = delete_unsafe_attributes(attrs, user)
491 500 return if attrs.empty?
492 501
493 502 if attrs['parent_issue_id'].present?
494 503 s = attrs['parent_issue_id'].to_s
495 504 unless (m = s.match(%r{\A#?(\d+)\z})) && (m[1] == parent_id.to_s || Issue.visible(user).exists?(m[1]))
496 505 @invalid_parent_issue_id = attrs.delete('parent_issue_id')
497 506 end
498 507 end
499 508
500 509 if attrs['custom_field_values'].present?
501 510 editable_custom_field_ids = editable_custom_field_values(user).map {|v| v.custom_field_id.to_s}
502 511 attrs['custom_field_values'].select! {|k, v| editable_custom_field_ids.include?(k.to_s)}
503 512 end
504 513
505 514 if attrs['custom_fields'].present?
506 515 editable_custom_field_ids = editable_custom_field_values(user).map {|v| v.custom_field_id.to_s}
507 516 attrs['custom_fields'].select! {|c| editable_custom_field_ids.include?(c['id'].to_s)}
508 517 end
509 518
510 519 # mass-assignment security bypass
511 520 assign_attributes attrs, :without_protection => true
512 521 end
513 522
514 523 def disabled_core_fields
515 524 tracker ? tracker.disabled_core_fields : []
516 525 end
517 526
518 527 # Returns the custom_field_values that can be edited by the given user
519 528 def editable_custom_field_values(user=nil)
520 529 visible_custom_field_values(user).reject do |value|
521 530 read_only_attribute_names(user).include?(value.custom_field_id.to_s)
522 531 end
523 532 end
524 533
525 534 # Returns the custom fields that can be edited by the given user
526 535 def editable_custom_fields(user=nil)
527 536 editable_custom_field_values(user).map(&:custom_field).uniq
528 537 end
529 538
530 539 # Returns the names of attributes that are read-only for user or the current user
531 540 # For users with multiple roles, the read-only fields are the intersection of
532 541 # read-only fields of each role
533 542 # The result is an array of strings where sustom fields are represented with their ids
534 543 #
535 544 # Examples:
536 545 # issue.read_only_attribute_names # => ['due_date', '2']
537 546 # issue.read_only_attribute_names(user) # => []
538 547 def read_only_attribute_names(user=nil)
539 548 workflow_rule_by_attribute(user).reject {|attr, rule| rule != 'readonly'}.keys
540 549 end
541 550
542 551 # Returns the names of required attributes for user or the current user
543 552 # For users with multiple roles, the required fields are the intersection of
544 553 # required fields of each role
545 554 # The result is an array of strings where sustom fields are represented with their ids
546 555 #
547 556 # Examples:
548 557 # issue.required_attribute_names # => ['due_date', '2']
549 558 # issue.required_attribute_names(user) # => []
550 559 def required_attribute_names(user=nil)
551 560 workflow_rule_by_attribute(user).reject {|attr, rule| rule != 'required'}.keys
552 561 end
553 562
554 563 # Returns true if the attribute is required for user
555 564 def required_attribute?(name, user=nil)
556 565 required_attribute_names(user).include?(name.to_s)
557 566 end
558 567
559 568 # Returns a hash of the workflow rule by attribute for the given user
560 569 #
561 570 # Examples:
562 571 # issue.workflow_rule_by_attribute # => {'due_date' => 'required', 'start_date' => 'readonly'}
563 572 def workflow_rule_by_attribute(user=nil)
564 573 return @workflow_rule_by_attribute if @workflow_rule_by_attribute && user.nil?
565 574
566 575 user_real = user || User.current
567 576 roles = user_real.admin ? Role.all.to_a : user_real.roles_for_project(project)
568 577 roles = roles.select(&:consider_workflow?)
569 578 return {} if roles.empty?
570 579
571 580 result = {}
572 581 workflow_permissions = WorkflowPermission.where(:tracker_id => tracker_id, :old_status_id => status_id, :role_id => roles.map(&:id)).to_a
573 582 if workflow_permissions.any?
574 583 workflow_rules = workflow_permissions.inject({}) do |h, wp|
575 584 h[wp.field_name] ||= {}
576 585 h[wp.field_name][wp.role_id] = wp.rule
577 586 h
578 587 end
579 588 fields_with_roles = {}
580 589 IssueCustomField.where(:visible => false).joins(:roles).pluck(:id, "role_id").each do |field_id, role_id|
581 590 fields_with_roles[field_id] ||= []
582 591 fields_with_roles[field_id] << role_id
583 592 end
584 593 roles.each do |role|
585 594 fields_with_roles.each do |field_id, role_ids|
586 595 unless role_ids.include?(role.id)
587 596 field_name = field_id.to_s
588 597 workflow_rules[field_name] ||= {}
589 598 workflow_rules[field_name][role.id] = 'readonly'
590 599 end
591 600 end
592 601 end
593 602 workflow_rules.each do |attr, rules|
594 603 next if rules.size < roles.size
595 604 uniq_rules = rules.values.uniq
596 605 if uniq_rules.size == 1
597 606 result[attr] = uniq_rules.first
598 607 else
599 608 result[attr] = 'required'
600 609 end
601 610 end
602 611 end
603 612 @workflow_rule_by_attribute = result if user.nil?
604 613 result
605 614 end
606 615 private :workflow_rule_by_attribute
607 616
608 617 def done_ratio
609 618 if Issue.use_status_for_done_ratio? && status && status.default_done_ratio
610 619 status.default_done_ratio
611 620 else
612 621 read_attribute(:done_ratio)
613 622 end
614 623 end
615 624
616 625 def self.use_status_for_done_ratio?
617 626 Setting.issue_done_ratio == 'issue_status'
618 627 end
619 628
620 629 def self.use_field_for_done_ratio?
621 630 Setting.issue_done_ratio == 'issue_field'
622 631 end
623 632
624 633 def validate_issue
625 634 if due_date && start_date && (start_date_changed? || due_date_changed?) && due_date < start_date
626 635 errors.add :due_date, :greater_than_start_date
627 636 end
628 637
629 638 if start_date && start_date_changed? && soonest_start && start_date < soonest_start
630 639 errors.add :start_date, :earlier_than_minimum_start_date, :date => format_date(soonest_start)
631 640 end
632 641
633 642 if fixed_version
634 643 if !assignable_versions.include?(fixed_version)
635 644 errors.add :fixed_version_id, :inclusion
636 645 elsif reopening? && fixed_version.closed?
637 646 errors.add :base, I18n.t(:error_can_not_reopen_issue_on_closed_version)
638 647 end
639 648 end
640 649
641 650 # Checks that the issue can not be added/moved to a disabled tracker
642 651 if project && (tracker_id_changed? || project_id_changed?)
643 652 unless project.trackers.include?(tracker)
644 653 errors.add :tracker_id, :inclusion
645 654 end
646 655 end
647 656
648 657 # Checks parent issue assignment
649 658 if @invalid_parent_issue_id.present?
650 659 errors.add :parent_issue_id, :invalid
651 660 elsif @parent_issue
652 661 if !valid_parent_project?(@parent_issue)
653 662 errors.add :parent_issue_id, :invalid
654 663 elsif (@parent_issue != parent) && (all_dependent_issues.include?(@parent_issue) || @parent_issue.all_dependent_issues.include?(self))
655 664 errors.add :parent_issue_id, :invalid
656 665 elsif !new_record?
657 666 # moving an existing issue
658 667 if move_possible?(@parent_issue)
659 668 # move accepted
660 669 else
661 670 errors.add :parent_issue_id, :invalid
662 671 end
663 672 end
664 673 end
665 674 end
666 675
667 676 # Validates the issue against additional workflow requirements
668 677 def validate_required_fields
669 678 user = new_record? ? author : current_journal.try(:user)
670 679
671 680 required_attribute_names(user).each do |attribute|
672 681 if attribute =~ /^\d+$/
673 682 attribute = attribute.to_i
674 683 v = custom_field_values.detect {|v| v.custom_field_id == attribute }
675 684 if v && Array(v.value).detect(&:present?).nil?
676 685 errors.add :base, v.custom_field.name + ' ' + l('activerecord.errors.messages.blank')
677 686 end
678 687 else
679 688 if respond_to?(attribute) && send(attribute).blank? && !disabled_core_fields.include?(attribute)
680 689 next if attribute == 'category_id' && project.try(:issue_categories).blank?
681 690 next if attribute == 'fixed_version_id' && assignable_versions.blank?
682 691 errors.add attribute, :blank
683 692 end
684 693 end
685 694 end
686 695 end
687 696
688 697 # Overrides Redmine::Acts::Customizable::InstanceMethods#validate_custom_field_values
689 698 # so that custom values that are not editable are not validated (eg. a custom field that
690 699 # is marked as required should not trigger a validation error if the user is not allowed
691 700 # to edit this field).
692 701 def validate_custom_field_values
693 702 user = new_record? ? author : current_journal.try(:user)
694 703 if new_record? || custom_field_values_changed?
695 704 editable_custom_field_values(user).each(&:validate_value)
696 705 end
697 706 end
698 707
699 708 # Set the done_ratio using the status if that setting is set. This will keep the done_ratios
700 709 # even if the user turns off the setting later
701 710 def update_done_ratio_from_issue_status
702 711 if Issue.use_status_for_done_ratio? && status && status.default_done_ratio
703 712 self.done_ratio = status.default_done_ratio
704 713 end
705 714 end
706 715
707 716 def init_journal(user, notes = "")
708 717 @current_journal ||= Journal.new(:journalized => self, :user => user, :notes => notes)
709 718 end
710 719
711 720 # Returns the current journal or nil if it's not initialized
712 721 def current_journal
713 722 @current_journal
714 723 end
715 724
716 725 # Returns the names of attributes that are journalized when updating the issue
717 726 def journalized_attribute_names
718 727 names = Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on closed_on)
719 728 if tracker
720 729 names -= tracker.disabled_core_fields
721 730 end
722 731 names
723 732 end
724 733
725 734 # Returns the id of the last journal or nil
726 735 def last_journal_id
727 736 if new_record?
728 737 nil
729 738 else
730 739 journals.maximum(:id)
731 740 end
732 741 end
733 742
734 743 # Returns a scope for journals that have an id greater than journal_id
735 744 def journals_after(journal_id)
736 745 scope = journals.reorder("#{Journal.table_name}.id ASC")
737 746 if journal_id.present?
738 747 scope = scope.where("#{Journal.table_name}.id > ?", journal_id.to_i)
739 748 end
740 749 scope
741 750 end
742 751
743 752 # Returns the initial status of the issue
744 753 # Returns nil for a new issue
745 754 def status_was
746 755 if status_id_changed?
747 756 if status_id_was.to_i > 0
748 757 @status_was ||= IssueStatus.find_by_id(status_id_was)
749 758 end
750 759 else
751 760 @status_was ||= status
752 761 end
753 762 end
754 763
755 764 # Return true if the issue is closed, otherwise false
756 765 def closed?
757 766 status.present? && status.is_closed?
758 767 end
759 768
760 769 # Returns true if the issue was closed when loaded
761 770 def was_closed?
762 771 status_was.present? && status_was.is_closed?
763 772 end
764 773
765 774 # Return true if the issue is being reopened
766 775 def reopening?
767 776 if new_record?
768 777 false
769 778 else
770 779 status_id_changed? && !closed? && was_closed?
771 780 end
772 781 end
773 782 alias :reopened? :reopening?
774 783
775 784 # Return true if the issue is being closed
776 785 def closing?
777 786 if new_record?
778 787 closed?
779 788 else
780 789 status_id_changed? && closed? && !was_closed?
781 790 end
782 791 end
783 792
784 793 # Returns true if the issue is overdue
785 794 def overdue?
786 795 due_date.present? && (due_date < Date.today) && !closed?
787 796 end
788 797
789 798 # Is the amount of work done less than it should for the due date
790 799 def behind_schedule?
791 800 return false if start_date.nil? || due_date.nil?
792 801 done_date = start_date + ((due_date - start_date + 1) * done_ratio / 100).floor
793 802 return done_date <= Date.today
794 803 end
795 804
796 805 # Does this issue have children?
797 806 def children?
798 807 !leaf?
799 808 end
800 809
801 810 # Users the issue can be assigned to
802 811 def assignable_users
803 812 users = project.assignable_users.to_a
804 813 users << author if author
805 814 users << assigned_to if assigned_to
806 815 users.uniq.sort
807 816 end
808 817
809 818 # Versions that the issue can be assigned to
810 819 def assignable_versions
811 820 return @assignable_versions if @assignable_versions
812 821
813 822 versions = project.shared_versions.open.to_a
814 823 if fixed_version
815 824 if fixed_version_id_changed?
816 825 # nothing to do
817 826 elsif project_id_changed?
818 827 if project.shared_versions.include?(fixed_version)
819 828 versions << fixed_version
820 829 end
821 830 else
822 831 versions << fixed_version
823 832 end
824 833 end
825 834 @assignable_versions = versions.uniq.sort
826 835 end
827 836
828 837 # Returns true if this issue is blocked by another issue that is still open
829 838 def blocked?
830 839 !relations_to.detect {|ir| ir.relation_type == 'blocks' && !ir.issue_from.closed?}.nil?
831 840 end
832 841
833 842 # Returns the default status of the issue based on its tracker
834 843 # Returns nil if tracker is nil
835 844 def default_status
836 845 tracker.try(:default_status)
837 846 end
838 847
839 848 # Returns an array of statuses that user is able to apply
840 849 def new_statuses_allowed_to(user=User.current, include_default=false)
841 850 if new_record? && @copied_from
842 851 [default_status, @copied_from.status].compact.uniq.sort
843 852 else
844 853 initial_status = nil
845 854 if new_record?
846 855 # nop
847 856 elsif tracker_id_changed?
848 857 if Tracker.where(:id => tracker_id_was, :default_status_id => status_id_was).any?
849 858 initial_status = default_status
850 859 elsif tracker.issue_status_ids.include?(status_id_was)
851 860 initial_status = IssueStatus.find_by_id(status_id_was)
852 861 else
853 862 initial_status = default_status
854 863 end
855 864 else
856 865 initial_status = status_was
857 866 end
858 867
859 868 initial_assigned_to_id = assigned_to_id_changed? ? assigned_to_id_was : assigned_to_id
860 869 assignee_transitions_allowed = initial_assigned_to_id.present? &&
861 870 (user.id == initial_assigned_to_id || user.group_ids.include?(initial_assigned_to_id))
862 871
863 872 statuses = []
864 873 statuses += IssueStatus.new_statuses_allowed(
865 874 initial_status,
866 875 user.admin ? Role.all.to_a : user.roles_for_project(project),
867 876 tracker,
868 877 author == user,
869 878 assignee_transitions_allowed
870 879 )
871 880 statuses << initial_status unless statuses.empty?
872 881 statuses << default_status if include_default || (new_record? && statuses.empty?)
873 882 statuses = statuses.compact.uniq.sort
874 883 if blocked?
875 884 statuses.reject!(&:is_closed?)
876 885 end
877 886 statuses
878 887 end
879 888 end
880 889
881 890 # Returns the previous assignee (user or group) if changed
882 891 def assigned_to_was
883 892 # assigned_to_id_was is reset before after_save callbacks
884 893 user_id = @previous_assigned_to_id || assigned_to_id_was
885 894 if user_id && user_id != assigned_to_id
886 895 @assigned_to_was ||= Principal.find_by_id(user_id)
887 896 end
888 897 end
889 898
890 899 # Returns the original tracker
891 900 def tracker_was
892 901 Tracker.find_by_id(tracker_id_was)
893 902 end
894 903
895 904 # Returns the users that should be notified
896 905 def notified_users
897 906 notified = []
898 907 # Author and assignee are always notified unless they have been
899 908 # locked or don't want to be notified
900 909 notified << author if author
901 910 if assigned_to
902 911 notified += (assigned_to.is_a?(Group) ? assigned_to.users : [assigned_to])
903 912 end
904 913 if assigned_to_was
905 914 notified += (assigned_to_was.is_a?(Group) ? assigned_to_was.users : [assigned_to_was])
906 915 end
907 916 notified = notified.select {|u| u.active? && u.notify_about?(self)}
908 917
909 918 notified += project.notified_users
910 919 notified.uniq!
911 920 # Remove users that can not view the issue
912 921 notified.reject! {|user| !visible?(user)}
913 922 notified
914 923 end
915 924
916 925 # Returns the email addresses that should be notified
917 926 def recipients
918 927 notified_users.collect(&:mail)
919 928 end
920 929
921 930 def each_notification(users, &block)
922 931 if users.any?
923 932 if custom_field_values.detect {|value| !value.custom_field.visible?}
924 933 users_by_custom_field_visibility = users.group_by do |user|
925 934 visible_custom_field_values(user).map(&:custom_field_id).sort
926 935 end
927 936 users_by_custom_field_visibility.values.each do |users|
928 937 yield(users)
929 938 end
930 939 else
931 940 yield(users)
932 941 end
933 942 end
934 943 end
935 944
936 945 def notify?
937 946 @notify != false
938 947 end
939 948
940 949 def notify=(arg)
941 950 @notify = arg
942 951 end
943 952
944 953 # Returns the number of hours spent on this issue
945 954 def spent_hours
946 955 @spent_hours ||= time_entries.sum(:hours) || 0
947 956 end
948 957
949 958 # Returns the total number of hours spent on this issue and its descendants
950 959 def total_spent_hours
951 960 @total_spent_hours ||= if leaf?
952 961 spent_hours
953 962 else
954 963 self_and_descendants.joins(:time_entries).sum("#{TimeEntry.table_name}.hours").to_f || 0.0
955 964 end
956 965 end
957 966
958 967 def total_estimated_hours
959 968 if leaf?
960 969 estimated_hours
961 970 else
962 971 @total_estimated_hours ||= self_and_descendants.sum(:estimated_hours)
963 972 end
964 973 end
965 974
966 975 def relations
967 976 @relations ||= IssueRelation::Relations.new(self, (relations_from + relations_to).sort)
968 977 end
969 978
970 979 # Preloads relations for a collection of issues
971 980 def self.load_relations(issues)
972 981 if issues.any?
973 982 relations = IssueRelation.where("issue_from_id IN (:ids) OR issue_to_id IN (:ids)", :ids => issues.map(&:id)).all
974 983 issues.each do |issue|
975 984 issue.instance_variable_set "@relations", relations.select {|r| r.issue_from_id == issue.id || r.issue_to_id == issue.id}
976 985 end
977 986 end
978 987 end
979 988
980 989 # Preloads visible spent time for a collection of issues
981 990 def self.load_visible_spent_hours(issues, user=User.current)
982 991 if issues.any?
983 992 hours_by_issue_id = TimeEntry.visible(user).where(:issue_id => issues.map(&:id)).group(:issue_id).sum(:hours)
984 993 issues.each do |issue|
985 994 issue.instance_variable_set "@spent_hours", (hours_by_issue_id[issue.id] || 0)
986 995 end
987 996 end
988 997 end
989 998
990 999 # Preloads visible total spent time for a collection of issues
991 1000 def self.load_visible_total_spent_hours(issues, user=User.current)
992 1001 if issues.any?
993 1002 hours_by_issue_id = TimeEntry.visible(user).joins(:issue).
994 1003 joins("JOIN #{Issue.table_name} parent ON parent.root_id = #{Issue.table_name}.root_id" +
995 1004 " AND parent.lft <= #{Issue.table_name}.lft AND parent.rgt >= #{Issue.table_name}.rgt").
996 1005 where("parent.id IN (?)", issues.map(&:id)).group("parent.id").sum(:hours)
997 1006 issues.each do |issue|
998 1007 issue.instance_variable_set "@total_spent_hours", (hours_by_issue_id[issue.id] || 0)
999 1008 end
1000 1009 end
1001 1010 end
1002 1011
1003 1012 # Preloads visible relations for a collection of issues
1004 1013 def self.load_visible_relations(issues, user=User.current)
1005 1014 if issues.any?
1006 1015 issue_ids = issues.map(&:id)
1007 1016 # Relations with issue_from in given issues and visible issue_to
1008 1017 relations_from = IssueRelation.joins(:issue_to => :project).
1009 1018 where(visible_condition(user)).where(:issue_from_id => issue_ids).to_a
1010 1019 # Relations with issue_to in given issues and visible issue_from
1011 1020 relations_to = IssueRelation.joins(:issue_from => :project).
1012 1021 where(visible_condition(user)).
1013 1022 where(:issue_to_id => issue_ids).to_a
1014 1023 issues.each do |issue|
1015 1024 relations =
1016 1025 relations_from.select {|relation| relation.issue_from_id == issue.id} +
1017 1026 relations_to.select {|relation| relation.issue_to_id == issue.id}
1018 1027
1019 1028 issue.instance_variable_set "@relations", IssueRelation::Relations.new(issue, relations.sort)
1020 1029 end
1021 1030 end
1022 1031 end
1023 1032
1024 1033 # Finds an issue relation given its id.
1025 1034 def find_relation(relation_id)
1026 1035 IssueRelation.where("issue_to_id = ? OR issue_from_id = ?", id, id).find(relation_id)
1027 1036 end
1028 1037
1029 1038 # Returns all the other issues that depend on the issue
1030 1039 # The algorithm is a modified breadth first search (bfs)
1031 1040 def all_dependent_issues(except=[])
1032 1041 # The found dependencies
1033 1042 dependencies = []
1034 1043
1035 1044 # The visited flag for every node (issue) used by the breadth first search
1036 1045 eNOT_DISCOVERED = 0 # The issue is "new" to the algorithm, it has not seen it before.
1037 1046
1038 1047 ePROCESS_ALL = 1 # The issue is added to the queue. Process both children and relations of
1039 1048 # the issue when it is processed.
1040 1049
1041 1050 ePROCESS_RELATIONS_ONLY = 2 # The issue was added to the queue and will be output as dependent issue,
1042 1051 # but its children will not be added to the queue when it is processed.
1043 1052
1044 1053 eRELATIONS_PROCESSED = 3 # The related issues, the parent issue and the issue itself have been added to
1045 1054 # the queue, but its children have not been added.
1046 1055
1047 1056 ePROCESS_CHILDREN_ONLY = 4 # The relations and the parent of the issue have been added to the queue, but
1048 1057 # the children still need to be processed.
1049 1058
1050 1059 eALL_PROCESSED = 5 # The issue and all its children, its parent and its related issues have been
1051 1060 # added as dependent issues. It needs no further processing.
1052 1061
1053 1062 issue_status = Hash.new(eNOT_DISCOVERED)
1054 1063
1055 1064 # The queue
1056 1065 queue = []
1057 1066
1058 1067 # Initialize the bfs, add start node (self) to the queue
1059 1068 queue << self
1060 1069 issue_status[self] = ePROCESS_ALL
1061 1070
1062 1071 while (!queue.empty?) do
1063 1072 current_issue = queue.shift
1064 1073 current_issue_status = issue_status[current_issue]
1065 1074 dependencies << current_issue
1066 1075
1067 1076 # Add parent to queue, if not already in it.
1068 1077 parent = current_issue.parent
1069 1078 parent_status = issue_status[parent]
1070 1079
1071 1080 if parent && (parent_status == eNOT_DISCOVERED) && !except.include?(parent)
1072 1081 queue << parent
1073 1082 issue_status[parent] = ePROCESS_RELATIONS_ONLY
1074 1083 end
1075 1084
1076 1085 # Add children to queue, but only if they are not already in it and
1077 1086 # the children of the current node need to be processed.
1078 1087 if (current_issue_status == ePROCESS_CHILDREN_ONLY || current_issue_status == ePROCESS_ALL)
1079 1088 current_issue.children.each do |child|
1080 1089 next if except.include?(child)
1081 1090
1082 1091 if (issue_status[child] == eNOT_DISCOVERED)
1083 1092 queue << child
1084 1093 issue_status[child] = ePROCESS_ALL
1085 1094 elsif (issue_status[child] == eRELATIONS_PROCESSED)
1086 1095 queue << child
1087 1096 issue_status[child] = ePROCESS_CHILDREN_ONLY
1088 1097 elsif (issue_status[child] == ePROCESS_RELATIONS_ONLY)
1089 1098 queue << child
1090 1099 issue_status[child] = ePROCESS_ALL
1091 1100 end
1092 1101 end
1093 1102 end
1094 1103
1095 1104 # Add related issues to the queue, if they are not already in it.
1096 1105 current_issue.relations_from.map(&:issue_to).each do |related_issue|
1097 1106 next if except.include?(related_issue)
1098 1107
1099 1108 if (issue_status[related_issue] == eNOT_DISCOVERED)
1100 1109 queue << related_issue
1101 1110 issue_status[related_issue] = ePROCESS_ALL
1102 1111 elsif (issue_status[related_issue] == eRELATIONS_PROCESSED)
1103 1112 queue << related_issue
1104 1113 issue_status[related_issue] = ePROCESS_CHILDREN_ONLY
1105 1114 elsif (issue_status[related_issue] == ePROCESS_RELATIONS_ONLY)
1106 1115 queue << related_issue
1107 1116 issue_status[related_issue] = ePROCESS_ALL
1108 1117 end
1109 1118 end
1110 1119
1111 1120 # Set new status for current issue
1112 1121 if (current_issue_status == ePROCESS_ALL) || (current_issue_status == ePROCESS_CHILDREN_ONLY)
1113 1122 issue_status[current_issue] = eALL_PROCESSED
1114 1123 elsif (current_issue_status == ePROCESS_RELATIONS_ONLY)
1115 1124 issue_status[current_issue] = eRELATIONS_PROCESSED
1116 1125 end
1117 1126 end # while
1118 1127
1119 1128 # Remove the issues from the "except" parameter from the result array
1120 1129 dependencies -= except
1121 1130 dependencies.delete(self)
1122 1131
1123 1132 dependencies
1124 1133 end
1125 1134
1126 1135 # Returns an array of issues that duplicate this one
1127 1136 def duplicates
1128 1137 relations_to.select {|r| r.relation_type == IssueRelation::TYPE_DUPLICATES}.collect {|r| r.issue_from}
1129 1138 end
1130 1139
1131 1140 # Returns the due date or the target due date if any
1132 1141 # Used on gantt chart
1133 1142 def due_before
1134 1143 due_date || (fixed_version ? fixed_version.effective_date : nil)
1135 1144 end
1136 1145
1137 1146 # Returns the time scheduled for this issue.
1138 1147 #
1139 1148 # Example:
1140 1149 # Start Date: 2/26/09, End Date: 3/04/09
1141 1150 # duration => 6
1142 1151 def duration
1143 1152 (start_date && due_date) ? due_date - start_date : 0
1144 1153 end
1145 1154
1146 1155 # Returns the duration in working days
1147 1156 def working_duration
1148 1157 (start_date && due_date) ? working_days(start_date, due_date) : 0
1149 1158 end
1150 1159
1151 1160 def soonest_start(reload=false)
1152 1161 if @soonest_start.nil? || reload
1153 1162 dates = relations_to(reload).collect{|relation| relation.successor_soonest_start}
1154 1163 p = @parent_issue || parent
1155 1164 if p && Setting.parent_issue_dates == 'derived'
1156 1165 dates << p.soonest_start
1157 1166 end
1158 1167 @soonest_start = dates.compact.max
1159 1168 end
1160 1169 @soonest_start
1161 1170 end
1162 1171
1163 1172 # Sets start_date on the given date or the next working day
1164 1173 # and changes due_date to keep the same working duration.
1165 1174 def reschedule_on(date)
1166 1175 wd = working_duration
1167 1176 date = next_working_date(date)
1168 1177 self.start_date = date
1169 1178 self.due_date = add_working_days(date, wd)
1170 1179 end
1171 1180
1172 1181 # Reschedules the issue on the given date or the next working day and saves the record.
1173 1182 # If the issue is a parent task, this is done by rescheduling its subtasks.
1174 1183 def reschedule_on!(date)
1175 1184 return if date.nil?
1176 1185 if leaf? || !dates_derived?
1177 1186 if start_date.nil? || start_date != date
1178 1187 if start_date && start_date > date
1179 1188 # Issue can not be moved earlier than its soonest start date
1180 1189 date = [soonest_start(true), date].compact.max
1181 1190 end
1182 1191 reschedule_on(date)
1183 1192 begin
1184 1193 save
1185 1194 rescue ActiveRecord::StaleObjectError
1186 1195 reload
1187 1196 reschedule_on(date)
1188 1197 save
1189 1198 end
1190 1199 end
1191 1200 else
1192 1201 leaves.each do |leaf|
1193 1202 if leaf.start_date
1194 1203 # Only move subtask if it starts at the same date as the parent
1195 1204 # or if it starts before the given date
1196 1205 if start_date == leaf.start_date || date > leaf.start_date
1197 1206 leaf.reschedule_on!(date)
1198 1207 end
1199 1208 else
1200 1209 leaf.reschedule_on!(date)
1201 1210 end
1202 1211 end
1203 1212 end
1204 1213 end
1205 1214
1206 1215 def dates_derived?
1207 1216 !leaf? && Setting.parent_issue_dates == 'derived'
1208 1217 end
1209 1218
1210 1219 def priority_derived?
1211 1220 !leaf? && Setting.parent_issue_priority == 'derived'
1212 1221 end
1213 1222
1214 1223 def done_ratio_derived?
1215 1224 !leaf? && Setting.parent_issue_done_ratio == 'derived'
1216 1225 end
1217 1226
1218 1227 def <=>(issue)
1219 1228 if issue.nil?
1220 1229 -1
1221 1230 elsif root_id != issue.root_id
1222 1231 (root_id || 0) <=> (issue.root_id || 0)
1223 1232 else
1224 1233 (lft || 0) <=> (issue.lft || 0)
1225 1234 end
1226 1235 end
1227 1236
1228 1237 def to_s
1229 1238 "#{tracker} ##{id}: #{subject}"
1230 1239 end
1231 1240
1232 1241 # Returns a string of css classes that apply to the issue
1233 1242 def css_classes(user=User.current)
1234 1243 s = "issue tracker-#{tracker_id} status-#{status_id} #{priority.try(:css_classes)}"
1235 1244 s << ' closed' if closed?
1236 1245 s << ' overdue' if overdue?
1237 1246 s << ' child' if child?
1238 1247 s << ' parent' unless leaf?
1239 1248 s << ' private' if is_private?
1240 1249 if user.logged?
1241 1250 s << ' created-by-me' if author_id == user.id
1242 1251 s << ' assigned-to-me' if assigned_to_id == user.id
1243 1252 s << ' assigned-to-my-group' if user.groups.any? {|g| g.id == assigned_to_id}
1244 1253 end
1245 1254 s
1246 1255 end
1247 1256
1248 1257 # Unassigns issues from +version+ if it's no longer shared with issue's project
1249 1258 def self.update_versions_from_sharing_change(version)
1250 1259 # Update issues assigned to the version
1251 1260 update_versions(["#{Issue.table_name}.fixed_version_id = ?", version.id])
1252 1261 end
1253 1262
1254 1263 # Unassigns issues from versions that are no longer shared
1255 1264 # after +project+ was moved
1256 1265 def self.update_versions_from_hierarchy_change(project)
1257 1266 moved_project_ids = project.self_and_descendants.reload.collect(&:id)
1258 1267 # Update issues of the moved projects and issues assigned to a version of a moved project
1259 1268 Issue.update_versions(
1260 1269 ["#{Version.table_name}.project_id IN (?) OR #{Issue.table_name}.project_id IN (?)",
1261 1270 moved_project_ids, moved_project_ids]
1262 1271 )
1263 1272 end
1264 1273
1265 1274 def parent_issue_id=(arg)
1266 1275 s = arg.to_s.strip.presence
1267 1276 if s && (m = s.match(%r{\A#?(\d+)\z})) && (@parent_issue = Issue.find_by_id(m[1]))
1268 1277 @invalid_parent_issue_id = nil
1269 1278 elsif s.blank?
1270 1279 @parent_issue = nil
1271 1280 @invalid_parent_issue_id = nil
1272 1281 else
1273 1282 @parent_issue = nil
1274 1283 @invalid_parent_issue_id = arg
1275 1284 end
1276 1285 end
1277 1286
1278 1287 def parent_issue_id
1279 1288 if @invalid_parent_issue_id
1280 1289 @invalid_parent_issue_id
1281 1290 elsif instance_variable_defined? :@parent_issue
1282 1291 @parent_issue.nil? ? nil : @parent_issue.id
1283 1292 else
1284 1293 parent_id
1285 1294 end
1286 1295 end
1287 1296
1288 1297 def set_parent_id
1289 1298 self.parent_id = parent_issue_id
1290 1299 end
1291 1300
1292 1301 # Returns true if issue's project is a valid
1293 1302 # parent issue project
1294 1303 def valid_parent_project?(issue=parent)
1295 1304 return true if issue.nil? || issue.project_id == project_id
1296 1305
1297 1306 case Setting.cross_project_subtasks
1298 1307 when 'system'
1299 1308 true
1300 1309 when 'tree'
1301 1310 issue.project.root == project.root
1302 1311 when 'hierarchy'
1303 1312 issue.project.is_or_is_ancestor_of?(project) || issue.project.is_descendant_of?(project)
1304 1313 when 'descendants'
1305 1314 issue.project.is_or_is_ancestor_of?(project)
1306 1315 else
1307 1316 false
1308 1317 end
1309 1318 end
1310 1319
1311 1320 # Returns an issue scope based on project and scope
1312 1321 def self.cross_project_scope(project, scope=nil)
1313 1322 if project.nil?
1314 1323 return Issue
1315 1324 end
1316 1325 case scope
1317 1326 when 'all', 'system'
1318 1327 Issue
1319 1328 when 'tree'
1320 1329 Issue.joins(:project).where("(#{Project.table_name}.lft >= :lft AND #{Project.table_name}.rgt <= :rgt)",
1321 1330 :lft => project.root.lft, :rgt => project.root.rgt)
1322 1331 when 'hierarchy'
1323 1332 Issue.joins(:project).where("(#{Project.table_name}.lft >= :lft AND #{Project.table_name}.rgt <= :rgt) OR (#{Project.table_name}.lft < :lft AND #{Project.table_name}.rgt > :rgt)",
1324 1333 :lft => project.lft, :rgt => project.rgt)
1325 1334 when 'descendants'
1326 1335 Issue.joins(:project).where("(#{Project.table_name}.lft >= :lft AND #{Project.table_name}.rgt <= :rgt)",
1327 1336 :lft => project.lft, :rgt => project.rgt)
1328 1337 else
1329 1338 Issue.where(:project_id => project.id)
1330 1339 end
1331 1340 end
1332 1341
1333 1342 def self.by_tracker(project)
1334 1343 count_and_group_by(:project => project, :association => :tracker)
1335 1344 end
1336 1345
1337 1346 def self.by_version(project)
1338 1347 count_and_group_by(:project => project, :association => :fixed_version)
1339 1348 end
1340 1349
1341 1350 def self.by_priority(project)
1342 1351 count_and_group_by(:project => project, :association => :priority)
1343 1352 end
1344 1353
1345 1354 def self.by_category(project)
1346 1355 count_and_group_by(:project => project, :association => :category)
1347 1356 end
1348 1357
1349 1358 def self.by_assigned_to(project)
1350 1359 count_and_group_by(:project => project, :association => :assigned_to)
1351 1360 end
1352 1361
1353 1362 def self.by_author(project)
1354 1363 count_and_group_by(:project => project, :association => :author)
1355 1364 end
1356 1365
1357 1366 def self.by_subproject(project)
1358 1367 r = count_and_group_by(:project => project, :with_subprojects => true, :association => :project)
1359 1368 r.reject {|r| r["project_id"] == project.id.to_s}
1360 1369 end
1361 1370
1362 1371 # Query generator for selecting groups of issue counts for a project
1363 1372 # based on specific criteria
1364 1373 #
1365 1374 # Options
1366 1375 # * project - Project to search in.
1367 1376 # * with_subprojects - Includes subprojects issues if set to true.
1368 1377 # * association - Symbol. Association for grouping.
1369 1378 def self.count_and_group_by(options)
1370 1379 assoc = reflect_on_association(options[:association])
1371 1380 select_field = assoc.foreign_key
1372 1381
1373 1382 Issue.
1374 1383 visible(User.current, :project => options[:project], :with_subprojects => options[:with_subprojects]).
1375 1384 joins(:status, assoc.name).
1376 1385 group(:status_id, :is_closed, select_field).
1377 1386 count.
1378 1387 map do |columns, total|
1379 1388 status_id, is_closed, field_value = columns
1380 1389 is_closed = ['t', 'true', '1'].include?(is_closed.to_s)
1381 1390 {
1382 1391 "status_id" => status_id.to_s,
1383 1392 "closed" => is_closed,
1384 1393 select_field => field_value.to_s,
1385 1394 "total" => total.to_s
1386 1395 }
1387 1396 end
1388 1397 end
1389 1398
1390 1399 # Returns a scope of projects that user can assign the issue to
1391 1400 def allowed_target_projects(user=User.current)
1392 1401 current_project = new_record? ? nil : project
1393 1402 self.class.allowed_target_projects(user, current_project)
1394 1403 end
1395 1404
1396 1405 # Returns a scope of projects that user can assign issues to
1397 1406 # If current_project is given, it will be included in the scope
1398 1407 def self.allowed_target_projects(user=User.current, current_project=nil)
1399 1408 condition = Project.allowed_to_condition(user, :add_issues)
1400 1409 if current_project
1401 1410 condition = ["(#{condition}) OR #{Project.table_name}.id = ?", current_project.id]
1402 1411 end
1403 1412 Project.where(condition).having_trackers
1404 1413 end
1405 1414
1406 1415 private
1407 1416
1408 1417 def after_project_change
1409 1418 # Update project_id on related time entries
1410 1419 TimeEntry.where({:issue_id => id}).update_all(["project_id = ?", project_id])
1411 1420
1412 1421 # Delete issue relations
1413 1422 unless Setting.cross_project_issue_relations?
1414 1423 relations_from.clear
1415 1424 relations_to.clear
1416 1425 end
1417 1426
1418 1427 # Move subtasks that were in the same project
1419 1428 children.each do |child|
1420 1429 next unless child.project_id == project_id_was
1421 1430 # Change project and keep project
1422 1431 child.send :project=, project, true
1423 1432 unless child.save
1424 1433 raise ActiveRecord::Rollback
1425 1434 end
1426 1435 end
1427 1436 end
1428 1437
1429 1438 # Callback for after the creation of an issue by copy
1430 1439 # * adds a "copied to" relation with the copied issue
1431 1440 # * copies subtasks from the copied issue
1432 1441 def after_create_from_copy
1433 1442 return unless copy? && !@after_create_from_copy_handled
1434 1443
1435 1444 if (@copied_from.project_id == project_id || Setting.cross_project_issue_relations?) && @copy_options[:link] != false
1436 1445 if @current_journal
1437 1446 @copied_from.init_journal(@current_journal.user)
1438 1447 end
1439 1448 relation = IssueRelation.new(:issue_from => @copied_from, :issue_to => self, :relation_type => IssueRelation::TYPE_COPIED_TO)
1440 1449 unless relation.save
1441 1450 logger.error "Could not create relation while copying ##{@copied_from.id} to ##{id} due to validation errors: #{relation.errors.full_messages.join(', ')}" if logger
1442 1451 end
1443 1452 end
1444 1453
1445 1454 unless @copied_from.leaf? || @copy_options[:subtasks] == false
1446 1455 copy_options = (@copy_options || {}).merge(:subtasks => false)
1447 1456 copied_issue_ids = {@copied_from.id => self.id}
1448 1457 @copied_from.reload.descendants.reorder("#{Issue.table_name}.lft").each do |child|
1449 1458 # Do not copy self when copying an issue as a descendant of the copied issue
1450 1459 next if child == self
1451 1460 # Do not copy subtasks of issues that were not copied
1452 1461 next unless copied_issue_ids[child.parent_id]
1453 1462 # Do not copy subtasks that are not visible to avoid potential disclosure of private data
1454 1463 unless child.visible?
1455 1464 logger.error "Subtask ##{child.id} was not copied during ##{@copied_from.id} copy because it is not visible to the current user" if logger
1456 1465 next
1457 1466 end
1458 1467 copy = Issue.new.copy_from(child, copy_options)
1459 1468 if @current_journal
1460 1469 copy.init_journal(@current_journal.user)
1461 1470 end
1462 1471 copy.author = author
1463 1472 copy.project = project
1464 1473 copy.parent_issue_id = copied_issue_ids[child.parent_id]
1465 1474 unless copy.save
1466 1475 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
1467 1476 next
1468 1477 end
1469 1478 copied_issue_ids[child.id] = copy.id
1470 1479 end
1471 1480 end
1472 1481 @after_create_from_copy_handled = true
1473 1482 end
1474 1483
1475 1484 def update_nested_set_attributes
1476 1485 if parent_id_changed?
1477 1486 update_nested_set_attributes_on_parent_change
1478 1487 end
1479 1488 remove_instance_variable(:@parent_issue) if instance_variable_defined?(:@parent_issue)
1480 1489 end
1481 1490
1482 1491 # Updates the nested set for when an existing issue is moved
1483 1492 def update_nested_set_attributes_on_parent_change
1484 1493 former_parent_id = parent_id_was
1485 1494 # delete invalid relations of all descendants
1486 1495 self_and_descendants.each do |issue|
1487 1496 issue.relations.each do |relation|
1488 1497 relation.destroy unless relation.valid?
1489 1498 end
1490 1499 end
1491 1500 # update former parent
1492 1501 recalculate_attributes_for(former_parent_id) if former_parent_id
1493 1502 end
1494 1503
1495 1504 def update_parent_attributes
1496 1505 if parent_id
1497 1506 recalculate_attributes_for(parent_id)
1498 1507 association(:parent).reset
1499 1508 end
1500 1509 end
1501 1510
1502 1511 def recalculate_attributes_for(issue_id)
1503 1512 if issue_id && p = Issue.find_by_id(issue_id)
1504 1513 if p.priority_derived?
1505 1514 # priority = highest priority of children
1506 1515 if priority_position = p.children.joins(:priority).maximum("#{IssuePriority.table_name}.position")
1507 1516 p.priority = IssuePriority.find_by_position(priority_position)
1508 1517 end
1509 1518 end
1510 1519
1511 1520 if p.dates_derived?
1512 1521 # start/due dates = lowest/highest dates of children
1513 1522 p.start_date = p.children.minimum(:start_date)
1514 1523 p.due_date = p.children.maximum(:due_date)
1515 1524 if p.start_date && p.due_date && p.due_date < p.start_date
1516 1525 p.start_date, p.due_date = p.due_date, p.start_date
1517 1526 end
1518 1527 end
1519 1528
1520 1529 if p.done_ratio_derived?
1521 1530 # done ratio = weighted average ratio of leaves
1522 1531 unless Issue.use_status_for_done_ratio? && p.status && p.status.default_done_ratio
1523 1532 leaves_count = p.leaves.count
1524 1533 if leaves_count > 0
1525 1534 average = p.leaves.where("estimated_hours > 0").average(:estimated_hours).to_f
1526 1535 if average == 0
1527 1536 average = 1
1528 1537 end
1529 1538 done = p.leaves.joins(:status).
1530 1539 sum("COALESCE(CASE WHEN estimated_hours > 0 THEN estimated_hours ELSE NULL END, #{average}) " +
1531 1540 "* (CASE WHEN is_closed = #{self.class.connection.quoted_true} THEN 100 ELSE COALESCE(done_ratio, 0) END)").to_f
1532 1541 progress = done / (average * leaves_count)
1533 1542 p.done_ratio = progress.round
1534 1543 end
1535 1544 end
1536 1545 end
1537 1546
1538 1547 # ancestors will be recursively updated
1539 1548 p.save(:validate => false)
1540 1549 end
1541 1550 end
1542 1551
1543 1552 # Update issues so their versions are not pointing to a
1544 1553 # fixed_version that is not shared with the issue's project
1545 1554 def self.update_versions(conditions=nil)
1546 1555 # Only need to update issues with a fixed_version from
1547 1556 # a different project and that is not systemwide shared
1548 1557 Issue.joins(:project, :fixed_version).
1549 1558 where("#{Issue.table_name}.fixed_version_id IS NOT NULL" +
1550 1559 " AND #{Issue.table_name}.project_id <> #{Version.table_name}.project_id" +
1551 1560 " AND #{Version.table_name}.sharing <> 'system'").
1552 1561 where(conditions).each do |issue|
1553 1562 next if issue.project.nil? || issue.fixed_version.nil?
1554 1563 unless issue.project.shared_versions.include?(issue.fixed_version)
1555 1564 issue.init_journal(User.current)
1556 1565 issue.fixed_version = nil
1557 1566 issue.save
1558 1567 end
1559 1568 end
1560 1569 end
1561 1570
1562 1571 # Callback on file attachment
1563 1572 def attachment_added(attachment)
1564 1573 if current_journal && !attachment.new_record?
1565 1574 current_journal.journalize_attachment(attachment, :added)
1566 1575 end
1567 1576 end
1568 1577
1569 1578 # Callback on attachment deletion
1570 1579 def attachment_removed(attachment)
1571 1580 if current_journal && !attachment.new_record?
1572 1581 current_journal.journalize_attachment(attachment, :removed)
1573 1582 current_journal.save
1574 1583 end
1575 1584 end
1576 1585
1577 1586 # Called after a relation is added
1578 1587 def relation_added(relation)
1579 1588 if current_journal
1580 1589 current_journal.journalize_relation(relation, :added)
1581 1590 current_journal.save
1582 1591 end
1583 1592 end
1584 1593
1585 1594 # Called after a relation is removed
1586 1595 def relation_removed(relation)
1587 1596 if current_journal
1588 1597 current_journal.journalize_relation(relation, :removed)
1589 1598 current_journal.save
1590 1599 end
1591 1600 end
1592 1601
1593 1602 # Default assignment based on category
1594 1603 def default_assign
1595 1604 if assigned_to.nil? && category && category.assigned_to
1596 1605 self.assigned_to = category.assigned_to
1597 1606 end
1598 1607 end
1599 1608
1600 1609 # Updates start/due dates of following issues
1601 1610 def reschedule_following_issues
1602 1611 if start_date_changed? || due_date_changed?
1603 1612 relations_from.each do |relation|
1604 1613 relation.set_issue_to_dates
1605 1614 end
1606 1615 end
1607 1616 end
1608 1617
1609 1618 # Closes duplicates if the issue is being closed
1610 1619 def close_duplicates
1611 1620 if closing?
1612 1621 duplicates.each do |duplicate|
1613 1622 # Reload is needed in case the duplicate was updated by a previous duplicate
1614 1623 duplicate.reload
1615 1624 # Don't re-close it if it's already closed
1616 1625 next if duplicate.closed?
1617 1626 # Same user and notes
1618 1627 if @current_journal
1619 1628 duplicate.init_journal(@current_journal.user, @current_journal.notes)
1620 1629 end
1621 1630 duplicate.update_attribute :status, self.status
1622 1631 end
1623 1632 end
1624 1633 end
1625 1634
1626 1635 # Make sure updated_on is updated when adding a note and set updated_on now
1627 1636 # so we can set closed_on with the same value on closing
1628 1637 def force_updated_on_change
1629 1638 if @current_journal || changed?
1630 1639 self.updated_on = current_time_from_proper_timezone
1631 1640 if new_record?
1632 1641 self.created_on = updated_on
1633 1642 end
1634 1643 end
1635 1644 end
1636 1645
1637 1646 # Callback for setting closed_on when the issue is closed.
1638 1647 # The closed_on attribute stores the time of the last closing
1639 1648 # and is preserved when the issue is reopened.
1640 1649 def update_closed_on
1641 1650 if closing?
1642 1651 self.closed_on = updated_on
1643 1652 end
1644 1653 end
1645 1654
1646 1655 # Saves the changes in a Journal
1647 1656 # Called after_save
1648 1657 def create_journal
1649 1658 if current_journal
1650 1659 current_journal.save
1651 1660 end
1652 1661 end
1653 1662
1654 1663 def send_notification
1655 1664 if notify? && Setting.notified_events.include?('issue_added')
1656 1665 Mailer.deliver_issue_add(self)
1657 1666 end
1658 1667 end
1659 1668
1660 1669 # Stores the previous assignee so we can still have access
1661 1670 # to it during after_save callbacks (assigned_to_id_was is reset)
1662 1671 def set_assigned_to_was
1663 1672 @previous_assigned_to_id = assigned_to_id_was
1664 1673 end
1665 1674
1666 1675 # Clears the previous assignee at the end of after_save callbacks
1667 1676 def clear_assigned_to_was
1668 1677 @assigned_to_was = nil
1669 1678 @previous_assigned_to_id = nil
1670 1679 end
1671 1680
1672 1681 def clear_disabled_fields
1673 1682 if tracker
1674 1683 tracker.disabled_core_fields.each do |attribute|
1675 1684 send "#{attribute}=", nil
1676 1685 end
1677 1686 self.done_ratio ||= 0
1678 1687 end
1679 1688 end
1680 1689 end
@@ -1,1042 +1,1044
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2015 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 Project < ActiveRecord::Base
19 19 include Redmine::SafeAttributes
20 20 include Redmine::NestedSet::ProjectNestedSet
21 21
22 22 # Project statuses
23 23 STATUS_ACTIVE = 1
24 24 STATUS_CLOSED = 5
25 25 STATUS_ARCHIVED = 9
26 26
27 27 # Maximum length for project identifiers
28 28 IDENTIFIER_MAX_LENGTH = 100
29 29
30 30 # Specific overridden Activities
31 31 has_many :time_entry_activities
32 32 has_many :memberships, :class_name => 'Member', :inverse_of => :project
33 33 # Memberships of active users only
34 34 has_many :members,
35 35 lambda { joins(:principal).where(:users => {:type => 'User', :status => Principal::STATUS_ACTIVE}) }
36 36 has_many :enabled_modules, :dependent => :delete_all
37 37 has_and_belongs_to_many :trackers, lambda {order(:position)}
38 38 has_many :issues, :dependent => :destroy
39 39 has_many :issue_changes, :through => :issues, :source => :journals
40 40 has_many :versions, lambda {order("#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC")}, :dependent => :destroy
41 belongs_to :default_version, :class_name => 'Version'
41 42 has_many :time_entries, :dependent => :destroy
42 43 has_many :queries, :class_name => 'IssueQuery', :dependent => :delete_all
43 44 has_many :documents, :dependent => :destroy
44 45 has_many :news, lambda {includes(:author)}, :dependent => :destroy
45 46 has_many :issue_categories, lambda {order("#{IssueCategory.table_name}.name")}, :dependent => :delete_all
46 47 has_many :boards, lambda {order("position ASC")}, :dependent => :destroy
47 48 has_one :repository, lambda {where(["is_default = ?", true])}
48 49 has_many :repositories, :dependent => :destroy
49 50 has_many :changesets, :through => :repository
50 51 has_one :wiki, :dependent => :destroy
51 52 # Custom field for the project issues
52 53 has_and_belongs_to_many :issue_custom_fields,
53 54 lambda {order("#{CustomField.table_name}.position")},
54 55 :class_name => 'IssueCustomField',
55 56 :join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}",
56 57 :association_foreign_key => 'custom_field_id'
57 58
58 59 acts_as_attachable :view_permission => :view_files,
59 60 :edit_permission => :manage_files,
60 61 :delete_permission => :manage_files
61 62
62 63 acts_as_customizable
63 64 acts_as_searchable :columns => ['name', 'identifier', 'description'], :project_key => "#{Project.table_name}.id", :permission => nil
64 65 acts_as_event :title => Proc.new {|o| "#{l(:label_project)}: #{o.name}"},
65 66 :url => Proc.new {|o| {:controller => 'projects', :action => 'show', :id => o}},
66 67 :author => nil
67 68
68 69 attr_protected :status
69 70
70 71 validates_presence_of :name, :identifier
71 72 validates_uniqueness_of :identifier, :if => Proc.new {|p| p.identifier_changed?}
72 73 validates_length_of :name, :maximum => 255
73 74 validates_length_of :homepage, :maximum => 255
74 75 validates_length_of :identifier, :in => 1..IDENTIFIER_MAX_LENGTH
75 76 # downcase letters, digits, dashes but not digits only
76 77 validates_format_of :identifier, :with => /\A(?!\d+$)[a-z0-9\-_]*\z/, :if => Proc.new { |p| p.identifier_changed? }
77 78 # reserved words
78 79 validates_exclusion_of :identifier, :in => %w( new )
79 80 validate :validate_parent
80 81
81 82 after_save :update_inherited_members, :if => Proc.new {|project| project.inherit_members_changed?}
82 83 after_save :remove_inherited_member_roles, :add_inherited_member_roles, :if => Proc.new {|project| project.parent_id_changed?}
83 84 after_update :update_versions_from_hierarchy_change, :if => Proc.new {|project| project.parent_id_changed?}
84 85 before_destroy :delete_all_members
85 86
86 87 scope :has_module, lambda {|mod|
87 88 where("#{Project.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name=?)", mod.to_s)
88 89 }
89 90 scope :active, lambda { where(:status => STATUS_ACTIVE) }
90 91 scope :status, lambda {|arg| where(arg.blank? ? nil : {:status => arg.to_i}) }
91 92 scope :all_public, lambda { where(:is_public => true) }
92 93 scope :visible, lambda {|*args| where(Project.visible_condition(args.shift || User.current, *args)) }
93 94 scope :allowed_to, lambda {|*args|
94 95 user = User.current
95 96 permission = nil
96 97 if args.first.is_a?(Symbol)
97 98 permission = args.shift
98 99 else
99 100 user = args.shift
100 101 permission = args.shift
101 102 end
102 103 where(Project.allowed_to_condition(user, permission, *args))
103 104 }
104 105 scope :like, lambda {|arg|
105 106 if arg.blank?
106 107 where(nil)
107 108 else
108 109 pattern = "%#{arg.to_s.strip.downcase}%"
109 110 where("LOWER(identifier) LIKE :p OR LOWER(name) LIKE :p", :p => pattern)
110 111 end
111 112 }
112 113 scope :sorted, lambda {order(:lft)}
113 114 scope :having_trackers, lambda {
114 115 where("#{Project.table_name}.id IN (SELECT DISTINCT project_id FROM #{table_name_prefix}projects_trackers#{table_name_suffix})")
115 116 }
116 117
117 118 def initialize(attributes=nil, *args)
118 119 super
119 120
120 121 initialized = (attributes || {}).stringify_keys
121 122 if !initialized.key?('identifier') && Setting.sequential_project_identifiers?
122 123 self.identifier = Project.next_identifier
123 124 end
124 125 if !initialized.key?('is_public')
125 126 self.is_public = Setting.default_projects_public?
126 127 end
127 128 if !initialized.key?('enabled_module_names')
128 129 self.enabled_module_names = Setting.default_projects_modules
129 130 end
130 131 if !initialized.key?('trackers') && !initialized.key?('tracker_ids')
131 132 default = Setting.default_projects_tracker_ids
132 133 if default.is_a?(Array)
133 134 self.trackers = Tracker.where(:id => default.map(&:to_i)).sorted.to_a
134 135 else
135 136 self.trackers = Tracker.sorted.to_a
136 137 end
137 138 end
138 139 end
139 140
140 141 def identifier=(identifier)
141 142 super unless identifier_frozen?
142 143 end
143 144
144 145 def identifier_frozen?
145 146 errors[:identifier].blank? && !(new_record? || identifier.blank?)
146 147 end
147 148
148 149 # returns latest created projects
149 150 # non public projects will be returned only if user is a member of those
150 151 def self.latest(user=nil, count=5)
151 152 visible(user).limit(count).order("created_on DESC").to_a
152 153 end
153 154
154 155 # Returns true if the project is visible to +user+ or to the current user.
155 156 def visible?(user=User.current)
156 157 user.allowed_to?(:view_project, self)
157 158 end
158 159
159 160 # Returns a SQL conditions string used to find all projects visible by the specified user.
160 161 #
161 162 # Examples:
162 163 # Project.visible_condition(admin) => "projects.status = 1"
163 164 # Project.visible_condition(normal_user) => "((projects.status = 1) AND (projects.is_public = 1 OR projects.id IN (1,3,4)))"
164 165 # Project.visible_condition(anonymous) => "((projects.status = 1) AND (projects.is_public = 1))"
165 166 def self.visible_condition(user, options={})
166 167 allowed_to_condition(user, :view_project, options)
167 168 end
168 169
169 170 # Returns a SQL conditions string used to find all projects for which +user+ has the given +permission+
170 171 #
171 172 # Valid options:
172 173 # * :project => limit the condition to project
173 174 # * :with_subprojects => limit the condition to project and its subprojects
174 175 # * :member => limit the condition to the user projects
175 176 def self.allowed_to_condition(user, permission, options={})
176 177 perm = Redmine::AccessControl.permission(permission)
177 178 base_statement = (perm && perm.read? ? "#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED}" : "#{Project.table_name}.status = #{Project::STATUS_ACTIVE}")
178 179 if perm && perm.project_module
179 180 # If the permission belongs to a project module, make sure the module is enabled
180 181 base_statement << " AND #{Project.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name='#{perm.project_module}')"
181 182 end
182 183 if project = options[:project]
183 184 project_statement = project.project_condition(options[:with_subprojects])
184 185 base_statement = "(#{project_statement}) AND (#{base_statement})"
185 186 end
186 187
187 188 if user.admin?
188 189 base_statement
189 190 else
190 191 statement_by_role = {}
191 192 unless options[:member]
192 193 role = user.builtin_role
193 194 if role.allowed_to?(permission)
194 195 s = "#{Project.table_name}.is_public = #{connection.quoted_true}"
195 196 if user.id
196 197 s = "(#{s} AND #{Project.table_name}.id NOT IN (SELECT project_id FROM #{Member.table_name} WHERE user_id = #{user.id}))"
197 198 end
198 199 statement_by_role[role] = s
199 200 end
200 201 end
201 202 user.projects_by_role.each do |role, projects|
202 203 if role.allowed_to?(permission) && projects.any?
203 204 statement_by_role[role] = "#{Project.table_name}.id IN (#{projects.collect(&:id).join(',')})"
204 205 end
205 206 end
206 207 if statement_by_role.empty?
207 208 "1=0"
208 209 else
209 210 if block_given?
210 211 statement_by_role.each do |role, statement|
211 212 if s = yield(role, user)
212 213 statement_by_role[role] = "(#{statement} AND (#{s}))"
213 214 end
214 215 end
215 216 end
216 217 "((#{base_statement}) AND (#{statement_by_role.values.join(' OR ')}))"
217 218 end
218 219 end
219 220 end
220 221
221 222 def override_roles(role)
222 223 @override_members ||= memberships.
223 224 joins(:principal).
224 225 where(:users => {:type => ['GroupAnonymous', 'GroupNonMember']}).to_a
225 226
226 227 group_class = role.anonymous? ? GroupAnonymous : GroupNonMember
227 228 member = @override_members.detect {|m| m.principal.is_a? group_class}
228 229 member ? member.roles.to_a : [role]
229 230 end
230 231
231 232 def principals
232 233 @principals ||= Principal.active.joins(:members).where("#{Member.table_name}.project_id = ?", id).uniq
233 234 end
234 235
235 236 def users
236 237 @users ||= User.active.joins(:members).where("#{Member.table_name}.project_id = ?", id).uniq
237 238 end
238 239
239 240 # Returns the Systemwide and project specific activities
240 241 def activities(include_inactive=false)
241 242 t = TimeEntryActivity.table_name
242 243 scope = TimeEntryActivity.where("#{t}.project_id IS NULL OR #{t}.project_id = ?", id)
243 244
244 245 overridden_activity_ids = self.time_entry_activities.pluck(:parent_id).compact
245 246 if overridden_activity_ids.any?
246 247 scope = scope.where("#{t}.id NOT IN (?)", overridden_activity_ids)
247 248 end
248 249 unless include_inactive
249 250 scope = scope.active
250 251 end
251 252 scope
252 253 end
253 254
254 255 # Will create a new Project specific Activity or update an existing one
255 256 #
256 257 # This will raise a ActiveRecord::Rollback if the TimeEntryActivity
257 258 # does not successfully save.
258 259 def update_or_create_time_entry_activity(id, activity_hash)
259 260 if activity_hash.respond_to?(:has_key?) && activity_hash.has_key?('parent_id')
260 261 self.create_time_entry_activity_if_needed(activity_hash)
261 262 else
262 263 activity = project.time_entry_activities.find_by_id(id.to_i)
263 264 activity.update_attributes(activity_hash) if activity
264 265 end
265 266 end
266 267
267 268 # Create a new TimeEntryActivity if it overrides a system TimeEntryActivity
268 269 #
269 270 # This will raise a ActiveRecord::Rollback if the TimeEntryActivity
270 271 # does not successfully save.
271 272 def create_time_entry_activity_if_needed(activity)
272 273 if activity['parent_id']
273 274 parent_activity = TimeEntryActivity.find(activity['parent_id'])
274 275 activity['name'] = parent_activity.name
275 276 activity['position'] = parent_activity.position
276 277 if Enumeration.overriding_change?(activity, parent_activity)
277 278 project_activity = self.time_entry_activities.create(activity)
278 279 if project_activity.new_record?
279 280 raise ActiveRecord::Rollback, "Overriding TimeEntryActivity was not successfully saved"
280 281 else
281 282 self.time_entries.
282 283 where(:activity_id => parent_activity.id).
283 284 update_all(:activity_id => project_activity.id)
284 285 end
285 286 end
286 287 end
287 288 end
288 289
289 290 # Returns a :conditions SQL string that can be used to find the issues associated with this project.
290 291 #
291 292 # Examples:
292 293 # project.project_condition(true) => "(projects.id = 1 OR (projects.lft > 1 AND projects.rgt < 10))"
293 294 # project.project_condition(false) => "projects.id = 1"
294 295 def project_condition(with_subprojects)
295 296 cond = "#{Project.table_name}.id = #{id}"
296 297 cond = "(#{cond} OR (#{Project.table_name}.lft > #{lft} AND #{Project.table_name}.rgt < #{rgt}))" if with_subprojects
297 298 cond
298 299 end
299 300
300 301 def self.find(*args)
301 302 if args.first && args.first.is_a?(String) && !args.first.match(/^\d*$/)
302 303 project = find_by_identifier(*args)
303 304 raise ActiveRecord::RecordNotFound, "Couldn't find Project with identifier=#{args.first}" if project.nil?
304 305 project
305 306 else
306 307 super
307 308 end
308 309 end
309 310
310 311 def self.find_by_param(*args)
311 312 self.find(*args)
312 313 end
313 314
314 315 alias :base_reload :reload
315 316 def reload(*args)
316 317 @principals = nil
317 318 @users = nil
318 319 @shared_versions = nil
319 320 @rolled_up_versions = nil
320 321 @rolled_up_trackers = nil
321 322 @all_issue_custom_fields = nil
322 323 @all_time_entry_custom_fields = nil
323 324 @to_param = nil
324 325 @allowed_parents = nil
325 326 @allowed_permissions = nil
326 327 @actions_allowed = nil
327 328 @start_date = nil
328 329 @due_date = nil
329 330 @override_members = nil
330 331 @assignable_users = nil
331 332 base_reload(*args)
332 333 end
333 334
334 335 def to_param
335 336 if new_record?
336 337 nil
337 338 else
338 339 # id is used for projects with a numeric identifier (compatibility)
339 340 @to_param ||= (identifier.to_s =~ %r{^\d*$} ? id.to_s : identifier)
340 341 end
341 342 end
342 343
343 344 def active?
344 345 self.status == STATUS_ACTIVE
345 346 end
346 347
347 348 def archived?
348 349 self.status == STATUS_ARCHIVED
349 350 end
350 351
351 352 # Archives the project and its descendants
352 353 def archive
353 354 # Check that there is no issue of a non descendant project that is assigned
354 355 # to one of the project or descendant versions
355 356 version_ids = self_and_descendants.joins(:versions).pluck("#{Version.table_name}.id")
356 357
357 358 if version_ids.any? &&
358 359 Issue.
359 360 includes(:project).
360 361 where("#{Project.table_name}.lft < ? OR #{Project.table_name}.rgt > ?", lft, rgt).
361 362 where(:fixed_version_id => version_ids).
362 363 exists?
363 364 return false
364 365 end
365 366 Project.transaction do
366 367 archive!
367 368 end
368 369 true
369 370 end
370 371
371 372 # Unarchives the project
372 373 # All its ancestors must be active
373 374 def unarchive
374 375 return false if ancestors.detect {|a| !a.active?}
375 376 update_attribute :status, STATUS_ACTIVE
376 377 end
377 378
378 379 def close
379 380 self_and_descendants.status(STATUS_ACTIVE).update_all :status => STATUS_CLOSED
380 381 end
381 382
382 383 def reopen
383 384 self_and_descendants.status(STATUS_CLOSED).update_all :status => STATUS_ACTIVE
384 385 end
385 386
386 387 # Returns an array of projects the project can be moved to
387 388 # by the current user
388 389 def allowed_parents(user=User.current)
389 390 return @allowed_parents if @allowed_parents
390 391 @allowed_parents = Project.allowed_to(user, :add_subprojects).to_a
391 392 @allowed_parents = @allowed_parents - self_and_descendants
392 393 if user.allowed_to?(:add_project, nil, :global => true) || (!new_record? && parent.nil?)
393 394 @allowed_parents << nil
394 395 end
395 396 unless parent.nil? || @allowed_parents.empty? || @allowed_parents.include?(parent)
396 397 @allowed_parents << parent
397 398 end
398 399 @allowed_parents
399 400 end
400 401
401 402 # Sets the parent of the project with authorization check
402 403 def set_allowed_parent!(p)
403 404 ActiveSupport::Deprecation.warn "Project#set_allowed_parent! is deprecated and will be removed in Redmine 4, use #safe_attributes= instead."
404 405 p = p.id if p.is_a?(Project)
405 406 send :safe_attributes, {:project_id => p}
406 407 save
407 408 end
408 409
409 410 # Sets the parent of the project and saves the project
410 411 # Argument can be either a Project, a String, a Fixnum or nil
411 412 def set_parent!(p)
412 413 if p.is_a?(Project)
413 414 self.parent = p
414 415 else
415 416 self.parent_id = p
416 417 end
417 418 save
418 419 end
419 420
420 421 # Returns an array of the trackers used by the project and its active sub projects
421 422 def rolled_up_trackers
422 423 @rolled_up_trackers ||=
423 424 Tracker.
424 425 joins(:projects).
425 426 joins("JOIN #{EnabledModule.table_name} ON #{EnabledModule.table_name}.project_id = #{Project.table_name}.id AND #{EnabledModule.table_name}.name = 'issue_tracking'").
426 427 where("#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status <> ?", lft, rgt, STATUS_ARCHIVED).
427 428 uniq.
428 429 sorted.
429 430 to_a
430 431 end
431 432
432 433 # Closes open and locked project versions that are completed
433 434 def close_completed_versions
434 435 Version.transaction do
435 436 versions.where(:status => %w(open locked)).each do |version|
436 437 if version.completed?
437 438 version.update_attribute(:status, 'closed')
438 439 end
439 440 end
440 441 end
441 442 end
442 443
443 444 # Returns a scope of the Versions on subprojects
444 445 def rolled_up_versions
445 446 @rolled_up_versions ||=
446 447 Version.
447 448 joins(:project).
448 449 where("#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status <> ?", lft, rgt, STATUS_ARCHIVED)
449 450 end
450 451
451 452 # Returns a scope of the Versions used by the project
452 453 def shared_versions
453 454 if new_record?
454 455 Version.
455 456 joins(:project).
456 457 preload(:project).
457 458 where("#{Project.table_name}.status <> ? AND #{Version.table_name}.sharing = 'system'", STATUS_ARCHIVED)
458 459 else
459 460 @shared_versions ||= begin
460 461 r = root? ? self : root
461 462 Version.
462 463 joins(:project).
463 464 preload(:project).
464 465 where("#{Project.table_name}.id = #{id}" +
465 466 " OR (#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED} AND (" +
466 467 " #{Version.table_name}.sharing = 'system'" +
467 468 " OR (#{Project.table_name}.lft >= #{r.lft} AND #{Project.table_name}.rgt <= #{r.rgt} AND #{Version.table_name}.sharing = 'tree')" +
468 469 " OR (#{Project.table_name}.lft < #{lft} AND #{Project.table_name}.rgt > #{rgt} AND #{Version.table_name}.sharing IN ('hierarchy', 'descendants'))" +
469 470 " OR (#{Project.table_name}.lft > #{lft} AND #{Project.table_name}.rgt < #{rgt} AND #{Version.table_name}.sharing = 'hierarchy')" +
470 471 "))")
471 472 end
472 473 end
473 474 end
474 475
475 476 # Returns a hash of project users grouped by role
476 477 def users_by_role
477 478 members.includes(:user, :roles).inject({}) do |h, m|
478 479 m.roles.each do |r|
479 480 h[r] ||= []
480 481 h[r] << m.user
481 482 end
482 483 h
483 484 end
484 485 end
485 486
486 487 # Adds user as a project member with the default role
487 488 # Used for when a non-admin user creates a project
488 489 def add_default_member(user)
489 490 role = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
490 491 member = Member.new(:project => self, :principal => user, :roles => [role])
491 492 self.members << member
492 493 member
493 494 end
494 495
495 496 # Deletes all project's members
496 497 def delete_all_members
497 498 me, mr = Member.table_name, MemberRole.table_name
498 499 self.class.connection.delete("DELETE FROM #{mr} WHERE #{mr}.member_id IN (SELECT #{me}.id FROM #{me} WHERE #{me}.project_id = #{id})")
499 500 Member.delete_all(['project_id = ?', id])
500 501 end
501 502
502 503 # Return a Principal scope of users/groups issues can be assigned to
503 504 def assignable_users
504 505 types = ['User']
505 506 types << 'Group' if Setting.issue_group_assignment?
506 507
507 508 @assignable_users ||= Principal.
508 509 active.
509 510 joins(:members => :roles).
510 511 where(:type => types, :members => {:project_id => id}, :roles => {:assignable => true}).
511 512 uniq.
512 513 sorted
513 514 end
514 515
515 516 # Returns the mail addresses of users that should be always notified on project events
516 517 def recipients
517 518 notified_users.collect {|user| user.mail}
518 519 end
519 520
520 521 # Returns the users that should be notified on project events
521 522 def notified_users
522 523 # TODO: User part should be extracted to User#notify_about?
523 524 members.select {|m| m.principal.present? && (m.mail_notification? || m.principal.mail_notification == 'all')}.collect {|m| m.principal}
524 525 end
525 526
526 527 # Returns a scope of all custom fields enabled for project issues
527 528 # (explicitly associated custom fields and custom fields enabled for all projects)
528 529 def all_issue_custom_fields
529 530 if new_record?
530 531 @all_issue_custom_fields ||= IssueCustomField.
531 532 sorted.
532 533 where("is_for_all = ? OR id IN (?)", true, issue_custom_field_ids)
533 534 else
534 535 @all_issue_custom_fields ||= IssueCustomField.
535 536 sorted.
536 537 where("is_for_all = ? OR id IN (SELECT DISTINCT cfp.custom_field_id" +
537 538 " FROM #{table_name_prefix}custom_fields_projects#{table_name_suffix} cfp" +
538 539 " WHERE cfp.project_id = ?)", true, id)
539 540 end
540 541 end
541 542
542 543 def project
543 544 self
544 545 end
545 546
546 547 def <=>(project)
547 548 name.casecmp(project.name)
548 549 end
549 550
550 551 def to_s
551 552 name
552 553 end
553 554
554 555 # Returns a short description of the projects (first lines)
555 556 def short_description(length = 255)
556 557 description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
557 558 end
558 559
559 560 def css_classes
560 561 s = 'project'
561 562 s << ' root' if root?
562 563 s << ' child' if child?
563 564 s << (leaf? ? ' leaf' : ' parent')
564 565 unless active?
565 566 if archived?
566 567 s << ' archived'
567 568 else
568 569 s << ' closed'
569 570 end
570 571 end
571 572 s
572 573 end
573 574
574 575 # The earliest start date of a project, based on it's issues and versions
575 576 def start_date
576 577 @start_date ||= [
577 578 issues.minimum('start_date'),
578 579 shared_versions.minimum('effective_date'),
579 580 Issue.fixed_version(shared_versions).minimum('start_date')
580 581 ].compact.min
581 582 end
582 583
583 584 # The latest due date of an issue or version
584 585 def due_date
585 586 @due_date ||= [
586 587 issues.maximum('due_date'),
587 588 shared_versions.maximum('effective_date'),
588 589 Issue.fixed_version(shared_versions).maximum('due_date')
589 590 ].compact.max
590 591 end
591 592
592 593 def overdue?
593 594 active? && !due_date.nil? && (due_date < Date.today)
594 595 end
595 596
596 597 # Returns the percent completed for this project, based on the
597 598 # progress on it's versions.
598 599 def completed_percent(options={:include_subprojects => false})
599 600 if options.delete(:include_subprojects)
600 601 total = self_and_descendants.collect(&:completed_percent).sum
601 602
602 603 total / self_and_descendants.count
603 604 else
604 605 if versions.count > 0
605 606 total = versions.collect(&:completed_percent).sum
606 607
607 608 total / versions.count
608 609 else
609 610 100
610 611 end
611 612 end
612 613 end
613 614
614 615 # Return true if this project allows to do the specified action.
615 616 # action can be:
616 617 # * a parameter-like Hash (eg. :controller => 'projects', :action => 'edit')
617 618 # * a permission Symbol (eg. :edit_project)
618 619 def allows_to?(action)
619 620 if archived?
620 621 # No action allowed on archived projects
621 622 return false
622 623 end
623 624 unless active? || Redmine::AccessControl.read_action?(action)
624 625 # No write action allowed on closed projects
625 626 return false
626 627 end
627 628 # No action allowed on disabled modules
628 629 if action.is_a? Hash
629 630 allowed_actions.include? "#{action[:controller]}/#{action[:action]}"
630 631 else
631 632 allowed_permissions.include? action
632 633 end
633 634 end
634 635
635 636 # Return the enabled module with the given name
636 637 # or nil if the module is not enabled for the project
637 638 def enabled_module(name)
638 639 name = name.to_s
639 640 enabled_modules.detect {|m| m.name == name}
640 641 end
641 642
642 643 # Return true if the module with the given name is enabled
643 644 def module_enabled?(name)
644 645 enabled_module(name).present?
645 646 end
646 647
647 648 def enabled_module_names=(module_names)
648 649 if module_names && module_names.is_a?(Array)
649 650 module_names = module_names.collect(&:to_s).reject(&:blank?)
650 651 self.enabled_modules = module_names.collect {|name| enabled_modules.detect {|mod| mod.name == name} || EnabledModule.new(:name => name)}
651 652 else
652 653 enabled_modules.clear
653 654 end
654 655 end
655 656
656 657 # Returns an array of the enabled modules names
657 658 def enabled_module_names
658 659 enabled_modules.collect(&:name)
659 660 end
660 661
661 662 # Enable a specific module
662 663 #
663 664 # Examples:
664 665 # project.enable_module!(:issue_tracking)
665 666 # project.enable_module!("issue_tracking")
666 667 def enable_module!(name)
667 668 enabled_modules << EnabledModule.new(:name => name.to_s) unless module_enabled?(name)
668 669 end
669 670
670 671 # Disable a module if it exists
671 672 #
672 673 # Examples:
673 674 # project.disable_module!(:issue_tracking)
674 675 # project.disable_module!("issue_tracking")
675 676 # project.disable_module!(project.enabled_modules.first)
676 677 def disable_module!(target)
677 678 target = enabled_modules.detect{|mod| target.to_s == mod.name} unless enabled_modules.include?(target)
678 679 target.destroy unless target.blank?
679 680 end
680 681
681 682 safe_attributes 'name',
682 683 'description',
683 684 'homepage',
684 685 'is_public',
685 686 'identifier',
686 687 'custom_field_values',
687 688 'custom_fields',
688 689 'tracker_ids',
689 690 'issue_custom_field_ids',
690 'parent_id'
691 'parent_id',
692 'default_version_id'
691 693
692 694 safe_attributes 'enabled_module_names',
693 695 :if => lambda {|project, user| project.new_record? || user.allowed_to?(:select_project_modules, project) }
694 696
695 697 safe_attributes 'inherit_members',
696 698 :if => lambda {|project, user| project.parent.nil? || project.parent.visible?(user)}
697 699
698 700 def safe_attributes=(attrs, user=User.current)
699 701 return unless attrs.is_a?(Hash)
700 702 attrs = attrs.deep_dup
701 703
702 704 @unallowed_parent_id = nil
703 705 if new_record? || attrs.key?('parent_id')
704 706 parent_id_param = attrs['parent_id'].to_s
705 707 if new_record? || parent_id_param != parent_id.to_s
706 708 p = parent_id_param.present? ? Project.find_by_id(parent_id_param) : nil
707 709 unless allowed_parents(user).include?(p)
708 710 attrs.delete('parent_id')
709 711 @unallowed_parent_id = true
710 712 end
711 713 end
712 714 end
713 715
714 716 super(attrs, user)
715 717 end
716 718
717 719 # Returns an auto-generated project identifier based on the last identifier used
718 720 def self.next_identifier
719 721 p = Project.order('id DESC').first
720 722 p.nil? ? nil : p.identifier.to_s.succ
721 723 end
722 724
723 725 # Copies and saves the Project instance based on the +project+.
724 726 # Duplicates the source project's:
725 727 # * Wiki
726 728 # * Versions
727 729 # * Categories
728 730 # * Issues
729 731 # * Members
730 732 # * Queries
731 733 #
732 734 # Accepts an +options+ argument to specify what to copy
733 735 #
734 736 # Examples:
735 737 # project.copy(1) # => copies everything
736 738 # project.copy(1, :only => 'members') # => copies members only
737 739 # project.copy(1, :only => ['members', 'versions']) # => copies members and versions
738 740 def copy(project, options={})
739 741 project = project.is_a?(Project) ? project : Project.find(project)
740 742
741 743 to_be_copied = %w(wiki versions issue_categories issues members queries boards)
742 744 to_be_copied = to_be_copied & Array.wrap(options[:only]) unless options[:only].nil?
743 745
744 746 Project.transaction do
745 747 if save
746 748 reload
747 749 to_be_copied.each do |name|
748 750 send "copy_#{name}", project
749 751 end
750 752 Redmine::Hook.call_hook(:model_project_copy_before_save, :source_project => project, :destination_project => self)
751 753 save
752 754 else
753 755 false
754 756 end
755 757 end
756 758 end
757 759
758 760 def member_principals
759 761 ActiveSupport::Deprecation.warn "Project#member_principals is deprecated and will be removed in Redmine 4.0. Use #memberships.active instead."
760 762 memberships.active
761 763 end
762 764
763 765 # Returns a new unsaved Project instance with attributes copied from +project+
764 766 def self.copy_from(project)
765 767 project = project.is_a?(Project) ? project : Project.find(project)
766 768 # clear unique attributes
767 769 attributes = project.attributes.dup.except('id', 'name', 'identifier', 'status', 'parent_id', 'lft', 'rgt')
768 770 copy = Project.new(attributes)
769 771 copy.enabled_module_names = project.enabled_module_names
770 772 copy.trackers = project.trackers
771 773 copy.custom_values = project.custom_values.collect {|v| v.clone}
772 774 copy.issue_custom_fields = project.issue_custom_fields
773 775 copy
774 776 end
775 777
776 778 # Yields the given block for each project with its level in the tree
777 779 def self.project_tree(projects, &block)
778 780 ancestors = []
779 781 projects.sort_by(&:lft).each do |project|
780 782 while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
781 783 ancestors.pop
782 784 end
783 785 yield project, ancestors.size
784 786 ancestors << project
785 787 end
786 788 end
787 789
788 790 private
789 791
790 792 def update_inherited_members
791 793 if parent
792 794 if inherit_members? && !inherit_members_was
793 795 remove_inherited_member_roles
794 796 add_inherited_member_roles
795 797 elsif !inherit_members? && inherit_members_was
796 798 remove_inherited_member_roles
797 799 end
798 800 end
799 801 end
800 802
801 803 def remove_inherited_member_roles
802 804 member_roles = memberships.map(&:member_roles).flatten
803 805 member_role_ids = member_roles.map(&:id)
804 806 member_roles.each do |member_role|
805 807 if member_role.inherited_from && !member_role_ids.include?(member_role.inherited_from)
806 808 member_role.destroy
807 809 end
808 810 end
809 811 end
810 812
811 813 def add_inherited_member_roles
812 814 if inherit_members? && parent
813 815 parent.memberships.each do |parent_member|
814 816 member = Member.find_or_new(self.id, parent_member.user_id)
815 817 parent_member.member_roles.each do |parent_member_role|
816 818 member.member_roles << MemberRole.new(:role => parent_member_role.role, :inherited_from => parent_member_role.id)
817 819 end
818 820 member.save!
819 821 end
820 822 memberships.reset
821 823 end
822 824 end
823 825
824 826 def update_versions_from_hierarchy_change
825 827 Issue.update_versions_from_hierarchy_change(self)
826 828 end
827 829
828 830 def validate_parent
829 831 if @unallowed_parent_id
830 832 errors.add(:parent_id, :invalid)
831 833 elsif parent_id_changed?
832 834 unless parent.nil? || (parent.active? && move_possible?(parent))
833 835 errors.add(:parent_id, :invalid)
834 836 end
835 837 end
836 838 end
837 839
838 840 # Copies wiki from +project+
839 841 def copy_wiki(project)
840 842 # Check that the source project has a wiki first
841 843 unless project.wiki.nil?
842 844 wiki = self.wiki || Wiki.new
843 845 wiki.attributes = project.wiki.attributes.dup.except("id", "project_id")
844 846 wiki_pages_map = {}
845 847 project.wiki.pages.each do |page|
846 848 # Skip pages without content
847 849 next if page.content.nil?
848 850 new_wiki_content = WikiContent.new(page.content.attributes.dup.except("id", "page_id", "updated_on"))
849 851 new_wiki_page = WikiPage.new(page.attributes.dup.except("id", "wiki_id", "created_on", "parent_id"))
850 852 new_wiki_page.content = new_wiki_content
851 853 wiki.pages << new_wiki_page
852 854 wiki_pages_map[page.id] = new_wiki_page
853 855 end
854 856
855 857 self.wiki = wiki
856 858 wiki.save
857 859 # Reproduce page hierarchy
858 860 project.wiki.pages.each do |page|
859 861 if page.parent_id && wiki_pages_map[page.id]
860 862 wiki_pages_map[page.id].parent = wiki_pages_map[page.parent_id]
861 863 wiki_pages_map[page.id].save
862 864 end
863 865 end
864 866 end
865 867 end
866 868
867 869 # Copies versions from +project+
868 870 def copy_versions(project)
869 871 project.versions.each do |version|
870 872 new_version = Version.new
871 873 new_version.attributes = version.attributes.dup.except("id", "project_id", "created_on", "updated_on")
872 874 self.versions << new_version
873 875 end
874 876 end
875 877
876 878 # Copies issue categories from +project+
877 879 def copy_issue_categories(project)
878 880 project.issue_categories.each do |issue_category|
879 881 new_issue_category = IssueCategory.new
880 882 new_issue_category.attributes = issue_category.attributes.dup.except("id", "project_id")
881 883 self.issue_categories << new_issue_category
882 884 end
883 885 end
884 886
885 887 # Copies issues from +project+
886 888 def copy_issues(project)
887 889 # Stores the source issue id as a key and the copied issues as the
888 890 # value. Used to map the two together for issue relations.
889 891 issues_map = {}
890 892
891 893 # Store status and reopen locked/closed versions
892 894 version_statuses = versions.reject(&:open?).map {|version| [version, version.status]}
893 895 version_statuses.each do |version, status|
894 896 version.update_attribute :status, 'open'
895 897 end
896 898
897 899 # Get issues sorted by root_id, lft so that parent issues
898 900 # get copied before their children
899 901 project.issues.reorder('root_id, lft').each do |issue|
900 902 new_issue = Issue.new
901 903 new_issue.copy_from(issue, :subtasks => false, :link => false)
902 904 new_issue.project = self
903 905 # Changing project resets the custom field values
904 906 # TODO: handle this in Issue#project=
905 907 new_issue.custom_field_values = issue.custom_field_values.inject({}) {|h,v| h[v.custom_field_id] = v.value; h}
906 908 # Reassign fixed_versions by name, since names are unique per project
907 909 if issue.fixed_version && issue.fixed_version.project == project
908 910 new_issue.fixed_version = self.versions.detect {|v| v.name == issue.fixed_version.name}
909 911 end
910 912 # Reassign version custom field values
911 913 new_issue.custom_field_values.each do |custom_value|
912 914 if custom_value.custom_field.field_format == 'version' && custom_value.value.present?
913 915 versions = Version.where(:id => custom_value.value).to_a
914 916 new_value = versions.map do |version|
915 917 if version.project == project
916 918 self.versions.detect {|v| v.name == version.name}.try(:id)
917 919 else
918 920 version.id
919 921 end
920 922 end
921 923 new_value.compact!
922 924 new_value = new_value.first unless custom_value.custom_field.multiple?
923 925 custom_value.value = new_value
924 926 end
925 927 end
926 928 # Reassign the category by name, since names are unique per project
927 929 if issue.category
928 930 new_issue.category = self.issue_categories.detect {|c| c.name == issue.category.name}
929 931 end
930 932 # Parent issue
931 933 if issue.parent_id
932 934 if copied_parent = issues_map[issue.parent_id]
933 935 new_issue.parent_issue_id = copied_parent.id
934 936 end
935 937 end
936 938
937 939 self.issues << new_issue
938 940 if new_issue.new_record?
939 941 logger.info "Project#copy_issues: issue ##{issue.id} could not be copied: #{new_issue.errors.full_messages}" if logger && logger.info?
940 942 else
941 943 issues_map[issue.id] = new_issue unless new_issue.new_record?
942 944 end
943 945 end
944 946
945 947 # Restore locked/closed version statuses
946 948 version_statuses.each do |version, status|
947 949 version.update_attribute :status, status
948 950 end
949 951
950 952 # Relations after in case issues related each other
951 953 project.issues.each do |issue|
952 954 new_issue = issues_map[issue.id]
953 955 unless new_issue
954 956 # Issue was not copied
955 957 next
956 958 end
957 959
958 960 # Relations
959 961 issue.relations_from.each do |source_relation|
960 962 new_issue_relation = IssueRelation.new
961 963 new_issue_relation.attributes = source_relation.attributes.dup.except("id", "issue_from_id", "issue_to_id")
962 964 new_issue_relation.issue_to = issues_map[source_relation.issue_to_id]
963 965 if new_issue_relation.issue_to.nil? && Setting.cross_project_issue_relations?
964 966 new_issue_relation.issue_to = source_relation.issue_to
965 967 end
966 968 new_issue.relations_from << new_issue_relation
967 969 end
968 970
969 971 issue.relations_to.each do |source_relation|
970 972 new_issue_relation = IssueRelation.new
971 973 new_issue_relation.attributes = source_relation.attributes.dup.except("id", "issue_from_id", "issue_to_id")
972 974 new_issue_relation.issue_from = issues_map[source_relation.issue_from_id]
973 975 if new_issue_relation.issue_from.nil? && Setting.cross_project_issue_relations?
974 976 new_issue_relation.issue_from = source_relation.issue_from
975 977 end
976 978 new_issue.relations_to << new_issue_relation
977 979 end
978 980 end
979 981 end
980 982
981 983 # Copies members from +project+
982 984 def copy_members(project)
983 985 # Copy users first, then groups to handle members with inherited and given roles
984 986 members_to_copy = []
985 987 members_to_copy += project.memberships.select {|m| m.principal.is_a?(User)}
986 988 members_to_copy += project.memberships.select {|m| !m.principal.is_a?(User)}
987 989
988 990 members_to_copy.each do |member|
989 991 new_member = Member.new
990 992 new_member.attributes = member.attributes.dup.except("id", "project_id", "created_on")
991 993 # only copy non inherited roles
992 994 # inherited roles will be added when copying the group membership
993 995 role_ids = member.member_roles.reject(&:inherited?).collect(&:role_id)
994 996 next if role_ids.empty?
995 997 new_member.role_ids = role_ids
996 998 new_member.project = self
997 999 self.members << new_member
998 1000 end
999 1001 end
1000 1002
1001 1003 # Copies queries from +project+
1002 1004 def copy_queries(project)
1003 1005 project.queries.each do |query|
1004 1006 new_query = IssueQuery.new
1005 1007 new_query.attributes = query.attributes.dup.except("id", "project_id", "sort_criteria", "user_id", "type")
1006 1008 new_query.sort_criteria = query.sort_criteria if query.sort_criteria
1007 1009 new_query.project = self
1008 1010 new_query.user_id = query.user_id
1009 1011 new_query.role_ids = query.role_ids if query.visibility == IssueQuery::VISIBILITY_ROLES
1010 1012 self.queries << new_query
1011 1013 end
1012 1014 end
1013 1015
1014 1016 # Copies boards from +project+
1015 1017 def copy_boards(project)
1016 1018 project.boards.each do |board|
1017 1019 new_board = Board.new
1018 1020 new_board.attributes = board.attributes.dup.except("id", "project_id", "topics_count", "messages_count", "last_message_id")
1019 1021 new_board.project = self
1020 1022 self.boards << new_board
1021 1023 end
1022 1024 end
1023 1025
1024 1026 def allowed_permissions
1025 1027 @allowed_permissions ||= begin
1026 1028 module_names = enabled_modules.loaded? ? enabled_modules.map(&:name) : enabled_modules.pluck(:name)
1027 1029 Redmine::AccessControl.modules_permissions(module_names).collect {|p| p.name}
1028 1030 end
1029 1031 end
1030 1032
1031 1033 def allowed_actions
1032 1034 @actions_allowed ||= allowed_permissions.inject([]) { |actions, permission| actions += Redmine::AccessControl.allowed_actions(permission) }.flatten
1033 1035 end
1034 1036
1035 1037 # Archives subprojects recursively
1036 1038 def archive!
1037 1039 children.each do |subproject|
1038 1040 subproject.send :archive!
1039 1041 end
1040 1042 update_attribute :status, STATUS_ARCHIVED
1041 1043 end
1042 1044 end
@@ -1,300 +1,307
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2015 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 Version < ActiveRecord::Base
19 19 include Redmine::SafeAttributes
20
20 21 after_update :update_issues_from_sharing_change
22 before_destroy :nullify_projects_default_version
23
21 24 belongs_to :project
22 25 has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id', :dependent => :nullify
23 26 acts_as_customizable
24 27 acts_as_attachable :view_permission => :view_files,
25 28 :edit_permission => :manage_files,
26 29 :delete_permission => :manage_files
27 30
28 31 VERSION_STATUSES = %w(open locked closed)
29 32 VERSION_SHARINGS = %w(none descendants hierarchy tree system)
30 33
31 34 validates_presence_of :name
32 35 validates_uniqueness_of :name, :scope => [:project_id]
33 36 validates_length_of :name, :maximum => 60
34 37 validates_length_of :description, :maximum => 255
35 38 validates :effective_date, :date => true
36 39 validates_inclusion_of :status, :in => VERSION_STATUSES
37 40 validates_inclusion_of :sharing, :in => VERSION_SHARINGS
38 41 attr_protected :id
39 42
40 43 scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)}
41 44 scope :open, lambda { where(:status => 'open') }
42 45 scope :visible, lambda {|*args|
43 46 joins(:project).
44 47 where(Project.allowed_to_condition(args.first || User.current, :view_issues))
45 48 }
46 49
47 50 safe_attributes 'name',
48 51 'description',
49 52 'effective_date',
50 53 'due_date',
51 54 'wiki_page_title',
52 55 'status',
53 56 'sharing',
54 57 'custom_field_values',
55 58 'custom_fields'
56 59
57 60 # Returns true if +user+ or current user is allowed to view the version
58 61 def visible?(user=User.current)
59 62 user.allowed_to?(:view_issues, self.project)
60 63 end
61 64
62 65 # Version files have same visibility as project files
63 66 def attachments_visible?(*args)
64 67 project.present? && project.attachments_visible?(*args)
65 68 end
66 69
67 70 def attachments_deletable?(usr=User.current)
68 71 project.present? && project.attachments_deletable?(usr)
69 72 end
70 73
71 74 def start_date
72 75 @start_date ||= fixed_issues.minimum('start_date')
73 76 end
74 77
75 78 def due_date
76 79 effective_date
77 80 end
78 81
79 82 def due_date=(arg)
80 83 self.effective_date=(arg)
81 84 end
82 85
83 86 # Returns the total estimated time for this version
84 87 # (sum of leaves estimated_hours)
85 88 def estimated_hours
86 89 @estimated_hours ||= fixed_issues.sum(:estimated_hours).to_f
87 90 end
88 91
89 92 # Returns the total reported time for this version
90 93 def spent_hours
91 94 @spent_hours ||= TimeEntry.joins(:issue).where("#{Issue.table_name}.fixed_version_id = ?", id).sum(:hours).to_f
92 95 end
93 96
94 97 def closed?
95 98 status == 'closed'
96 99 end
97 100
98 101 def open?
99 102 status == 'open'
100 103 end
101 104
102 105 # Returns true if the version is completed: due date reached and no open issues
103 106 def completed?
104 107 effective_date && (effective_date < Date.today) && (open_issues_count == 0)
105 108 end
106 109
107 110 def behind_schedule?
108 111 if completed_percent == 100
109 112 return false
110 113 elsif due_date && start_date
111 114 done_date = start_date + ((due_date - start_date+1)* completed_percent/100).floor
112 115 return done_date <= Date.today
113 116 else
114 117 false # No issues so it's not late
115 118 end
116 119 end
117 120
118 121 # Returns the completion percentage of this version based on the amount of open/closed issues
119 122 # and the time spent on the open issues.
120 123 def completed_percent
121 124 if issues_count == 0
122 125 0
123 126 elsif open_issues_count == 0
124 127 100
125 128 else
126 129 issues_progress(false) + issues_progress(true)
127 130 end
128 131 end
129 132
130 133 # Returns the percentage of issues that have been marked as 'closed'.
131 134 def closed_percent
132 135 if issues_count == 0
133 136 0
134 137 else
135 138 issues_progress(false)
136 139 end
137 140 end
138 141
139 142 # Returns true if the version is overdue: due date reached and some open issues
140 143 def overdue?
141 144 effective_date && (effective_date < Date.today) && (open_issues_count > 0)
142 145 end
143 146
144 147 # Returns assigned issues count
145 148 def issues_count
146 149 load_issue_counts
147 150 @issue_count
148 151 end
149 152
150 153 # Returns the total amount of open issues for this version.
151 154 def open_issues_count
152 155 load_issue_counts
153 156 @open_issues_count
154 157 end
155 158
156 159 # Returns the total amount of closed issues for this version.
157 160 def closed_issues_count
158 161 load_issue_counts
159 162 @closed_issues_count
160 163 end
161 164
162 165 def wiki_page
163 166 if project.wiki && !wiki_page_title.blank?
164 167 @wiki_page ||= project.wiki.find_page(wiki_page_title)
165 168 end
166 169 @wiki_page
167 170 end
168 171
169 172 def to_s; name end
170 173
171 174 def to_s_with_project
172 175 "#{project} - #{name}"
173 176 end
174 177
175 178 # Versions are sorted by effective_date and name
176 179 # Those with no effective_date are at the end, sorted by name
177 180 def <=>(version)
178 181 if self.effective_date
179 182 if version.effective_date
180 183 if self.effective_date == version.effective_date
181 184 name == version.name ? id <=> version.id : name <=> version.name
182 185 else
183 186 self.effective_date <=> version.effective_date
184 187 end
185 188 else
186 189 -1
187 190 end
188 191 else
189 192 if version.effective_date
190 193 1
191 194 else
192 195 name == version.name ? id <=> version.id : name <=> version.name
193 196 end
194 197 end
195 198 end
196 199
197 200 def self.fields_for_order_statement(table=nil)
198 201 table ||= table_name
199 202 ["(CASE WHEN #{table}.effective_date IS NULL THEN 1 ELSE 0 END)", "#{table}.effective_date", "#{table}.name", "#{table}.id"]
200 203 end
201 204
202 205 scope :sorted, lambda { order(fields_for_order_statement) }
203 206
204 207 # Returns the sharings that +user+ can set the version to
205 208 def allowed_sharings(user = User.current)
206 209 VERSION_SHARINGS.select do |s|
207 210 if sharing == s
208 211 true
209 212 else
210 213 case s
211 214 when 'system'
212 215 # Only admin users can set a systemwide sharing
213 216 user.admin?
214 217 when 'hierarchy', 'tree'
215 218 # Only users allowed to manage versions of the root project can
216 219 # set sharing to hierarchy or tree
217 220 project.nil? || user.allowed_to?(:manage_versions, project.root)
218 221 else
219 222 true
220 223 end
221 224 end
222 225 end
223 226 end
224 227
225 228 # Returns true if the version is shared, otherwise false
226 229 def shared?
227 230 sharing != 'none'
228 231 end
229 232
230 233 def deletable?
231 234 fixed_issues.empty? && !referenced_by_a_custom_field?
232 235 end
233 236
234 237 private
235 238
236 239 def load_issue_counts
237 240 unless @issue_count
238 241 @open_issues_count = 0
239 242 @closed_issues_count = 0
240 243 fixed_issues.group(:status).count.each do |status, count|
241 244 if status.is_closed?
242 245 @closed_issues_count += count
243 246 else
244 247 @open_issues_count += count
245 248 end
246 249 end
247 250 @issue_count = @open_issues_count + @closed_issues_count
248 251 end
249 252 end
250 253
251 254 # Update the issue's fixed versions. Used if a version's sharing changes.
252 255 def update_issues_from_sharing_change
253 256 if sharing_changed?
254 257 if VERSION_SHARINGS.index(sharing_was).nil? ||
255 258 VERSION_SHARINGS.index(sharing).nil? ||
256 259 VERSION_SHARINGS.index(sharing_was) > VERSION_SHARINGS.index(sharing)
257 260 Issue.update_versions_from_sharing_change self
258 261 end
259 262 end
260 263 end
261 264
262 265 # Returns the average estimated time of assigned issues
263 266 # or 1 if no issue has an estimated time
264 267 # Used to weight unestimated issues in progress calculation
265 268 def estimated_average
266 269 if @estimated_average.nil?
267 270 average = fixed_issues.average(:estimated_hours).to_f
268 271 if average == 0
269 272 average = 1
270 273 end
271 274 @estimated_average = average
272 275 end
273 276 @estimated_average
274 277 end
275 278
276 279 # Returns the total progress of open or closed issues. The returned percentage takes into account
277 280 # the amount of estimated time set for this version.
278 281 #
279 282 # Examples:
280 283 # issues_progress(true) => returns the progress percentage for open issues.
281 284 # issues_progress(false) => returns the progress percentage for closed issues.
282 285 def issues_progress(open)
283 286 @issues_progress ||= {}
284 287 @issues_progress[open] ||= begin
285 288 progress = 0
286 289 if issues_count > 0
287 290 ratio = open ? 'done_ratio' : 100
288 291
289 292 done = fixed_issues.open(open).sum("COALESCE(estimated_hours, #{estimated_average}) * #{ratio}").to_f
290 293 progress = done / (estimated_average * issues_count)
291 294 end
292 295 progress
293 296 end
294 297 end
295 298
296 299 def referenced_by_a_custom_field?
297 300 CustomValue.joins(:custom_field).
298 301 where(:value => id.to_s, :custom_fields => {:field_format => 'version'}).any?
299 302 end
303
304 def nullify_projects_default_version
305 Project.where(:default_version_id => id).update_all(:default_version_id => nil)
306 end
300 307 end
@@ -1,102 +1,106
1 1 <%= error_messages_for 'project' %>
2 2
3 3 <div class="box tabular">
4 4 <!--[form:project]-->
5 5 <p><%= f.text_field :name, :required => true, :size => 60 %></p>
6 6
7 7 <p><%= f.text_area :description, :rows => 8, :class => 'wiki-edit' %></p>
8 8 <p><%= f.text_field :identifier, :required => true, :size => 60, :disabled => @project.identifier_frozen?, :maxlength => Project::IDENTIFIER_MAX_LENGTH %>
9 9 <% unless @project.identifier_frozen? %>
10 10 <em class="info"><%= l(:text_length_between, :min => 1, :max => Project::IDENTIFIER_MAX_LENGTH) %> <%= l(:text_project_identifier_info).html_safe %></em>
11 11 <% end %></p>
12 12 <p><%= f.text_field :homepage, :size => 60 %></p>
13 13 <p><%= f.check_box :is_public %></p>
14 14
15 15 <% unless @project.allowed_parents.compact.empty? %>
16 16 <p><%= label(:project, :parent_id, l(:field_parent)) %><%= parent_project_select_tag(@project) %></p>
17 17 <% end %>
18 18
19 19 <% if @project.safe_attribute? 'inherit_members' %>
20 20 <p><%= f.check_box :inherit_members %></p>
21 21 <% end %>
22 22
23 <% if @project.safe_attribute?('default_version_id') && (default_version_options = project_default_version_options(@project)).present? %>
24 <p><%= f.select :default_version_id, project_default_version_options(@project), :include_blank => true %></p>
25 <% end %>
26
23 27 <%= wikitoolbar_for 'project_description' %>
24 28
25 29 <% @project.custom_field_values.each do |value| %>
26 30 <p><%= custom_field_tag_with_label :project, value %></p>
27 31 <% end %>
28 32 <%= call_hook(:view_projects_form, :project => @project, :form => f) %>
29 33 </div>
30 34
31 35 <% if @project.new_record? %>
32 36 <fieldset class="box tabular"><legend><%= l(:label_module_plural) %></legend>
33 37 <% Redmine::AccessControl.available_project_modules.each do |m| %>
34 38 <label class="floating">
35 39 <%= check_box_tag 'project[enabled_module_names][]', m, @project.module_enabled?(m), :id => "project_enabled_module_names_#{m}" %>
36 40 <%= l_or_humanize(m, :prefix => "project_module_") %>
37 41 </label>
38 42 <% end %>
39 43 <%= hidden_field_tag 'project[enabled_module_names][]', '' %>
40 44 </fieldset>
41 45 <% end %>
42 46
43 47 <% if @project.new_record? || @project.module_enabled?('issue_tracking') %>
44 48 <% unless @trackers.empty? %>
45 49 <fieldset class="box tabular" id="project_trackers"><legend><%=l(:label_tracker_plural)%></legend>
46 50 <% @trackers.each do |tracker| %>
47 51 <label class="floating">
48 52 <%= check_box_tag 'project[tracker_ids][]', tracker.id, @project.trackers.to_a.include?(tracker), :id => nil %>
49 53 <%= tracker %>
50 54 </label>
51 55 <% end %>
52 56 <%= hidden_field_tag 'project[tracker_ids][]', '' %>
53 57 </fieldset>
54 58 <% end %>
55 59
56 60 <% unless @issue_custom_fields.empty? %>
57 61 <fieldset class="box tabular" id="project_issue_custom_fields"><legend><%=l(:label_custom_field_plural)%></legend>
58 62 <% @issue_custom_fields.each do |custom_field| %>
59 63 <label class="floating">
60 64 <%= check_box_tag 'project[issue_custom_field_ids][]', custom_field.id, (@project.all_issue_custom_fields.include? custom_field),
61 65 :disabled => (custom_field.is_for_all? ? "disabled" : nil),
62 66 :id => nil %>
63 67 <%= custom_field_name_tag(custom_field) %>
64 68 </label>
65 69 <% end %>
66 70 <%= hidden_field_tag 'project[issue_custom_field_ids][]', '' %>
67 71 </fieldset>
68 72 <% end %>
69 73 <% end %>
70 74 <!--[eoform:project]-->
71 75
72 76 <% unless @project.identifier_frozen? %>
73 77 <% content_for :header_tags do %>
74 78 <%= javascript_include_tag 'project_identifier' %>
75 79 <% end %>
76 80 <% end %>
77 81
78 82 <% if !User.current.admin? && @project.inherit_members? && @project.parent && User.current.member_of?(@project.parent) %>
79 83 <%= javascript_tag do %>
80 84 $(document).ready(function() {
81 85 $("#project_inherit_members").change(function(){
82 86 if (!$(this).is(':checked')) {
83 87 if (!confirm("<%= escape_javascript(l(:text_own_membership_delete_confirmation)) %>")) {
84 88 $("#project_inherit_members").attr("checked", true);
85 89 }
86 90 }
87 91 });
88 92 });
89 93 <% end %>
90 94 <% end %>
91 95
92 96 <%= javascript_tag do %>
93 97 $(document).ready(function() {
94 98 $('#project_enabled_module_names_issue_tracking').on('change', function(){
95 99 if ($(this).prop('checked')){
96 100 $('#project_trackers, #project_issue_custom_fields').show();
97 101 } else {
98 102 $('#project_trackers, #project_issue_custom_fields').hide();
99 103 }
100 104 }).trigger('change');
101 105 });
102 106 <% end %>
@@ -1,1167 +1,1168
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: "cannot be empty"
114 114 blank: "cannot 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 earlier_than_minimum_start_date: "cannot be earlier than %{date} because of preceding issues"
133 133
134 134 actionview_instancetag_blank_option: Please select
135 135
136 136 general_text_No: 'No'
137 137 general_text_Yes: 'Yes'
138 138 general_text_no: 'no'
139 139 general_text_yes: 'yes'
140 140 general_lang_name: 'English'
141 141 general_csv_separator: ','
142 142 general_csv_decimal_separator: '.'
143 143 general_csv_encoding: ISO-8859-1
144 144 general_pdf_fontname: freesans
145 145 general_first_day_of_week: '7'
146 146
147 147 notice_account_updated: Account was successfully updated.
148 148 notice_account_invalid_creditentials: Invalid user or password
149 149 notice_account_password_updated: Password was successfully updated.
150 150 notice_account_wrong_password: Wrong password
151 151 notice_account_register_done: Account was successfully created. An email containing the instructions to activate your account was sent to %{email}.
152 152 notice_account_unknown_email: Unknown user.
153 153 notice_account_not_activated_yet: You haven't activated your account yet. If you want to receive a new activation email, please <a href="%{url}">click this link</a>.
154 154 notice_account_locked: Your account is locked.
155 155 notice_can_t_change_password: This account uses an external authentication source. Impossible to change the password.
156 156 notice_account_lost_email_sent: An email with instructions to choose a new password has been sent to you.
157 157 notice_account_activated: Your account has been activated. You can now log in.
158 158 notice_successful_create: Successful creation.
159 159 notice_successful_update: Successful update.
160 160 notice_successful_delete: Successful deletion.
161 161 notice_successful_connection: Successful connection.
162 162 notice_file_not_found: The page you were trying to access doesn't exist or has been removed.
163 163 notice_locking_conflict: Data has been updated by another user.
164 164 notice_not_authorized: You are not authorized to access this page.
165 165 notice_not_authorized_archived_project: The project you're trying to access has been archived.
166 166 notice_email_sent: "An email was sent to %{value}"
167 167 notice_email_error: "An error occurred while sending mail (%{value})"
168 168 notice_feeds_access_key_reseted: Your Atom access key was reset.
169 169 notice_api_access_key_reseted: Your API access key was reset.
170 170 notice_failed_to_save_issues: "Failed to save %{count} issue(s) on %{total} selected: %{ids}."
171 171 notice_failed_to_save_time_entries: "Failed to save %{count} time entrie(s) on %{total} selected: %{ids}."
172 172 notice_failed_to_save_members: "Failed to save member(s): %{errors}."
173 173 notice_no_issue_selected: "No issue is selected! Please, check the issues you want to edit."
174 174 notice_account_pending: "Your account was created and is now pending administrator approval."
175 175 notice_default_data_loaded: Default configuration successfully loaded.
176 176 notice_unable_delete_version: Unable to delete version.
177 177 notice_unable_delete_time_entry: Unable to delete time log entry.
178 178 notice_issue_done_ratios_updated: Issue done ratios updated.
179 179 notice_gantt_chart_truncated: "The chart was truncated because it exceeds the maximum number of items that can be displayed (%{max})"
180 180 notice_issue_successful_create: "Issue %{id} created."
181 181 notice_issue_update_conflict: "The issue has been updated by an other user while you were editing it."
182 182 notice_account_deleted: "Your account has been permanently deleted."
183 183 notice_user_successful_create: "User %{id} created."
184 184 notice_new_password_must_be_different: The new password must be different from the current password
185 185 notice_import_finished: "All %{count} items have been imported."
186 186 notice_import_finished_with_errors: "%{count} out of %{total} items could not be imported."
187 187
188 188 error_can_t_load_default_data: "Default configuration could not be loaded: %{value}"
189 189 error_scm_not_found: "The entry or revision was not found in the repository."
190 190 error_scm_command_failed: "An error occurred when trying to access the repository: %{value}"
191 191 error_scm_annotate: "The entry does not exist or cannot be annotated."
192 192 error_scm_annotate_big_text_file: "The entry cannot be annotated, as it exceeds the maximum text file size."
193 193 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
194 194 error_no_tracker_in_project: 'No tracker is associated to this project. Please check the Project settings.'
195 195 error_no_default_issue_status: 'No default issue status is defined. Please check your configuration (Go to "Administration -> Issue statuses").'
196 196 error_can_not_delete_custom_field: Unable to delete custom field
197 197 error_can_not_delete_tracker: "This tracker contains issues and cannot be deleted."
198 198 error_can_not_remove_role: "This role is in use and cannot be deleted."
199 199 error_can_not_reopen_issue_on_closed_version: 'An issue assigned to a closed version cannot be reopened'
200 200 error_can_not_archive_project: This project cannot be archived
201 201 error_issue_done_ratios_not_updated: "Issue done ratios not updated."
202 202 error_workflow_copy_source: 'Please select a source tracker or role'
203 203 error_workflow_copy_target: 'Please select target tracker(s) and role(s)'
204 204 error_unable_delete_issue_status: 'Unable to delete issue status'
205 205 error_unable_to_connect: "Unable to connect (%{value})"
206 206 error_attachment_too_big: "This file cannot be uploaded because it exceeds the maximum allowed file size (%{max_size})"
207 207 error_session_expired: "Your session has expired. Please login again."
208 208 warning_attachments_not_saved: "%{count} file(s) could not be saved."
209 209 error_password_expired: "Your password has expired or the administrator requires you to change it."
210 210 error_invalid_file_encoding: "The file is not a valid %{encoding} encoded file"
211 211 error_invalid_csv_file_or_settings: "The file is not a CSV file or does not match the settings below"
212 212 error_can_not_read_import_file: "An error occurred while reading the file to import"
213 213
214 214 mail_subject_lost_password: "Your %{value} password"
215 215 mail_body_lost_password: 'To change your password, click on the following link:'
216 216 mail_subject_register: "Your %{value} account activation"
217 217 mail_body_register: 'To activate your account, click on the following link:'
218 218 mail_body_account_information_external: "You can use your %{value} account to log in."
219 219 mail_body_account_information: Your account information
220 220 mail_subject_account_activation_request: "%{value} account activation request"
221 221 mail_body_account_activation_request: "A new user (%{value}) has registered. The account is pending your approval:"
222 222 mail_subject_reminder: "%{count} issue(s) due in the next %{days} days"
223 223 mail_body_reminder: "%{count} issue(s) that are assigned to you are due in the next %{days} days:"
224 224 mail_subject_wiki_content_added: "'%{id}' wiki page has been added"
225 225 mail_body_wiki_content_added: "The '%{id}' wiki page has been added by %{author}."
226 226 mail_subject_wiki_content_updated: "'%{id}' wiki page has been updated"
227 227 mail_body_wiki_content_updated: "The '%{id}' wiki page has been updated by %{author}."
228 228
229 229 field_name: Name
230 230 field_description: Description
231 231 field_summary: Summary
232 232 field_is_required: Required
233 233 field_firstname: First name
234 234 field_lastname: Last name
235 235 field_mail: Email
236 236 field_address: Email
237 237 field_filename: File
238 238 field_filesize: Size
239 239 field_downloads: Downloads
240 240 field_author: Author
241 241 field_created_on: Created
242 242 field_updated_on: Updated
243 243 field_closed_on: Closed
244 244 field_field_format: Format
245 245 field_is_for_all: For all projects
246 246 field_possible_values: Possible values
247 247 field_regexp: Regular expression
248 248 field_min_length: Minimum length
249 249 field_max_length: Maximum length
250 250 field_value: Value
251 251 field_category: Category
252 252 field_title: Title
253 253 field_project: Project
254 254 field_issue: Issue
255 255 field_status: Status
256 256 field_notes: Notes
257 257 field_is_closed: Issue closed
258 258 field_is_default: Default value
259 259 field_tracker: Tracker
260 260 field_subject: Subject
261 261 field_due_date: Due date
262 262 field_assigned_to: Assignee
263 263 field_priority: Priority
264 264 field_fixed_version: Target version
265 265 field_user: User
266 266 field_principal: Principal
267 267 field_role: Role
268 268 field_homepage: Homepage
269 269 field_is_public: Public
270 270 field_parent: Subproject of
271 271 field_is_in_roadmap: Issues displayed in roadmap
272 272 field_login: Login
273 273 field_mail_notification: Email notifications
274 274 field_admin: Administrator
275 275 field_last_login_on: Last connection
276 276 field_language: Language
277 277 field_effective_date: Date
278 278 field_password: Password
279 279 field_new_password: New password
280 280 field_password_confirmation: Confirmation
281 281 field_version: Version
282 282 field_type: Type
283 283 field_host: Host
284 284 field_port: Port
285 285 field_account: Account
286 286 field_base_dn: Base DN
287 287 field_attr_login: Login attribute
288 288 field_attr_firstname: Firstname attribute
289 289 field_attr_lastname: Lastname attribute
290 290 field_attr_mail: Email attribute
291 291 field_onthefly: On-the-fly user creation
292 292 field_start_date: Start date
293 293 field_done_ratio: "% Done"
294 294 field_auth_source: Authentication mode
295 295 field_hide_mail: Hide my email address
296 296 field_comments: Comment
297 297 field_url: URL
298 298 field_start_page: Start page
299 299 field_subproject: Subproject
300 300 field_hours: Hours
301 301 field_activity: Activity
302 302 field_spent_on: Date
303 303 field_identifier: Identifier
304 304 field_is_filter: Used as a filter
305 305 field_issue_to: Related issue
306 306 field_delay: Delay
307 307 field_assignable: Issues can be assigned to this role
308 308 field_redirect_existing_links: Redirect existing links
309 309 field_estimated_hours: Estimated time
310 310 field_column_names: Columns
311 311 field_time_entries: Log time
312 312 field_time_zone: Time zone
313 313 field_searchable: Searchable
314 314 field_default_value: Default value
315 315 field_comments_sorting: Display comments
316 316 field_parent_title: Parent page
317 317 field_editable: Editable
318 318 field_watcher: Watcher
319 319 field_identity_url: OpenID URL
320 320 field_content: Content
321 321 field_group_by: Group results by
322 322 field_sharing: Sharing
323 323 field_parent_issue: Parent task
324 324 field_member_of_group: "Assignee's group"
325 325 field_assigned_to_role: "Assignee's role"
326 326 field_text: Text field
327 327 field_visible: Visible
328 328 field_warn_on_leaving_unsaved: "Warn me when leaving a page with unsaved text"
329 329 field_issues_visibility: Issues visibility
330 330 field_is_private: Private
331 331 field_commit_logs_encoding: Commit messages encoding
332 332 field_scm_path_encoding: Path encoding
333 333 field_path_to_repository: Path to repository
334 334 field_root_directory: Root directory
335 335 field_cvsroot: CVSROOT
336 336 field_cvs_module: Module
337 337 field_repository_is_default: Main repository
338 338 field_multiple: Multiple values
339 339 field_auth_source_ldap_filter: LDAP filter
340 340 field_core_fields: Standard fields
341 341 field_timeout: "Timeout (in seconds)"
342 342 field_board_parent: Parent forum
343 343 field_private_notes: Private notes
344 344 field_inherit_members: Inherit members
345 345 field_generate_password: Generate password
346 346 field_must_change_passwd: Must change password at next logon
347 347 field_default_status: Default status
348 348 field_users_visibility: Users visibility
349 349 field_time_entries_visibility: Time logs visibility
350 350 field_total_estimated_hours: Total estimated time
351 field_default_version: Default version
351 352
352 353 setting_app_title: Application title
353 354 setting_app_subtitle: Application subtitle
354 355 setting_welcome_text: Welcome text
355 356 setting_default_language: Default language
356 357 setting_login_required: Authentication required
357 358 setting_self_registration: Self-registration
358 359 setting_attachment_max_size: Maximum attachment size
359 360 setting_issues_export_limit: Issues export limit
360 361 setting_mail_from: Emission email address
361 362 setting_bcc_recipients: Blind carbon copy recipients (bcc)
362 363 setting_plain_text_mail: Plain text mail (no HTML)
363 364 setting_host_name: Host name and path
364 365 setting_text_formatting: Text formatting
365 366 setting_wiki_compression: Wiki history compression
366 367 setting_feeds_limit: Maximum number of items in Atom feeds
367 368 setting_default_projects_public: New projects are public by default
368 369 setting_autofetch_changesets: Fetch commits automatically
369 370 setting_sys_api_enabled: Enable WS for repository management
370 371 setting_commit_ref_keywords: Referencing keywords
371 372 setting_commit_fix_keywords: Fixing keywords
372 373 setting_autologin: Autologin
373 374 setting_date_format: Date format
374 375 setting_time_format: Time format
375 376 setting_cross_project_issue_relations: Allow cross-project issue relations
376 377 setting_cross_project_subtasks: Allow cross-project subtasks
377 378 setting_issue_list_default_columns: Default columns displayed on the issue list
378 379 setting_repositories_encodings: Attachments and repositories encodings
379 380 setting_emails_header: Email header
380 381 setting_emails_footer: Email footer
381 382 setting_protocol: Protocol
382 383 setting_per_page_options: Objects per page options
383 384 setting_user_format: Users display format
384 385 setting_activity_days_default: Days displayed on project activity
385 386 setting_display_subprojects_issues: Display subprojects issues on main projects by default
386 387 setting_enabled_scm: Enabled SCM
387 388 setting_mail_handler_body_delimiters: "Truncate emails after one of these lines"
388 389 setting_mail_handler_api_enabled: Enable WS for incoming emails
389 390 setting_mail_handler_api_key: API key
390 391 setting_sequential_project_identifiers: Generate sequential project identifiers
391 392 setting_gravatar_enabled: Use Gravatar user icons
392 393 setting_gravatar_default: Default Gravatar image
393 394 setting_diff_max_lines_displayed: Maximum number of diff lines displayed
394 395 setting_file_max_size_displayed: Maximum size of text files displayed inline
395 396 setting_repository_log_display_limit: Maximum number of revisions displayed on file log
396 397 setting_openid: Allow OpenID login and registration
397 398 setting_password_max_age: Require password change after
398 399 setting_password_min_length: Minimum password length
399 400 setting_new_project_user_role_id: Role given to a non-admin user who creates a project
400 401 setting_default_projects_modules: Default enabled modules for new projects
401 402 setting_issue_done_ratio: Calculate the issue done ratio with
402 403 setting_issue_done_ratio_issue_field: Use the issue field
403 404 setting_issue_done_ratio_issue_status: Use the issue status
404 405 setting_start_of_week: Start calendars on
405 406 setting_rest_api_enabled: Enable REST web service
406 407 setting_cache_formatted_text: Cache formatted text
407 408 setting_default_notification_option: Default notification option
408 409 setting_commit_logtime_enabled: Enable time logging
409 410 setting_commit_logtime_activity_id: Activity for logged time
410 411 setting_gantt_items_limit: Maximum number of items displayed on the gantt chart
411 412 setting_issue_group_assignment: Allow issue assignment to groups
412 413 setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
413 414 setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed
414 415 setting_unsubscribe: Allow users to delete their own account
415 416 setting_session_lifetime: Session maximum lifetime
416 417 setting_session_timeout: Session inactivity timeout
417 418 setting_thumbnails_enabled: Display attachment thumbnails
418 419 setting_thumbnails_size: Thumbnails size (in pixels)
419 420 setting_non_working_week_days: Non-working days
420 421 setting_jsonp_enabled: Enable JSONP support
421 422 setting_default_projects_tracker_ids: Default trackers for new projects
422 423 setting_mail_handler_excluded_filenames: Exclude attachments by name
423 424 setting_force_default_language_for_anonymous: Force default language for anonymous users
424 425 setting_force_default_language_for_loggedin: Force default language for logged-in users
425 426 setting_link_copied_issue: Link issues on copy
426 427 setting_max_additional_emails: Maximum number of additional email addresses
427 428 setting_search_results_per_page: Search results per page
428 429
429 430 permission_add_project: Create project
430 431 permission_add_subprojects: Create subprojects
431 432 permission_edit_project: Edit project
432 433 permission_close_project: Close / reopen the project
433 434 permission_select_project_modules: Select project modules
434 435 permission_manage_members: Manage members
435 436 permission_manage_project_activities: Manage project activities
436 437 permission_manage_versions: Manage versions
437 438 permission_manage_categories: Manage issue categories
438 439 permission_view_issues: View Issues
439 440 permission_add_issues: Add issues
440 441 permission_edit_issues: Edit issues
441 442 permission_copy_issues: Copy issues
442 443 permission_manage_issue_relations: Manage issue relations
443 444 permission_set_issues_private: Set issues public or private
444 445 permission_set_own_issues_private: Set own issues public or private
445 446 permission_add_issue_notes: Add notes
446 447 permission_edit_issue_notes: Edit notes
447 448 permission_edit_own_issue_notes: Edit own notes
448 449 permission_view_private_notes: View private notes
449 450 permission_set_notes_private: Set notes as private
450 451 permission_move_issues: Move issues
451 452 permission_delete_issues: Delete issues
452 453 permission_manage_public_queries: Manage public queries
453 454 permission_save_queries: Save queries
454 455 permission_view_gantt: View gantt chart
455 456 permission_view_calendar: View calendar
456 457 permission_view_issue_watchers: View watchers list
457 458 permission_add_issue_watchers: Add watchers
458 459 permission_delete_issue_watchers: Delete watchers
459 460 permission_log_time: Log spent time
460 461 permission_view_time_entries: View spent time
461 462 permission_edit_time_entries: Edit time logs
462 463 permission_edit_own_time_entries: Edit own time logs
463 464 permission_manage_news: Manage news
464 465 permission_comment_news: Comment news
465 466 permission_view_documents: View documents
466 467 permission_add_documents: Add documents
467 468 permission_edit_documents: Edit documents
468 469 permission_delete_documents: Delete documents
469 470 permission_manage_files: Manage files
470 471 permission_view_files: View files
471 472 permission_manage_wiki: Manage wiki
472 473 permission_rename_wiki_pages: Rename wiki pages
473 474 permission_delete_wiki_pages: Delete wiki pages
474 475 permission_view_wiki_pages: View wiki
475 476 permission_view_wiki_edits: View wiki history
476 477 permission_edit_wiki_pages: Edit wiki pages
477 478 permission_delete_wiki_pages_attachments: Delete attachments
478 479 permission_protect_wiki_pages: Protect wiki pages
479 480 permission_manage_repository: Manage repository
480 481 permission_browse_repository: Browse repository
481 482 permission_view_changesets: View changesets
482 483 permission_commit_access: Commit access
483 484 permission_manage_boards: Manage forums
484 485 permission_view_messages: View messages
485 486 permission_add_messages: Post messages
486 487 permission_edit_messages: Edit messages
487 488 permission_edit_own_messages: Edit own messages
488 489 permission_delete_messages: Delete messages
489 490 permission_delete_own_messages: Delete own messages
490 491 permission_export_wiki_pages: Export wiki pages
491 492 permission_manage_subtasks: Manage subtasks
492 493 permission_manage_related_issues: Manage related issues
493 494 permission_import_issues: Import issues
494 495
495 496 project_module_issue_tracking: Issue tracking
496 497 project_module_time_tracking: Time tracking
497 498 project_module_news: News
498 499 project_module_documents: Documents
499 500 project_module_files: Files
500 501 project_module_wiki: Wiki
501 502 project_module_repository: Repository
502 503 project_module_boards: Forums
503 504 project_module_calendar: Calendar
504 505 project_module_gantt: Gantt
505 506
506 507 label_user: User
507 508 label_user_plural: Users
508 509 label_user_new: New user
509 510 label_user_anonymous: Anonymous
510 511 label_project: Project
511 512 label_project_new: New project
512 513 label_project_plural: Projects
513 514 label_x_projects:
514 515 zero: no projects
515 516 one: 1 project
516 517 other: "%{count} projects"
517 518 label_project_all: All Projects
518 519 label_project_latest: Latest projects
519 520 label_issue: Issue
520 521 label_issue_new: New issue
521 522 label_issue_plural: Issues
522 523 label_issue_view_all: View all issues
523 524 label_issues_by: "Issues by %{value}"
524 525 label_issue_added: Issue added
525 526 label_issue_updated: Issue updated
526 527 label_issue_note_added: Note added
527 528 label_issue_status_updated: Status updated
528 529 label_issue_assigned_to_updated: Assignee updated
529 530 label_issue_priority_updated: Priority updated
530 531 label_document: Document
531 532 label_document_new: New document
532 533 label_document_plural: Documents
533 534 label_document_added: Document added
534 535 label_role: Role
535 536 label_role_plural: Roles
536 537 label_role_new: New role
537 538 label_role_and_permissions: Roles and permissions
538 539 label_role_anonymous: Anonymous
539 540 label_role_non_member: Non member
540 541 label_member: Member
541 542 label_member_new: New member
542 543 label_member_plural: Members
543 544 label_tracker: Tracker
544 545 label_tracker_plural: Trackers
545 546 label_tracker_new: New tracker
546 547 label_workflow: Workflow
547 548 label_issue_status: Issue status
548 549 label_issue_status_plural: Issue statuses
549 550 label_issue_status_new: New status
550 551 label_issue_category: Issue category
551 552 label_issue_category_plural: Issue categories
552 553 label_issue_category_new: New category
553 554 label_custom_field: Custom field
554 555 label_custom_field_plural: Custom fields
555 556 label_custom_field_new: New custom field
556 557 label_enumerations: Enumerations
557 558 label_enumeration_new: New value
558 559 label_information: Information
559 560 label_information_plural: Information
560 561 label_please_login: Please log in
561 562 label_register: Register
562 563 label_login_with_open_id_option: or login with OpenID
563 564 label_password_lost: Lost password
564 565 label_password_required: Confirm your password to continue
565 566 label_home: Home
566 567 label_my_page: My page
567 568 label_my_account: My account
568 569 label_my_projects: My projects
569 570 label_my_page_block: My page block
570 571 label_administration: Administration
571 572 label_login: Sign in
572 573 label_logout: Sign out
573 574 label_help: Help
574 575 label_reported_issues: Reported issues
575 576 label_assigned_issues: Assigned issues
576 577 label_assigned_to_me_issues: Issues assigned to me
577 578 label_last_login: Last connection
578 579 label_registered_on: Registered on
579 580 label_activity: Activity
580 581 label_overall_activity: Overall activity
581 582 label_user_activity: "%{value}'s activity"
582 583 label_new: New
583 584 label_logged_as: Logged in as
584 585 label_environment: Environment
585 586 label_authentication: Authentication
586 587 label_auth_source: Authentication mode
587 588 label_auth_source_new: New authentication mode
588 589 label_auth_source_plural: Authentication modes
589 590 label_subproject_plural: Subprojects
590 591 label_subproject_new: New subproject
591 592 label_and_its_subprojects: "%{value} and its subprojects"
592 593 label_min_max_length: Min - Max length
593 594 label_list: List
594 595 label_date: Date
595 596 label_integer: Integer
596 597 label_float: Float
597 598 label_boolean: Boolean
598 599 label_string: Text
599 600 label_text: Long text
600 601 label_attribute: Attribute
601 602 label_attribute_plural: Attributes
602 603 label_no_data: No data to display
603 604 label_change_status: Change status
604 605 label_history: History
605 606 label_attachment: File
606 607 label_attachment_new: New file
607 608 label_attachment_delete: Delete file
608 609 label_attachment_plural: Files
609 610 label_file_added: File added
610 611 label_report: Report
611 612 label_report_plural: Reports
612 613 label_news: News
613 614 label_news_new: Add news
614 615 label_news_plural: News
615 616 label_news_latest: Latest news
616 617 label_news_view_all: View all news
617 618 label_news_added: News added
618 619 label_news_comment_added: Comment added to a news
619 620 label_settings: Settings
620 621 label_overview: Overview
621 622 label_version: Version
622 623 label_version_new: New version
623 624 label_version_plural: Versions
624 625 label_close_versions: Close completed versions
625 626 label_confirmation: Confirmation
626 627 label_export_to: 'Also available in:'
627 628 label_read: Read...
628 629 label_public_projects: Public projects
629 630 label_open_issues: open
630 631 label_open_issues_plural: open
631 632 label_closed_issues: closed
632 633 label_closed_issues_plural: closed
633 634 label_x_open_issues_abbr:
634 635 zero: 0 open
635 636 one: 1 open
636 637 other: "%{count} open"
637 638 label_x_closed_issues_abbr:
638 639 zero: 0 closed
639 640 one: 1 closed
640 641 other: "%{count} closed"
641 642 label_x_issues:
642 643 zero: 0 issues
643 644 one: 1 issue
644 645 other: "%{count} issues"
645 646 label_total: Total
646 647 label_total_plural: Totals
647 648 label_total_time: Total time
648 649 label_permissions: Permissions
649 650 label_current_status: Current status
650 651 label_new_statuses_allowed: New statuses allowed
651 652 label_all: all
652 653 label_any: any
653 654 label_none: none
654 655 label_nobody: nobody
655 656 label_next: Next
656 657 label_previous: Previous
657 658 label_used_by: Used by
658 659 label_details: Details
659 660 label_add_note: Add a note
660 661 label_calendar: Calendar
661 662 label_months_from: months from
662 663 label_gantt: Gantt
663 664 label_internal: Internal
664 665 label_last_changes: "last %{count} changes"
665 666 label_change_view_all: View all changes
666 667 label_personalize_page: Personalize this page
667 668 label_comment: Comment
668 669 label_comment_plural: Comments
669 670 label_x_comments:
670 671 zero: no comments
671 672 one: 1 comment
672 673 other: "%{count} comments"
673 674 label_comment_add: Add a comment
674 675 label_comment_added: Comment added
675 676 label_comment_delete: Delete comments
676 677 label_query: Custom query
677 678 label_query_plural: Custom queries
678 679 label_query_new: New query
679 680 label_my_queries: My custom queries
680 681 label_filter_add: Add filter
681 682 label_filter_plural: Filters
682 683 label_equals: is
683 684 label_not_equals: is not
684 685 label_in_less_than: in less than
685 686 label_in_more_than: in more than
686 687 label_in_the_next_days: in the next
687 688 label_in_the_past_days: in the past
688 689 label_greater_or_equal: '>='
689 690 label_less_or_equal: '<='
690 691 label_between: between
691 692 label_in: in
692 693 label_today: today
693 694 label_all_time: all time
694 695 label_yesterday: yesterday
695 696 label_this_week: this week
696 697 label_last_week: last week
697 698 label_last_n_weeks: "last %{count} weeks"
698 699 label_last_n_days: "last %{count} days"
699 700 label_this_month: this month
700 701 label_last_month: last month
701 702 label_this_year: this year
702 703 label_date_range: Date range
703 704 label_less_than_ago: less than days ago
704 705 label_more_than_ago: more than days ago
705 706 label_ago: days ago
706 707 label_contains: contains
707 708 label_not_contains: doesn't contain
708 709 label_any_issues_in_project: any issues in project
709 710 label_any_issues_not_in_project: any issues not in project
710 711 label_no_issues_in_project: no issues in project
711 712 label_day_plural: days
712 713 label_repository: Repository
713 714 label_repository_new: New repository
714 715 label_repository_plural: Repositories
715 716 label_browse: Browse
716 717 label_branch: Branch
717 718 label_tag: Tag
718 719 label_revision: Revision
719 720 label_revision_plural: Revisions
720 721 label_revision_id: "Revision %{value}"
721 722 label_associated_revisions: Associated revisions
722 723 label_added: added
723 724 label_modified: modified
724 725 label_copied: copied
725 726 label_renamed: renamed
726 727 label_deleted: deleted
727 728 label_latest_revision: Latest revision
728 729 label_latest_revision_plural: Latest revisions
729 730 label_view_revisions: View revisions
730 731 label_view_all_revisions: View all revisions
731 732 label_max_size: Maximum size
732 733 label_sort_highest: Move to top
733 734 label_sort_higher: Move up
734 735 label_sort_lower: Move down
735 736 label_sort_lowest: Move to bottom
736 737 label_roadmap: Roadmap
737 738 label_roadmap_due_in: "Due in %{value}"
738 739 label_roadmap_overdue: "%{value} late"
739 740 label_roadmap_no_issues: No issues for this version
740 741 label_search: Search
741 742 label_result_plural: Results
742 743 label_all_words: All words
743 744 label_wiki: Wiki
744 745 label_wiki_edit: Wiki edit
745 746 label_wiki_edit_plural: Wiki edits
746 747 label_wiki_page: Wiki page
747 748 label_wiki_page_plural: Wiki pages
748 749 label_index_by_title: Index by title
749 750 label_index_by_date: Index by date
750 751 label_current_version: Current version
751 752 label_preview: Preview
752 753 label_feed_plural: Feeds
753 754 label_changes_details: Details of all changes
754 755 label_issue_tracking: Issue tracking
755 756 label_spent_time: Spent time
756 757 label_total_spent_time: Total spent time
757 758 label_overall_spent_time: Overall spent time
758 759 label_f_hour: "%{value} hour"
759 760 label_f_hour_plural: "%{value} hours"
760 761 label_f_hour_short: "%{value} h"
761 762 label_time_tracking: Time tracking
762 763 label_change_plural: Changes
763 764 label_statistics: Statistics
764 765 label_commits_per_month: Commits per month
765 766 label_commits_per_author: Commits per author
766 767 label_diff: diff
767 768 label_view_diff: View differences
768 769 label_diff_inline: inline
769 770 label_diff_side_by_side: side by side
770 771 label_options: Options
771 772 label_copy_workflow_from: Copy workflow from
772 773 label_permissions_report: Permissions report
773 774 label_watched_issues: Watched issues
774 775 label_related_issues: Related issues
775 776 label_applied_status: Applied status
776 777 label_loading: Loading...
777 778 label_relation_new: New relation
778 779 label_relation_delete: Delete relation
779 780 label_relates_to: Related to
780 781 label_duplicates: Duplicates
781 782 label_duplicated_by: Duplicated by
782 783 label_blocks: Blocks
783 784 label_blocked_by: Blocked by
784 785 label_precedes: Precedes
785 786 label_follows: Follows
786 787 label_copied_to: Copied to
787 788 label_copied_from: Copied from
788 789 label_end_to_start: end to start
789 790 label_end_to_end: end to end
790 791 label_start_to_start: start to start
791 792 label_start_to_end: start to end
792 793 label_stay_logged_in: Stay logged in
793 794 label_disabled: disabled
794 795 label_show_completed_versions: Show completed versions
795 796 label_me: me
796 797 label_board: Forum
797 798 label_board_new: New forum
798 799 label_board_plural: Forums
799 800 label_board_locked: Locked
800 801 label_board_sticky: Sticky
801 802 label_topic_plural: Topics
802 803 label_message_plural: Messages
803 804 label_message_last: Last message
804 805 label_message_new: New message
805 806 label_message_posted: Message added
806 807 label_reply_plural: Replies
807 808 label_send_information: Send account information to the user
808 809 label_year: Year
809 810 label_month: Month
810 811 label_week: Week
811 812 label_date_from: From
812 813 label_date_to: To
813 814 label_language_based: Based on user's language
814 815 label_sort_by: "Sort by %{value}"
815 816 label_send_test_email: Send a test email
816 817 label_feeds_access_key: Atom access key
817 818 label_missing_feeds_access_key: Missing a Atom access key
818 819 label_feeds_access_key_created_on: "Atom access key created %{value} ago"
819 820 label_module_plural: Modules
820 821 label_added_time_by: "Added by %{author} %{age} ago"
821 822 label_updated_time_by: "Updated by %{author} %{age} ago"
822 823 label_updated_time: "Updated %{value} ago"
823 824 label_jump_to_a_project: Jump to a project...
824 825 label_file_plural: Files
825 826 label_changeset_plural: Changesets
826 827 label_default_columns: Default columns
827 828 label_no_change_option: (No change)
828 829 label_bulk_edit_selected_issues: Bulk edit selected issues
829 830 label_bulk_edit_selected_time_entries: Bulk edit selected time entries
830 831 label_theme: Theme
831 832 label_default: Default
832 833 label_search_titles_only: Search titles only
833 834 label_user_mail_option_all: "For any event on all my projects"
834 835 label_user_mail_option_selected: "For any event on the selected projects only..."
835 836 label_user_mail_option_none: "No events"
836 837 label_user_mail_option_only_my_events: "Only for things I watch or I'm involved in"
837 838 label_user_mail_option_only_assigned: "Only for things I am assigned to"
838 839 label_user_mail_option_only_owner: "Only for things I am the owner of"
839 840 label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
840 841 label_registration_activation_by_email: account activation by email
841 842 label_registration_manual_activation: manual account activation
842 843 label_registration_automatic_activation: automatic account activation
843 844 label_display_per_page: "Per page: %{value}"
844 845 label_age: Age
845 846 label_change_properties: Change properties
846 847 label_general: General
847 848 label_more: More
848 849 label_scm: SCM
849 850 label_plugins: Plugins
850 851 label_ldap_authentication: LDAP authentication
851 852 label_downloads_abbr: D/L
852 853 label_optional_description: Optional description
853 854 label_add_another_file: Add another file
854 855 label_preferences: Preferences
855 856 label_chronological_order: In chronological order
856 857 label_reverse_chronological_order: In reverse chronological order
857 858 label_planning: Planning
858 859 label_incoming_emails: Incoming emails
859 860 label_generate_key: Generate a key
860 861 label_issue_watchers: Watchers
861 862 label_example: Example
862 863 label_display: Display
863 864 label_sort: Sort
864 865 label_ascending: Ascending
865 866 label_descending: Descending
866 867 label_date_from_to: From %{start} to %{end}
867 868 label_wiki_content_added: Wiki page added
868 869 label_wiki_content_updated: Wiki page updated
869 870 label_group: Group
870 871 label_group_plural: Groups
871 872 label_group_new: New group
872 873 label_group_anonymous: Anonymous users
873 874 label_group_non_member: Non member users
874 875 label_time_entry_plural: Spent time
875 876 label_version_sharing_none: Not shared
876 877 label_version_sharing_descendants: With subprojects
877 878 label_version_sharing_hierarchy: With project hierarchy
878 879 label_version_sharing_tree: With project tree
879 880 label_version_sharing_system: With all projects
880 881 label_update_issue_done_ratios: Update issue done ratios
881 882 label_copy_source: Source
882 883 label_copy_target: Target
883 884 label_copy_same_as_target: Same as target
884 885 label_display_used_statuses_only: Only display statuses that are used by this tracker
885 886 label_api_access_key: API access key
886 887 label_missing_api_access_key: Missing an API access key
887 888 label_api_access_key_created_on: "API access key created %{value} ago"
888 889 label_profile: Profile
889 890 label_subtask_plural: Subtasks
890 891 label_project_copy_notifications: Send email notifications during the project copy
891 892 label_principal_search: "Search for user or group:"
892 893 label_user_search: "Search for user:"
893 894 label_additional_workflow_transitions_for_author: Additional transitions allowed when the user is the author
894 895 label_additional_workflow_transitions_for_assignee: Additional transitions allowed when the user is the assignee
895 896 label_issues_visibility_all: All issues
896 897 label_issues_visibility_public: All non private issues
897 898 label_issues_visibility_own: Issues created by or assigned to the user
898 899 label_git_report_last_commit: Report last commit for files and directories
899 900 label_parent_revision: Parent
900 901 label_child_revision: Child
901 902 label_export_options: "%{export_format} export options"
902 903 label_copy_attachments: Copy attachments
903 904 label_copy_subtasks: Copy subtasks
904 905 label_item_position: "%{position} of %{count}"
905 906 label_completed_versions: Completed versions
906 907 label_search_for_watchers: Search for watchers to add
907 908 label_session_expiration: Session expiration
908 909 label_show_closed_projects: View closed projects
909 910 label_status_transitions: Status transitions
910 911 label_fields_permissions: Fields permissions
911 912 label_readonly: Read-only
912 913 label_required: Required
913 914 label_hidden: Hidden
914 915 label_attribute_of_project: "Project's %{name}"
915 916 label_attribute_of_issue: "Issue's %{name}"
916 917 label_attribute_of_author: "Author's %{name}"
917 918 label_attribute_of_assigned_to: "Assignee's %{name}"
918 919 label_attribute_of_user: "User's %{name}"
919 920 label_attribute_of_fixed_version: "Target version's %{name}"
920 921 label_cross_project_descendants: With subprojects
921 922 label_cross_project_tree: With project tree
922 923 label_cross_project_hierarchy: With project hierarchy
923 924 label_cross_project_system: With all projects
924 925 label_gantt_progress_line: Progress line
925 926 label_visibility_private: to me only
926 927 label_visibility_roles: to these roles only
927 928 label_visibility_public: to any users
928 929 label_link: Link
929 930 label_only: only
930 931 label_drop_down_list: drop-down list
931 932 label_checkboxes: checkboxes
932 933 label_radio_buttons: radio buttons
933 934 label_link_values_to: Link values to URL
934 935 label_custom_field_select_type: Select the type of object to which the custom field is to be attached
935 936 label_check_for_updates: Check for updates
936 937 label_latest_compatible_version: Latest compatible version
937 938 label_unknown_plugin: Unknown plugin
938 939 label_add_projects: Add projects
939 940 label_users_visibility_all: All active users
940 941 label_users_visibility_members_of_visible_projects: Members of visible projects
941 942 label_edit_attachments: Edit attached files
942 943 label_link_copied_issue: Link copied issue
943 944 label_ask: Ask
944 945 label_search_attachments_yes: Search attachment filenames and descriptions
945 946 label_search_attachments_no: Do not search attachments
946 947 label_search_attachments_only: Search attachments only
947 948 label_search_open_issues_only: Open issues only
948 949 label_email_address_plural: Emails
949 950 label_email_address_add: Add email address
950 951 label_enable_notifications: Enable notifications
951 952 label_disable_notifications: Disable notifications
952 953 label_blank_value: blank
953 954 label_parent_task_attributes: Parent tasks attributes
954 955 label_parent_task_attributes_derived: Calculated from subtasks
955 956 label_parent_task_attributes_independent: Independent of subtasks
956 957 label_time_entries_visibility_all: All time entries
957 958 label_time_entries_visibility_own: Time entries created by the user
958 959 label_member_management: Member management
959 960 label_member_management_all_roles: All roles
960 961 label_member_management_selected_roles_only: Only these roles
961 962 label_import_issues: Import issues
962 963 label_select_file_to_import: Select the file to import
963 964 label_fields_separator: Field separator
964 965 label_fields_wrapper: Field wrapper
965 966 label_encoding: Encoding
966 967 label_comma_char: Comma
967 968 label_semi_colon_char: Semi colon
968 969 label_quote_char: Quote
969 970 label_double_quote_char: Double quote
970 971 label_fields_mapping: Fields mapping
971 972 label_file_content_preview: File content preview
972 973 label_create_missing_values: Create missing values
973 974 label_api: API
974 975 label_field_format_enumeration: Key/value list
975 976
976 977 button_login: Login
977 978 button_submit: Submit
978 979 button_save: Save
979 980 button_check_all: Check all
980 981 button_uncheck_all: Uncheck all
981 982 button_collapse_all: Collapse all
982 983 button_expand_all: Expand all
983 984 button_delete: Delete
984 985 button_create: Create
985 986 button_create_and_continue: Create and continue
986 987 button_test: Test
987 988 button_edit: Edit
988 989 button_edit_associated_wikipage: "Edit associated Wiki page: %{page_title}"
989 990 button_add: Add
990 991 button_change: Change
991 992 button_apply: Apply
992 993 button_clear: Clear
993 994 button_lock: Lock
994 995 button_unlock: Unlock
995 996 button_download: Download
996 997 button_list: List
997 998 button_view: View
998 999 button_move: Move
999 1000 button_move_and_follow: Move and follow
1000 1001 button_back: Back
1001 1002 button_cancel: Cancel
1002 1003 button_activate: Activate
1003 1004 button_sort: Sort
1004 1005 button_log_time: Log time
1005 1006 button_rollback: Rollback to this version
1006 1007 button_watch: Watch
1007 1008 button_unwatch: Unwatch
1008 1009 button_reply: Reply
1009 1010 button_archive: Archive
1010 1011 button_unarchive: Unarchive
1011 1012 button_reset: Reset
1012 1013 button_rename: Rename
1013 1014 button_change_password: Change password
1014 1015 button_copy: Copy
1015 1016 button_copy_and_follow: Copy and follow
1016 1017 button_annotate: Annotate
1017 1018 button_update: Update
1018 1019 button_configure: Configure
1019 1020 button_quote: Quote
1020 1021 button_duplicate: Duplicate
1021 1022 button_show: Show
1022 1023 button_hide: Hide
1023 1024 button_edit_section: Edit this section
1024 1025 button_export: Export
1025 1026 button_delete_my_account: Delete my account
1026 1027 button_close: Close
1027 1028 button_reopen: Reopen
1028 1029 button_import: Import
1029 1030
1030 1031 status_active: active
1031 1032 status_registered: registered
1032 1033 status_locked: locked
1033 1034
1034 1035 project_status_active: active
1035 1036 project_status_closed: closed
1036 1037 project_status_archived: archived
1037 1038
1038 1039 version_status_open: open
1039 1040 version_status_locked: locked
1040 1041 version_status_closed: closed
1041 1042
1042 1043 field_active: Active
1043 1044
1044 1045 text_select_mail_notifications: Select actions for which email notifications should be sent.
1045 1046 text_regexp_info: eg. ^[A-Z0-9]+$
1046 1047 text_min_max_length_info: 0 means no restriction
1047 1048 text_project_destroy_confirmation: Are you sure you want to delete this project and related data?
1048 1049 text_subprojects_destroy_warning: "Its subproject(s): %{value} will be also deleted."
1049 1050 text_workflow_edit: Select a role and a tracker to edit the workflow
1050 1051 text_are_you_sure: Are you sure?
1051 1052 text_journal_changed: "%{label} changed from %{old} to %{new}"
1052 1053 text_journal_changed_no_detail: "%{label} updated"
1053 1054 text_journal_set_to: "%{label} set to %{value}"
1054 1055 text_journal_deleted: "%{label} deleted (%{old})"
1055 1056 text_journal_added: "%{label} %{value} added"
1056 1057 text_tip_issue_begin_day: issue beginning this day
1057 1058 text_tip_issue_end_day: issue ending this day
1058 1059 text_tip_issue_begin_end_day: issue beginning and ending this day
1059 1060 text_project_identifier_info: 'Only lower case letters (a-z), numbers, dashes and underscores are allowed, must start with a lower case letter.<br />Once saved, the identifier cannot be changed.'
1060 1061 text_caracters_maximum: "%{count} characters maximum."
1061 1062 text_caracters_minimum: "Must be at least %{count} characters long."
1062 1063 text_length_between: "Length between %{min} and %{max} characters."
1063 1064 text_tracker_no_workflow: No workflow defined for this tracker
1064 1065 text_unallowed_characters: Unallowed characters
1065 1066 text_comma_separated: Multiple values allowed (comma separated).
1066 1067 text_line_separated: Multiple values allowed (one line for each value).
1067 1068 text_issues_ref_in_commit_messages: Referencing and fixing issues in commit messages
1068 1069 text_issue_added: "Issue %{id} has been reported by %{author}."
1069 1070 text_issue_updated: "Issue %{id} has been updated by %{author}."
1070 1071 text_wiki_destroy_confirmation: Are you sure you want to delete this wiki and all its content?
1071 1072 text_issue_category_destroy_question: "Some issues (%{count}) are assigned to this category. What do you want to do?"
1072 1073 text_issue_category_destroy_assignments: Remove category assignments
1073 1074 text_issue_category_reassign_to: Reassign issues to this category
1074 1075 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)."
1075 1076 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."
1076 1077 text_load_default_configuration: Load the default configuration
1077 1078 text_status_changed_by_changeset: "Applied in changeset %{value}."
1078 1079 text_time_logged_by_changeset: "Applied in changeset %{value}."
1079 1080 text_issues_destroy_confirmation: 'Are you sure you want to delete the selected issue(s)?'
1080 1081 text_issues_destroy_descendants_confirmation: "This will also delete %{count} subtask(s)."
1081 1082 text_time_entries_destroy_confirmation: 'Are you sure you want to delete the selected time entr(y/ies)?'
1082 1083 text_select_project_modules: 'Select modules to enable for this project:'
1083 1084 text_default_administrator_account_changed: Default administrator account changed
1084 1085 text_file_repository_writable: Attachments directory writable
1085 1086 text_plugin_assets_writable: Plugin assets directory writable
1086 1087 text_rmagick_available: RMagick available (optional)
1087 1088 text_convert_available: ImageMagick convert available (optional)
1088 1089 text_destroy_time_entries_question: "%{hours} hours were reported on the issues you are about to delete. What do you want to do?"
1089 1090 text_destroy_time_entries: Delete reported hours
1090 1091 text_assign_time_entries_to_project: Assign reported hours to the project
1091 1092 text_reassign_time_entries: 'Reassign reported hours to this issue:'
1092 1093 text_user_wrote: "%{value} wrote:"
1093 1094 text_enumeration_destroy_question: "%{count} objects are assigned to the value β€œ%{name}”."
1094 1095 text_enumeration_category_reassign_to: 'Reassign them to this value:'
1095 1096 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."
1096 1097 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."
1097 1098 text_diff_truncated: '... This diff was truncated because it exceeds the maximum size that can be displayed.'
1098 1099 text_custom_field_possible_values_info: 'One line for each value'
1099 1100 text_wiki_page_destroy_question: "This page has %{descendants} child page(s) and descendant(s). What do you want to do?"
1100 1101 text_wiki_page_nullify_children: "Keep child pages as root pages"
1101 1102 text_wiki_page_destroy_children: "Delete child pages and all their descendants"
1102 1103 text_wiki_page_reassign_children: "Reassign child pages to this parent page"
1103 1104 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?"
1104 1105 text_zoom_in: Zoom in
1105 1106 text_zoom_out: Zoom out
1106 1107 text_warn_on_leaving_unsaved: "The current page contains unsaved text that will be lost if you leave this page."
1107 1108 text_scm_path_encoding_note: "Default: UTF-8"
1108 1109 text_subversion_repository_note: "Examples: file:///, http://, https://, svn://, svn+[tunnelscheme]://"
1109 1110 text_git_repository_note: Repository is bare and local (e.g. /gitrepo, c:\gitrepo)
1110 1111 text_mercurial_repository_note: Local repository (e.g. /hgrepo, c:\hgrepo)
1111 1112 text_scm_command: Command
1112 1113 text_scm_command_version: Version
1113 1114 text_scm_config: You can configure your SCM commands in config/configuration.yml. Please restart the application after editing it.
1114 1115 text_scm_command_not_available: SCM command is not available. Please check settings on the administration panel.
1115 1116 text_issue_conflict_resolution_overwrite: "Apply my changes anyway (previous notes will be kept but some changes may be overwritten)"
1116 1117 text_issue_conflict_resolution_add_notes: "Add my notes and discard my other changes"
1117 1118 text_issue_conflict_resolution_cancel: "Discard all my changes and redisplay %{link}"
1118 1119 text_account_destroy_confirmation: "Are you sure you want to proceed?\nYour account will be permanently deleted, with no way to reactivate it."
1119 1120 text_session_expiration_settings: "Warning: changing these settings may expire the current sessions including yours."
1120 1121 text_project_closed: This project is closed and read-only.
1121 1122 text_turning_multiple_off: "If you disable multiple values, multiple values will be removed in order to preserve only one value per item."
1122 1123
1123 1124 default_role_manager: Manager
1124 1125 default_role_developer: Developer
1125 1126 default_role_reporter: Reporter
1126 1127 default_tracker_bug: Bug
1127 1128 default_tracker_feature: Feature
1128 1129 default_tracker_support: Support
1129 1130 default_issue_status_new: New
1130 1131 default_issue_status_in_progress: In Progress
1131 1132 default_issue_status_resolved: Resolved
1132 1133 default_issue_status_feedback: Feedback
1133 1134 default_issue_status_closed: Closed
1134 1135 default_issue_status_rejected: Rejected
1135 1136 default_doc_category_user: User documentation
1136 1137 default_doc_category_tech: Technical documentation
1137 1138 default_priority_low: Low
1138 1139 default_priority_normal: Normal
1139 1140 default_priority_high: High
1140 1141 default_priority_urgent: Urgent
1141 1142 default_priority_immediate: Immediate
1142 1143 default_activity_design: Design
1143 1144 default_activity_development: Development
1144 1145
1145 1146 enumeration_issue_priorities: Issue priorities
1146 1147 enumeration_doc_categories: Document categories
1147 1148 enumeration_activities: Activities (time tracking)
1148 1149 enumeration_system_activity: System Activity
1149 1150 description_filter: Filter
1150 1151 description_search: Searchfield
1151 1152 description_choose_project: Projects
1152 1153 description_project_scope: Search scope
1153 1154 description_notes: Notes
1154 1155 description_message_content: Message content
1155 1156 description_query_sort_criteria_attribute: Sort attribute
1156 1157 description_query_sort_criteria_direction: Sort direction
1157 1158 description_user_mail_notification: Mail notification settings
1158 1159 description_available_columns: Available Columns
1159 1160 description_selected_columns: Selected Columns
1160 1161 description_all_columns: All Columns
1161 1162 description_issue_category_reassign: Choose issue category
1162 1163 description_wiki_subpages_reassign: Choose new parent page
1163 1164 description_date_range_list: Choose range from list
1164 1165 description_date_range_interval: Choose range by selecting start and end date
1165 1166 description_date_from: Enter start date
1166 1167 description_date_to: Enter end date
1167 1168 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,1187 +1,1188
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
19 19 # Don't forget the nil at the beginning; there's no such thing as a 0th month
20 20 month_names: [~, janvier, fΓ©vrier, mars, avril, mai, juin, juillet, aoΓ»t, septembre, octobre, novembre, dΓ©cembre]
21 21 abbr_month_names: [~, jan., fΓ©v., mar., avr., mai, juin, juil., aoΓ»t, sept., oct., nov., dΓ©c.]
22 22 # Used in date_select and datime_select.
23 23 order:
24 24 - :day
25 25 - :month
26 26 - :year
27 27
28 28 time:
29 29 formats:
30 30 default: "%d/%m/%Y %H:%M"
31 31 time: "%H:%M"
32 32 short: "%d %b %H:%M"
33 33 long: "%A %d %B %Y %H:%M:%S %Z"
34 34 long_ordinal: "%A %d %B %Y %H:%M:%S %Z"
35 35 only_second: "%S"
36 36 am: 'am'
37 37 pm: 'pm'
38 38
39 39 datetime:
40 40 distance_in_words:
41 41 half_a_minute: "30 secondes"
42 42 less_than_x_seconds:
43 43 zero: "moins d'une seconde"
44 44 one: "moins d'uneΒ seconde"
45 45 other: "moins de %{count}Β secondes"
46 46 x_seconds:
47 47 one: "1Β seconde"
48 48 other: "%{count}Β secondes"
49 49 less_than_x_minutes:
50 50 zero: "moins d'une minute"
51 51 one: "moins d'uneΒ minute"
52 52 other: "moins de %{count}Β minutes"
53 53 x_minutes:
54 54 one: "1Β minute"
55 55 other: "%{count}Β minutes"
56 56 about_x_hours:
57 57 one: "environ une heure"
58 58 other: "environ %{count}Β heures"
59 59 x_hours:
60 60 one: "une heure"
61 61 other: "%{count}Β heures"
62 62 x_days:
63 63 one: "unΒ jour"
64 64 other: "%{count}Β jours"
65 65 about_x_months:
66 66 one: "environ un mois"
67 67 other: "environ %{count}Β mois"
68 68 x_months:
69 69 one: "unΒ mois"
70 70 other: "%{count}Β mois"
71 71 about_x_years:
72 72 one: "environ un an"
73 73 other: "environ %{count}Β ans"
74 74 over_x_years:
75 75 one: "plus d'un an"
76 76 other: "plus de %{count}Β ans"
77 77 almost_x_years:
78 78 one: "presqu'un an"
79 79 other: "presque %{count} ans"
80 80 prompts:
81 81 year: "AnnΓ©e"
82 82 month: "Mois"
83 83 day: "Jour"
84 84 hour: "Heure"
85 85 minute: "Minute"
86 86 second: "Seconde"
87 87
88 88 number:
89 89 format:
90 90 precision: 3
91 91 separator: ','
92 92 delimiter: 'Β '
93 93 currency:
94 94 format:
95 95 unit: '€'
96 96 precision: 2
97 97 format: '%nΒ %u'
98 98 human:
99 99 format:
100 100 precision: 3
101 101 storage_units:
102 102 format: "%n %u"
103 103 units:
104 104 byte:
105 105 one: "octet"
106 106 other: "octets"
107 107 kb: "ko"
108 108 mb: "Mo"
109 109 gb: "Go"
110 110 tb: "To"
111 111
112 112 support:
113 113 array:
114 114 sentence_connector: 'et'
115 115 skip_last_comma: true
116 116 word_connector: ", "
117 117 two_words_connector: " et "
118 118 last_word_connector: " et "
119 119
120 120 activerecord:
121 121 errors:
122 122 template:
123 123 header:
124 124 one: "Impossible d'enregistrer %{model} : une erreur"
125 125 other: "Impossible d'enregistrer %{model} : %{count} erreurs."
126 126 body: "Veuillez vΓ©rifier les champs suivantsΒ :"
127 127 messages:
128 128 inclusion: "n'est pas inclus(e) dans la liste"
129 129 exclusion: "n'est pas disponible"
130 130 invalid: "n'est pas valide"
131 131 confirmation: "ne concorde pas avec la confirmation"
132 132 accepted: "doit Γͺtre acceptΓ©(e)"
133 133 empty: "doit Γͺtre renseignΓ©(e)"
134 134 blank: "doit Γͺtre renseignΓ©(e)"
135 135 too_long: "est trop long (pas plus de %{count} caractères)"
136 136 too_short: "est trop court (au moins %{count} caractères)"
137 137 wrong_length: "ne fait pas la bonne longueur (doit comporter %{count} caractères)"
138 138 taken: "est dΓ©jΓ  utilisΓ©"
139 139 not_a_number: "n'est pas un nombre"
140 140 not_a_date: "n'est pas une date valide"
141 141 greater_than: "doit Γͺtre supΓ©rieur Γ  %{count}"
142 142 greater_than_or_equal_to: "doit Γͺtre supΓ©rieur ou Γ©gal Γ  %{count}"
143 143 equal_to: "doit Γͺtre Γ©gal Γ  %{count}"
144 144 less_than: "doit Γͺtre infΓ©rieur Γ  %{count}"
145 145 less_than_or_equal_to: "doit Γͺtre infΓ©rieur ou Γ©gal Γ  %{count}"
146 146 odd: "doit Γͺtre impair"
147 147 even: "doit Γͺtre pair"
148 148 greater_than_start_date: "doit Γͺtre postΓ©rieure Γ  la date de dΓ©but"
149 149 not_same_project: "n'appartient pas au mΓͺme projet"
150 150 circular_dependency: "Cette relation crΓ©erait une dΓ©pendance circulaire"
151 151 cant_link_an_issue_with_a_descendant: "Une demande ne peut pas Γͺtre liΓ©e Γ  l'une de ses sous-tΓ’ches"
152 152 earlier_than_minimum_start_date: "ne peut pas Γͺtre antΓ©rieure au %{date} Γ  cause des demandes qui prΓ©cΓ¨dent"
153 153
154 154 actionview_instancetag_blank_option: Choisir
155 155
156 156 general_text_No: 'Non'
157 157 general_text_Yes: 'Oui'
158 158 general_text_no: 'non'
159 159 general_text_yes: 'oui'
160 160 general_lang_name: 'French (FranΓ§ais)'
161 161 general_csv_separator: ';'
162 162 general_csv_decimal_separator: ','
163 163 general_csv_encoding: ISO-8859-1
164 164 general_pdf_fontname: freesans
165 165 general_first_day_of_week: '1'
166 166
167 167 notice_account_updated: Le compte a été mis à jour avec succès.
168 168 notice_account_invalid_creditentials: Identifiant ou mot de passe invalide.
169 169 notice_account_password_updated: Mot de passe mis à jour avec succès.
170 170 notice_account_wrong_password: Mot de passe incorrect
171 171 notice_account_register_done: Un message contenant les instructions pour activer votre compte vous a Γ©tΓ© envoyΓ© Γ  l'adresse %{email}.
172 172 notice_account_unknown_email: Aucun compte ne correspond Γ  cette adresse.
173 173 notice_account_not_activated_yet: Vous n'avez pas encore activΓ© votre compte. Si vous voulez recevoir un nouveau message d'activation, veuillez <a href="%{url}">cliquer sur ce lien</a>.
174 174 notice_account_locked: Votre compte est verrouillΓ©.
175 175 notice_can_t_change_password: Ce compte utilise une authentification externe. Impossible de changer le mot de passe.
176 176 notice_account_lost_email_sent: Un message contenant les instructions pour choisir un nouveau mot de passe vous a Γ©tΓ© envoyΓ©.
177 177 notice_account_activated: Votre compte a Γ©tΓ© activΓ©. Vous pouvez Γ  prΓ©sent vous connecter.
178 178 notice_successful_create: Création effectuée avec succès.
179 179 notice_successful_update: Mise à jour effectuée avec succès.
180 180 notice_successful_delete: Suppression effectuée avec succès.
181 181 notice_successful_connection: Connexion rΓ©ussie.
182 182 notice_file_not_found: "La page Γ  laquelle vous souhaitez accΓ©der n'existe pas ou a Γ©tΓ© supprimΓ©e."
183 183 notice_locking_conflict: Les donnΓ©es ont Γ©tΓ© mises Γ  jour par un autre utilisateur. Mise Γ  jour impossible.
184 184 notice_not_authorized: "Vous n'Γͺtes pas autorisΓ© Γ  accΓ©der Γ  cette page."
185 185 notice_not_authorized_archived_project: Le projet auquel vous tentez d'accΓ©der a Γ©tΓ© archivΓ©.
186 186 notice_email_sent: "Un email a Γ©tΓ© envoyΓ© Γ  %{value}"
187 187 notice_email_error: "Erreur lors de l'envoi de l'email (%{value})"
188 188 notice_feeds_access_key_reseted: "Votre clé d'accès aux flux Atom a été réinitialisée."
189 189 notice_api_access_key_reseted: Votre clé d'accès API a été réinitialisée.
190 190 notice_failed_to_save_issues: "%{count} demande(s) sur les %{total} sΓ©lectionnΓ©es n'ont pas pu Γͺtre mise(s) Γ  jour : %{ids}."
191 191 notice_failed_to_save_time_entries: "%{count} temps passΓ©(s) sur les %{total} sΓ©lectionnΓ©s n'ont pas pu Γͺtre mis Γ  jour: %{ids}."
192 192 notice_failed_to_save_members: "Erreur lors de la sauvegarde des membres: %{errors}."
193 193 notice_no_issue_selected: "Aucune demande sΓ©lectionnΓ©e ! Cochez les demandes que vous voulez mettre Γ  jour."
194 194 notice_account_pending: "Votre compte a été créé et attend l'approbation de l'administrateur."
195 195 notice_default_data_loaded: Paramétrage par défaut chargé avec succès.
196 196 notice_unable_delete_version: Impossible de supprimer cette version.
197 197 notice_unable_delete_time_entry: Impossible de supprimer le temps passΓ©.
198 198 notice_issue_done_ratios_updated: L'avancement des demandes a Γ©tΓ© mis Γ  jour.
199 199 notice_gantt_chart_truncated: "Le diagramme a Γ©tΓ© tronquΓ© car il excΓ¨de le nombre maximal d'Γ©lΓ©ments pouvant Γͺtre affichΓ©s (%{max})"
200 200 notice_issue_successful_create: "Demande %{id} créée."
201 201 notice_issue_update_conflict: "La demande a Γ©tΓ© mise Γ  jour par un autre utilisateur pendant que vous la modifiez."
202 202 notice_account_deleted: "Votre compte a Γ©tΓ© dΓ©finitivement supprimΓ©."
203 203 notice_user_successful_create: "Utilisateur %{id} créé."
204 204 notice_new_password_must_be_different: Votre nouveau mot de passe doit Γͺtre diffΓ©rent de votre mot de passe actuel
205 205 notice_import_finished: "Les %{count} Γ©lΓ©ments ont Γ©tΓ© importΓ©(s)."
206 206 notice_import_finished_with_errors: "%{count} Γ©lΓ©ment(s) sur %{total} n'ont pas pu Γͺtre importΓ©(s)."
207 207
208 208 error_can_t_load_default_data: "Une erreur s'est produite lors du chargement du paramΓ©trage : %{value}"
209 209 error_scm_not_found: "L'entrΓ©e et/ou la rΓ©vision demandΓ©e n'existe pas dans le dΓ©pΓ΄t."
210 210 error_scm_command_failed: "Une erreur s'est produite lors de l'accès au dépôt : %{value}"
211 211 error_scm_annotate: "L'entrΓ©e n'existe pas ou ne peut pas Γͺtre annotΓ©e."
212 212 error_scm_annotate_big_text_file: Cette entrΓ©e ne peut pas Γͺtre annotΓ©e car elle excΓ¨de la taille maximale.
213 213 error_issue_not_found_in_project: "La demande n'existe pas ou n'appartient pas Γ  ce projet"
214 214 error_no_tracker_in_project: "Aucun tracker n'est associΓ© Γ  ce projet. VΓ©rifier la configuration du projet."
215 215 error_no_default_issue_status: "Aucun statut de demande n'est dΓ©fini par dΓ©faut. VΓ©rifier votre configuration (Administration -> Statuts de demandes)."
216 216 error_can_not_delete_custom_field: Impossible de supprimer le champ personnalisΓ©
217 217 error_can_not_delete_tracker: Ce tracker contient des demandes et ne peut pas Γͺtre supprimΓ©.
218 218 error_can_not_remove_role: Ce rΓ΄le est utilisΓ© et ne peut pas Γͺtre supprimΓ©.
219 219 error_can_not_reopen_issue_on_closed_version: 'Une demande assignΓ©e Γ  une version fermΓ©e ne peut pas Γͺtre rΓ©ouverte'
220 220 error_can_not_archive_project: "Ce projet ne peut pas Γͺtre archivΓ©"
221 221 error_issue_done_ratios_not_updated: L'avancement des demandes n'a pas pu Γͺtre mis Γ  jour.
222 222 error_workflow_copy_source: 'Veuillez sΓ©lectionner un tracker et/ou un rΓ΄le source'
223 223 error_workflow_copy_target: 'Veuillez sΓ©lectionner les trackers et rΓ΄les cibles'
224 224 error_unable_delete_issue_status: Impossible de supprimer le statut de demande
225 225 error_unable_to_connect: Connexion impossible (%{value})
226 226 error_attachment_too_big: Ce fichier ne peut pas Γͺtre attachΓ© car il excΓ¨de la taille maximale autorisΓ©e (%{max_size})
227 227 error_session_expired: "Votre session a expirΓ©. Veuillez vous reconnecter."
228 228 warning_attachments_not_saved: "%{count} fichier(s) n'ont pas pu Γͺtre sauvegardΓ©s."
229 229 error_password_expired: "Votre mot de passe a expirΓ© ou nΓ©cessite d'Γͺtre changΓ©."
230 230 error_invalid_file_encoding: "Le fichier n'est pas un fichier %{encoding} valide"
231 231 error_invalid_csv_file_or_settings: "Le fichier n'est pas un fichier CSV ou n'est pas conforme aux paramètres sélectionnés"
232 232 error_can_not_read_import_file: "Une erreur est survenue lors de la lecture du fichier Γ  importer"
233 233
234 234 mail_subject_lost_password: "Votre mot de passe %{value}"
235 235 mail_body_lost_password: 'Pour changer votre mot de passe, cliquez sur le lien suivant :'
236 236 mail_subject_register: "Activation de votre compte %{value}"
237 237 mail_body_register: 'Pour activer votre compte, cliquez sur le lien suivant :'
238 238 mail_body_account_information_external: "Vous pouvez utiliser votre compte %{value} pour vous connecter."
239 239 mail_body_account_information: Paramètres de connexion de votre compte
240 240 mail_subject_account_activation_request: "Demande d'activation d'un compte %{value}"
241 241 mail_body_account_activation_request: "Un nouvel utilisateur (%{value}) s'est inscrit. Son compte nΓ©cessite votre approbation :"
242 242 mail_subject_reminder: "%{count} demande(s) arrivent Γ  Γ©chΓ©ance (%{days})"
243 243 mail_body_reminder: "%{count} demande(s) qui vous sont assignΓ©es arrivent Γ  Γ©chΓ©ance dans les %{days} prochains jours :"
244 244 mail_subject_wiki_content_added: "Page wiki '%{id}' ajoutΓ©e"
245 245 mail_body_wiki_content_added: "La page wiki '%{id}' a Γ©tΓ© ajoutΓ©e par %{author}."
246 246 mail_subject_wiki_content_updated: "Page wiki '%{id}' mise Γ  jour"
247 247 mail_body_wiki_content_updated: "La page wiki '%{id}' a Γ©tΓ© mise Γ  jour par %{author}."
248 248
249 249 field_name: Nom
250 250 field_description: Description
251 251 field_summary: RΓ©sumΓ©
252 252 field_is_required: Obligatoire
253 253 field_firstname: PrΓ©nom
254 254 field_lastname: Nom
255 255 field_mail: Email
256 256 field_address: Email
257 257 field_filename: Fichier
258 258 field_filesize: Taille
259 259 field_downloads: TΓ©lΓ©chargements
260 260 field_author: Auteur
261 261 field_created_on: Créé
262 262 field_updated_on: Mis-Γ -jour
263 263 field_closed_on: FermΓ©
264 264 field_field_format: Format
265 265 field_is_for_all: Pour tous les projets
266 266 field_possible_values: Valeurs possibles
267 267 field_regexp: Expression régulière
268 268 field_min_length: Longueur minimum
269 269 field_max_length: Longueur maximum
270 270 field_value: Valeur
271 271 field_category: CatΓ©gorie
272 272 field_title: Titre
273 273 field_project: Projet
274 274 field_issue: Demande
275 275 field_status: Statut
276 276 field_notes: Notes
277 277 field_is_closed: Demande fermΓ©e
278 278 field_is_default: Valeur par dΓ©faut
279 279 field_tracker: Tracker
280 280 field_subject: Sujet
281 281 field_due_date: EchΓ©ance
282 282 field_assigned_to: AssignΓ© Γ 
283 283 field_priority: PrioritΓ©
284 284 field_fixed_version: Version cible
285 285 field_user: Utilisateur
286 286 field_principal: Principal
287 287 field_role: RΓ΄le
288 288 field_homepage: Site web
289 289 field_is_public: Public
290 290 field_parent: Sous-projet de
291 291 field_is_in_roadmap: Demandes affichΓ©es dans la roadmap
292 292 field_login: Identifiant
293 293 field_mail_notification: Notifications par mail
294 294 field_admin: Administrateur
295 295 field_last_login_on: Dernière connexion
296 296 field_language: Langue
297 297 field_effective_date: Date
298 298 field_password: Mot de passe
299 299 field_new_password: Nouveau mot de passe
300 300 field_password_confirmation: Confirmation
301 301 field_version: Version
302 302 field_type: Type
303 303 field_host: HΓ΄te
304 304 field_port: Port
305 305 field_account: Compte
306 306 field_base_dn: Base DN
307 307 field_attr_login: Attribut Identifiant
308 308 field_attr_firstname: Attribut PrΓ©nom
309 309 field_attr_lastname: Attribut Nom
310 310 field_attr_mail: Attribut Email
311 311 field_onthefly: CrΓ©ation des utilisateurs Γ  la volΓ©e
312 312 field_start_date: DΓ©but
313 313 field_done_ratio: "% rΓ©alisΓ©"
314 314 field_auth_source: Mode d'authentification
315 315 field_hide_mail: Cacher mon adresse mail
316 316 field_comments: Commentaire
317 317 field_url: URL
318 318 field_start_page: Page de dΓ©marrage
319 319 field_subproject: Sous-projet
320 320 field_hours: Heures
321 321 field_activity: ActivitΓ©
322 322 field_spent_on: Date
323 323 field_identifier: Identifiant
324 324 field_is_filter: UtilisΓ© comme filtre
325 325 field_issue_to: Demande liΓ©e
326 326 field_delay: Retard
327 327 field_assignable: Demandes assignables Γ  ce rΓ΄le
328 328 field_redirect_existing_links: Rediriger les liens existants
329 329 field_estimated_hours: Temps estimΓ©
330 330 field_column_names: Colonnes
331 331 field_time_entries: Temps passΓ©
332 332 field_time_zone: Fuseau horaire
333 333 field_searchable: UtilisΓ© pour les recherches
334 334 field_default_value: Valeur par dΓ©faut
335 335 field_comments_sorting: Afficher les commentaires
336 336 field_parent_title: Page parent
337 337 field_editable: Modifiable
338 338 field_watcher: Observateur
339 339 field_identity_url: URL OpenID
340 340 field_content: Contenu
341 341 field_group_by: Grouper par
342 342 field_sharing: Partage
343 343 field_parent_issue: TΓ’che parente
344 344 field_member_of_group: Groupe de l'assignΓ©
345 345 field_assigned_to_role: RΓ΄le de l'assignΓ©
346 346 field_text: Champ texte
347 347 field_visible: Visible
348 348 field_warn_on_leaving_unsaved: "M'avertir lorsque je quitte une page contenant du texte non sauvegardΓ©"
349 349 field_issues_visibility: VisibilitΓ© des demandes
350 350 field_is_private: PrivΓ©e
351 351 field_commit_logs_encoding: Encodage des messages de commit
352 352 field_scm_path_encoding: Encodage des chemins
353 353 field_path_to_repository: Chemin du dΓ©pΓ΄t
354 354 field_root_directory: RΓ©pertoire racine
355 355 field_cvsroot: CVSROOT
356 356 field_cvs_module: Module
357 357 field_repository_is_default: DΓ©pΓ΄t principal
358 358 field_multiple: Valeurs multiples
359 359 field_auth_source_ldap_filter: Filtre LDAP
360 360 field_core_fields: Champs standards
361 361 field_timeout: "Timeout (en secondes)"
362 362 field_board_parent: Forum parent
363 363 field_private_notes: Notes privΓ©es
364 364 field_inherit_members: HΓ©riter les membres
365 365 field_generate_password: GΓ©nΓ©rer un mot de passe
366 366 field_must_change_passwd: Doit changer de mot de passe Γ  la prochaine connexion
367 367 field_default_status: Statut par dΓ©faut
368 368 field_users_visibility: VisibilitΓ© des utilisateurs
369 369 field_time_entries_visibility: VisibilitΓ© du temps passΓ©
370 370 field_total_estimated_hours: Temps estimΓ© total
371 field_default_version: Version par dΓ©faut
371 372
372 373 setting_app_title: Titre de l'application
373 374 setting_app_subtitle: Sous-titre de l'application
374 375 setting_welcome_text: Texte d'accueil
375 376 setting_default_language: Langue par dΓ©faut
376 377 setting_login_required: Authentification obligatoire
377 378 setting_self_registration: Inscription des nouveaux utilisateurs
378 379 setting_attachment_max_size: Taille maximale des fichiers
379 380 setting_issues_export_limit: Limite d'exportation des demandes
380 381 setting_mail_from: Adresse d'Γ©mission
381 382 setting_bcc_recipients: Destinataires en copie cachΓ©e (cci)
382 383 setting_plain_text_mail: Mail en texte brut (non HTML)
383 384 setting_host_name: Nom d'hΓ΄te et chemin
384 385 setting_text_formatting: Formatage du texte
385 386 setting_wiki_compression: Compression de l'historique des pages wiki
386 387 setting_feeds_limit: Nombre maximal d'Γ©lΓ©ments dans les flux Atom
387 388 setting_default_projects_public: DΓ©finir les nouveaux projets comme publics par dΓ©faut
388 389 setting_autofetch_changesets: RΓ©cupΓ©ration automatique des commits
389 390 setting_sys_api_enabled: Activer les WS pour la gestion des dΓ©pΓ΄ts
390 391 setting_commit_ref_keywords: Mots-clΓ©s de rΓ©fΓ©rencement
391 392 setting_commit_fix_keywords: Mots-clΓ©s de rΓ©solution
392 393 setting_autologin: DurΓ©e maximale de connexion automatique
393 394 setting_date_format: Format de date
394 395 setting_time_format: Format d'heure
395 396 setting_cross_project_issue_relations: Autoriser les relations entre demandes de diffΓ©rents projets
396 397 setting_cross_project_subtasks: Autoriser les sous-tΓ’ches dans des projets diffΓ©rents
397 398 setting_issue_list_default_columns: Colonnes affichΓ©es par dΓ©faut sur la liste des demandes
398 399 setting_repositories_encodings: Encodages des fichiers et des dΓ©pΓ΄ts
399 400 setting_emails_header: En-tΓͺte des emails
400 401 setting_emails_footer: Pied-de-page des emails
401 402 setting_protocol: Protocole
402 403 setting_per_page_options: Options d'objets affichΓ©s par page
403 404 setting_user_format: Format d'affichage des utilisateurs
404 405 setting_activity_days_default: Nombre de jours affichΓ©s sur l'activitΓ© des projets
405 406 setting_display_subprojects_issues: Afficher par dΓ©faut les demandes des sous-projets sur les projets principaux
406 407 setting_enabled_scm: SCM activΓ©s
407 408 setting_mail_handler_body_delimiters: "Tronquer les emails après l'une de ces lignes"
408 409 setting_mail_handler_api_enabled: "Activer le WS pour la rΓ©ception d'emails"
409 410 setting_mail_handler_api_key: ClΓ© de protection de l'API
410 411 setting_sequential_project_identifiers: GΓ©nΓ©rer des identifiants de projet sΓ©quentiels
411 412 setting_gravatar_enabled: Afficher les Gravatar des utilisateurs
412 413 setting_gravatar_default: Image Gravatar par dΓ©faut
413 414 setting_diff_max_lines_displayed: Nombre maximum de lignes de diff affichΓ©es
414 415 setting_file_max_size_displayed: Taille maximum des fichiers texte affichΓ©s en ligne
415 416 setting_repository_log_display_limit: "Nombre maximum de rΓ©visions affichΓ©es sur l'historique d'un fichier"
416 417 setting_openid: "Autoriser l'authentification et l'enregistrement OpenID"
417 418 setting_password_max_age: Expiration des mots de passe après
418 419 setting_password_min_length: Longueur minimum des mots de passe
419 420 setting_new_project_user_role_id: RΓ΄le donnΓ© Γ  un utilisateur non-administrateur qui crΓ©e un projet
420 421 setting_default_projects_modules: Modules activΓ©s par dΓ©faut pour les nouveaux projets
421 422 setting_issue_done_ratio: Calcul de l'avancement des demandes
422 423 setting_issue_done_ratio_issue_field: 'Utiliser le champ % effectuΓ©'
423 424 setting_issue_done_ratio_issue_status: Utiliser le statut
424 425 setting_start_of_week: Jour de dΓ©but des calendriers
425 426 setting_rest_api_enabled: Activer l'API REST
426 427 setting_cache_formatted_text: Mettre en cache le texte formatΓ©
427 428 setting_default_notification_option: Option de notification par dΓ©faut
428 429 setting_commit_logtime_enabled: Permettre la saisie de temps
429 430 setting_commit_logtime_activity_id: ActivitΓ© pour le temps saisi
430 431 setting_gantt_items_limit: Nombre maximum d'Γ©lΓ©ments affichΓ©s sur le gantt
431 432 setting_issue_group_assignment: Permettre l'assignement des demandes aux groupes
432 433 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
433 434 setting_commit_cross_project_ref: Permettre le rΓ©fΓ©rencement et la rΓ©solution des demandes de tous les autres projets
434 435 setting_unsubscribe: Permettre aux utilisateurs de supprimer leur propre compte
435 436 setting_session_lifetime: DurΓ©e de vie maximale des sessions
436 437 setting_session_timeout: DurΓ©e maximale d'inactivitΓ©
437 438 setting_thumbnails_enabled: Afficher les vignettes des images
438 439 setting_thumbnails_size: Taille des vignettes (en pixels)
439 440 setting_non_working_week_days: Jours non travaillΓ©s
440 441 setting_jsonp_enabled: Activer le support JSONP
441 442 setting_default_projects_tracker_ids: Trackers par dΓ©faut pour les nouveaux projets
442 443 setting_mail_handler_excluded_filenames: Exclure les fichiers attachΓ©s par leur nom
443 444 setting_force_default_language_for_anonymous: Forcer la langue par dΓ©fault pour les utilisateurs anonymes
444 445 setting_force_default_language_for_loggedin: Forcer la langue par dΓ©fault pour les utilisateurs identifiΓ©s
445 446 setting_link_copied_issue: Lier les demandes lors de la copie
446 447 setting_max_additional_emails: Nombre maximal d'adresses email additionnelles
447 448 setting_search_results_per_page: RΓ©sultats de recherche affichΓ©s par page
448 449
449 450 permission_add_project: CrΓ©er un projet
450 451 permission_add_subprojects: CrΓ©er des sous-projets
451 452 permission_edit_project: Modifier le projet
452 453 permission_close_project: Fermer / rΓ©ouvrir le projet
453 454 permission_select_project_modules: Choisir les modules
454 455 permission_manage_members: GΓ©rer les membres
455 456 permission_manage_project_activities: GΓ©rer les activitΓ©s
456 457 permission_manage_versions: GΓ©rer les versions
457 458 permission_manage_categories: GΓ©rer les catΓ©gories de demandes
458 459 permission_view_issues: Voir les demandes
459 460 permission_add_issues: CrΓ©er des demandes
460 461 permission_edit_issues: Modifier les demandes
461 462 permission_copy_issues: Copier les demandes
462 463 permission_manage_issue_relations: GΓ©rer les relations
463 464 permission_set_issues_private: Rendre les demandes publiques ou privΓ©es
464 465 permission_set_own_issues_private: Rendre ses propres demandes publiques ou privΓ©es
465 466 permission_add_issue_notes: Ajouter des notes
466 467 permission_edit_issue_notes: Modifier les notes
467 468 permission_edit_own_issue_notes: Modifier ses propres notes
468 469 permission_view_private_notes: Voir les notes privΓ©es
469 470 permission_set_notes_private: Rendre les notes privΓ©es
470 471 permission_move_issues: DΓ©placer les demandes
471 472 permission_delete_issues: Supprimer les demandes
472 473 permission_manage_public_queries: GΓ©rer les requΓͺtes publiques
473 474 permission_save_queries: Sauvegarder les requΓͺtes
474 475 permission_view_gantt: Voir le gantt
475 476 permission_view_calendar: Voir le calendrier
476 477 permission_view_issue_watchers: Voir la liste des observateurs
477 478 permission_add_issue_watchers: Ajouter des observateurs
478 479 permission_delete_issue_watchers: Supprimer des observateurs
479 480 permission_log_time: Saisir le temps passΓ©
480 481 permission_view_time_entries: Voir le temps passΓ©
481 482 permission_edit_time_entries: Modifier les temps passΓ©s
482 483 permission_edit_own_time_entries: Modifier son propre temps passΓ©
483 484 permission_manage_news: GΓ©rer les annonces
484 485 permission_comment_news: Commenter les annonces
485 486 permission_view_documents: Voir les documents
486 487 permission_add_documents: Ajouter des documents
487 488 permission_edit_documents: Modifier les documents
488 489 permission_delete_documents: Supprimer les documents
489 490 permission_manage_files: GΓ©rer les fichiers
490 491 permission_view_files: Voir les fichiers
491 492 permission_manage_wiki: GΓ©rer le wiki
492 493 permission_rename_wiki_pages: Renommer les pages
493 494 permission_delete_wiki_pages: Supprimer les pages
494 495 permission_view_wiki_pages: Voir le wiki
495 496 permission_view_wiki_edits: "Voir l'historique des modifications"
496 497 permission_edit_wiki_pages: Modifier les pages
497 498 permission_delete_wiki_pages_attachments: Supprimer les fichiers joints
498 499 permission_protect_wiki_pages: ProtΓ©ger les pages
499 500 permission_manage_repository: GΓ©rer le dΓ©pΓ΄t de sources
500 501 permission_browse_repository: Parcourir les sources
501 502 permission_view_changesets: Voir les rΓ©visions
502 503 permission_commit_access: Droit de commit
503 504 permission_manage_boards: GΓ©rer les forums
504 505 permission_view_messages: Voir les messages
505 506 permission_add_messages: Poster un message
506 507 permission_edit_messages: Modifier les messages
507 508 permission_edit_own_messages: Modifier ses propres messages
508 509 permission_delete_messages: Supprimer les messages
509 510 permission_delete_own_messages: Supprimer ses propres messages
510 511 permission_export_wiki_pages: Exporter les pages
511 512 permission_manage_subtasks: GΓ©rer les sous-tΓ’ches
512 513 permission_manage_related_issues: GΓ©rer les demandes associΓ©es
513 514 permission_import_issues: Importer des demandes
514 515
515 516 project_module_issue_tracking: Suivi des demandes
516 517 project_module_time_tracking: Suivi du temps passΓ©
517 518 project_module_news: Publication d'annonces
518 519 project_module_documents: Publication de documents
519 520 project_module_files: Publication de fichiers
520 521 project_module_wiki: Wiki
521 522 project_module_repository: DΓ©pΓ΄t de sources
522 523 project_module_boards: Forums de discussion
523 524 project_module_calendar: Calendrier
524 525 project_module_gantt: Gantt
525 526
526 527 label_user: Utilisateur
527 528 label_user_plural: Utilisateurs
528 529 label_user_new: Nouvel utilisateur
529 530 label_user_anonymous: Anonyme
530 531 label_project: Projet
531 532 label_project_new: Nouveau projet
532 533 label_project_plural: Projets
533 534 label_x_projects:
534 535 zero: aucun projet
535 536 one: un projet
536 537 other: "%{count} projets"
537 538 label_project_all: Tous les projets
538 539 label_project_latest: Derniers projets
539 540 label_issue: Demande
540 541 label_issue_new: Nouvelle demande
541 542 label_issue_plural: Demandes
542 543 label_issue_view_all: Voir toutes les demandes
543 544 label_issues_by: "Demandes par %{value}"
544 545 label_issue_added: Demande ajoutΓ©e
545 546 label_issue_updated: Demande mise Γ  jour
546 547 label_issue_note_added: Note ajoutΓ©e
547 548 label_issue_status_updated: Statut changΓ©
548 549 label_issue_assigned_to_updated: AssignΓ© changΓ©
549 550 label_issue_priority_updated: PrioritΓ© changΓ©e
550 551 label_document: Document
551 552 label_document_new: Nouveau document
552 553 label_document_plural: Documents
553 554 label_document_added: Document ajoutΓ©
554 555 label_role: RΓ΄le
555 556 label_role_plural: RΓ΄les
556 557 label_role_new: Nouveau rΓ΄le
557 558 label_role_and_permissions: RΓ΄les et permissions
558 559 label_role_anonymous: Anonyme
559 560 label_role_non_member: Non membre
560 561 label_member: Membre
561 562 label_member_new: Nouveau membre
562 563 label_member_plural: Membres
563 564 label_tracker: Tracker
564 565 label_tracker_plural: Trackers
565 566 label_tracker_new: Nouveau tracker
566 567 label_workflow: Workflow
567 568 label_issue_status: Statut de demandes
568 569 label_issue_status_plural: Statuts de demandes
569 570 label_issue_status_new: Nouveau statut
570 571 label_issue_category: CatΓ©gorie de demandes
571 572 label_issue_category_plural: CatΓ©gories de demandes
572 573 label_issue_category_new: Nouvelle catΓ©gorie
573 574 label_custom_field: Champ personnalisΓ©
574 575 label_custom_field_plural: Champs personnalisΓ©s
575 576 label_custom_field_new: Nouveau champ personnalisΓ©
576 577 label_enumerations: Listes de valeurs
577 578 label_enumeration_new: Nouvelle valeur
578 579 label_information: Information
579 580 label_information_plural: Informations
580 581 label_please_login: Identification
581 582 label_register: S'enregistrer
582 583 label_login_with_open_id_option: S'authentifier avec OpenID
583 584 label_password_lost: Mot de passe perdu
584 585 label_password_required: Confirmez votre mot de passe pour continuer
585 586 label_home: Accueil
586 587 label_my_page: Ma page
587 588 label_my_account: Mon compte
588 589 label_my_projects: Mes projets
589 590 label_my_page_block: Blocs disponibles
590 591 label_administration: Administration
591 592 label_login: Connexion
592 593 label_logout: DΓ©connexion
593 594 label_help: Aide
594 595 label_reported_issues: Demandes soumises
595 596 label_assigned_issues: Demandes assignΓ©es
596 597 label_assigned_to_me_issues: Demandes qui me sont assignΓ©es
597 598 label_last_login: Dernière connexion
598 599 label_registered_on: Inscrit le
599 600 label_activity: ActivitΓ©
600 601 label_overall_activity: ActivitΓ© globale
601 602 label_user_activity: "ActivitΓ© de %{value}"
602 603 label_new: Nouveau
603 604 label_logged_as: ConnectΓ© en tant que
604 605 label_environment: Environnement
605 606 label_authentication: Authentification
606 607 label_auth_source: Mode d'authentification
607 608 label_auth_source_new: Nouveau mode d'authentification
608 609 label_auth_source_plural: Modes d'authentification
609 610 label_subproject_plural: Sous-projets
610 611 label_subproject_new: Nouveau sous-projet
611 612 label_and_its_subprojects: "%{value} et ses sous-projets"
612 613 label_min_max_length: Longueurs mini - maxi
613 614 label_list: Liste
614 615 label_date: Date
615 616 label_integer: Entier
616 617 label_float: Nombre dΓ©cimal
617 618 label_boolean: BoolΓ©en
618 619 label_string: Texte
619 620 label_text: Texte long
620 621 label_attribute: Attribut
621 622 label_attribute_plural: Attributs
622 623 label_no_data: Aucune donnΓ©e Γ  afficher
623 624 label_change_status: Changer le statut
624 625 label_history: Historique
625 626 label_attachment: Fichier
626 627 label_attachment_new: Nouveau fichier
627 628 label_attachment_delete: Supprimer le fichier
628 629 label_attachment_plural: Fichiers
629 630 label_file_added: Fichier ajoutΓ©
630 631 label_report: Rapport
631 632 label_report_plural: Rapports
632 633 label_news: Annonce
633 634 label_news_new: Nouvelle annonce
634 635 label_news_plural: Annonces
635 636 label_news_latest: Dernières annonces
636 637 label_news_view_all: Voir toutes les annonces
637 638 label_news_added: Annonce ajoutΓ©e
638 639 label_news_comment_added: Commentaire ajoutΓ© Γ  une annonce
639 640 label_settings: Configuration
640 641 label_overview: AperΓ§u
641 642 label_version: Version
642 643 label_version_new: Nouvelle version
643 644 label_version_plural: Versions
644 645 label_close_versions: Fermer les versions terminΓ©es
645 646 label_confirmation: Confirmation
646 647 label_export_to: 'Formats disponibles :'
647 648 label_read: Lire...
648 649 label_public_projects: Projets publics
649 650 label_open_issues: ouvert
650 651 label_open_issues_plural: ouverts
651 652 label_closed_issues: fermΓ©
652 653 label_closed_issues_plural: fermΓ©s
653 654 label_x_open_issues_abbr:
654 655 zero: 0 ouverte
655 656 one: 1 ouverte
656 657 other: "%{count} ouvertes"
657 658 label_x_closed_issues_abbr:
658 659 zero: 0 fermΓ©e
659 660 one: 1 fermΓ©e
660 661 other: "%{count} fermΓ©es"
661 662 label_x_issues:
662 663 zero: 0 demande
663 664 one: 1 demande
664 665 other: "%{count} demandes"
665 666 label_total: Total
666 667 label_total_plural: Totaux
667 668 label_total_time: Temps total
668 669 label_permissions: Permissions
669 670 label_current_status: Statut actuel
670 671 label_new_statuses_allowed: Nouveaux statuts autorisΓ©s
671 672 label_all: tous
672 673 label_any: tous
673 674 label_none: aucun
674 675 label_nobody: personne
675 676 label_next: Suivant
676 677 label_previous: PrΓ©cΓ©dent
677 678 label_used_by: UtilisΓ© par
678 679 label_details: DΓ©tails
679 680 label_add_note: Ajouter une note
680 681 label_calendar: Calendrier
681 682 label_months_from: mois depuis
682 683 label_gantt: Gantt
683 684 label_internal: Interne
684 685 label_last_changes: "%{count} derniers changements"
685 686 label_change_view_all: Voir tous les changements
686 687 label_personalize_page: Personnaliser cette page
687 688 label_comment: Commentaire
688 689 label_comment_plural: Commentaires
689 690 label_x_comments:
690 691 zero: aucun commentaire
691 692 one: un commentaire
692 693 other: "%{count} commentaires"
693 694 label_comment_add: Ajouter un commentaire
694 695 label_comment_added: Commentaire ajoutΓ©
695 696 label_comment_delete: Supprimer les commentaires
696 697 label_query: Rapport personnalisΓ©
697 698 label_query_plural: Rapports personnalisΓ©s
698 699 label_query_new: Nouveau rapport
699 700 label_my_queries: Mes rapports personnalisΓ©s
700 701 label_filter_add: Ajouter le filtre
701 702 label_filter_plural: Filtres
702 703 label_equals: Γ©gal
703 704 label_not_equals: diffΓ©rent
704 705 label_in_less_than: dans moins de
705 706 label_in_more_than: dans plus de
706 707 label_in_the_next_days: dans les prochains jours
707 708 label_in_the_past_days: dans les derniers jours
708 709 label_greater_or_equal: '>='
709 710 label_less_or_equal: '<='
710 711 label_between: entre
711 712 label_in: dans
712 713 label_today: aujourd'hui
713 714 label_all_time: toute la pΓ©riode
714 715 label_yesterday: hier
715 716 label_this_week: cette semaine
716 717 label_last_week: la semaine dernière
717 718 label_last_n_weeks: "les %{count} dernières semaines"
718 719 label_last_n_days: "les %{count} derniers jours"
719 720 label_this_month: ce mois-ci
720 721 label_last_month: le mois dernier
721 722 label_this_year: cette annΓ©e
722 723 label_date_range: PΓ©riode
723 724 label_less_than_ago: il y a moins de
724 725 label_more_than_ago: il y a plus de
725 726 label_ago: il y a
726 727 label_contains: contient
727 728 label_not_contains: ne contient pas
728 729 label_any_issues_in_project: une demande du projet
729 730 label_any_issues_not_in_project: une demande hors du projet
730 731 label_no_issues_in_project: aucune demande du projet
731 732 label_day_plural: jours
732 733 label_repository: DΓ©pΓ΄t
733 734 label_repository_new: Nouveau dΓ©pΓ΄t
734 735 label_repository_plural: DΓ©pΓ΄ts
735 736 label_browse: Parcourir
736 737 label_branch: Branche
737 738 label_tag: Tag
738 739 label_revision: RΓ©vision
739 740 label_revision_plural: RΓ©visions
740 741 label_revision_id: "RΓ©vision %{value}"
741 742 label_associated_revisions: RΓ©visions associΓ©es
742 743 label_added: ajoutΓ©
743 744 label_modified: modifiΓ©
744 745 label_copied: copiΓ©
745 746 label_renamed: renommΓ©
746 747 label_deleted: supprimΓ©
747 748 label_latest_revision: Dernière révision
748 749 label_latest_revision_plural: Dernières révisions
749 750 label_view_revisions: Voir les rΓ©visions
750 751 label_view_all_revisions: Voir toutes les rΓ©visions
751 752 label_max_size: Taille maximale
752 753 label_sort_highest: Remonter en premier
753 754 label_sort_higher: Remonter
754 755 label_sort_lower: Descendre
755 756 label_sort_lowest: Descendre en dernier
756 757 label_roadmap: Roadmap
757 758 label_roadmap_due_in: "Γ‰chΓ©ance dans %{value}"
758 759 label_roadmap_overdue: "En retard de %{value}"
759 760 label_roadmap_no_issues: Aucune demande pour cette version
760 761 label_search: Recherche
761 762 label_result_plural: RΓ©sultats
762 763 label_all_words: Tous les mots
763 764 label_wiki: Wiki
764 765 label_wiki_edit: RΓ©vision wiki
765 766 label_wiki_edit_plural: RΓ©visions wiki
766 767 label_wiki_page: Page wiki
767 768 label_wiki_page_plural: Pages wiki
768 769 label_index_by_title: Index par titre
769 770 label_index_by_date: Index par date
770 771 label_current_version: Version actuelle
771 772 label_preview: PrΓ©visualisation
772 773 label_feed_plural: Flux Atom
773 774 label_changes_details: DΓ©tails de tous les changements
774 775 label_issue_tracking: Suivi des demandes
775 776 label_spent_time: Temps passΓ©
776 777 label_total_spent_time: Temps passΓ© total
777 778 label_overall_spent_time: Temps passΓ© global
778 779 label_f_hour: "%{value} heure"
779 780 label_f_hour_plural: "%{value} heures"
780 781 label_f_hour_short: "%{value} h"
781 782 label_time_tracking: Suivi du temps
782 783 label_change_plural: Changements
783 784 label_statistics: Statistiques
784 785 label_commits_per_month: Commits par mois
785 786 label_commits_per_author: Commits par auteur
786 787 label_diff: diff
787 788 label_view_diff: Voir les diffΓ©rences
788 789 label_diff_inline: en ligne
789 790 label_diff_side_by_side: cΓ΄te Γ  cΓ΄te
790 791 label_options: Options
791 792 label_copy_workflow_from: Copier le workflow de
792 793 label_permissions_report: Synthèse des permissions
793 794 label_watched_issues: Demandes surveillΓ©es
794 795 label_related_issues: Demandes liΓ©es
795 796 label_applied_status: Statut appliquΓ©
796 797 label_loading: Chargement...
797 798 label_relation_new: Nouvelle relation
798 799 label_relation_delete: Supprimer la relation
799 800 label_relates_to: LiΓ© Γ 
800 801 label_duplicates: Duplique
801 802 label_duplicated_by: DupliquΓ© par
802 803 label_blocks: Bloque
803 804 label_blocked_by: BloquΓ© par
804 805 label_precedes: Précède
805 806 label_follows: Suit
806 807 label_copied_to: CopiΓ© vers
807 808 label_copied_from: CopiΓ© depuis
808 809 label_end_to_start: fin Γ  dΓ©but
809 810 label_end_to_end: fin Γ  fin
810 811 label_start_to_start: dΓ©but Γ  dΓ©but
811 812 label_start_to_end: dΓ©but Γ  fin
812 813 label_stay_logged_in: Rester connectΓ©
813 814 label_disabled: dΓ©sactivΓ©
814 815 label_show_completed_versions: Voir les versions passΓ©es
815 816 label_me: moi
816 817 label_board: Forum
817 818 label_board_new: Nouveau forum
818 819 label_board_plural: Forums
819 820 label_board_locked: VerrouillΓ©
820 821 label_board_sticky: Sticky
821 822 label_topic_plural: Discussions
822 823 label_message_plural: Messages
823 824 label_message_last: Dernier message
824 825 label_message_new: Nouveau message
825 826 label_message_posted: Message ajoutΓ©
826 827 label_reply_plural: RΓ©ponses
827 828 label_send_information: Envoyer les informations Γ  l'utilisateur
828 829 label_year: AnnΓ©e
829 830 label_month: Mois
830 831 label_week: Semaine
831 832 label_date_from: Du
832 833 label_date_to: Au
833 834 label_language_based: BasΓ© sur la langue de l'utilisateur
834 835 label_sort_by: "Trier par %{value}"
835 836 label_send_test_email: Envoyer un email de test
836 837 label_feeds_access_key: Clé d'accès Atom
837 838 label_missing_feeds_access_key: Clé d'accès Atom manquante
838 839 label_feeds_access_key_created_on: "Clé d'accès Atom créée il y a %{value}"
839 840 label_module_plural: Modules
840 841 label_added_time_by: "AjoutΓ© par %{author} il y a %{age}"
841 842 label_updated_time_by: "Mis Γ  jour par %{author} il y a %{age}"
842 843 label_updated_time: "Mis Γ  jour il y a %{value}"
843 844 label_jump_to_a_project: Aller Γ  un projet...
844 845 label_file_plural: Fichiers
845 846 label_changeset_plural: RΓ©visions
846 847 label_default_columns: Colonnes par dΓ©faut
847 848 label_no_change_option: (Pas de changement)
848 849 label_bulk_edit_selected_issues: Modifier les demandes sΓ©lectionnΓ©es
849 850 label_bulk_edit_selected_time_entries: Modifier les temps passΓ©s sΓ©lectionnΓ©s
850 851 label_theme: Thème
851 852 label_default: DΓ©faut
852 853 label_search_titles_only: Uniquement dans les titres
853 854 label_user_mail_option_all: "Pour tous les Γ©vΓ©nements de tous mes projets"
854 855 label_user_mail_option_selected: "Pour tous les Γ©vΓ©nements des projets sΓ©lectionnΓ©s..."
855 856 label_user_mail_option_none: Aucune notification
856 857 label_user_mail_option_only_my_events: Seulement pour ce que je surveille
857 858 label_user_mail_option_only_assigned: Seulement pour ce qui m'est assignΓ©
858 859 label_user_mail_option_only_owner: Seulement pour ce que j'ai créé
859 860 label_user_mail_no_self_notified: "Je ne veux pas Γͺtre notifiΓ© des changements que j'effectue"
860 861 label_registration_activation_by_email: activation du compte par email
861 862 label_registration_manual_activation: activation manuelle du compte
862 863 label_registration_automatic_activation: activation automatique du compte
863 864 label_display_per_page: "Par page : %{value}"
864 865 label_age: Γ‚ge
865 866 label_change_properties: Changer les propriΓ©tΓ©s
866 867 label_general: GΓ©nΓ©ral
867 868 label_more: Plus
868 869 label_scm: SCM
869 870 label_plugins: Plugins
870 871 label_ldap_authentication: Authentification LDAP
871 872 label_downloads_abbr: D/L
872 873 label_optional_description: Description facultative
873 874 label_add_another_file: Ajouter un autre fichier
874 875 label_preferences: PrΓ©fΓ©rences
875 876 label_chronological_order: Dans l'ordre chronologique
876 877 label_reverse_chronological_order: Dans l'ordre chronologique inverse
877 878 label_planning: Planning
878 879 label_incoming_emails: Emails entrants
879 880 label_generate_key: GΓ©nΓ©rer une clΓ©
880 881 label_issue_watchers: Observateurs
881 882 label_example: Exemple
882 883 label_display: Affichage
883 884 label_sort: Tri
884 885 label_ascending: Croissant
885 886 label_descending: DΓ©croissant
886 887 label_date_from_to: Du %{start} au %{end}
887 888 label_wiki_content_added: Page wiki ajoutΓ©e
888 889 label_wiki_content_updated: Page wiki mise Γ  jour
889 890 label_group: Groupe
890 891 label_group_plural: Groupes
891 892 label_group_new: Nouveau groupe
892 893 label_group_anonymous: Utilisateurs anonymes
893 894 label_group_non_member: Utilisateurs non membres
894 895 label_time_entry_plural: Temps passΓ©
895 896 label_version_sharing_none: Non partagΓ©
896 897 label_version_sharing_descendants: Avec les sous-projets
897 898 label_version_sharing_hierarchy: Avec toute la hiΓ©rarchie
898 899 label_version_sharing_tree: Avec tout l'arbre
899 900 label_version_sharing_system: Avec tous les projets
900 901 label_update_issue_done_ratios: Mettre Γ  jour l'avancement des demandes
901 902 label_copy_source: Source
902 903 label_copy_target: Cible
903 904 label_copy_same_as_target: Comme la cible
904 905 label_display_used_statuses_only: N'afficher que les statuts utilisΓ©s dans ce tracker
905 906 label_api_access_key: Clé d'accès API
906 907 label_missing_api_access_key: Clé d'accès API manquante
907 908 label_api_access_key_created_on: Clé d'accès API créée il y a %{value}
908 909 label_profile: Profil
909 910 label_subtask_plural: Sous-tΓ’ches
910 911 label_project_copy_notifications: Envoyer les notifications durant la copie du projet
911 912 label_principal_search: "Rechercher un utilisateur ou un groupe :"
912 913 label_user_search: "Rechercher un utilisateur :"
913 914 label_additional_workflow_transitions_for_author: Autorisations supplémentaires lorsque l'utilisateur a créé la demande
914 915 label_additional_workflow_transitions_for_assignee: Autorisations supplΓ©mentaires lorsque la demande est assignΓ©e Γ  l'utilisateur
915 916 label_issues_visibility_all: Toutes les demandes
916 917 label_issues_visibility_public: Toutes les demandes non privΓ©es
917 918 label_issues_visibility_own: Demandes créées par ou assignées à l'utilisateur
918 919 label_git_report_last_commit: Afficher le dernier commit des fichiers et rΓ©pertoires
919 920 label_parent_revision: Parent
920 921 label_child_revision: Enfant
921 922 label_export_options: Options d'exportation %{export_format}
922 923 label_copy_attachments: Copier les fichiers
923 924 label_copy_subtasks: Copier les sous-tΓ’ches
924 925 label_item_position: "%{position} sur %{count}"
925 926 label_completed_versions: Versions passΓ©es
926 927 label_search_for_watchers: Rechercher des observateurs
927 928 label_session_expiration: Expiration des sessions
928 929 label_show_closed_projects: Voir les projets fermΓ©s
929 930 label_status_transitions: Changements de statut
930 931 label_fields_permissions: Permissions sur les champs
931 932 label_readonly: Lecture
932 933 label_required: Obligatoire
933 934 label_hidden: CachΓ©
934 935 label_attribute_of_project: "%{name} du projet"
935 936 label_attribute_of_issue: "%{name} de la demande"
936 937 label_attribute_of_author: "%{name} de l'auteur"
937 938 label_attribute_of_assigned_to: "%{name} de l'assignΓ©"
938 939 label_attribute_of_user: "%{name} de l'utilisateur"
939 940 label_attribute_of_fixed_version: "%{name} de la version cible"
940 941 label_cross_project_descendants: Avec les sous-projets
941 942 label_cross_project_tree: Avec tout l'arbre
942 943 label_cross_project_hierarchy: Avec toute la hiΓ©rarchie
943 944 label_cross_project_system: Avec tous les projets
944 945 label_gantt_progress_line: Ligne de progression
945 946 label_visibility_private: par moi uniquement
946 947 label_visibility_roles: par ces rΓ΄les uniquement
947 948 label_visibility_public: par tout le monde
948 949 label_link: Lien
949 950 label_only: seulement
950 951 label_drop_down_list: liste dΓ©roulante
951 952 label_checkboxes: cases Γ  cocher
952 953 label_radio_buttons: boutons radio
953 954 label_link_values_to: Lier les valeurs vers l'URL
954 955 label_custom_field_select_type: Selectionner le type d'objet auquel attacher le champ personnalisΓ©
955 956 label_check_for_updates: VΓ©rifier les mises Γ  jour
956 957 label_latest_compatible_version: Dernière version compatible
957 958 label_unknown_plugin: Plugin inconnu
958 959 label_add_projects: Ajouter des projets
959 960 label_users_visibility_all: Tous les utilisateurs actifs
960 961 label_users_visibility_members_of_visible_projects: Membres des projets visibles
961 962 label_edit_attachments: Modifier les fichiers attachΓ©s
962 963 label_link_copied_issue: Lier la demande copiΓ©e
963 964 label_ask: Demander
964 965 label_search_attachments_yes: Rechercher les noms et descriptions de fichiers
965 966 label_search_attachments_no: Ne pas rechercher les fichiers
966 967 label_search_attachments_only: Rechercher les fichiers uniquement
967 968 label_search_open_issues_only: Demandes ouvertes uniquement
968 969 label_email_address_plural: Emails
969 970 label_email_address_add: Ajouter une adresse email
970 971 label_enable_notifications: Activer les notifications
971 972 label_disable_notifications: DΓ©sactiver les notifications
972 973 label_blank_value: non renseignΓ©
973 974 label_parent_task_attributes: Attributs des tΓ’ches parentes
974 975 label_time_entries_visibility_all: Tous les temps passΓ©s
975 976 label_time_entries_visibility_own: Ses propres temps passΓ©s
976 977 label_member_management: Gestion des membres
977 978 label_member_management_all_roles: Tous les rΓ΄les
978 979 label_member_management_selected_roles_only: Ces rΓ΄les uniquement
979 980 label_import_issues: Importer des demandes
980 981 label_select_file_to_import: SΓ©lectionner le fichier Γ  importer
981 982 label_fields_separator: SΓ©parateur de champs
982 983 label_fields_wrapper: DΓ©limiteur de texte
983 984 label_encoding: Encodage
984 985 label_comma_char: Virgule
985 986 label_semi_colon_char: Point virgule
986 987 label_quote_char: Apostrophe
987 988 label_double_quote_char: Double apostrophe
988 989 label_fields_mapping: Correspondance des champs
989 990 label_file_content_preview: AperΓ§u du contenu du fichier
990 991 label_create_missing_values: CrΓ©er les valeurs manquantes
991 992 label_api: API
992 993 label_field_format_enumeration: Liste clΓ©/valeur
993 994
994 995 button_login: Connexion
995 996 button_submit: Soumettre
996 997 button_save: Sauvegarder
997 998 button_check_all: Tout cocher
998 999 button_uncheck_all: Tout dΓ©cocher
999 1000 button_collapse_all: Plier tout
1000 1001 button_expand_all: DΓ©plier tout
1001 1002 button_delete: Supprimer
1002 1003 button_create: CrΓ©er
1003 1004 button_create_and_continue: CrΓ©er et continuer
1004 1005 button_test: Tester
1005 1006 button_edit: Modifier
1006 1007 button_edit_associated_wikipage: "Modifier la page wiki associΓ©e: %{page_title}"
1007 1008 button_add: Ajouter
1008 1009 button_change: Changer
1009 1010 button_apply: Appliquer
1010 1011 button_clear: Effacer
1011 1012 button_lock: Verrouiller
1012 1013 button_unlock: DΓ©verrouiller
1013 1014 button_download: TΓ©lΓ©charger
1014 1015 button_list: Lister
1015 1016 button_view: Voir
1016 1017 button_move: DΓ©placer
1017 1018 button_move_and_follow: DΓ©placer et suivre
1018 1019 button_back: Retour
1019 1020 button_cancel: Annuler
1020 1021 button_activate: Activer
1021 1022 button_sort: Trier
1022 1023 button_log_time: Saisir temps
1023 1024 button_rollback: Revenir Γ  cette version
1024 1025 button_watch: Surveiller
1025 1026 button_unwatch: Ne plus surveiller
1026 1027 button_reply: RΓ©pondre
1027 1028 button_archive: Archiver
1028 1029 button_unarchive: DΓ©sarchiver
1029 1030 button_reset: RΓ©initialiser
1030 1031 button_rename: Renommer
1031 1032 button_change_password: Changer de mot de passe
1032 1033 button_copy: Copier
1033 1034 button_copy_and_follow: Copier et suivre
1034 1035 button_annotate: Annoter
1035 1036 button_update: Mettre Γ  jour
1036 1037 button_configure: Configurer
1037 1038 button_quote: Citer
1038 1039 button_duplicate: Dupliquer
1039 1040 button_show: Afficher
1040 1041 button_hide: Cacher
1041 1042 button_edit_section: Modifier cette section
1042 1043 button_export: Exporter
1043 1044 button_delete_my_account: Supprimer mon compte
1044 1045 button_close: Fermer
1045 1046 button_reopen: RΓ©ouvrir
1046 1047 button_import: Importer
1047 1048
1048 1049 status_active: actif
1049 1050 status_registered: enregistrΓ©
1050 1051 status_locked: verrouillΓ©
1051 1052
1052 1053 project_status_active: actif
1053 1054 project_status_closed: fermΓ©
1054 1055 project_status_archived: archivΓ©
1055 1056
1056 1057 version_status_open: ouvert
1057 1058 version_status_locked: verrouillΓ©
1058 1059 version_status_closed: fermΓ©
1059 1060
1060 1061 field_active: Actif
1061 1062
1062 1063 text_select_mail_notifications: Actions pour lesquelles une notification par e-mail est envoyΓ©e
1063 1064 text_regexp_info: ex. ^[A-Z0-9]+$
1064 1065 text_min_max_length_info: 0 pour aucune restriction
1065 1066 text_project_destroy_confirmation: Êtes-vous sûr de vouloir supprimer ce projet et toutes ses données ?
1066 1067 text_subprojects_destroy_warning: "Ses sous-projets : %{value} seront Γ©galement supprimΓ©s."
1067 1068 text_workflow_edit: SΓ©lectionner un tracker et un rΓ΄le pour Γ©diter le workflow
1068 1069 text_are_you_sure: Êtes-vous sûr ?
1069 1070 text_journal_changed: "%{label} changΓ© de %{old} Γ  %{new}"
1070 1071 text_journal_changed_no_detail: "%{label} mis Γ  jour"
1071 1072 text_journal_set_to: "%{label} mis Γ  %{value}"
1072 1073 text_journal_deleted: "%{label} %{old} supprimΓ©"
1073 1074 text_journal_added: "%{label} %{value} ajoutΓ©"
1074 1075 text_tip_issue_begin_day: tΓ’che commenΓ§ant ce jour
1075 1076 text_tip_issue_end_day: tΓ’che finissant ce jour
1076 1077 text_tip_issue_begin_end_day: tΓ’che commenΓ§ant et finissant ce jour
1077 1078 text_project_identifier_info: 'Seuls les lettres minuscules (a-z), chiffres, tirets et tirets bas sont autorisΓ©s, doit commencer par une minuscule.<br />Un fois sauvegardΓ©, l''identifiant ne pourra plus Γͺtre modifiΓ©.'
1078 1079 text_caracters_maximum: "%{count} caractères maximum."
1079 1080 text_caracters_minimum: "%{count} caractères minimum."
1080 1081 text_length_between: "Longueur comprise entre %{min} et %{max} caractères."
1081 1082 text_tracker_no_workflow: Aucun worflow n'est dΓ©fini pour ce tracker
1082 1083 text_unallowed_characters: Caractères non autorisés
1083 1084 text_comma_separated: Plusieurs valeurs possibles (sΓ©parΓ©es par des virgules).
1084 1085 text_line_separated: Plusieurs valeurs possibles (une valeur par ligne).
1085 1086 text_issues_ref_in_commit_messages: RΓ©fΓ©rencement et rΓ©solution des demandes dans les commentaires de commits
1086 1087 text_issue_added: "La demande %{id} a Γ©tΓ© soumise par %{author}."
1087 1088 text_issue_updated: "La demande %{id} a Γ©tΓ© mise Γ  jour par %{author}."
1088 1089 text_wiki_destroy_confirmation: Etes-vous sΓ»r de vouloir supprimer ce wiki et tout son contenu ?
1089 1090 text_issue_category_destroy_question: "%{count} demandes sont affectΓ©es Γ  cette catΓ©gorie. Que voulez-vous faire ?"
1090 1091 text_issue_category_destroy_assignments: N'affecter les demandes Γ  aucune autre catΓ©gorie
1091 1092 text_issue_category_reassign_to: RΓ©affecter les demandes Γ  cette catΓ©gorie
1092 1093 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)."
1093 1094 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Γ©."
1094 1095 text_load_default_configuration: Charger le paramΓ©trage par dΓ©faut
1095 1096 text_status_changed_by_changeset: "AppliquΓ© par commit %{value}."
1096 1097 text_time_logged_by_changeset: "AppliquΓ© par commit %{value}"
1097 1098 text_issues_destroy_confirmation: 'Êtes-vous sûr de vouloir supprimer la ou les demandes(s) selectionnée(s) ?'
1098 1099 text_issues_destroy_descendants_confirmation: "Cela entrainera Γ©galement la suppression de %{count} sous-tΓ’che(s)."
1099 1100 text_time_entries_destroy_confirmation: "Etes-vous sΓ»r de vouloir supprimer les temps passΓ©s sΓ©lectionnΓ©s ?"
1100 1101 text_select_project_modules: 'SΓ©lectionner les modules Γ  activer pour ce projet :'
1101 1102 text_default_administrator_account_changed: Compte administrateur par dΓ©faut changΓ©
1102 1103 text_file_repository_writable: RΓ©pertoire de stockage des fichiers accessible en Γ©criture
1103 1104 text_plugin_assets_writable: RΓ©pertoire public des plugins accessible en Γ©criture
1104 1105 text_rmagick_available: Bibliothèque RMagick présente (optionnelle)
1105 1106 text_convert_available: Binaire convert de ImageMagick prΓ©sent (optionel)
1106 1107 text_destroy_time_entries_question: "%{hours} heures ont Γ©tΓ© enregistrΓ©es sur les demandes Γ  supprimer. Que voulez-vous faire ?"
1107 1108 text_destroy_time_entries: Supprimer les heures
1108 1109 text_assign_time_entries_to_project: Reporter les heures sur le projet
1109 1110 text_reassign_time_entries: 'Reporter les heures sur cette demande:'
1110 1111 text_user_wrote: "%{value} a Γ©crit :"
1111 1112 text_enumeration_destroy_question: "La valeur Β« %{name} Β» est affectΓ©e Γ  %{count} objet(s)."
1112 1113 text_enumeration_category_reassign_to: 'RΓ©affecter les objets Γ  cette valeur:'
1113 1114 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."
1114 1115 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."
1115 1116 text_diff_truncated: '... Ce diffΓ©rentiel a Γ©tΓ© tronquΓ© car il excΓ¨de la taille maximale pouvant Γͺtre affichΓ©e.'
1116 1117 text_custom_field_possible_values_info: 'Une ligne par valeur'
1117 1118 text_wiki_page_destroy_question: "Cette page possède %{descendants} sous-page(s) et descendante(s). Que voulez-vous faire ?"
1118 1119 text_wiki_page_nullify_children: "Conserver les sous-pages en tant que pages racines"
1119 1120 text_wiki_page_destroy_children: "Supprimer les sous-pages et toutes leurs descedantes"
1120 1121 text_wiki_page_reassign_children: "RΓ©affecter les sous-pages Γ  cette page"
1121 1122 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 ?"
1122 1123 text_zoom_in: Zoom avant
1123 1124 text_zoom_out: Zoom arrière
1124 1125 text_warn_on_leaving_unsaved: "Cette page contient du texte non sauvegardΓ© qui sera perdu si vous quittez la page."
1125 1126 text_scm_path_encoding_note: "DΓ©faut : UTF-8"
1126 1127 text_subversion_repository_note: "Exemples (en fonction des protocoles supportΓ©s) : file:///, http://, https://, svn://, svn+[tunnelscheme]://"
1127 1128 text_git_repository_note: "Chemin vers un dΓ©pΓ΄t vide et local (exemples : /gitrepo, c:\\gitrepo)"
1128 1129 text_mercurial_repository_note: "Chemin vers un dΓ©pΓ΄t local (exemples : /hgrepo, c:\\hgrepo)"
1129 1130 text_scm_command: Commande
1130 1131 text_scm_command_version: Version
1131 1132 text_scm_config: Vous pouvez configurer les commandes des SCM dans config/configuration.yml. Redémarrer l'application après modification.
1132 1133 text_scm_command_not_available: Ce SCM n'est pas disponible. Vérifier les paramètres dans la section administration.
1133 1134 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)"
1134 1135 text_issue_conflict_resolution_add_notes: "Ajouter mes notes et ignorer mes autres changements"
1135 1136 text_issue_conflict_resolution_cancel: "Annuler ma mise Γ  jour et rΓ©afficher %{link}"
1136 1137 text_account_destroy_confirmation: "Êtes-vous sûr de vouloir continuer ?\nVotre compte sera définitivement supprimé, sans aucune possibilité de le réactiver."
1137 1138 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."
1138 1139 text_project_closed: Ce projet est fermΓ© et accessible en lecture seule.
1139 1140 text_turning_multiple_off: "Si vous dΓ©sactivez les valeurs multiples, les valeurs multiples seront supprimΓ©es pour n'en conserver qu'une par objet."
1140 1141
1141 1142 default_role_manager: Manager
1142 1143 default_role_developer: DΓ©veloppeur
1143 1144 default_role_reporter: Rapporteur
1144 1145 default_tracker_bug: Anomalie
1145 1146 default_tracker_feature: Evolution
1146 1147 default_tracker_support: Assistance
1147 1148 default_issue_status_new: Nouveau
1148 1149 default_issue_status_in_progress: En cours
1149 1150 default_issue_status_resolved: RΓ©solu
1150 1151 default_issue_status_feedback: Commentaire
1151 1152 default_issue_status_closed: FermΓ©
1152 1153 default_issue_status_rejected: RejetΓ©
1153 1154 default_doc_category_user: Documentation utilisateur
1154 1155 default_doc_category_tech: Documentation technique
1155 1156 default_priority_low: Bas
1156 1157 default_priority_normal: Normal
1157 1158 default_priority_high: Haut
1158 1159 default_priority_urgent: Urgent
1159 1160 default_priority_immediate: ImmΓ©diat
1160 1161 default_activity_design: Conception
1161 1162 default_activity_development: DΓ©veloppement
1162 1163
1163 1164 enumeration_issue_priorities: PrioritΓ©s des demandes
1164 1165 enumeration_doc_categories: CatΓ©gories des documents
1165 1166 enumeration_activities: ActivitΓ©s (suivi du temps)
1166 1167 enumeration_system_activity: Activité système
1167 1168 description_filter: Filtre
1168 1169 description_search: Champ de recherche
1169 1170 description_choose_project: Projets
1170 1171 description_project_scope: Périmètre de recherche
1171 1172 description_notes: Notes
1172 1173 description_message_content: Contenu du message
1173 1174 description_query_sort_criteria_attribute: Critère de tri
1174 1175 description_query_sort_criteria_direction: Ordre de tri
1175 1176 description_user_mail_notification: Option de notification
1176 1177 description_available_columns: Colonnes disponibles
1177 1178 description_selected_columns: Colonnes sΓ©lectionnΓ©es
1178 1179 description_all_columns: Toutes les colonnes
1179 1180 description_issue_category_reassign: Choisir une catΓ©gorie
1180 1181 description_wiki_subpages_reassign: Choisir une nouvelle page parent
1181 1182 description_date_range_list: Choisir une pΓ©riode prΓ©dΓ©finie
1182 1183 description_date_range_interval: Choisir une pΓ©riode
1183 1184 description_date_from: Date de dΓ©but
1184 1185 description_date_to: Date de fin
1185 1186 text_repository_identifier_info: 'Seuls les lettres minuscules (a-z), chiffres, tirets et tirets bas sont autorisΓ©s.<br />Un fois sauvegardΓ©, l''identifiant ne pourra plus Γͺtre modifiΓ©.'
1186 1187 label_parent_task_attributes_derived: Calculated from subtasks
1187 1188 label_parent_task_attributes_independent: Independent of subtasks
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
@@ -1,2759 +1,2767
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2015 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, :email_addresses, :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 setup
35 35 set_language_if_valid 'en'
36 36 end
37 37
38 38 def teardown
39 39 User.current = nil
40 40 end
41 41
42 42 def test_initialize
43 43 issue = Issue.new
44 44
45 45 assert_nil issue.project_id
46 46 assert_nil issue.tracker_id
47 47 assert_nil issue.status_id
48 48 assert_nil issue.author_id
49 49 assert_nil issue.assigned_to_id
50 50 assert_nil issue.category_id
51 51
52 52 assert_equal IssuePriority.default, issue.priority
53 53 end
54 54
55 55 def test_create
56 56 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
57 57 :status_id => 1, :priority => IssuePriority.all.first,
58 58 :subject => 'test_create',
59 59 :description => 'IssueTest#test_create', :estimated_hours => '1:30')
60 60 assert issue.save
61 61 issue.reload
62 62 assert_equal 1.5, issue.estimated_hours
63 63 end
64 64
65 65 def test_create_minimal
66 66 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, :subject => 'test_create')
67 67 assert issue.save
68 68 assert_equal issue.tracker.default_status, issue.status
69 69 assert issue.description.nil?
70 70 assert_nil issue.estimated_hours
71 71 end
72 72
73 73 def test_create_with_all_fields_disabled
74 74 tracker = Tracker.find(1)
75 75 tracker.core_fields = []
76 76 tracker.save!
77 77
78 78 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, :subject => 'test_create_with_all_fields_disabled')
79 79 assert_save issue
80 80 end
81 81
82 82 def test_start_date_format_should_be_validated
83 83 set_language_if_valid 'en'
84 84 ['2012', 'ABC', '2012-15-20'].each do |invalid_date|
85 85 issue = Issue.new(:start_date => invalid_date)
86 86 assert !issue.valid?
87 87 assert_include 'Start date is not a valid date', issue.errors.full_messages, "No error found for invalid date #{invalid_date}"
88 88 end
89 89 end
90 90
91 91 def test_due_date_format_should_be_validated
92 92 set_language_if_valid 'en'
93 93 ['2012', 'ABC', '2012-15-20'].each do |invalid_date|
94 94 issue = Issue.new(:due_date => invalid_date)
95 95 assert !issue.valid?
96 96 assert_include 'Due date is not a valid date', issue.errors.full_messages, "No error found for invalid date #{invalid_date}"
97 97 end
98 98 end
99 99
100 100 def test_due_date_lesser_than_start_date_should_not_validate
101 101 set_language_if_valid 'en'
102 102 issue = Issue.new(:start_date => '2012-10-06', :due_date => '2012-10-02')
103 103 assert !issue.valid?
104 104 assert_include 'Due date must be greater than start date', issue.errors.full_messages
105 105 end
106 106
107 107 def test_start_date_lesser_than_soonest_start_should_not_validate_on_create
108 108 issue = Issue.generate(:start_date => '2013-06-04')
109 109 issue.stubs(:soonest_start).returns(Date.parse('2013-06-10'))
110 110 assert !issue.valid?
111 111 assert_include "Start date cannot be earlier than 06/10/2013 because of preceding issues", issue.errors.full_messages
112 112 end
113 113
114 114 def test_start_date_lesser_than_soonest_start_should_not_validate_on_update_if_changed
115 115 issue = Issue.generate!(:start_date => '2013-06-04')
116 116 issue.stubs(:soonest_start).returns(Date.parse('2013-06-10'))
117 117 issue.start_date = '2013-06-07'
118 118 assert !issue.valid?
119 119 assert_include "Start date cannot be earlier than 06/10/2013 because of preceding issues", issue.errors.full_messages
120 120 end
121 121
122 122 def test_start_date_lesser_than_soonest_start_should_validate_on_update_if_unchanged
123 123 issue = Issue.generate!(:start_date => '2013-06-04')
124 124 issue.stubs(:soonest_start).returns(Date.parse('2013-06-10'))
125 125 assert issue.valid?
126 126 end
127 127
128 128 def test_estimated_hours_should_be_validated
129 129 set_language_if_valid 'en'
130 130 ['-2'].each do |invalid|
131 131 issue = Issue.new(:estimated_hours => invalid)
132 132 assert !issue.valid?
133 133 assert_include 'Estimated time is invalid', issue.errors.full_messages
134 134 end
135 135 end
136 136
137 137 def test_create_with_required_custom_field
138 138 set_language_if_valid 'en'
139 139 field = IssueCustomField.find_by_name('Database')
140 140 field.update_attribute(:is_required, true)
141 141
142 142 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1,
143 143 :status_id => 1, :subject => 'test_create',
144 144 :description => 'IssueTest#test_create_with_required_custom_field')
145 145 assert issue.available_custom_fields.include?(field)
146 146 # No value for the custom field
147 147 assert !issue.save
148 148 assert_equal ["Database cannot be blank"], issue.errors.full_messages
149 149 # Blank value
150 150 issue.custom_field_values = { field.id => '' }
151 151 assert !issue.save
152 152 assert_equal ["Database cannot be blank"], issue.errors.full_messages
153 153 # Invalid value
154 154 issue.custom_field_values = { field.id => 'SQLServer' }
155 155 assert !issue.save
156 156 assert_equal ["Database is not included in the list"], issue.errors.full_messages
157 157 # Valid value
158 158 issue.custom_field_values = { field.id => 'PostgreSQL' }
159 159 assert issue.save
160 160 issue.reload
161 161 assert_equal 'PostgreSQL', issue.custom_value_for(field).value
162 162 end
163 163
164 164 def test_create_with_group_assignment
165 165 with_settings :issue_group_assignment => '1' do
166 166 assert Issue.new(:project_id => 2, :tracker_id => 1, :author_id => 1,
167 167 :subject => 'Group assignment',
168 168 :assigned_to_id => 11).save
169 169 issue = Issue.order('id DESC').first
170 170 assert_kind_of Group, issue.assigned_to
171 171 assert_equal Group.find(11), issue.assigned_to
172 172 end
173 173 end
174 174
175 175 def test_create_with_parent_issue_id
176 176 issue = Issue.new(:project_id => 1, :tracker_id => 1,
177 177 :author_id => 1, :subject => 'Group assignment',
178 178 :parent_issue_id => 1)
179 179 assert_save issue
180 180 assert_equal 1, issue.parent_issue_id
181 181 assert_equal Issue.find(1), issue.parent
182 182 end
183 183
184 184 def test_create_with_sharp_parent_issue_id
185 185 issue = Issue.new(:project_id => 1, :tracker_id => 1,
186 186 :author_id => 1, :subject => 'Group assignment',
187 187 :parent_issue_id => "#1")
188 188 assert_save issue
189 189 assert_equal 1, issue.parent_issue_id
190 190 assert_equal Issue.find(1), issue.parent
191 191 end
192 192
193 193 def test_create_with_invalid_parent_issue_id
194 194 set_language_if_valid 'en'
195 195 issue = Issue.new(:project_id => 1, :tracker_id => 1,
196 196 :author_id => 1, :subject => 'Group assignment',
197 197 :parent_issue_id => '01ABC')
198 198 assert !issue.save
199 199 assert_equal '01ABC', issue.parent_issue_id
200 200 assert_include 'Parent task is invalid', issue.errors.full_messages
201 201 end
202 202
203 203 def test_create_with_invalid_sharp_parent_issue_id
204 204 set_language_if_valid 'en'
205 205 issue = Issue.new(:project_id => 1, :tracker_id => 1,
206 206 :author_id => 1, :subject => 'Group assignment',
207 207 :parent_issue_id => '#01ABC')
208 208 assert !issue.save
209 209 assert_equal '#01ABC', issue.parent_issue_id
210 210 assert_include 'Parent task is invalid', issue.errors.full_messages
211 211 end
212 212
213 213 def assert_visibility_match(user, issues)
214 214 assert_equal issues.collect(&:id).sort, Issue.all.select {|issue| issue.visible?(user)}.collect(&:id).sort
215 215 end
216 216
217 217 def test_visible_scope_for_anonymous
218 218 # Anonymous user should see issues of public projects only
219 219 issues = Issue.visible(User.anonymous).to_a
220 220 assert issues.any?
221 221 assert_nil issues.detect {|issue| !issue.project.is_public?}
222 222 assert_nil issues.detect {|issue| issue.is_private?}
223 223 assert_visibility_match User.anonymous, issues
224 224 end
225 225
226 226 def test_visible_scope_for_anonymous_without_view_issues_permissions
227 227 # Anonymous user should not see issues without permission
228 228 Role.anonymous.remove_permission!(:view_issues)
229 229 issues = Issue.visible(User.anonymous).to_a
230 230 assert issues.empty?
231 231 assert_visibility_match User.anonymous, issues
232 232 end
233 233
234 234 def test_visible_scope_for_anonymous_without_view_issues_permissions_and_membership
235 235 Role.anonymous.remove_permission!(:view_issues)
236 236 Member.create!(:project_id => 1, :principal => Group.anonymous, :role_ids => [2])
237 237
238 238 issues = Issue.visible(User.anonymous).all
239 239 assert issues.any?
240 240 assert_equal [1], issues.map(&:project_id).uniq.sort
241 241 assert_visibility_match User.anonymous, issues
242 242 end
243 243
244 244 def test_anonymous_should_not_see_private_issues_with_issues_visibility_set_to_default
245 245 assert Role.anonymous.update_attribute(:issues_visibility, 'default')
246 246 issue = Issue.generate!(:author => User.anonymous, :assigned_to => User.anonymous, :is_private => true)
247 247 assert_nil Issue.where(:id => issue.id).visible(User.anonymous).first
248 248 assert !issue.visible?(User.anonymous)
249 249 end
250 250
251 251 def test_anonymous_should_not_see_private_issues_with_issues_visibility_set_to_own
252 252 assert Role.anonymous.update_attribute(:issues_visibility, 'own')
253 253 issue = Issue.generate!(:author => User.anonymous, :assigned_to => User.anonymous, :is_private => true)
254 254 assert_nil Issue.where(:id => issue.id).visible(User.anonymous).first
255 255 assert !issue.visible?(User.anonymous)
256 256 end
257 257
258 258 def test_visible_scope_for_non_member
259 259 user = User.find(9)
260 260 assert user.projects.empty?
261 261 # Non member user should see issues of public projects only
262 262 issues = Issue.visible(user).to_a
263 263 assert issues.any?
264 264 assert_nil issues.detect {|issue| !issue.project.is_public?}
265 265 assert_nil issues.detect {|issue| issue.is_private?}
266 266 assert_visibility_match user, issues
267 267 end
268 268
269 269 def test_visible_scope_for_non_member_with_own_issues_visibility
270 270 Role.non_member.update_attribute :issues_visibility, 'own'
271 271 Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 9, :subject => 'Issue by non member')
272 272 user = User.find(9)
273 273
274 274 issues = Issue.visible(user).to_a
275 275 assert issues.any?
276 276 assert_nil issues.detect {|issue| issue.author != user}
277 277 assert_visibility_match user, issues
278 278 end
279 279
280 280 def test_visible_scope_for_non_member_without_view_issues_permissions
281 281 # Non member user should not see issues without permission
282 282 Role.non_member.remove_permission!(:view_issues)
283 283 user = User.find(9)
284 284 assert user.projects.empty?
285 285 issues = Issue.visible(user).to_a
286 286 assert issues.empty?
287 287 assert_visibility_match user, issues
288 288 end
289 289
290 290 def test_visible_scope_for_non_member_without_view_issues_permissions_and_membership
291 291 Role.non_member.remove_permission!(:view_issues)
292 292 Member.create!(:project_id => 1, :principal => Group.non_member, :role_ids => [2])
293 293 user = User.find(9)
294 294
295 295 issues = Issue.visible(user).all
296 296 assert issues.any?
297 297 assert_equal [1], issues.map(&:project_id).uniq.sort
298 298 assert_visibility_match user, issues
299 299 end
300 300
301 301 def test_visible_scope_for_member
302 302 user = User.find(9)
303 303 # User should see issues of projects for which user has view_issues permissions only
304 304 Role.non_member.remove_permission!(:view_issues)
305 305 Member.create!(:principal => user, :project_id => 3, :role_ids => [2])
306 306 issues = Issue.visible(user).to_a
307 307 assert issues.any?
308 308 assert_nil issues.detect {|issue| issue.project_id != 3}
309 309 assert_nil issues.detect {|issue| issue.is_private?}
310 310 assert_visibility_match user, issues
311 311 end
312 312
313 313 def test_visible_scope_for_member_without_view_issues_permission_and_non_member_role_having_the_permission
314 314 Role.non_member.add_permission!(:view_issues)
315 315 Role.find(1).remove_permission!(:view_issues)
316 316 user = User.find(2)
317 317
318 318 assert_equal 0, Issue.where(:project_id => 1).visible(user).count
319 319 assert_equal false, Issue.where(:project_id => 1).first.visible?(user)
320 320 end
321 321
322 322 def test_visible_scope_for_member_with_groups_should_return_assigned_issues
323 323 user = User.find(8)
324 324 assert user.groups.any?
325 325 Member.create!(:principal => user.groups.first, :project_id => 1, :role_ids => [2])
326 326 Role.non_member.remove_permission!(:view_issues)
327 327
328 328 issue = Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 3,
329 329 :status_id => 1, :priority => IssuePriority.all.first,
330 330 :subject => 'Assignment test',
331 331 :assigned_to => user.groups.first,
332 332 :is_private => true)
333 333
334 334 Role.find(2).update_attribute :issues_visibility, 'default'
335 335 issues = Issue.visible(User.find(8)).to_a
336 336 assert issues.any?
337 337 assert issues.include?(issue)
338 338
339 339 Role.find(2).update_attribute :issues_visibility, 'own'
340 340 issues = Issue.visible(User.find(8)).to_a
341 341 assert issues.any?
342 342 assert_include issue, issues
343 343 end
344 344
345 345 def test_visible_scope_for_admin
346 346 user = User.find(1)
347 347 user.members.each(&:destroy)
348 348 assert user.projects.empty?
349 349 issues = Issue.visible(user).to_a
350 350 assert issues.any?
351 351 # Admin should see issues on private projects that admin does not belong to
352 352 assert issues.detect {|issue| !issue.project.is_public?}
353 353 # Admin should see private issues of other users
354 354 assert issues.detect {|issue| issue.is_private? && issue.author != user}
355 355 assert_visibility_match user, issues
356 356 end
357 357
358 358 def test_visible_scope_with_project
359 359 project = Project.find(1)
360 360 issues = Issue.visible(User.find(2), :project => project).to_a
361 361 projects = issues.collect(&:project).uniq
362 362 assert_equal 1, projects.size
363 363 assert_equal project, projects.first
364 364 end
365 365
366 366 def test_visible_scope_with_project_and_subprojects
367 367 project = Project.find(1)
368 368 issues = Issue.visible(User.find(2), :project => project, :with_subprojects => true).to_a
369 369 projects = issues.collect(&:project).uniq
370 370 assert projects.size > 1
371 371 assert_equal [], projects.select {|p| !p.is_or_is_descendant_of?(project)}
372 372 end
373 373
374 374 def test_visible_and_nested_set_scopes
375 375 user = User.generate!
376 376 parent = Issue.generate!(:assigned_to => user)
377 377 assert parent.visible?(user)
378 378 child1 = Issue.generate!(:parent_issue_id => parent.id, :assigned_to => user)
379 379 child2 = Issue.generate!(:parent_issue_id => parent.id, :assigned_to => user)
380 380 parent.reload
381 381 child1.reload
382 382 child2.reload
383 383 assert child1.visible?(user)
384 384 assert child2.visible?(user)
385 385 assert_equal 2, parent.descendants.count
386 386 assert_equal 2, parent.descendants.visible(user).count
387 387 # awesome_nested_set 2-1-stable branch has regression.
388 388 # https://github.com/collectiveidea/awesome_nested_set/commit/3d5ac746542b564f6586c2316180254b088bebb6
389 389 # ActiveRecord::StatementInvalid: SQLite3::SQLException: ambiguous column name: lft:
390 390 assert_equal 2, parent.descendants.collect{|i| i}.size
391 391 assert_equal 2, parent.descendants.visible(user).collect{|i| i}.size
392 392 end
393 393
394 394 def test_visible_scope_with_unsaved_user_should_not_raise_an_error
395 395 user = User.new
396 396 assert_nothing_raised do
397 397 Issue.visible(user).to_a
398 398 end
399 399 end
400 400
401 401 def test_open_scope
402 402 issues = Issue.open.to_a
403 403 assert_nil issues.detect(&:closed?)
404 404 end
405 405
406 406 def test_open_scope_with_arg
407 407 issues = Issue.open(false).to_a
408 408 assert_equal issues, issues.select(&:closed?)
409 409 end
410 410
411 411 def test_fixed_version_scope_with_a_version_should_return_its_fixed_issues
412 412 version = Version.find(2)
413 413 assert version.fixed_issues.any?
414 414 assert_equal version.fixed_issues.to_a.sort, Issue.fixed_version(version).to_a.sort
415 415 end
416 416
417 417 def test_fixed_version_scope_with_empty_array_should_return_no_result
418 418 assert_equal 0, Issue.fixed_version([]).count
419 419 end
420 420
421 421 def test_assigned_to_scope_should_return_issues_assigned_to_the_user
422 422 user = User.generate!
423 423 issue = Issue.generate!
424 424 Issue.where(:id => issue.id).update_all :assigned_to_id => user.id
425 425 assert_equal [issue], Issue.assigned_to(user).to_a
426 426 end
427 427
428 428 def test_assigned_to_scope_should_return_issues_assigned_to_the_user_groups
429 429 group = Group.generate!
430 430 user = User.generate!
431 431 group.users << user
432 432 issue = Issue.generate!
433 433 Issue.where(:id => issue.id).update_all :assigned_to_id => group.id
434 434 assert_equal [issue], Issue.assigned_to(user).to_a
435 435 end
436 436
437 437 def test_errors_full_messages_should_include_custom_fields_errors
438 438 field = IssueCustomField.find_by_name('Database')
439 439
440 440 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1,
441 441 :status_id => 1, :subject => 'test_create',
442 442 :description => 'IssueTest#test_create_with_required_custom_field')
443 443 assert issue.available_custom_fields.include?(field)
444 444 # Invalid value
445 445 issue.custom_field_values = { field.id => 'SQLServer' }
446 446
447 447 assert !issue.valid?
448 448 assert_equal 1, issue.errors.full_messages.size
449 449 assert_equal "Database #{I18n.translate('activerecord.errors.messages.inclusion')}",
450 450 issue.errors.full_messages.first
451 451 end
452 452
453 453 def test_update_issue_with_required_custom_field
454 454 field = IssueCustomField.find_by_name('Database')
455 455 field.update_attribute(:is_required, true)
456 456
457 457 issue = Issue.find(1)
458 458 assert_nil issue.custom_value_for(field)
459 459 assert issue.available_custom_fields.include?(field)
460 460 # No change to custom values, issue can be saved
461 461 assert issue.save
462 462 # Blank value
463 463 issue.custom_field_values = { field.id => '' }
464 464 assert !issue.save
465 465 # Valid value
466 466 issue.custom_field_values = { field.id => 'PostgreSQL' }
467 467 assert issue.save
468 468 issue.reload
469 469 assert_equal 'PostgreSQL', issue.custom_value_for(field).value
470 470 end
471 471
472 472 def test_should_not_update_attributes_if_custom_fields_validation_fails
473 473 issue = Issue.find(1)
474 474 field = IssueCustomField.find_by_name('Database')
475 475 assert issue.available_custom_fields.include?(field)
476 476
477 477 issue.custom_field_values = { field.id => 'Invalid' }
478 478 issue.subject = 'Should be not be saved'
479 479 assert !issue.save
480 480
481 481 issue.reload
482 482 assert_equal "Cannot print recipes", issue.subject
483 483 end
484 484
485 485 def test_should_not_recreate_custom_values_objects_on_update
486 486 field = IssueCustomField.find_by_name('Database')
487 487
488 488 issue = Issue.find(1)
489 489 issue.custom_field_values = { field.id => 'PostgreSQL' }
490 490 assert issue.save
491 491 custom_value = issue.custom_value_for(field)
492 492 issue.reload
493 493 issue.custom_field_values = { field.id => 'MySQL' }
494 494 assert issue.save
495 495 issue.reload
496 496 assert_equal custom_value.id, issue.custom_value_for(field).id
497 497 end
498 498
499 def test_setting_project_should_set_version_to_default_version
500 version = Version.generate!(:project_id => 1)
501 Project.find(1).update_attribute(:default_version_id, version.id)
502
503 issue = Issue.new(:project_id => 1)
504 assert_equal version, issue.fixed_version
505 end
506
499 507 def test_should_not_update_custom_fields_on_changing_tracker_with_different_custom_fields
500 508 issue = Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 1,
501 509 :status_id => 1, :subject => 'Test',
502 510 :custom_field_values => {'2' => 'Test'})
503 511 assert !Tracker.find(2).custom_field_ids.include?(2)
504 512
505 513 issue = Issue.find(issue.id)
506 514 issue.attributes = {:tracker_id => 2, :custom_field_values => {'1' => ''}}
507 515
508 516 issue = Issue.find(issue.id)
509 517 custom_value = issue.custom_value_for(2)
510 518 assert_not_nil custom_value
511 519 assert_equal 'Test', custom_value.value
512 520 end
513 521
514 522 def test_assigning_tracker_id_should_reload_custom_fields_values
515 523 issue = Issue.new(:project => Project.find(1))
516 524 assert issue.custom_field_values.empty?
517 525 issue.tracker_id = 1
518 526 assert issue.custom_field_values.any?
519 527 end
520 528
521 529 def test_assigning_attributes_should_assign_project_and_tracker_first
522 530 seq = sequence('seq')
523 531 issue = Issue.new
524 532 issue.expects(:project_id=).in_sequence(seq)
525 533 issue.expects(:tracker_id=).in_sequence(seq)
526 534 issue.expects(:subject=).in_sequence(seq)
527 535 issue.attributes = {:tracker_id => 2, :project_id => 1, :subject => 'Test'}
528 536 end
529 537
530 538 def test_assigning_tracker_and_custom_fields_should_assign_custom_fields
531 539 attributes = ActiveSupport::OrderedHash.new
532 540 attributes['custom_field_values'] = { '1' => 'MySQL' }
533 541 attributes['tracker_id'] = '1'
534 542 issue = Issue.new(:project => Project.find(1))
535 543 issue.attributes = attributes
536 544 assert_equal 'MySQL', issue.custom_field_value(1)
537 545 end
538 546
539 547 def test_changing_tracker_should_clear_disabled_core_fields
540 548 tracker = Tracker.find(2)
541 549 tracker.core_fields = tracker.core_fields - %w(due_date)
542 550 tracker.save!
543 551
544 552 issue = Issue.generate!(:tracker_id => 1, :start_date => Date.today, :due_date => Date.today)
545 553 issue.save!
546 554
547 555 issue.tracker_id = 2
548 556 issue.save!
549 557 assert_not_nil issue.start_date
550 558 assert_nil issue.due_date
551 559 end
552 560
553 561 def test_changing_tracker_should_not_add_cleared_fields_to_journal
554 562 tracker = Tracker.find(2)
555 563 tracker.core_fields = tracker.core_fields - %w(due_date)
556 564 tracker.save!
557 565
558 566 issue = Issue.generate!(:tracker_id => 1, :due_date => Date.today)
559 567 issue.save!
560 568
561 569 assert_difference 'Journal.count' do
562 570 issue.init_journal User.find(1)
563 571 issue.tracker_id = 2
564 572 issue.save!
565 573 assert_nil issue.due_date
566 574 end
567 575 journal = Journal.order('id DESC').first
568 576 assert_equal 1, journal.details.count
569 577 end
570 578
571 579 def test_reload_should_reload_custom_field_values
572 580 issue = Issue.generate!
573 581 issue.custom_field_values = {'2' => 'Foo'}
574 582 issue.save!
575 583
576 584 issue = Issue.order('id desc').first
577 585 assert_equal 'Foo', issue.custom_field_value(2)
578 586
579 587 issue.custom_field_values = {'2' => 'Bar'}
580 588 assert_equal 'Bar', issue.custom_field_value(2)
581 589
582 590 issue.reload
583 591 assert_equal 'Foo', issue.custom_field_value(2)
584 592 end
585 593
586 594 def test_should_update_issue_with_disabled_tracker
587 595 p = Project.find(1)
588 596 issue = Issue.find(1)
589 597
590 598 p.trackers.delete(issue.tracker)
591 599 assert !p.trackers.include?(issue.tracker)
592 600
593 601 issue.reload
594 602 issue.subject = 'New subject'
595 603 assert issue.save
596 604 end
597 605
598 606 def test_should_not_set_a_disabled_tracker
599 607 p = Project.find(1)
600 608 p.trackers.delete(Tracker.find(2))
601 609
602 610 issue = Issue.find(1)
603 611 issue.tracker_id = 2
604 612 issue.subject = 'New subject'
605 613 assert !issue.save
606 614 assert_not_equal [], issue.errors[:tracker_id]
607 615 end
608 616
609 617 def test_category_based_assignment
610 618 issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3,
611 619 :status_id => 1, :priority => IssuePriority.all.first,
612 620 :subject => 'Assignment test',
613 621 :description => 'Assignment test', :category_id => 1)
614 622 assert_equal IssueCategory.find(1).assigned_to, issue.assigned_to
615 623 end
616 624
617 625 def test_new_statuses_allowed_to
618 626 WorkflowTransition.delete_all
619 627 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1,
620 628 :old_status_id => 1, :new_status_id => 2,
621 629 :author => false, :assignee => false)
622 630 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1,
623 631 :old_status_id => 1, :new_status_id => 3,
624 632 :author => true, :assignee => false)
625 633 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1,
626 634 :old_status_id => 1, :new_status_id => 4,
627 635 :author => false, :assignee => true)
628 636 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1,
629 637 :old_status_id => 1, :new_status_id => 5,
630 638 :author => true, :assignee => true)
631 639 status = IssueStatus.find(1)
632 640 role = Role.find(1)
633 641 tracker = Tracker.find(1)
634 642 user = User.find(2)
635 643
636 644 issue = Issue.generate!(:tracker => tracker, :status => status,
637 645 :project_id => 1, :author_id => 1)
638 646 assert_equal [1, 2], issue.new_statuses_allowed_to(user).map(&:id)
639 647
640 648 issue = Issue.generate!(:tracker => tracker, :status => status,
641 649 :project_id => 1, :author => user)
642 650 assert_equal [1, 2, 3, 5], issue.new_statuses_allowed_to(user).map(&:id)
643 651
644 652 issue = Issue.generate!(:tracker => tracker, :status => status,
645 653 :project_id => 1, :author_id => 1,
646 654 :assigned_to => user)
647 655 assert_equal [1, 2, 4, 5], issue.new_statuses_allowed_to(user).map(&:id)
648 656
649 657 issue = Issue.generate!(:tracker => tracker, :status => status,
650 658 :project_id => 1, :author => user,
651 659 :assigned_to => user)
652 660 assert_equal [1, 2, 3, 4, 5], issue.new_statuses_allowed_to(user).map(&:id)
653 661
654 662 group = Group.generate!
655 663 group.users << user
656 664 issue = Issue.generate!(:tracker => tracker, :status => status,
657 665 :project_id => 1, :author => user,
658 666 :assigned_to => group)
659 667 assert_equal [1, 2, 3, 4, 5], issue.new_statuses_allowed_to(user).map(&:id)
660 668 end
661 669
662 670 def test_new_statuses_allowed_to_should_consider_group_assignment
663 671 WorkflowTransition.delete_all
664 672 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1,
665 673 :old_status_id => 1, :new_status_id => 4,
666 674 :author => false, :assignee => true)
667 675 user = User.find(2)
668 676 group = Group.generate!
669 677 group.users << user
670 678
671 679 issue = Issue.generate!(:author_id => 1, :assigned_to => group)
672 680 assert_include 4, issue.new_statuses_allowed_to(user).map(&:id)
673 681 end
674 682
675 683 def test_new_statuses_allowed_to_should_return_all_transitions_for_admin
676 684 admin = User.find(1)
677 685 issue = Issue.find(1)
678 686 assert !admin.member_of?(issue.project)
679 687 expected_statuses = [issue.status] +
680 688 WorkflowTransition.where(:old_status_id => issue.status_id).
681 689 map(&:new_status).uniq.sort
682 690 assert_equal expected_statuses, issue.new_statuses_allowed_to(admin)
683 691 end
684 692
685 693 def test_new_statuses_allowed_to_should_return_default_and_current_status_when_copying
686 694 issue = Issue.find(1).copy
687 695 assert_equal [1], issue.new_statuses_allowed_to(User.find(2)).map(&:id)
688 696
689 697 issue = Issue.find(2).copy
690 698 assert_equal [1, 2], issue.new_statuses_allowed_to(User.find(2)).map(&:id)
691 699 end
692 700
693 701 def test_safe_attributes_names_should_not_include_disabled_field
694 702 tracker = Tracker.new(:core_fields => %w(assigned_to_id fixed_version_id))
695 703
696 704 issue = Issue.new(:tracker => tracker)
697 705 assert_include 'tracker_id', issue.safe_attribute_names
698 706 assert_include 'status_id', issue.safe_attribute_names
699 707 assert_include 'subject', issue.safe_attribute_names
700 708 assert_include 'description', issue.safe_attribute_names
701 709 assert_include 'custom_field_values', issue.safe_attribute_names
702 710 assert_include 'custom_fields', issue.safe_attribute_names
703 711 assert_include 'lock_version', issue.safe_attribute_names
704 712
705 713 tracker.core_fields.each do |field|
706 714 assert_include field, issue.safe_attribute_names
707 715 end
708 716
709 717 tracker.disabled_core_fields.each do |field|
710 718 assert_not_include field, issue.safe_attribute_names
711 719 end
712 720 end
713 721
714 722 def test_safe_attributes_should_ignore_disabled_fields
715 723 tracker = Tracker.find(1)
716 724 tracker.core_fields = %w(assigned_to_id due_date)
717 725 tracker.save!
718 726
719 727 issue = Issue.new(:tracker => tracker)
720 728 issue.safe_attributes = {'start_date' => '2012-07-14', 'due_date' => '2012-07-14'}
721 729 assert_nil issue.start_date
722 730 assert_equal Date.parse('2012-07-14'), issue.due_date
723 731 end
724 732
725 733 def test_safe_attributes_should_accept_target_tracker_enabled_fields
726 734 source = Tracker.find(1)
727 735 source.core_fields = []
728 736 source.save!
729 737 target = Tracker.find(2)
730 738 target.core_fields = %w(assigned_to_id due_date)
731 739 target.save!
732 740
733 741 issue = Issue.new(:tracker => source)
734 742 issue.safe_attributes = {'tracker_id' => 2, 'due_date' => '2012-07-14'}
735 743 assert_equal target, issue.tracker
736 744 assert_equal Date.parse('2012-07-14'), issue.due_date
737 745 end
738 746
739 747 def test_safe_attributes_should_not_include_readonly_fields
740 748 WorkflowPermission.delete_all
741 749 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1,
742 750 :role_id => 1, :field_name => 'due_date',
743 751 :rule => 'readonly')
744 752 user = User.find(2)
745 753
746 754 issue = Issue.new(:project_id => 1, :tracker_id => 1)
747 755 assert_equal %w(due_date), issue.read_only_attribute_names(user)
748 756 assert_not_include 'due_date', issue.safe_attribute_names(user)
749 757
750 758 issue.send :safe_attributes=, {'start_date' => '2012-07-14', 'due_date' => '2012-07-14'}, user
751 759 assert_equal Date.parse('2012-07-14'), issue.start_date
752 760 assert_nil issue.due_date
753 761 end
754 762
755 763 def test_safe_attributes_should_not_include_readonly_custom_fields
756 764 cf1 = IssueCustomField.create!(:name => 'Writable field',
757 765 :field_format => 'string',
758 766 :is_for_all => true, :tracker_ids => [1])
759 767 cf2 = IssueCustomField.create!(:name => 'Readonly field',
760 768 :field_format => 'string',
761 769 :is_for_all => true, :tracker_ids => [1])
762 770 WorkflowPermission.delete_all
763 771 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1,
764 772 :role_id => 1, :field_name => cf2.id.to_s,
765 773 :rule => 'readonly')
766 774 user = User.find(2)
767 775 issue = Issue.new(:project_id => 1, :tracker_id => 1)
768 776 assert_equal [cf2.id.to_s], issue.read_only_attribute_names(user)
769 777 assert_not_include cf2.id.to_s, issue.safe_attribute_names(user)
770 778
771 779 issue.send :safe_attributes=, {'custom_field_values' => {
772 780 cf1.id.to_s => 'value1', cf2.id.to_s => 'value2'
773 781 }}, user
774 782 assert_equal 'value1', issue.custom_field_value(cf1)
775 783 assert_nil issue.custom_field_value(cf2)
776 784
777 785 issue.send :safe_attributes=, {'custom_fields' => [
778 786 {'id' => cf1.id.to_s, 'value' => 'valuea'},
779 787 {'id' => cf2.id.to_s, 'value' => 'valueb'}
780 788 ]}, user
781 789 assert_equal 'valuea', issue.custom_field_value(cf1)
782 790 assert_nil issue.custom_field_value(cf2)
783 791 end
784 792
785 793 def test_editable_custom_field_values_should_return_non_readonly_custom_values
786 794 cf1 = IssueCustomField.create!(:name => 'Writable field', :field_format => 'string',
787 795 :is_for_all => true, :tracker_ids => [1, 2])
788 796 cf2 = IssueCustomField.create!(:name => 'Readonly field', :field_format => 'string',
789 797 :is_for_all => true, :tracker_ids => [1, 2])
790 798 WorkflowPermission.delete_all
791 799 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1,
792 800 :field_name => cf2.id.to_s, :rule => 'readonly')
793 801 user = User.find(2)
794 802
795 803 issue = Issue.new(:project_id => 1, :tracker_id => 1)
796 804 values = issue.editable_custom_field_values(user)
797 805 assert values.detect {|value| value.custom_field == cf1}
798 806 assert_nil values.detect {|value| value.custom_field == cf2}
799 807
800 808 issue.tracker_id = 2
801 809 values = issue.editable_custom_field_values(user)
802 810 assert values.detect {|value| value.custom_field == cf1}
803 811 assert values.detect {|value| value.custom_field == cf2}
804 812 end
805 813
806 814 def test_editable_custom_fields_should_return_custom_field_that_is_enabled_for_the_role_only
807 815 enabled_cf = IssueCustomField.generate!(:is_for_all => true, :tracker_ids => [1], :visible => false, :role_ids => [1,2])
808 816 disabled_cf = IssueCustomField.generate!(:is_for_all => true, :tracker_ids => [1], :visible => false, :role_ids => [2])
809 817 user = User.find(2)
810 818 issue = Issue.new(:project_id => 1, :tracker_id => 1)
811 819
812 820 assert_include enabled_cf, issue.editable_custom_fields(user)
813 821 assert_not_include disabled_cf, issue.editable_custom_fields(user)
814 822 end
815 823
816 824 def test_safe_attributes_should_accept_target_tracker_writable_fields
817 825 WorkflowPermission.delete_all
818 826 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1,
819 827 :role_id => 1, :field_name => 'due_date',
820 828 :rule => 'readonly')
821 829 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2,
822 830 :role_id => 1, :field_name => 'start_date',
823 831 :rule => 'readonly')
824 832 user = User.find(2)
825 833
826 834 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1)
827 835
828 836 issue.send :safe_attributes=, {'start_date' => '2012-07-12',
829 837 'due_date' => '2012-07-14'}, user
830 838 assert_equal Date.parse('2012-07-12'), issue.start_date
831 839 assert_nil issue.due_date
832 840
833 841 issue.send :safe_attributes=, {'start_date' => '2012-07-15',
834 842 'due_date' => '2012-07-16',
835 843 'tracker_id' => 2}, user
836 844 assert_equal Date.parse('2012-07-12'), issue.start_date
837 845 assert_equal Date.parse('2012-07-16'), issue.due_date
838 846 end
839 847
840 848 def test_safe_attributes_should_accept_target_status_writable_fields
841 849 WorkflowPermission.delete_all
842 850 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1,
843 851 :role_id => 1, :field_name => 'due_date',
844 852 :rule => 'readonly')
845 853 WorkflowPermission.create!(:old_status_id => 2, :tracker_id => 1,
846 854 :role_id => 1, :field_name => 'start_date',
847 855 :rule => 'readonly')
848 856 user = User.find(2)
849 857
850 858 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1)
851 859
852 860 issue.send :safe_attributes=, {'start_date' => '2012-07-12',
853 861 'due_date' => '2012-07-14'},
854 862 user
855 863 assert_equal Date.parse('2012-07-12'), issue.start_date
856 864 assert_nil issue.due_date
857 865
858 866 issue.send :safe_attributes=, {'start_date' => '2012-07-15',
859 867 'due_date' => '2012-07-16',
860 868 'status_id' => 2},
861 869 user
862 870 assert_equal Date.parse('2012-07-12'), issue.start_date
863 871 assert_equal Date.parse('2012-07-16'), issue.due_date
864 872 end
865 873
866 874 def test_required_attributes_should_be_validated
867 875 cf = IssueCustomField.create!(:name => 'Foo', :field_format => 'string',
868 876 :is_for_all => true, :tracker_ids => [1, 2])
869 877
870 878 WorkflowPermission.delete_all
871 879 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1,
872 880 :role_id => 1, :field_name => 'due_date',
873 881 :rule => 'required')
874 882 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1,
875 883 :role_id => 1, :field_name => 'category_id',
876 884 :rule => 'required')
877 885 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1,
878 886 :role_id => 1, :field_name => cf.id.to_s,
879 887 :rule => 'required')
880 888
881 889 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2,
882 890 :role_id => 1, :field_name => 'start_date',
883 891 :rule => 'required')
884 892 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2,
885 893 :role_id => 1, :field_name => cf.id.to_s,
886 894 :rule => 'required')
887 895 user = User.find(2)
888 896
889 897 issue = Issue.new(:project_id => 1, :tracker_id => 1,
890 898 :status_id => 1, :subject => 'Required fields',
891 899 :author => user)
892 900 assert_equal [cf.id.to_s, "category_id", "due_date"],
893 901 issue.required_attribute_names(user).sort
894 902 assert !issue.save, "Issue was saved"
895 903 assert_equal ["Category cannot be blank", "Due date cannot be blank", "Foo cannot be blank"],
896 904 issue.errors.full_messages.sort
897 905
898 906 issue.tracker_id = 2
899 907 assert_equal [cf.id.to_s, "start_date"], issue.required_attribute_names(user).sort
900 908 assert !issue.save, "Issue was saved"
901 909 assert_equal ["Foo cannot be blank", "Start date cannot be blank"],
902 910 issue.errors.full_messages.sort
903 911
904 912 issue.start_date = Date.today
905 913 issue.custom_field_values = {cf.id.to_s => 'bar'}
906 914 assert issue.save
907 915 end
908 916
909 917 def test_required_attribute_that_is_disabled_for_the_tracker_should_not_be_required
910 918 WorkflowPermission.delete_all
911 919 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1,
912 920 :role_id => 1, :field_name => 'start_date',
913 921 :rule => 'required')
914 922 user = User.find(2)
915 923
916 924 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1,
917 925 :subject => 'Required fields', :author => user)
918 926 assert !issue.save
919 927 assert_include "Start date cannot be blank", issue.errors.full_messages
920 928
921 929 tracker = Tracker.find(1)
922 930 tracker.core_fields -= %w(start_date)
923 931 tracker.save!
924 932 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1,
925 933 :subject => 'Required fields', :author => user)
926 934 assert issue.save
927 935 end
928 936
929 937 def test_category_should_not_be_required_if_project_has_no_categories
930 938 Project.find(1).issue_categories.delete_all
931 939 WorkflowPermission.delete_all
932 940 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1,
933 941 :role_id => 1, :field_name => 'category_id',:rule => 'required')
934 942 user = User.find(2)
935 943
936 944 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1,
937 945 :subject => 'Required fields', :author => user)
938 946 assert_save issue
939 947 end
940 948
941 949 def test_fixed_version_should_not_be_required_no_assignable_versions
942 950 Version.delete_all
943 951 WorkflowPermission.delete_all
944 952 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1,
945 953 :role_id => 1, :field_name => 'fixed_version_id',:rule => 'required')
946 954 user = User.find(2)
947 955
948 956 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1,
949 957 :subject => 'Required fields', :author => user)
950 958 assert_save issue
951 959 end
952 960
953 961 def test_required_custom_field_that_is_not_visible_for_the_user_should_not_be_required
954 962 CustomField.delete_all
955 963 field = IssueCustomField.generate!(:is_required => true, :visible => false, :role_ids => [1], :trackers => Tracker.all, :is_for_all => true)
956 964 user = User.generate!
957 965 User.add_to_project(user, Project.find(1), Role.find(2))
958 966
959 967 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1,
960 968 :subject => 'Required fields', :author => user)
961 969 assert_save issue
962 970 end
963 971
964 972 def test_required_custom_field_that_is_visible_for_the_user_should_be_required
965 973 CustomField.delete_all
966 974 field = IssueCustomField.generate!(:is_required => true, :visible => false, :role_ids => [1], :trackers => Tracker.all, :is_for_all => true)
967 975 user = User.generate!
968 976 User.add_to_project(user, Project.find(1), Role.find(1))
969 977
970 978 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1,
971 979 :subject => 'Required fields', :author => user)
972 980 assert !issue.save
973 981 assert_include "#{field.name} cannot be blank", issue.errors.full_messages
974 982 end
975 983
976 984 def test_required_attribute_names_for_multiple_roles_should_intersect_rules
977 985 WorkflowPermission.delete_all
978 986 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1,
979 987 :role_id => 1, :field_name => 'due_date',
980 988 :rule => 'required')
981 989 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1,
982 990 :role_id => 1, :field_name => 'start_date',
983 991 :rule => 'required')
984 992 user = User.find(2)
985 993 member = Member.find(1)
986 994 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1)
987 995
988 996 assert_equal %w(due_date start_date), issue.required_attribute_names(user).sort
989 997
990 998 member.role_ids = [1, 2]
991 999 member.save!
992 1000 assert_equal [], issue.required_attribute_names(user.reload)
993 1001
994 1002 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1,
995 1003 :role_id => 2, :field_name => 'due_date',
996 1004 :rule => 'required')
997 1005 assert_equal %w(due_date), issue.required_attribute_names(user)
998 1006
999 1007 member.role_ids = [1, 2, 3]
1000 1008 member.save!
1001 1009 assert_equal [], issue.required_attribute_names(user.reload)
1002 1010
1003 1011 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1,
1004 1012 :role_id => 3, :field_name => 'due_date',
1005 1013 :rule => 'readonly')
1006 1014 # required + readonly => required
1007 1015 assert_equal %w(due_date), issue.required_attribute_names(user)
1008 1016 end
1009 1017
1010 1018 def test_read_only_attribute_names_for_multiple_roles_should_intersect_rules
1011 1019 WorkflowPermission.delete_all
1012 1020 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1,
1013 1021 :role_id => 1, :field_name => 'due_date',
1014 1022 :rule => 'readonly')
1015 1023 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1,
1016 1024 :role_id => 1, :field_name => 'start_date',
1017 1025 :rule => 'readonly')
1018 1026 user = User.find(2)
1019 1027 member = Member.find(1)
1020 1028 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1)
1021 1029
1022 1030 assert_equal %w(due_date start_date), issue.read_only_attribute_names(user).sort
1023 1031
1024 1032 member.role_ids = [1, 2]
1025 1033 member.save!
1026 1034 assert_equal [], issue.read_only_attribute_names(user.reload)
1027 1035
1028 1036 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1,
1029 1037 :role_id => 2, :field_name => 'due_date',
1030 1038 :rule => 'readonly')
1031 1039 assert_equal %w(due_date), issue.read_only_attribute_names(user)
1032 1040 end
1033 1041
1034 1042 # A field that is not visible by role 2 and readonly by role 1 should be readonly for user with role 1 and 2
1035 1043 def test_read_only_attribute_names_should_include_custom_fields_that_combine_readonly_and_not_visible_for_roles
1036 1044 field = IssueCustomField.generate!(
1037 1045 :is_for_all => true, :trackers => Tracker.all, :visible => false, :role_ids => [1]
1038 1046 )
1039 1047 WorkflowPermission.delete_all
1040 1048 WorkflowPermission.create!(
1041 1049 :old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => field.id, :rule => 'readonly'
1042 1050 )
1043 1051 user = User.generate!
1044 1052 project = Project.find(1)
1045 1053 User.add_to_project(user, project, Role.where(:id => [1, 2]))
1046 1054
1047 1055 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1)
1048 1056 assert_equal [field.id.to_s], issue.read_only_attribute_names(user)
1049 1057 end
1050 1058
1051 1059 def test_workflow_rules_should_ignore_roles_without_issue_permissions
1052 1060 role = Role.generate! :permissions => [:view_issues, :edit_issues]
1053 1061 ignored_role = Role.generate! :permissions => [:view_issues]
1054 1062
1055 1063 WorkflowPermission.delete_all
1056 1064 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1,
1057 1065 :role => role, :field_name => 'due_date',
1058 1066 :rule => 'required')
1059 1067 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1,
1060 1068 :role => role, :field_name => 'start_date',
1061 1069 :rule => 'readonly')
1062 1070 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1,
1063 1071 :role => role, :field_name => 'done_ratio',
1064 1072 :rule => 'readonly')
1065 1073 user = User.generate!
1066 1074 User.add_to_project user, Project.find(1), [role, ignored_role]
1067 1075
1068 1076 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1)
1069 1077
1070 1078 assert_equal %w(due_date), issue.required_attribute_names(user)
1071 1079 assert_equal %w(done_ratio start_date), issue.read_only_attribute_names(user).sort
1072 1080 end
1073 1081
1074 1082 def test_workflow_rules_should_work_for_member_with_duplicate_role
1075 1083 WorkflowPermission.delete_all
1076 1084 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1,
1077 1085 :role_id => 1, :field_name => 'due_date',
1078 1086 :rule => 'required')
1079 1087 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1,
1080 1088 :role_id => 1, :field_name => 'start_date',
1081 1089 :rule => 'readonly')
1082 1090
1083 1091 user = User.generate!
1084 1092 m = Member.new(:user_id => user.id, :project_id => 1)
1085 1093 m.member_roles.build(:role_id => 1)
1086 1094 m.member_roles.build(:role_id => 1)
1087 1095 m.save!
1088 1096
1089 1097 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1)
1090 1098
1091 1099 assert_equal %w(due_date), issue.required_attribute_names(user)
1092 1100 assert_equal %w(start_date), issue.read_only_attribute_names(user)
1093 1101 end
1094 1102
1095 1103 def test_copy
1096 1104 issue = Issue.new.copy_from(1)
1097 1105 assert issue.copy?
1098 1106 assert issue.save
1099 1107 issue.reload
1100 1108 orig = Issue.find(1)
1101 1109 assert_equal orig.subject, issue.subject
1102 1110 assert_equal orig.tracker, issue.tracker
1103 1111 assert_equal "125", issue.custom_value_for(2).value
1104 1112 end
1105 1113
1106 1114 def test_copy_should_copy_status
1107 1115 orig = Issue.find(8)
1108 1116 assert orig.status != orig.default_status
1109 1117
1110 1118 issue = Issue.new.copy_from(orig)
1111 1119 assert issue.save
1112 1120 issue.reload
1113 1121 assert_equal orig.status, issue.status
1114 1122 end
1115 1123
1116 1124 def test_copy_should_add_relation_with_copied_issue
1117 1125 copied = Issue.find(1)
1118 1126 issue = Issue.new.copy_from(copied)
1119 1127 assert issue.save
1120 1128 issue.reload
1121 1129
1122 1130 assert_equal 1, issue.relations.size
1123 1131 relation = issue.relations.first
1124 1132 assert_equal 'copied_to', relation.relation_type
1125 1133 assert_equal copied, relation.issue_from
1126 1134 assert_equal issue, relation.issue_to
1127 1135 end
1128 1136
1129 1137 def test_copy_should_copy_subtasks
1130 1138 issue = Issue.generate_with_descendants!
1131 1139
1132 1140 copy = issue.reload.copy
1133 1141 copy.author = User.find(7)
1134 1142 assert_difference 'Issue.count', 1+issue.descendants.count do
1135 1143 assert copy.save
1136 1144 end
1137 1145 copy.reload
1138 1146 assert_equal %w(Child1 Child2), copy.children.map(&:subject).sort
1139 1147 child_copy = copy.children.detect {|c| c.subject == 'Child1'}
1140 1148 assert_equal %w(Child11), child_copy.children.map(&:subject).sort
1141 1149 assert_equal copy.author, child_copy.author
1142 1150 end
1143 1151
1144 1152 def test_copy_as_a_child_of_copied_issue_should_not_copy_itself
1145 1153 parent = Issue.generate!
1146 1154 child1 = Issue.generate!(:parent_issue_id => parent.id, :subject => 'Child 1')
1147 1155 child2 = Issue.generate!(:parent_issue_id => parent.id, :subject => 'Child 2')
1148 1156
1149 1157 copy = parent.reload.copy
1150 1158 copy.parent_issue_id = parent.id
1151 1159 copy.author = User.find(7)
1152 1160 assert_difference 'Issue.count', 3 do
1153 1161 assert copy.save
1154 1162 end
1155 1163 parent.reload
1156 1164 copy.reload
1157 1165 assert_equal parent, copy.parent
1158 1166 assert_equal 3, parent.children.count
1159 1167 assert_equal 5, parent.descendants.count
1160 1168 assert_equal 2, copy.children.count
1161 1169 assert_equal 2, copy.descendants.count
1162 1170 end
1163 1171
1164 1172 def test_copy_as_a_descendant_of_copied_issue_should_not_copy_itself
1165 1173 parent = Issue.generate!
1166 1174 child1 = Issue.generate!(:parent_issue_id => parent.id, :subject => 'Child 1')
1167 1175 child2 = Issue.generate!(:parent_issue_id => parent.id, :subject => 'Child 2')
1168 1176
1169 1177 copy = parent.reload.copy
1170 1178 copy.parent_issue_id = child1.id
1171 1179 copy.author = User.find(7)
1172 1180 assert_difference 'Issue.count', 3 do
1173 1181 assert copy.save
1174 1182 end
1175 1183 parent.reload
1176 1184 child1.reload
1177 1185 copy.reload
1178 1186 assert_equal child1, copy.parent
1179 1187 assert_equal 2, parent.children.count
1180 1188 assert_equal 5, parent.descendants.count
1181 1189 assert_equal 1, child1.children.count
1182 1190 assert_equal 3, child1.descendants.count
1183 1191 assert_equal 2, copy.children.count
1184 1192 assert_equal 2, copy.descendants.count
1185 1193 end
1186 1194
1187 1195 def test_copy_should_copy_subtasks_to_target_project
1188 1196 issue = Issue.generate_with_descendants!
1189 1197
1190 1198 copy = issue.copy(:project_id => 3)
1191 1199 assert_difference 'Issue.count', 1+issue.descendants.count do
1192 1200 assert copy.save
1193 1201 end
1194 1202 assert_equal [3], copy.reload.descendants.map(&:project_id).uniq
1195 1203 end
1196 1204
1197 1205 def test_copy_should_not_copy_subtasks_twice_when_saving_twice
1198 1206 issue = Issue.generate_with_descendants!
1199 1207
1200 1208 copy = issue.reload.copy
1201 1209 assert_difference 'Issue.count', 1+issue.descendants.count do
1202 1210 assert copy.save
1203 1211 assert copy.save
1204 1212 end
1205 1213 end
1206 1214
1207 1215 def test_should_not_call_after_project_change_on_creation
1208 1216 issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1,
1209 1217 :subject => 'Test', :author_id => 1)
1210 1218 issue.expects(:after_project_change).never
1211 1219 issue.save!
1212 1220 end
1213 1221
1214 1222 def test_should_not_call_after_project_change_on_update
1215 1223 issue = Issue.find(1)
1216 1224 issue.project = Project.find(1)
1217 1225 issue.subject = 'No project change'
1218 1226 issue.expects(:after_project_change).never
1219 1227 issue.save!
1220 1228 end
1221 1229
1222 1230 def test_should_call_after_project_change_on_project_change
1223 1231 issue = Issue.find(1)
1224 1232 issue.project = Project.find(2)
1225 1233 issue.expects(:after_project_change).once
1226 1234 issue.save!
1227 1235 end
1228 1236
1229 1237 def test_adding_journal_should_update_timestamp
1230 1238 issue = Issue.find(1)
1231 1239 updated_on_was = issue.updated_on
1232 1240
1233 1241 issue.init_journal(User.first, "Adding notes")
1234 1242 assert_difference 'Journal.count' do
1235 1243 assert issue.save
1236 1244 end
1237 1245 issue.reload
1238 1246
1239 1247 assert_not_equal updated_on_was, issue.updated_on
1240 1248 end
1241 1249
1242 1250 def test_should_close_duplicates
1243 1251 # Create 3 issues
1244 1252 issue1 = Issue.generate!
1245 1253 issue2 = Issue.generate!
1246 1254 issue3 = Issue.generate!
1247 1255
1248 1256 # 2 is a dupe of 1
1249 1257 IssueRelation.create!(:issue_from => issue2, :issue_to => issue1,
1250 1258 :relation_type => IssueRelation::TYPE_DUPLICATES)
1251 1259 # And 3 is a dupe of 2
1252 1260 # IssueRelation.create!(:issue_from => issue3, :issue_to => issue2,
1253 1261 # :relation_type => IssueRelation::TYPE_DUPLICATES)
1254 1262 # And 3 is a dupe of 1 (circular duplicates)
1255 1263 IssueRelation.create!(:issue_from => issue3, :issue_to => issue1,
1256 1264 :relation_type => IssueRelation::TYPE_DUPLICATES)
1257 1265
1258 1266 assert issue1.reload.duplicates.include?(issue2)
1259 1267
1260 1268 # Closing issue 1
1261 1269 issue1.init_journal(User.first, "Closing issue1")
1262 1270 issue1.status = IssueStatus.where(:is_closed => true).first
1263 1271 assert issue1.save
1264 1272 # 2 and 3 should be also closed
1265 1273 assert issue2.reload.closed?
1266 1274 assert issue3.reload.closed?
1267 1275 end
1268 1276
1269 1277 def test_should_not_close_duplicated_issue
1270 1278 issue1 = Issue.generate!
1271 1279 issue2 = Issue.generate!
1272 1280
1273 1281 # 2 is a dupe of 1
1274 1282 IssueRelation.create(:issue_from => issue2, :issue_to => issue1,
1275 1283 :relation_type => IssueRelation::TYPE_DUPLICATES)
1276 1284 # 2 is a dup of 1 but 1 is not a duplicate of 2
1277 1285 assert !issue2.reload.duplicates.include?(issue1)
1278 1286
1279 1287 # Closing issue 2
1280 1288 issue2.init_journal(User.first, "Closing issue2")
1281 1289 issue2.status = IssueStatus.where(:is_closed => true).first
1282 1290 assert issue2.save
1283 1291 # 1 should not be also closed
1284 1292 assert !issue1.reload.closed?
1285 1293 end
1286 1294
1287 1295 def test_assignable_versions
1288 1296 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1,
1289 1297 :status_id => 1, :fixed_version_id => 1,
1290 1298 :subject => 'New issue')
1291 1299 assert_equal ['open'], issue.assignable_versions.collect(&:status).uniq
1292 1300 end
1293 1301
1294 1302 def test_should_not_be_able_to_assign_a_new_issue_to_a_closed_version
1295 1303 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1,
1296 1304 :status_id => 1, :fixed_version_id => 1,
1297 1305 :subject => 'New issue')
1298 1306 assert !issue.save
1299 1307 assert_not_equal [], issue.errors[:fixed_version_id]
1300 1308 end
1301 1309
1302 1310 def test_should_not_be_able_to_assign_a_new_issue_to_a_locked_version
1303 1311 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1,
1304 1312 :status_id => 1, :fixed_version_id => 2,
1305 1313 :subject => 'New issue')
1306 1314 assert !issue.save
1307 1315 assert_not_equal [], issue.errors[:fixed_version_id]
1308 1316 end
1309 1317
1310 1318 def test_should_be_able_to_assign_a_new_issue_to_an_open_version
1311 1319 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1,
1312 1320 :status_id => 1, :fixed_version_id => 3,
1313 1321 :subject => 'New issue')
1314 1322 assert issue.save
1315 1323 end
1316 1324
1317 1325 def test_should_be_able_to_update_an_issue_assigned_to_a_closed_version
1318 1326 issue = Issue.find(11)
1319 1327 assert_equal 'closed', issue.fixed_version.status
1320 1328 issue.subject = 'Subject changed'
1321 1329 assert issue.save
1322 1330 end
1323 1331
1324 1332 def test_should_not_be_able_to_reopen_an_issue_assigned_to_a_closed_version
1325 1333 issue = Issue.find(11)
1326 1334 issue.status_id = 1
1327 1335 assert !issue.save
1328 1336 assert_not_equal [], issue.errors[:base]
1329 1337 end
1330 1338
1331 1339 def test_should_be_able_to_reopen_and_reassign_an_issue_assigned_to_a_closed_version
1332 1340 issue = Issue.find(11)
1333 1341 issue.status_id = 1
1334 1342 issue.fixed_version_id = 3
1335 1343 assert issue.save
1336 1344 end
1337 1345
1338 1346 def test_should_be_able_to_reopen_an_issue_assigned_to_a_locked_version
1339 1347 issue = Issue.find(12)
1340 1348 assert_equal 'locked', issue.fixed_version.status
1341 1349 issue.status_id = 1
1342 1350 assert issue.save
1343 1351 end
1344 1352
1345 1353 def test_should_not_be_able_to_keep_unshared_version_when_changing_project
1346 1354 issue = Issue.find(2)
1347 1355 assert_equal 2, issue.fixed_version_id
1348 1356 issue.project_id = 3
1349 1357 assert_nil issue.fixed_version_id
1350 1358 issue.fixed_version_id = 2
1351 1359 assert !issue.save
1352 1360 assert_include 'Target version is not included in the list', issue.errors.full_messages
1353 1361 end
1354 1362
1355 1363 def test_should_keep_shared_version_when_changing_project
1356 1364 Version.find(2).update_attribute :sharing, 'tree'
1357 1365
1358 1366 issue = Issue.find(2)
1359 1367 assert_equal 2, issue.fixed_version_id
1360 1368 issue.project_id = 3
1361 1369 assert_equal 2, issue.fixed_version_id
1362 1370 assert issue.save
1363 1371 end
1364 1372
1365 1373 def test_allowed_target_projects_should_include_projects_with_issue_tracking_enabled
1366 1374 assert_include Project.find(2), Issue.allowed_target_projects(User.find(2))
1367 1375 end
1368 1376
1369 1377 def test_allowed_target_projects_should_not_include_projects_with_issue_tracking_disabled
1370 1378 Project.find(2).disable_module! :issue_tracking
1371 1379 assert_not_include Project.find(2), Issue.allowed_target_projects(User.find(2))
1372 1380 end
1373 1381
1374 1382 def test_allowed_target_projects_should_not_include_projects_without_trackers
1375 1383 project = Project.generate!(:tracker_ids => [])
1376 1384 assert project.trackers.empty?
1377 1385 assert_not_include project, Issue.allowed_target_projects(User.find(1))
1378 1386 end
1379 1387
1380 1388 def test_move_to_another_project_with_same_category
1381 1389 issue = Issue.find(1)
1382 1390 issue.project = Project.find(2)
1383 1391 assert issue.save
1384 1392 issue.reload
1385 1393 assert_equal 2, issue.project_id
1386 1394 # Category changes
1387 1395 assert_equal 4, issue.category_id
1388 1396 # Make sure time entries were move to the target project
1389 1397 assert_equal 2, issue.time_entries.first.project_id
1390 1398 end
1391 1399
1392 1400 def test_move_to_another_project_without_same_category
1393 1401 issue = Issue.find(2)
1394 1402 issue.project = Project.find(2)
1395 1403 assert issue.save
1396 1404 issue.reload
1397 1405 assert_equal 2, issue.project_id
1398 1406 # Category cleared
1399 1407 assert_nil issue.category_id
1400 1408 end
1401 1409
1402 1410 def test_move_to_another_project_should_clear_fixed_version_when_not_shared
1403 1411 issue = Issue.find(1)
1404 1412 issue.update_attribute(:fixed_version_id, 1)
1405 1413 issue.project = Project.find(2)
1406 1414 assert issue.save
1407 1415 issue.reload
1408 1416 assert_equal 2, issue.project_id
1409 1417 # Cleared fixed_version
1410 1418 assert_equal nil, issue.fixed_version
1411 1419 end
1412 1420
1413 1421 def test_move_to_another_project_should_keep_fixed_version_when_shared_with_the_target_project
1414 1422 issue = Issue.find(1)
1415 1423 issue.update_attribute(:fixed_version_id, 4)
1416 1424 issue.project = Project.find(5)
1417 1425 assert issue.save
1418 1426 issue.reload
1419 1427 assert_equal 5, issue.project_id
1420 1428 # Keep fixed_version
1421 1429 assert_equal 4, issue.fixed_version_id
1422 1430 end
1423 1431
1424 1432 def test_move_to_another_project_should_clear_fixed_version_when_not_shared_with_the_target_project
1425 1433 issue = Issue.find(1)
1426 1434 issue.update_attribute(:fixed_version_id, 1)
1427 1435 issue.project = Project.find(5)
1428 1436 assert issue.save
1429 1437 issue.reload
1430 1438 assert_equal 5, issue.project_id
1431 1439 # Cleared fixed_version
1432 1440 assert_equal nil, issue.fixed_version
1433 1441 end
1434 1442
1435 1443 def test_move_to_another_project_should_keep_fixed_version_when_shared_systemwide
1436 1444 issue = Issue.find(1)
1437 1445 issue.update_attribute(:fixed_version_id, 7)
1438 1446 issue.project = Project.find(2)
1439 1447 assert issue.save
1440 1448 issue.reload
1441 1449 assert_equal 2, issue.project_id
1442 1450 # Keep fixed_version
1443 1451 assert_equal 7, issue.fixed_version_id
1444 1452 end
1445 1453
1446 1454 def test_move_to_another_project_should_keep_parent_if_valid
1447 1455 issue = Issue.find(1)
1448 1456 issue.update_attribute(:parent_issue_id, 2)
1449 1457 issue.project = Project.find(3)
1450 1458 assert issue.save
1451 1459 issue.reload
1452 1460 assert_equal 2, issue.parent_id
1453 1461 end
1454 1462
1455 1463 def test_move_to_another_project_should_clear_parent_if_not_valid
1456 1464 issue = Issue.find(1)
1457 1465 issue.update_attribute(:parent_issue_id, 2)
1458 1466 issue.project = Project.find(2)
1459 1467 assert issue.save
1460 1468 issue.reload
1461 1469 assert_nil issue.parent_id
1462 1470 end
1463 1471
1464 1472 def test_move_to_another_project_with_disabled_tracker
1465 1473 issue = Issue.find(1)
1466 1474 target = Project.find(2)
1467 1475 target.tracker_ids = [3]
1468 1476 target.save
1469 1477 issue.project = target
1470 1478 assert issue.save
1471 1479 issue.reload
1472 1480 assert_equal 2, issue.project_id
1473 1481 assert_equal 3, issue.tracker_id
1474 1482 end
1475 1483
1476 1484 def test_copy_to_the_same_project
1477 1485 issue = Issue.find(1)
1478 1486 copy = issue.copy
1479 1487 assert_difference 'Issue.count' do
1480 1488 copy.save!
1481 1489 end
1482 1490 assert_kind_of Issue, copy
1483 1491 assert_equal issue.project, copy.project
1484 1492 assert_equal "125", copy.custom_value_for(2).value
1485 1493 end
1486 1494
1487 1495 def test_copy_to_another_project_and_tracker
1488 1496 issue = Issue.find(1)
1489 1497 copy = issue.copy(:project_id => 3, :tracker_id => 2)
1490 1498 assert_difference 'Issue.count' do
1491 1499 copy.save!
1492 1500 end
1493 1501 copy.reload
1494 1502 assert_kind_of Issue, copy
1495 1503 assert_equal Project.find(3), copy.project
1496 1504 assert_equal Tracker.find(2), copy.tracker
1497 1505 # Custom field #2 is not associated with target tracker
1498 1506 assert_nil copy.custom_value_for(2)
1499 1507 end
1500 1508
1501 1509 test "#copy should not create a journal" do
1502 1510 copy = Issue.find(1).copy({:project_id => 3, :tracker_id => 2, :assigned_to_id => 3}, :link => false)
1503 1511 copy.save!
1504 1512 assert_equal 0, copy.reload.journals.size
1505 1513 end
1506 1514
1507 1515 test "#copy should allow assigned_to changes" do
1508 1516 copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2, :assigned_to_id => 3)
1509 1517 assert_equal 3, copy.assigned_to_id
1510 1518 end
1511 1519
1512 1520 test "#copy should allow status changes" do
1513 1521 copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2, :status_id => 2)
1514 1522 assert_equal 2, copy.status_id
1515 1523 end
1516 1524
1517 1525 test "#copy should allow start date changes" do
1518 1526 date = Date.today
1519 1527 copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2, :start_date => date)
1520 1528 assert_equal date, copy.start_date
1521 1529 end
1522 1530
1523 1531 test "#copy should allow due date changes" do
1524 1532 date = Date.today
1525 1533 copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2, :due_date => date)
1526 1534 assert_equal date, copy.due_date
1527 1535 end
1528 1536
1529 1537 test "#copy should set current user as author" do
1530 1538 User.current = User.find(9)
1531 1539 copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2)
1532 1540 assert_equal User.current, copy.author
1533 1541 end
1534 1542
1535 1543 test "#copy should create a journal with notes" do
1536 1544 date = Date.today
1537 1545 notes = "Notes added when copying"
1538 1546 copy = Issue.find(1).copy({:project_id => 3, :tracker_id => 2, :start_date => date}, :link => false)
1539 1547 copy.init_journal(User.current, notes)
1540 1548 copy.save!
1541 1549
1542 1550 assert_equal 1, copy.journals.size
1543 1551 journal = copy.journals.first
1544 1552 assert_equal 0, journal.details.size
1545 1553 assert_equal notes, journal.notes
1546 1554 end
1547 1555
1548 1556 def test_valid_parent_project
1549 1557 issue = Issue.find(1)
1550 1558 issue_in_same_project = Issue.find(2)
1551 1559 issue_in_child_project = Issue.find(5)
1552 1560 issue_in_grandchild_project = Issue.generate!(:project_id => 6, :tracker_id => 1)
1553 1561 issue_in_other_child_project = Issue.find(6)
1554 1562 issue_in_different_tree = Issue.find(4)
1555 1563
1556 1564 with_settings :cross_project_subtasks => '' do
1557 1565 assert_equal true, issue.valid_parent_project?(issue_in_same_project)
1558 1566 assert_equal false, issue.valid_parent_project?(issue_in_child_project)
1559 1567 assert_equal false, issue.valid_parent_project?(issue_in_grandchild_project)
1560 1568 assert_equal false, issue.valid_parent_project?(issue_in_different_tree)
1561 1569 end
1562 1570
1563 1571 with_settings :cross_project_subtasks => 'system' do
1564 1572 assert_equal true, issue.valid_parent_project?(issue_in_same_project)
1565 1573 assert_equal true, issue.valid_parent_project?(issue_in_child_project)
1566 1574 assert_equal true, issue.valid_parent_project?(issue_in_different_tree)
1567 1575 end
1568 1576
1569 1577 with_settings :cross_project_subtasks => 'tree' do
1570 1578 assert_equal true, issue.valid_parent_project?(issue_in_same_project)
1571 1579 assert_equal true, issue.valid_parent_project?(issue_in_child_project)
1572 1580 assert_equal true, issue.valid_parent_project?(issue_in_grandchild_project)
1573 1581 assert_equal false, issue.valid_parent_project?(issue_in_different_tree)
1574 1582
1575 1583 assert_equal true, issue_in_child_project.valid_parent_project?(issue_in_same_project)
1576 1584 assert_equal true, issue_in_child_project.valid_parent_project?(issue_in_other_child_project)
1577 1585 end
1578 1586
1579 1587 with_settings :cross_project_subtasks => 'descendants' do
1580 1588 assert_equal true, issue.valid_parent_project?(issue_in_same_project)
1581 1589 assert_equal false, issue.valid_parent_project?(issue_in_child_project)
1582 1590 assert_equal false, issue.valid_parent_project?(issue_in_grandchild_project)
1583 1591 assert_equal false, issue.valid_parent_project?(issue_in_different_tree)
1584 1592
1585 1593 assert_equal true, issue_in_child_project.valid_parent_project?(issue)
1586 1594 assert_equal false, issue_in_child_project.valid_parent_project?(issue_in_other_child_project)
1587 1595 end
1588 1596 end
1589 1597
1590 1598 def test_recipients_should_include_previous_assignee
1591 1599 user = User.find(3)
1592 1600 user.members.update_all ["mail_notification = ?", false]
1593 1601 user.update_attribute :mail_notification, 'only_assigned'
1594 1602
1595 1603 issue = Issue.find(2)
1596 1604 issue.assigned_to = nil
1597 1605 assert_include user.mail, issue.recipients
1598 1606 issue.save!
1599 1607 assert !issue.recipients.include?(user.mail)
1600 1608 end
1601 1609
1602 1610 def test_recipients_should_not_include_users_that_cannot_view_the_issue
1603 1611 issue = Issue.find(12)
1604 1612 assert issue.recipients.include?(issue.author.mail)
1605 1613 # copy the issue to a private project
1606 1614 copy = issue.copy(:project_id => 5, :tracker_id => 2)
1607 1615 # author is not a member of project anymore
1608 1616 assert !copy.recipients.include?(copy.author.mail)
1609 1617 end
1610 1618
1611 1619 def test_recipients_should_include_the_assigned_group_members
1612 1620 group_member = User.generate!
1613 1621 group = Group.generate!
1614 1622 group.users << group_member
1615 1623
1616 1624 issue = Issue.find(12)
1617 1625 issue.assigned_to = group
1618 1626 assert issue.recipients.include?(group_member.mail)
1619 1627 end
1620 1628
1621 1629 def test_watcher_recipients_should_not_include_users_that_cannot_view_the_issue
1622 1630 user = User.find(3)
1623 1631 issue = Issue.find(9)
1624 1632 Watcher.create!(:user => user, :watchable => issue)
1625 1633 assert issue.watched_by?(user)
1626 1634 assert !issue.watcher_recipients.include?(user.mail)
1627 1635 end
1628 1636
1629 1637 def test_issue_destroy
1630 1638 Issue.find(1).destroy
1631 1639 assert_nil Issue.find_by_id(1)
1632 1640 assert_nil TimeEntry.find_by_issue_id(1)
1633 1641 end
1634 1642
1635 1643 def test_destroy_should_delete_time_entries_custom_values
1636 1644 issue = Issue.generate!
1637 1645 time_entry = TimeEntry.generate!(:issue => issue, :custom_field_values => {10 => '1'})
1638 1646
1639 1647 assert_difference 'CustomValue.where(:customized_type => "TimeEntry").count', -1 do
1640 1648 assert issue.destroy
1641 1649 end
1642 1650 end
1643 1651
1644 1652 def test_destroying_a_deleted_issue_should_not_raise_an_error
1645 1653 issue = Issue.find(1)
1646 1654 Issue.find(1).destroy
1647 1655
1648 1656 assert_nothing_raised do
1649 1657 assert_no_difference 'Issue.count' do
1650 1658 issue.destroy
1651 1659 end
1652 1660 assert issue.destroyed?
1653 1661 end
1654 1662 end
1655 1663
1656 1664 def test_destroying_a_stale_issue_should_not_raise_an_error
1657 1665 issue = Issue.find(1)
1658 1666 Issue.find(1).update_attribute :subject, "Updated"
1659 1667
1660 1668 assert_nothing_raised do
1661 1669 assert_difference 'Issue.count', -1 do
1662 1670 issue.destroy
1663 1671 end
1664 1672 assert issue.destroyed?
1665 1673 end
1666 1674 end
1667 1675
1668 1676 def test_blocked
1669 1677 blocked_issue = Issue.find(9)
1670 1678 blocking_issue = Issue.find(10)
1671 1679
1672 1680 assert blocked_issue.blocked?
1673 1681 assert !blocking_issue.blocked?
1674 1682 end
1675 1683
1676 1684 def test_blocked_issues_dont_allow_closed_statuses
1677 1685 blocked_issue = Issue.find(9)
1678 1686
1679 1687 allowed_statuses = blocked_issue.new_statuses_allowed_to(users(:users_002))
1680 1688 assert !allowed_statuses.empty?
1681 1689 closed_statuses = allowed_statuses.select {|st| st.is_closed?}
1682 1690 assert closed_statuses.empty?
1683 1691 end
1684 1692
1685 1693 def test_unblocked_issues_allow_closed_statuses
1686 1694 blocking_issue = Issue.find(10)
1687 1695
1688 1696 allowed_statuses = blocking_issue.new_statuses_allowed_to(users(:users_002))
1689 1697 assert !allowed_statuses.empty?
1690 1698 closed_statuses = allowed_statuses.select {|st| st.is_closed?}
1691 1699 assert !closed_statuses.empty?
1692 1700 end
1693 1701
1694 1702 def test_reschedule_an_issue_without_dates
1695 1703 with_settings :non_working_week_days => [] do
1696 1704 issue = Issue.new(:start_date => nil, :due_date => nil)
1697 1705 issue.reschedule_on '2012-10-09'.to_date
1698 1706 assert_equal '2012-10-09'.to_date, issue.start_date
1699 1707 assert_equal '2012-10-09'.to_date, issue.due_date
1700 1708 end
1701 1709
1702 1710 with_settings :non_working_week_days => %w(6 7) do
1703 1711 issue = Issue.new(:start_date => nil, :due_date => nil)
1704 1712 issue.reschedule_on '2012-10-09'.to_date
1705 1713 assert_equal '2012-10-09'.to_date, issue.start_date
1706 1714 assert_equal '2012-10-09'.to_date, issue.due_date
1707 1715
1708 1716 issue = Issue.new(:start_date => nil, :due_date => nil)
1709 1717 issue.reschedule_on '2012-10-13'.to_date
1710 1718 assert_equal '2012-10-15'.to_date, issue.start_date
1711 1719 assert_equal '2012-10-15'.to_date, issue.due_date
1712 1720 end
1713 1721 end
1714 1722
1715 1723 def test_reschedule_an_issue_with_start_date
1716 1724 with_settings :non_working_week_days => [] do
1717 1725 issue = Issue.new(:start_date => '2012-10-09', :due_date => nil)
1718 1726 issue.reschedule_on '2012-10-13'.to_date
1719 1727 assert_equal '2012-10-13'.to_date, issue.start_date
1720 1728 assert_equal '2012-10-13'.to_date, issue.due_date
1721 1729 end
1722 1730
1723 1731 with_settings :non_working_week_days => %w(6 7) do
1724 1732 issue = Issue.new(:start_date => '2012-10-09', :due_date => nil)
1725 1733 issue.reschedule_on '2012-10-11'.to_date
1726 1734 assert_equal '2012-10-11'.to_date, issue.start_date
1727 1735 assert_equal '2012-10-11'.to_date, issue.due_date
1728 1736
1729 1737 issue = Issue.new(:start_date => '2012-10-09', :due_date => nil)
1730 1738 issue.reschedule_on '2012-10-13'.to_date
1731 1739 assert_equal '2012-10-15'.to_date, issue.start_date
1732 1740 assert_equal '2012-10-15'.to_date, issue.due_date
1733 1741 end
1734 1742 end
1735 1743
1736 1744 def test_reschedule_an_issue_with_start_and_due_dates
1737 1745 with_settings :non_working_week_days => [] do
1738 1746 issue = Issue.new(:start_date => '2012-10-09', :due_date => '2012-10-15')
1739 1747 issue.reschedule_on '2012-10-13'.to_date
1740 1748 assert_equal '2012-10-13'.to_date, issue.start_date
1741 1749 assert_equal '2012-10-19'.to_date, issue.due_date
1742 1750 end
1743 1751
1744 1752 with_settings :non_working_week_days => %w(6 7) do
1745 1753 issue = Issue.new(:start_date => '2012-10-09', :due_date => '2012-10-19') # 8 working days
1746 1754 issue.reschedule_on '2012-10-11'.to_date
1747 1755 assert_equal '2012-10-11'.to_date, issue.start_date
1748 1756 assert_equal '2012-10-23'.to_date, issue.due_date
1749 1757
1750 1758 issue = Issue.new(:start_date => '2012-10-09', :due_date => '2012-10-19')
1751 1759 issue.reschedule_on '2012-10-13'.to_date
1752 1760 assert_equal '2012-10-15'.to_date, issue.start_date
1753 1761 assert_equal '2012-10-25'.to_date, issue.due_date
1754 1762 end
1755 1763 end
1756 1764
1757 1765 def test_rescheduling_an_issue_to_a_later_due_date_should_reschedule_following_issue
1758 1766 issue1 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
1759 1767 issue2 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
1760 1768 IssueRelation.create!(:issue_from => issue1, :issue_to => issue2,
1761 1769 :relation_type => IssueRelation::TYPE_PRECEDES)
1762 1770 assert_equal Date.parse('2012-10-18'), issue2.reload.start_date
1763 1771
1764 1772 issue1.reload
1765 1773 issue1.due_date = '2012-10-23'
1766 1774 issue1.save!
1767 1775 issue2.reload
1768 1776 assert_equal Date.parse('2012-10-24'), issue2.start_date
1769 1777 assert_equal Date.parse('2012-10-26'), issue2.due_date
1770 1778 end
1771 1779
1772 1780 def test_rescheduling_an_issue_to_an_earlier_due_date_should_reschedule_following_issue
1773 1781 issue1 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
1774 1782 issue2 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
1775 1783 IssueRelation.create!(:issue_from => issue1, :issue_to => issue2,
1776 1784 :relation_type => IssueRelation::TYPE_PRECEDES)
1777 1785 assert_equal Date.parse('2012-10-18'), issue2.reload.start_date
1778 1786
1779 1787 issue1.reload
1780 1788 issue1.start_date = '2012-09-17'
1781 1789 issue1.due_date = '2012-09-18'
1782 1790 issue1.save!
1783 1791 issue2.reload
1784 1792 assert_equal Date.parse('2012-09-19'), issue2.start_date
1785 1793 assert_equal Date.parse('2012-09-21'), issue2.due_date
1786 1794 end
1787 1795
1788 1796 def test_rescheduling_reschedule_following_issue_earlier_should_consider_other_preceding_issues
1789 1797 issue1 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
1790 1798 issue2 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
1791 1799 issue3 = Issue.generate!(:start_date => '2012-10-01', :due_date => '2012-10-02')
1792 1800 IssueRelation.create!(:issue_from => issue1, :issue_to => issue2,
1793 1801 :relation_type => IssueRelation::TYPE_PRECEDES)
1794 1802 IssueRelation.create!(:issue_from => issue3, :issue_to => issue2,
1795 1803 :relation_type => IssueRelation::TYPE_PRECEDES)
1796 1804 assert_equal Date.parse('2012-10-18'), issue2.reload.start_date
1797 1805
1798 1806 issue1.reload
1799 1807 issue1.start_date = '2012-09-17'
1800 1808 issue1.due_date = '2012-09-18'
1801 1809 issue1.save!
1802 1810 issue2.reload
1803 1811 # Issue 2 must start after Issue 3
1804 1812 assert_equal Date.parse('2012-10-03'), issue2.start_date
1805 1813 assert_equal Date.parse('2012-10-05'), issue2.due_date
1806 1814 end
1807 1815
1808 1816 def test_rescheduling_a_stale_issue_should_not_raise_an_error
1809 1817 with_settings :non_working_week_days => [] do
1810 1818 stale = Issue.find(1)
1811 1819 issue = Issue.find(1)
1812 1820 issue.subject = "Updated"
1813 1821 issue.save!
1814 1822 date = 10.days.from_now.to_date
1815 1823 assert_nothing_raised do
1816 1824 stale.reschedule_on!(date)
1817 1825 end
1818 1826 assert_equal date, stale.reload.start_date
1819 1827 end
1820 1828 end
1821 1829
1822 1830 def test_child_issue_should_consider_parent_soonest_start_on_create
1823 1831 set_language_if_valid 'en'
1824 1832 issue1 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
1825 1833 issue2 = Issue.generate!(:start_date => '2012-10-18', :due_date => '2012-10-20')
1826 1834 IssueRelation.create!(:issue_from => issue1, :issue_to => issue2,
1827 1835 :relation_type => IssueRelation::TYPE_PRECEDES)
1828 1836 issue1.reload
1829 1837 issue2.reload
1830 1838 assert_equal Date.parse('2012-10-18'), issue2.start_date
1831 1839
1832 1840 with_settings :date_format => '%m/%d/%Y' do
1833 1841 child = Issue.new(:parent_issue_id => issue2.id, :start_date => '2012-10-16',
1834 1842 :project_id => 1, :tracker_id => 1, :status_id => 1, :subject => 'Child', :author_id => 1)
1835 1843 assert !child.valid?
1836 1844 assert_include 'Start date cannot be earlier than 10/18/2012 because of preceding issues', child.errors.full_messages
1837 1845 assert_equal Date.parse('2012-10-18'), child.soonest_start
1838 1846 child.start_date = '2012-10-18'
1839 1847 assert child.save
1840 1848 end
1841 1849 end
1842 1850
1843 1851 def test_setting_parent_to_a_dependent_issue_should_not_validate
1844 1852 set_language_if_valid 'en'
1845 1853 issue1 = Issue.generate!
1846 1854 issue2 = Issue.generate!
1847 1855 issue3 = Issue.generate!
1848 1856 IssueRelation.create!(:issue_from => issue1, :issue_to => issue2, :relation_type => IssueRelation::TYPE_PRECEDES)
1849 1857 IssueRelation.create!(:issue_from => issue3, :issue_to => issue1, :relation_type => IssueRelation::TYPE_PRECEDES)
1850 1858 issue3.reload
1851 1859 issue3.parent_issue_id = issue2.id
1852 1860 assert !issue3.valid?
1853 1861 assert_include 'Parent task is invalid', issue3.errors.full_messages
1854 1862 end
1855 1863
1856 1864 def test_setting_parent_should_not_allow_circular_dependency
1857 1865 set_language_if_valid 'en'
1858 1866 issue1 = Issue.generate!
1859 1867 issue2 = Issue.generate!
1860 1868 IssueRelation.create!(:issue_from => issue1, :issue_to => issue2, :relation_type => IssueRelation::TYPE_PRECEDES)
1861 1869 issue3 = Issue.generate!
1862 1870 issue2.reload
1863 1871 issue2.parent_issue_id = issue3.id
1864 1872 issue2.save!
1865 1873 issue4 = Issue.generate!
1866 1874 IssueRelation.create!(:issue_from => issue3, :issue_to => issue4, :relation_type => IssueRelation::TYPE_PRECEDES)
1867 1875 issue4.reload
1868 1876 issue4.parent_issue_id = issue1.id
1869 1877 assert !issue4.valid?
1870 1878 assert_include 'Parent task is invalid', issue4.errors.full_messages
1871 1879 end
1872 1880
1873 1881 def test_overdue
1874 1882 assert Issue.new(:due_date => 1.day.ago.to_date).overdue?
1875 1883 assert !Issue.new(:due_date => Date.today).overdue?
1876 1884 assert !Issue.new(:due_date => 1.day.from_now.to_date).overdue?
1877 1885 assert !Issue.new(:due_date => nil).overdue?
1878 1886 assert !Issue.new(:due_date => 1.day.ago.to_date,
1879 1887 :status => IssueStatus.where(:is_closed => true).first
1880 1888 ).overdue?
1881 1889 end
1882 1890
1883 1891 test "#behind_schedule? should be false if the issue has no start_date" do
1884 1892 assert !Issue.new(:start_date => nil,
1885 1893 :due_date => 1.day.from_now.to_date,
1886 1894 :done_ratio => 0).behind_schedule?
1887 1895 end
1888 1896
1889 1897 test "#behind_schedule? should be false if the issue has no end_date" do
1890 1898 assert !Issue.new(:start_date => 1.day.from_now.to_date,
1891 1899 :due_date => nil,
1892 1900 :done_ratio => 0).behind_schedule?
1893 1901 end
1894 1902
1895 1903 test "#behind_schedule? should be false if the issue has more done than it's calendar time" do
1896 1904 assert !Issue.new(:start_date => 50.days.ago.to_date,
1897 1905 :due_date => 50.days.from_now.to_date,
1898 1906 :done_ratio => 90).behind_schedule?
1899 1907 end
1900 1908
1901 1909 test "#behind_schedule? should be true if the issue hasn't been started at all" do
1902 1910 assert Issue.new(:start_date => 1.day.ago.to_date,
1903 1911 :due_date => 1.day.from_now.to_date,
1904 1912 :done_ratio => 0).behind_schedule?
1905 1913 end
1906 1914
1907 1915 test "#behind_schedule? should be true if the issue has used more calendar time than it's done ratio" do
1908 1916 assert Issue.new(:start_date => 100.days.ago.to_date,
1909 1917 :due_date => Date.today,
1910 1918 :done_ratio => 90).behind_schedule?
1911 1919 end
1912 1920
1913 1921 test "#assignable_users should be Users" do
1914 1922 assert_kind_of User, Issue.find(1).assignable_users.first
1915 1923 end
1916 1924
1917 1925 test "#assignable_users should include the issue author" do
1918 1926 non_project_member = User.generate!
1919 1927 issue = Issue.generate!(:author => non_project_member)
1920 1928
1921 1929 assert issue.assignable_users.include?(non_project_member)
1922 1930 end
1923 1931
1924 1932 test "#assignable_users should include the current assignee" do
1925 1933 user = User.generate!
1926 1934 issue = Issue.generate!(:assigned_to => user)
1927 1935 user.lock!
1928 1936
1929 1937 assert Issue.find(issue.id).assignable_users.include?(user)
1930 1938 end
1931 1939
1932 1940 test "#assignable_users should not show the issue author twice" do
1933 1941 assignable_user_ids = Issue.find(1).assignable_users.collect(&:id)
1934 1942 assert_equal 2, assignable_user_ids.length
1935 1943
1936 1944 assignable_user_ids.each do |user_id|
1937 1945 assert_equal 1, assignable_user_ids.select {|i| i == user_id}.length,
1938 1946 "User #{user_id} appears more or less than once"
1939 1947 end
1940 1948 end
1941 1949
1942 1950 test "#assignable_users with issue_group_assignment should include groups" do
1943 1951 issue = Issue.new(:project => Project.find(2))
1944 1952
1945 1953 with_settings :issue_group_assignment => '1' do
1946 1954 assert_equal %w(Group User), issue.assignable_users.map {|a| a.class.name}.uniq.sort
1947 1955 assert issue.assignable_users.include?(Group.find(11))
1948 1956 end
1949 1957 end
1950 1958
1951 1959 test "#assignable_users without issue_group_assignment should not include groups" do
1952 1960 issue = Issue.new(:project => Project.find(2))
1953 1961
1954 1962 with_settings :issue_group_assignment => '0' do
1955 1963 assert_equal %w(User), issue.assignable_users.map {|a| a.class.name}.uniq.sort
1956 1964 assert !issue.assignable_users.include?(Group.find(11))
1957 1965 end
1958 1966 end
1959 1967
1960 1968 def test_assignable_users_should_not_include_builtin_groups
1961 1969 Member.create!(:project_id => 1, :principal => Group.non_member, :role_ids => [1])
1962 1970 Member.create!(:project_id => 1, :principal => Group.anonymous, :role_ids => [1])
1963 1971 issue = Issue.new(:project => Project.find(1))
1964 1972
1965 1973 with_settings :issue_group_assignment => '1' do
1966 1974 assert_nil issue.assignable_users.detect {|u| u.is_a?(GroupBuiltin)}
1967 1975 end
1968 1976 end
1969 1977
1970 1978 def test_create_should_send_email_notification
1971 1979 ActionMailer::Base.deliveries.clear
1972 1980 issue = Issue.new(:project_id => 1, :tracker_id => 1,
1973 1981 :author_id => 3, :status_id => 1,
1974 1982 :priority => IssuePriority.all.first,
1975 1983 :subject => 'test_create', :estimated_hours => '1:30')
1976 1984 with_settings :notified_events => %w(issue_added) do
1977 1985 assert issue.save
1978 1986 assert_equal 1, ActionMailer::Base.deliveries.size
1979 1987 end
1980 1988 end
1981 1989
1982 1990 def test_create_should_send_one_email_notification_with_both_settings
1983 1991 ActionMailer::Base.deliveries.clear
1984 1992 issue = Issue.new(:project_id => 1, :tracker_id => 1,
1985 1993 :author_id => 3, :status_id => 1,
1986 1994 :priority => IssuePriority.all.first,
1987 1995 :subject => 'test_create', :estimated_hours => '1:30')
1988 1996 with_settings :notified_events => %w(issue_added issue_updated) do
1989 1997 assert issue.save
1990 1998 assert_equal 1, ActionMailer::Base.deliveries.size
1991 1999 end
1992 2000 end
1993 2001
1994 2002 def test_create_should_not_send_email_notification_with_no_setting
1995 2003 ActionMailer::Base.deliveries.clear
1996 2004 issue = Issue.new(:project_id => 1, :tracker_id => 1,
1997 2005 :author_id => 3, :status_id => 1,
1998 2006 :priority => IssuePriority.all.first,
1999 2007 :subject => 'test_create', :estimated_hours => '1:30')
2000 2008 with_settings :notified_events => [] do
2001 2009 assert issue.save
2002 2010 assert_equal 0, ActionMailer::Base.deliveries.size
2003 2011 end
2004 2012 end
2005 2013
2006 2014 def test_update_should_notify_previous_assignee
2007 2015 ActionMailer::Base.deliveries.clear
2008 2016 user = User.find(3)
2009 2017 user.members.update_all ["mail_notification = ?", false]
2010 2018 user.update_attribute :mail_notification, 'only_assigned'
2011 2019
2012 2020 with_settings :notified_events => %w(issue_updated) do
2013 2021 issue = Issue.find(2)
2014 2022 issue.init_journal User.find(1)
2015 2023 issue.assigned_to = nil
2016 2024 issue.save!
2017 2025 assert_include user.mail, ActionMailer::Base.deliveries.last.bcc
2018 2026 end
2019 2027 end
2020 2028
2021 2029 def test_stale_issue_should_not_send_email_notification
2022 2030 ActionMailer::Base.deliveries.clear
2023 2031 issue = Issue.find(1)
2024 2032 stale = Issue.find(1)
2025 2033
2026 2034 issue.init_journal(User.find(1))
2027 2035 issue.subject = 'Subjet update'
2028 2036 with_settings :notified_events => %w(issue_updated) do
2029 2037 assert issue.save
2030 2038 assert_equal 1, ActionMailer::Base.deliveries.size
2031 2039 ActionMailer::Base.deliveries.clear
2032 2040
2033 2041 stale.init_journal(User.find(1))
2034 2042 stale.subject = 'Another subjet update'
2035 2043 assert_raise ActiveRecord::StaleObjectError do
2036 2044 stale.save
2037 2045 end
2038 2046 assert ActionMailer::Base.deliveries.empty?
2039 2047 end
2040 2048 end
2041 2049
2042 2050 def test_journalized_description
2043 2051 IssueCustomField.delete_all
2044 2052
2045 2053 i = Issue.first
2046 2054 old_description = i.description
2047 2055 new_description = "This is the new description"
2048 2056
2049 2057 i.init_journal(User.find(2))
2050 2058 i.description = new_description
2051 2059 assert_difference 'Journal.count', 1 do
2052 2060 assert_difference 'JournalDetail.count', 1 do
2053 2061 i.save!
2054 2062 end
2055 2063 end
2056 2064
2057 2065 detail = JournalDetail.order('id DESC').first
2058 2066 assert_equal i, detail.journal.journalized
2059 2067 assert_equal 'attr', detail.property
2060 2068 assert_equal 'description', detail.prop_key
2061 2069 assert_equal old_description, detail.old_value
2062 2070 assert_equal new_description, detail.value
2063 2071 end
2064 2072
2065 2073 def test_blank_descriptions_should_not_be_journalized
2066 2074 IssueCustomField.delete_all
2067 2075 Issue.where(:id => 1).update_all("description = NULL")
2068 2076
2069 2077 i = Issue.find(1)
2070 2078 i.init_journal(User.find(2))
2071 2079 i.subject = "blank description"
2072 2080 i.description = "\r\n"
2073 2081
2074 2082 assert_difference 'Journal.count', 1 do
2075 2083 assert_difference 'JournalDetail.count', 1 do
2076 2084 i.save!
2077 2085 end
2078 2086 end
2079 2087 end
2080 2088
2081 2089 def test_journalized_multi_custom_field
2082 2090 field = IssueCustomField.create!(:name => 'filter', :field_format => 'list',
2083 2091 :is_filter => true, :is_for_all => true,
2084 2092 :tracker_ids => [1],
2085 2093 :possible_values => ['value1', 'value2', 'value3'],
2086 2094 :multiple => true)
2087 2095
2088 2096 issue = Issue.create!(:project_id => 1, :tracker_id => 1,
2089 2097 :subject => 'Test', :author_id => 1)
2090 2098
2091 2099 assert_difference 'Journal.count' do
2092 2100 assert_difference 'JournalDetail.count' do
2093 2101 issue.init_journal(User.first)
2094 2102 issue.custom_field_values = {field.id => ['value1']}
2095 2103 issue.save!
2096 2104 end
2097 2105 assert_difference 'JournalDetail.count' do
2098 2106 issue.init_journal(User.first)
2099 2107 issue.custom_field_values = {field.id => ['value1', 'value2']}
2100 2108 issue.save!
2101 2109 end
2102 2110 assert_difference 'JournalDetail.count', 2 do
2103 2111 issue.init_journal(User.first)
2104 2112 issue.custom_field_values = {field.id => ['value3', 'value2']}
2105 2113 issue.save!
2106 2114 end
2107 2115 assert_difference 'JournalDetail.count', 2 do
2108 2116 issue.init_journal(User.first)
2109 2117 issue.custom_field_values = {field.id => nil}
2110 2118 issue.save!
2111 2119 end
2112 2120 end
2113 2121 end
2114 2122
2115 2123 def test_description_eol_should_be_normalized
2116 2124 i = Issue.new(:description => "CR \r LF \n CRLF \r\n")
2117 2125 assert_equal "CR \r\n LF \r\n CRLF \r\n", i.description
2118 2126 end
2119 2127
2120 2128 def test_saving_twice_should_not_duplicate_journal_details
2121 2129 i = Issue.first
2122 2130 i.init_journal(User.find(2), 'Some notes')
2123 2131 # initial changes
2124 2132 i.subject = 'New subject'
2125 2133 i.done_ratio = i.done_ratio + 10
2126 2134 assert_difference 'Journal.count' do
2127 2135 assert i.save
2128 2136 end
2129 2137 # 1 more change
2130 2138 i.priority = IssuePriority.where("id <> ?", i.priority_id).first
2131 2139 assert_no_difference 'Journal.count' do
2132 2140 assert_difference 'JournalDetail.count', 1 do
2133 2141 i.save
2134 2142 end
2135 2143 end
2136 2144 # no more change
2137 2145 assert_no_difference 'Journal.count' do
2138 2146 assert_no_difference 'JournalDetail.count' do
2139 2147 i.save
2140 2148 end
2141 2149 end
2142 2150 end
2143 2151
2144 2152 def test_all_dependent_issues
2145 2153 IssueRelation.delete_all
2146 2154 assert IssueRelation.create!(:issue_from => Issue.find(1),
2147 2155 :issue_to => Issue.find(2),
2148 2156 :relation_type => IssueRelation::TYPE_PRECEDES)
2149 2157 assert IssueRelation.create!(:issue_from => Issue.find(2),
2150 2158 :issue_to => Issue.find(3),
2151 2159 :relation_type => IssueRelation::TYPE_PRECEDES)
2152 2160 assert IssueRelation.create!(:issue_from => Issue.find(3),
2153 2161 :issue_to => Issue.find(8),
2154 2162 :relation_type => IssueRelation::TYPE_PRECEDES)
2155 2163
2156 2164 assert_equal [2, 3, 8], Issue.find(1).all_dependent_issues.collect(&:id).sort
2157 2165 end
2158 2166
2159 2167 def test_all_dependent_issues_with_subtask
2160 2168 IssueRelation.delete_all
2161 2169
2162 2170 project = Project.generate!(:name => "testproject")
2163 2171
2164 2172 parentIssue = Issue.generate!(:project => project)
2165 2173 childIssue1 = Issue.generate!(:project => project, :parent_issue_id => parentIssue.id)
2166 2174 childIssue2 = Issue.generate!(:project => project, :parent_issue_id => parentIssue.id)
2167 2175
2168 2176 assert_equal [childIssue1.id, childIssue2.id].sort, parentIssue.all_dependent_issues.collect(&:id).uniq.sort
2169 2177 end
2170 2178
2171 2179 def test_all_dependent_issues_does_not_include_self
2172 2180 IssueRelation.delete_all
2173 2181
2174 2182 project = Project.generate!(:name => "testproject")
2175 2183
2176 2184 parentIssue = Issue.generate!(:project => project)
2177 2185 childIssue = Issue.generate!(:project => project, :parent_issue_id => parentIssue.id)
2178 2186
2179 2187 assert_equal [childIssue.id], parentIssue.all_dependent_issues.collect(&:id)
2180 2188 end
2181 2189
2182 2190 def test_all_dependent_issues_with_parenttask_and_sibling
2183 2191 IssueRelation.delete_all
2184 2192
2185 2193 project = Project.generate!(:name => "testproject")
2186 2194
2187 2195 parentIssue = Issue.generate!(:project => project)
2188 2196 childIssue1 = Issue.generate!(:project => project, :parent_issue_id => parentIssue.id)
2189 2197 childIssue2 = Issue.generate!(:project => project, :parent_issue_id => parentIssue.id)
2190 2198
2191 2199 assert_equal [parentIssue.id].sort, childIssue1.all_dependent_issues.collect(&:id)
2192 2200 end
2193 2201
2194 2202 def test_all_dependent_issues_with_relation_to_leaf_in_other_tree
2195 2203 IssueRelation.delete_all
2196 2204
2197 2205 project = Project.generate!(:name => "testproject")
2198 2206
2199 2207 parentIssue1 = Issue.generate!(:project => project)
2200 2208 childIssue1_1 = Issue.generate!(:project => project, :parent_issue_id => parentIssue1.id)
2201 2209 childIssue1_2 = Issue.generate!(:project => project, :parent_issue_id => parentIssue1.id)
2202 2210
2203 2211 parentIssue2 = Issue.generate!(:project => project)
2204 2212 childIssue2_1 = Issue.generate!(:project => project, :parent_issue_id => parentIssue2.id)
2205 2213 childIssue2_2 = Issue.generate!(:project => project, :parent_issue_id => parentIssue2.id)
2206 2214
2207 2215
2208 2216 assert IssueRelation.create(:issue_from => parentIssue1,
2209 2217 :issue_to => childIssue2_2,
2210 2218 :relation_type => IssueRelation::TYPE_BLOCKS)
2211 2219
2212 2220 assert_equal [childIssue1_1.id, childIssue1_2.id, parentIssue2.id, childIssue2_2.id].sort,
2213 2221 parentIssue1.all_dependent_issues.collect(&:id).uniq.sort
2214 2222 end
2215 2223
2216 2224 def test_all_dependent_issues_with_relation_to_parent_in_other_tree
2217 2225 IssueRelation.delete_all
2218 2226
2219 2227 project = Project.generate!(:name => "testproject")
2220 2228
2221 2229 parentIssue1 = Issue.generate!(:project => project)
2222 2230 childIssue1_1 = Issue.generate!(:project => project, :parent_issue_id => parentIssue1.id)
2223 2231 childIssue1_2 = Issue.generate!(:project => project, :parent_issue_id => parentIssue1.id)
2224 2232
2225 2233 parentIssue2 = Issue.generate!(:project => project)
2226 2234 childIssue2_1 = Issue.generate!(:project => project, :parent_issue_id => parentIssue2.id)
2227 2235 childIssue2_2 = Issue.generate!(:project => project, :parent_issue_id => parentIssue2.id)
2228 2236
2229 2237
2230 2238 assert IssueRelation.create(:issue_from => parentIssue1,
2231 2239 :issue_to => parentIssue2,
2232 2240 :relation_type => IssueRelation::TYPE_BLOCKS)
2233 2241
2234 2242 assert_equal [childIssue1_1.id, childIssue1_2.id, parentIssue2.id, childIssue2_1.id, childIssue2_2.id].sort,
2235 2243 parentIssue1.all_dependent_issues.collect(&:id).uniq.sort
2236 2244 end
2237 2245
2238 2246 def test_all_dependent_issues_with_transitive_relation
2239 2247 IssueRelation.delete_all
2240 2248
2241 2249 project = Project.generate!(:name => "testproject")
2242 2250
2243 2251 parentIssue1 = Issue.generate!(:project => project)
2244 2252 childIssue1_1 = Issue.generate!(:project => project, :parent_issue_id => parentIssue1.id)
2245 2253
2246 2254 parentIssue2 = Issue.generate!(:project => project)
2247 2255 childIssue2_1 = Issue.generate!(:project => project, :parent_issue_id => parentIssue2.id)
2248 2256
2249 2257 independentIssue = Issue.generate!(:project => project)
2250 2258
2251 2259 assert IssueRelation.create(:issue_from => parentIssue1,
2252 2260 :issue_to => childIssue2_1,
2253 2261 :relation_type => IssueRelation::TYPE_RELATES)
2254 2262
2255 2263 assert IssueRelation.create(:issue_from => childIssue2_1,
2256 2264 :issue_to => independentIssue,
2257 2265 :relation_type => IssueRelation::TYPE_RELATES)
2258 2266
2259 2267 assert_equal [childIssue1_1.id, parentIssue2.id, childIssue2_1.id, independentIssue.id].sort,
2260 2268 parentIssue1.all_dependent_issues.collect(&:id).uniq.sort
2261 2269 end
2262 2270
2263 2271 def test_all_dependent_issues_with_transitive_relation2
2264 2272 IssueRelation.delete_all
2265 2273
2266 2274 project = Project.generate!(:name => "testproject")
2267 2275
2268 2276 parentIssue1 = Issue.generate!(:project => project)
2269 2277 childIssue1_1 = Issue.generate!(:project => project, :parent_issue_id => parentIssue1.id)
2270 2278
2271 2279 parentIssue2 = Issue.generate!(:project => project)
2272 2280 childIssue2_1 = Issue.generate!(:project => project, :parent_issue_id => parentIssue2.id)
2273 2281
2274 2282 independentIssue = Issue.generate!(:project => project)
2275 2283
2276 2284 assert IssueRelation.create(:issue_from => parentIssue1,
2277 2285 :issue_to => independentIssue,
2278 2286 :relation_type => IssueRelation::TYPE_RELATES)
2279 2287
2280 2288 assert IssueRelation.create(:issue_from => independentIssue,
2281 2289 :issue_to => childIssue2_1,
2282 2290 :relation_type => IssueRelation::TYPE_RELATES)
2283 2291
2284 2292 assert_equal [childIssue1_1.id, parentIssue2.id, childIssue2_1.id, independentIssue.id].sort,
2285 2293 parentIssue1.all_dependent_issues.collect(&:id).uniq.sort
2286 2294
2287 2295 end
2288 2296
2289 2297 def test_all_dependent_issues_with_persistent_circular_dependency
2290 2298 IssueRelation.delete_all
2291 2299 assert IssueRelation.create!(:issue_from => Issue.find(1),
2292 2300 :issue_to => Issue.find(2),
2293 2301 :relation_type => IssueRelation::TYPE_PRECEDES)
2294 2302 assert IssueRelation.create!(:issue_from => Issue.find(2),
2295 2303 :issue_to => Issue.find(3),
2296 2304 :relation_type => IssueRelation::TYPE_PRECEDES)
2297 2305
2298 2306 r = IssueRelation.create!(:issue_from => Issue.find(3),
2299 2307 :issue_to => Issue.find(7),
2300 2308 :relation_type => IssueRelation::TYPE_PRECEDES)
2301 2309 IssueRelation.where(["id = ?", r.id]).update_all("issue_to_id = 1")
2302 2310
2303 2311 assert_equal [2, 3], Issue.find(1).all_dependent_issues.collect(&:id).sort
2304 2312 end
2305 2313
2306 2314 def test_all_dependent_issues_with_persistent_multiple_circular_dependencies
2307 2315 IssueRelation.delete_all
2308 2316 assert IssueRelation.create!(:issue_from => Issue.find(1),
2309 2317 :issue_to => Issue.find(2),
2310 2318 :relation_type => IssueRelation::TYPE_RELATES)
2311 2319 assert IssueRelation.create!(:issue_from => Issue.find(2),
2312 2320 :issue_to => Issue.find(3),
2313 2321 :relation_type => IssueRelation::TYPE_RELATES)
2314 2322 assert IssueRelation.create!(:issue_from => Issue.find(3),
2315 2323 :issue_to => Issue.find(8),
2316 2324 :relation_type => IssueRelation::TYPE_RELATES)
2317 2325
2318 2326 r = IssueRelation.create!(:issue_from => Issue.find(8),
2319 2327 :issue_to => Issue.find(7),
2320 2328 :relation_type => IssueRelation::TYPE_RELATES)
2321 2329 IssueRelation.where(["id = ?", r.id]).update_all("issue_to_id = 2")
2322 2330
2323 2331 r = IssueRelation.create!(:issue_from => Issue.find(3),
2324 2332 :issue_to => Issue.find(7),
2325 2333 :relation_type => IssueRelation::TYPE_RELATES)
2326 2334 IssueRelation.where(["id = ?", r.id]).update_all("issue_to_id = 1")
2327 2335
2328 2336 assert_equal [2, 3, 8], Issue.find(1).all_dependent_issues.collect(&:id).sort
2329 2337 end
2330 2338
2331 2339 test "#done_ratio should use the issue_status according to Setting.issue_done_ratio" do
2332 2340 @issue = Issue.find(1)
2333 2341 @issue_status = IssueStatus.find(1)
2334 2342 @issue_status.update_attribute(:default_done_ratio, 50)
2335 2343 @issue2 = Issue.find(2)
2336 2344 @issue_status2 = IssueStatus.find(2)
2337 2345 @issue_status2.update_attribute(:default_done_ratio, 0)
2338 2346
2339 2347 with_settings :issue_done_ratio => 'issue_field' do
2340 2348 assert_equal 0, @issue.done_ratio
2341 2349 assert_equal 30, @issue2.done_ratio
2342 2350 end
2343 2351
2344 2352 with_settings :issue_done_ratio => 'issue_status' do
2345 2353 assert_equal 50, @issue.done_ratio
2346 2354 assert_equal 0, @issue2.done_ratio
2347 2355 end
2348 2356 end
2349 2357
2350 2358 test "#update_done_ratio_from_issue_status should update done_ratio according to Setting.issue_done_ratio" do
2351 2359 @issue = Issue.find(1)
2352 2360 @issue_status = IssueStatus.find(1)
2353 2361 @issue_status.update_attribute(:default_done_ratio, 50)
2354 2362 @issue2 = Issue.find(2)
2355 2363 @issue_status2 = IssueStatus.find(2)
2356 2364 @issue_status2.update_attribute(:default_done_ratio, 0)
2357 2365
2358 2366 with_settings :issue_done_ratio => 'issue_field' do
2359 2367 @issue.update_done_ratio_from_issue_status
2360 2368 @issue2.update_done_ratio_from_issue_status
2361 2369
2362 2370 assert_equal 0, @issue.read_attribute(:done_ratio)
2363 2371 assert_equal 30, @issue2.read_attribute(:done_ratio)
2364 2372 end
2365 2373
2366 2374 with_settings :issue_done_ratio => 'issue_status' do
2367 2375 @issue.update_done_ratio_from_issue_status
2368 2376 @issue2.update_done_ratio_from_issue_status
2369 2377
2370 2378 assert_equal 50, @issue.read_attribute(:done_ratio)
2371 2379 assert_equal 0, @issue2.read_attribute(:done_ratio)
2372 2380 end
2373 2381 end
2374 2382
2375 2383 test "#by_tracker" do
2376 2384 User.current = User.anonymous
2377 2385 groups = Issue.by_tracker(Project.find(1))
2378 2386 assert_equal 3, groups.count
2379 2387 assert_equal 7, groups.inject(0) {|sum, group| sum + group['total'].to_i}
2380 2388 end
2381 2389
2382 2390 test "#by_version" do
2383 2391 User.current = User.anonymous
2384 2392 groups = Issue.by_version(Project.find(1))
2385 2393 assert_equal 3, groups.count
2386 2394 assert_equal 3, groups.inject(0) {|sum, group| sum + group['total'].to_i}
2387 2395 end
2388 2396
2389 2397 test "#by_priority" do
2390 2398 User.current = User.anonymous
2391 2399 groups = Issue.by_priority(Project.find(1))
2392 2400 assert_equal 4, groups.count
2393 2401 assert_equal 7, groups.inject(0) {|sum, group| sum + group['total'].to_i}
2394 2402 end
2395 2403
2396 2404 test "#by_category" do
2397 2405 User.current = User.anonymous
2398 2406 groups = Issue.by_category(Project.find(1))
2399 2407 assert_equal 2, groups.count
2400 2408 assert_equal 3, groups.inject(0) {|sum, group| sum + group['total'].to_i}
2401 2409 end
2402 2410
2403 2411 test "#by_assigned_to" do
2404 2412 User.current = User.anonymous
2405 2413 groups = Issue.by_assigned_to(Project.find(1))
2406 2414 assert_equal 2, groups.count
2407 2415 assert_equal 2, groups.inject(0) {|sum, group| sum + group['total'].to_i}
2408 2416 end
2409 2417
2410 2418 test "#by_author" do
2411 2419 User.current = User.anonymous
2412 2420 groups = Issue.by_author(Project.find(1))
2413 2421 assert_equal 4, groups.count
2414 2422 assert_equal 7, groups.inject(0) {|sum, group| sum + group['total'].to_i}
2415 2423 end
2416 2424
2417 2425 test "#by_subproject" do
2418 2426 User.current = User.anonymous
2419 2427 groups = Issue.by_subproject(Project.find(1))
2420 2428 # Private descendant not visible
2421 2429 assert_equal 1, groups.count
2422 2430 assert_equal 2, groups.inject(0) {|sum, group| sum + group['total'].to_i}
2423 2431 end
2424 2432
2425 2433 def test_recently_updated_scope
2426 2434 #should return the last updated issue
2427 2435 assert_equal Issue.reorder("updated_on DESC").first, Issue.recently_updated.limit(1).first
2428 2436 end
2429 2437
2430 2438 def test_on_active_projects_scope
2431 2439 assert Project.find(2).archive
2432 2440
2433 2441 before = Issue.on_active_project.length
2434 2442 # test inclusion to results
2435 2443 issue = Issue.generate!(:tracker => Project.find(2).trackers.first)
2436 2444 assert_equal before + 1, Issue.on_active_project.length
2437 2445
2438 2446 # Move to an archived project
2439 2447 issue.project = Project.find(2)
2440 2448 assert issue.save
2441 2449 assert_equal before, Issue.on_active_project.length
2442 2450 end
2443 2451
2444 2452 test "Issue#recipients should include project recipients" do
2445 2453 issue = Issue.generate!
2446 2454 assert issue.project.recipients.present?
2447 2455 issue.project.recipients.each do |project_recipient|
2448 2456 assert issue.recipients.include?(project_recipient)
2449 2457 end
2450 2458 end
2451 2459
2452 2460 test "Issue#recipients should include the author if the author is active" do
2453 2461 issue = Issue.generate!(:author => User.generate!)
2454 2462 assert issue.author, "No author set for Issue"
2455 2463 assert issue.recipients.include?(issue.author.mail)
2456 2464 end
2457 2465
2458 2466 test "Issue#recipients should include the assigned to user if the assigned to user is active" do
2459 2467 issue = Issue.generate!(:assigned_to => User.generate!)
2460 2468 assert issue.assigned_to, "No assigned_to set for Issue"
2461 2469 assert issue.recipients.include?(issue.assigned_to.mail)
2462 2470 end
2463 2471
2464 2472 test "Issue#recipients should not include users who opt out of all email" do
2465 2473 issue = Issue.generate!(:author => User.generate!)
2466 2474 issue.author.update_attribute(:mail_notification, :none)
2467 2475 assert !issue.recipients.include?(issue.author.mail)
2468 2476 end
2469 2477
2470 2478 test "Issue#recipients should not include the issue author if they are only notified of assigned issues" do
2471 2479 issue = Issue.generate!(:author => User.generate!)
2472 2480 issue.author.update_attribute(:mail_notification, :only_assigned)
2473 2481 assert !issue.recipients.include?(issue.author.mail)
2474 2482 end
2475 2483
2476 2484 test "Issue#recipients should not include the assigned user if they are only notified of owned issues" do
2477 2485 issue = Issue.generate!(:assigned_to => User.generate!)
2478 2486 issue.assigned_to.update_attribute(:mail_notification, :only_owner)
2479 2487 assert !issue.recipients.include?(issue.assigned_to.mail)
2480 2488 end
2481 2489
2482 2490 def test_last_journal_id_with_journals_should_return_the_journal_id
2483 2491 assert_equal 2, Issue.find(1).last_journal_id
2484 2492 end
2485 2493
2486 2494 def test_last_journal_id_without_journals_should_return_nil
2487 2495 assert_nil Issue.find(3).last_journal_id
2488 2496 end
2489 2497
2490 2498 def test_journals_after_should_return_journals_with_greater_id
2491 2499 assert_equal [Journal.find(2)], Issue.find(1).journals_after('1')
2492 2500 assert_equal [], Issue.find(1).journals_after('2')
2493 2501 end
2494 2502
2495 2503 def test_journals_after_with_blank_arg_should_return_all_journals
2496 2504 assert_equal [Journal.find(1), Journal.find(2)], Issue.find(1).journals_after('')
2497 2505 end
2498 2506
2499 2507 def test_css_classes_should_include_tracker
2500 2508 issue = Issue.new(:tracker => Tracker.find(2))
2501 2509 classes = issue.css_classes.split(' ')
2502 2510 assert_include 'tracker-2', classes
2503 2511 end
2504 2512
2505 2513 def test_css_classes_should_include_priority
2506 2514 issue = Issue.new(:priority => IssuePriority.find(8))
2507 2515 classes = issue.css_classes.split(' ')
2508 2516 assert_include 'priority-8', classes
2509 2517 assert_include 'priority-highest', classes
2510 2518 end
2511 2519
2512 2520 def test_css_classes_should_include_user_and_group_assignment
2513 2521 project = Project.first
2514 2522 user = User.generate!
2515 2523 group = Group.generate!
2516 2524 Member.create!(:principal => group, :project => project, :role_ids => [1, 2])
2517 2525 group.users << user
2518 2526 assert user.member_of?(project)
2519 2527 issue1 = Issue.generate(:assigned_to_id => group.id)
2520 2528 assert_include 'assigned-to-my-group', issue1.css_classes(user)
2521 2529 assert_not_include 'assigned-to-me', issue1.css_classes(user)
2522 2530 issue2 = Issue.generate(:assigned_to_id => user.id)
2523 2531 assert_not_include 'assigned-to-my-group', issue2.css_classes(user)
2524 2532 assert_include 'assigned-to-me', issue2.css_classes(user)
2525 2533 end
2526 2534
2527 2535 def test_save_attachments_with_hash_should_save_attachments_in_keys_order
2528 2536 set_tmp_attachments_directory
2529 2537 issue = Issue.generate!
2530 2538 issue.save_attachments({
2531 2539 'p0' => {'file' => mock_file_with_options(:original_filename => 'upload')},
2532 2540 '3' => {'file' => mock_file_with_options(:original_filename => 'bar')},
2533 2541 '1' => {'file' => mock_file_with_options(:original_filename => 'foo')}
2534 2542 })
2535 2543 issue.attach_saved_attachments
2536 2544
2537 2545 assert_equal 3, issue.reload.attachments.count
2538 2546 assert_equal %w(upload foo bar), issue.attachments.map(&:filename)
2539 2547 end
2540 2548
2541 2549 def test_closed_on_should_be_nil_when_creating_an_open_issue
2542 2550 issue = Issue.generate!(:status_id => 1).reload
2543 2551 assert !issue.closed?
2544 2552 assert_nil issue.closed_on
2545 2553 end
2546 2554
2547 2555 def test_closed_on_should_be_set_when_creating_a_closed_issue
2548 2556 issue = Issue.generate!(:status_id => 5).reload
2549 2557 assert issue.closed?
2550 2558 assert_not_nil issue.closed_on
2551 2559 assert_equal issue.updated_on, issue.closed_on
2552 2560 assert_equal issue.created_on, issue.closed_on
2553 2561 end
2554 2562
2555 2563 def test_closed_on_should_be_nil_when_updating_an_open_issue
2556 2564 issue = Issue.find(1)
2557 2565 issue.subject = 'Not closed yet'
2558 2566 issue.save!
2559 2567 issue.reload
2560 2568 assert_nil issue.closed_on
2561 2569 end
2562 2570
2563 2571 def test_closed_on_should_be_set_when_closing_an_open_issue
2564 2572 issue = Issue.find(1)
2565 2573 issue.subject = 'Now closed'
2566 2574 issue.status_id = 5
2567 2575 issue.save!
2568 2576 issue.reload
2569 2577 assert_not_nil issue.closed_on
2570 2578 assert_equal issue.updated_on, issue.closed_on
2571 2579 end
2572 2580
2573 2581 def test_closed_on_should_not_be_updated_when_updating_a_closed_issue
2574 2582 issue = Issue.open(false).first
2575 2583 was_closed_on = issue.closed_on
2576 2584 assert_not_nil was_closed_on
2577 2585 issue.subject = 'Updating a closed issue'
2578 2586 issue.save!
2579 2587 issue.reload
2580 2588 assert_equal was_closed_on, issue.closed_on
2581 2589 end
2582 2590
2583 2591 def test_closed_on_should_be_preserved_when_reopening_a_closed_issue
2584 2592 issue = Issue.open(false).first
2585 2593 was_closed_on = issue.closed_on
2586 2594 assert_not_nil was_closed_on
2587 2595 issue.subject = 'Reopening a closed issue'
2588 2596 issue.status_id = 1
2589 2597 issue.save!
2590 2598 issue.reload
2591 2599 assert !issue.closed?
2592 2600 assert_equal was_closed_on, issue.closed_on
2593 2601 end
2594 2602
2595 2603 def test_status_was_should_return_nil_for_new_issue
2596 2604 issue = Issue.new
2597 2605 assert_nil issue.status_was
2598 2606 end
2599 2607
2600 2608 def test_status_was_should_return_status_before_change
2601 2609 issue = Issue.find(1)
2602 2610 issue.status = IssueStatus.find(2)
2603 2611 assert_equal IssueStatus.find(1), issue.status_was
2604 2612 end
2605 2613
2606 2614 def test_status_was_should_return_status_before_change_with_status_id
2607 2615 issue = Issue.find(1)
2608 2616 assert_equal IssueStatus.find(1), issue.status
2609 2617 issue.status_id = 2
2610 2618 assert_equal IssueStatus.find(1), issue.status_was
2611 2619 end
2612 2620
2613 2621 def test_status_was_should_be_reset_on_save
2614 2622 issue = Issue.find(1)
2615 2623 issue.status = IssueStatus.find(2)
2616 2624 assert_equal IssueStatus.find(1), issue.status_was
2617 2625 assert issue.save!
2618 2626 assert_equal IssueStatus.find(2), issue.status_was
2619 2627 end
2620 2628
2621 2629 def test_closing_should_return_true_when_closing_an_issue
2622 2630 issue = Issue.find(1)
2623 2631 issue.status = IssueStatus.find(2)
2624 2632 assert_equal false, issue.closing?
2625 2633 issue.status = IssueStatus.find(5)
2626 2634 assert_equal true, issue.closing?
2627 2635 end
2628 2636
2629 2637 def test_closing_should_return_true_when_closing_an_issue_with_status_id
2630 2638 issue = Issue.find(1)
2631 2639 issue.status_id = 2
2632 2640 assert_equal false, issue.closing?
2633 2641 issue.status_id = 5
2634 2642 assert_equal true, issue.closing?
2635 2643 end
2636 2644
2637 2645 def test_closing_should_return_true_for_new_closed_issue
2638 2646 issue = Issue.new
2639 2647 assert_equal false, issue.closing?
2640 2648 issue.status = IssueStatus.find(5)
2641 2649 assert_equal true, issue.closing?
2642 2650 end
2643 2651
2644 2652 def test_closing_should_return_true_for_new_closed_issue_with_status_id
2645 2653 issue = Issue.new
2646 2654 assert_equal false, issue.closing?
2647 2655 issue.status_id = 5
2648 2656 assert_equal true, issue.closing?
2649 2657 end
2650 2658
2651 2659 def test_closing_should_be_reset_after_save
2652 2660 issue = Issue.find(1)
2653 2661 issue.status_id = 5
2654 2662 assert_equal true, issue.closing?
2655 2663 issue.save!
2656 2664 assert_equal false, issue.closing?
2657 2665 end
2658 2666
2659 2667 def test_reopening_should_return_true_when_reopening_an_issue
2660 2668 issue = Issue.find(8)
2661 2669 issue.status = IssueStatus.find(6)
2662 2670 assert_equal false, issue.reopening?
2663 2671 issue.status = IssueStatus.find(2)
2664 2672 assert_equal true, issue.reopening?
2665 2673 end
2666 2674
2667 2675 def test_reopening_should_return_true_when_reopening_an_issue_with_status_id
2668 2676 issue = Issue.find(8)
2669 2677 issue.status_id = 6
2670 2678 assert_equal false, issue.reopening?
2671 2679 issue.status_id = 2
2672 2680 assert_equal true, issue.reopening?
2673 2681 end
2674 2682
2675 2683 def test_reopening_should_return_false_for_new_open_issue
2676 2684 issue = Issue.new
2677 2685 issue.status = IssueStatus.find(1)
2678 2686 assert_equal false, issue.reopening?
2679 2687 end
2680 2688
2681 2689 def test_reopening_should_be_reset_after_save
2682 2690 issue = Issue.find(8)
2683 2691 issue.status_id = 2
2684 2692 assert_equal true, issue.reopening?
2685 2693 issue.save!
2686 2694 assert_equal false, issue.reopening?
2687 2695 end
2688 2696
2689 2697 def test_default_status_without_tracker_should_be_nil
2690 2698 issue = Issue.new
2691 2699 assert_nil issue.tracker
2692 2700 assert_nil issue.default_status
2693 2701 end
2694 2702
2695 2703 def test_default_status_should_be_tracker_default_status
2696 2704 issue = Issue.new(:tracker_id => 1)
2697 2705 assert_not_nil issue.status
2698 2706 assert_equal issue.tracker.default_status, issue.default_status
2699 2707 end
2700 2708
2701 2709 def test_initializing_with_tracker_should_set_default_status
2702 2710 issue = Issue.new(:tracker => Tracker.find(1))
2703 2711 assert_not_nil issue.status
2704 2712 assert_equal issue.default_status, issue.status
2705 2713 end
2706 2714
2707 2715 def test_initializing_with_tracker_id_should_set_default_status
2708 2716 issue = Issue.new(:tracker_id => 1)
2709 2717 assert_not_nil issue.status
2710 2718 assert_equal issue.default_status, issue.status
2711 2719 end
2712 2720
2713 2721 def test_setting_tracker_should_set_default_status
2714 2722 issue = Issue.new
2715 2723 issue.tracker = Tracker.find(1)
2716 2724 assert_not_nil issue.status
2717 2725 assert_equal issue.default_status, issue.status
2718 2726 end
2719 2727
2720 2728 def test_changing_tracker_should_set_default_status_if_status_was_default
2721 2729 WorkflowTransition.delete_all
2722 2730 WorkflowTransition.create! :role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 1
2723 2731 Tracker.find(2).update! :default_status_id => 2
2724 2732
2725 2733 issue = Issue.new(:tracker_id => 1, :status_id => 1)
2726 2734 assert_equal IssueStatus.find(1), issue.status
2727 2735 issue.tracker = Tracker.find(2)
2728 2736 assert_equal IssueStatus.find(2), issue.status
2729 2737 end
2730 2738
2731 2739 def test_changing_tracker_should_set_default_status_if_status_is_not_used_by_tracker
2732 2740 WorkflowTransition.delete_all
2733 2741 Tracker.find(2).update! :default_status_id => 2
2734 2742
2735 2743 issue = Issue.new(:tracker_id => 1, :status_id => 3)
2736 2744 assert_equal IssueStatus.find(3), issue.status
2737 2745 issue.tracker = Tracker.find(2)
2738 2746 assert_equal IssueStatus.find(2), issue.status
2739 2747 end
2740 2748
2741 2749 def test_changing_tracker_should_keep_status_if_status_was_not_default_and_is_used_by_tracker
2742 2750 WorkflowTransition.delete_all
2743 2751 WorkflowTransition.create! :role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 3
2744 2752 Tracker.find(2).update! :default_status_id => 2
2745 2753
2746 2754 issue = Issue.new(:tracker_id => 1, :status_id => 3)
2747 2755 assert_equal IssueStatus.find(3), issue.status
2748 2756 issue.tracker = Tracker.find(2)
2749 2757 assert_equal IssueStatus.find(3), issue.status
2750 2758 end
2751 2759
2752 2760 def test_assigned_to_was_with_a_group
2753 2761 group = Group.find(10)
2754 2762
2755 2763 issue = Issue.generate!(:assigned_to => group)
2756 2764 issue.reload.assigned_to = nil
2757 2765 assert_equal group, issue.assigned_to_was
2758 2766 end
2759 2767 end
General Comments 0
You need to be logged in to leave comments. Login now