Patch #13400 » 0001-patch.diff
| app/models/issue.rb | ||
|---|---|---|
|
acts_as_activity_provider :find_options => {:include => [:project, :author, :tracker]},
|
||
|
:author_key => :author_id
|
||
|
DONE_RATIO_OPTIONS = %w(issue_field issue_status)
|
||
|
DONE_RATIO_OPTIONS = %w(issue_field issue_status logged_time)
|
||
|
attr_reader :current_journal
|
||
| ... | ... | |
|
:conditions => ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"]
|
||
|
before_create :default_assign
|
||
|
before_save :close_duplicates, :update_done_ratio_from_issue_status
|
||
|
before_save :close_duplicates, :update_done_ratio
|
||
|
after_save {|issue| issue.send :after_project_change if !issue.id_changed? && issue.project_id_changed?}
|
||
|
after_save :reschedule_following_issues, :update_nested_set_attributes, :update_parent_attributes, :create_journal
|
||
|
after_destroy :update_parent_attributes
|
||
| ... | ... | |
|
end
|
||
|
def done_ratio
|
||
|
if Issue.use_status_for_done_ratio? && status && status.default_done_ratio
|
||
|
if use_status_for_done_ratio?
|
||
|
status.default_done_ratio
|
||
|
elsif use_time_for_done_ratio?
|
||
|
if estimated_hours && estimated_hours.to_f > 0
|
||
|
ratio = (total_spent_hours.to_f / estimated_hours.to_f) * 100
|
||
|
[ratio, 100].min.to_i
|
||
|
else
|
||
|
0.0
|
||
|
end
|
||
|
else
|
||
|
read_attribute(:done_ratio)
|
||
|
end
|
||
| ... | ... | |
|
def self.use_status_for_done_ratio?
|
||
|
Setting.issue_done_ratio == 'issue_status'
|
||
|
end
|
||
|
def use_status_for_done_ratio?
|
||
|
Issue.use_status_for_done_ratio? && status && status.default_done_ratio
|
||
|
end
|
||
|
def self.use_time_for_done_ratio?
|
||
|
Setting.issue_done_ratio == 'logged_time'
|
||
|
end
|
||
|
def use_time_for_done_ratio?
|
||
|
Issue.use_time_for_done_ratio?
|
||
|
end
|
||
|
def self.use_field_for_done_ratio?
|
||
|
Setting.issue_done_ratio == 'issue_field'
|
||
|
end
|
||
|
def use_field_for_done_ratio?
|
||
|
!(use_status_for_done_ratio? || use_time_for_done_ratio?)
|
||
|
end
|
||
|
def validate_issue
|
||
|
if self.due_date.nil? && @attributes['due_date'] && !@attributes['due_date'].empty?
|
||
| ... | ... | |
|
# Set the done_ratio using the status if that setting is set. This will keep the done_ratios
|
||
|
# even if the user turns off the setting later
|
||
|
def update_done_ratio_from_issue_status
|
||
|
if Issue.use_status_for_done_ratio? && status && status.default_done_ratio
|
||
|
self.done_ratio = status.default_done_ratio
|
||
|
def update_done_ratio
|
||
|
unless use_field_for_done_ratio?
|
||
|
self.done_ratio = self.done_ratio
|
||
|
end
|
||
|
end
|
||
|
def update_done_ratio!
|
||
|
self.init_journal(User.current, "")
|
||
|
self.update_done_ratio
|
||
|
self.save
|
||
|
end
|
||
|
def init_journal(user, notes = "")
|
||
|
@current_journal ||= Journal.new(:journalized => self, :user => user, :notes => notes)
|
||
|
if new_record?
|
||
| ... | ... | |
|
end
|
||
|
# done ratio = weighted average ratio of leaves
|
||
|
unless Issue.use_status_for_done_ratio? && p.status && p.status.default_done_ratio
|
||
|
if p.use_field_for_done_ratio
|
||
|
leaves_count = p.leaves.count
|
||
|
if leaves_count > 0
|
||
|
average = p.leaves.average(:estimated_hours).to_f
|
||
| app/models/time_entry.rb | ||
|---|---|---|
|
validates_numericality_of :hours, :allow_nil => true, :message => :invalid
|
||
|
validates_length_of :comments, :maximum => 255, :allow_nil => true
|
||
|
before_validation :set_project_if_nil
|
||
|
after_save :update_done_ratio
|
||
|
after_destroy :update_done_ratio
|
||
|
validate :validate_time_entry
|
||
|
named_scope :visible, lambda {|*args| {
|
||
| ... | ... | |
|
errors.add :issue_id, :invalid if (issue_id && !issue) || (issue && project!=issue.project)
|
||
|
end
|
||
|
def update_done_ratio
|
||
|
if issue && Issue.use_time_for_done_ratio?
|
||
|
issue.update_done_ratio!
|
||
|
end
|
||
|
end
|
||
|
def hours=(h)
|
||
|
write_attribute :hours, (h.is_a?(String) ? (h.to_hours || h) : h)
|
||
|
end
|
||
| config/locales/ar.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/bg.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/bs.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/ca.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/cs.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/da.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/de.yml | ||
|---|---|---|
|
label_required: Required
|
||
|
label_attribute_of_project: Project's %{name}
|
||
|
label_status_transitions: Status transitions
|
||
|
setting_issue_done_ratio_logged_time: Geschätzter und gebuchter Zeit
|
||
| config/locales/el.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/en-GB.yml | ||
|---|---|---|
|
label_attribute_of_project: Project's %{name}
|
||
|
label_status_transitions: Status transitions
|
||
|
button_mail_link: Send by e-mail
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/en.yml | ||
|---|---|---|
|
setting_issue_done_ratio: Calculate the issue done ratio with
|
||
|
setting_issue_done_ratio_issue_field: Use the issue field
|
||
|
setting_issue_done_ratio_issue_status: Use the issue status
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
|
setting_start_of_week: Start calendars on
|
||
|
setting_rest_api_enabled: Enable REST web service
|
||
|
setting_cache_formatted_text: Cache formatted text
|
||
| config/locales/es.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/et.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/eu.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/fa.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/fi.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/fr.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/gl.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/he.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/hr.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/hu.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/id.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/it.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/ja.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/ko.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/lt.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/lv.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/mk.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/mn.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/nl.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/no.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/pl.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/pt-BR.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/pt.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/ro.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/ru.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/sk.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/sl.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/sq.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/sr-YU.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/sr.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/sv.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/th.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/tr.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/uk.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/vi.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/zh-TW.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| config/locales/zh.yml | ||
|---|---|---|
|
field_author_role: Author's role
|
||
|
button_mail_link: Send by e-mail
|
||
|
label_add_to_all_workflows: Add to all workflows
|
||
|
setting_issue_done_ratio_logged_time: Use the logged and estimated time
|
||
| test/unit/issue_test.rb | ||
|---|---|---|
|
end
|
||
|
end
|
||
|
context "#update_done_ratio_from_issue_status" do
|
||
|
context "#update_done_ratio" do
|
||
|
setup do
|
||
|
@issue = Issue.find(1)
|
||
|
@issue_status = IssueStatus.find(1)
|
||
| ... | ... | |
|
end
|
||
|
should "not change the issue" do
|
||
|
@issue.update_done_ratio_from_issue_status
|
||
|
@issue2.update_done_ratio_from_issue_status
|
||
|
@issue.update_done_ratio
|
||
|
@issue2.update_done_ratio
|
||
|
assert_equal 0, @issue.read_attribute(:done_ratio)
|
||
|
assert_equal 30, @issue2.read_attribute(:done_ratio)
|
||
| ... | ... | |
|
end
|
||
|
should "change the issue's done ratio" do
|
||
|
@issue.update_done_ratio_from_issue_status
|
||
|
@issue2.update_done_ratio_from_issue_status
|
||
|
@issue.update_done_ratio
|
||
|
@issue2.update_done_ratio
|
||
|
assert_equal 50, @issue.read_attribute(:done_ratio)
|
||
|
assert_equal 0, @issue2.read_attribute(:done_ratio)
|
||