Fixes reverting an issue to a status with a done_ratio of 0%. #5170
Contributed by Felix Schäfer git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4186 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
76fcf136d0
commit
83e0be5d07
|
@ -263,7 +263,7 @@ class Issue < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def done_ratio
|
||||
if Issue.use_status_for_done_ratio? && status && status.default_done_ratio?
|
||||
if Issue.use_status_for_done_ratio? && status && status.default_done_ratio
|
||||
status.default_done_ratio
|
||||
else
|
||||
read_attribute(:done_ratio)
|
||||
|
@ -326,7 +326,7 @@ class Issue < ActiveRecord::Base
|
|||
# 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?
|
||||
if Issue.use_status_for_done_ratio? && status && status.default_done_ratio
|
||||
self.done_ratio = status.default_done_ratio
|
||||
end
|
||||
end
|
||||
|
@ -714,7 +714,7 @@ class Issue < ActiveRecord::Base
|
|||
end
|
||||
|
||||
# done ratio = weighted average ratio of leaves
|
||||
unless Issue.use_status_for_done_ratio? && p.status && p.status.default_done_ratio?
|
||||
unless Issue.use_status_for_done_ratio? && p.status && p.status.default_done_ratio
|
||||
leaves_count = p.leaves.count
|
||||
if leaves_count > 0
|
||||
average = p.leaves.average(:estimated_hours).to_f
|
||||
|
|
|
@ -38,6 +38,7 @@ issues_002:
|
|||
lft: 1
|
||||
rgt: 2
|
||||
lock_version: 3
|
||||
done_ratio: 30
|
||||
issues_003:
|
||||
created_on: 2006-07-19 21:07:27 +02:00
|
||||
project_id: 1
|
||||
|
|
|
@ -593,6 +593,9 @@ class IssueTest < ActiveSupport::TestCase
|
|||
@issue = Issue.find(1)
|
||||
@issue_status = IssueStatus.find(1)
|
||||
@issue_status.update_attribute(:default_done_ratio, 50)
|
||||
@issue2 = Issue.find(2)
|
||||
@issue_status2 = IssueStatus.find(2)
|
||||
@issue_status2.update_attribute(:default_done_ratio, 0)
|
||||
end
|
||||
|
||||
context "with Setting.issue_done_ratio using the issue_field" do
|
||||
|
@ -602,6 +605,7 @@ class IssueTest < ActiveSupport::TestCase
|
|||
|
||||
should "read the issue's field" do
|
||||
assert_equal 0, @issue.done_ratio
|
||||
assert_equal 30, @issue2.done_ratio
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -612,6 +616,7 @@ class IssueTest < ActiveSupport::TestCase
|
|||
|
||||
should "read the Issue Status's default done ratio" do
|
||||
assert_equal 50, @issue.done_ratio
|
||||
assert_equal 0, @issue2.done_ratio
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -621,6 +626,9 @@ class IssueTest < ActiveSupport::TestCase
|
|||
@issue = Issue.find(1)
|
||||
@issue_status = IssueStatus.find(1)
|
||||
@issue_status.update_attribute(:default_done_ratio, 50)
|
||||
@issue2 = Issue.find(2)
|
||||
@issue_status2 = IssueStatus.find(2)
|
||||
@issue_status2.update_attribute(:default_done_ratio, 0)
|
||||
end
|
||||
|
||||
context "with Setting.issue_done_ratio using the issue_field" do
|
||||
|
@ -630,8 +638,10 @@ class IssueTest < ActiveSupport::TestCase
|
|||
|
||||
should "not change the issue" do
|
||||
@issue.update_done_ratio_from_issue_status
|
||||
@issue2.update_done_ratio_from_issue_status
|
||||
|
||||
assert_equal 0, @issue.done_ratio
|
||||
assert_equal 0, @issue.read_attribute(:done_ratio)
|
||||
assert_equal 30, @issue2.read_attribute(:done_ratio)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -640,10 +650,12 @@ class IssueTest < ActiveSupport::TestCase
|
|||
Setting.issue_done_ratio = 'issue_status'
|
||||
end
|
||||
|
||||
should "not change the issue's done ratio" do
|
||||
should "change the issue's done ratio" do
|
||||
@issue.update_done_ratio_from_issue_status
|
||||
@issue2.update_done_ratio_from_issue_status
|
||||
|
||||
assert_equal 50, @issue.done_ratio
|
||||
assert_equal 50, @issue.read_attribute(:done_ratio)
|
||||
assert_equal 0, @issue2.read_attribute(:done_ratio)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue