mirror of
https://github.com/meineerde/redmine.git
synced 2025-10-17 17:01:01 +00:00
Merged r4186 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.0-stable@4204 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
98eaff414f
commit
dd91dc4cb7
@ -245,7 +245,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)
|
||||
@ -308,7 +308,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
|
||||
@ -689,7 +689,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
|
||||
|
||||
1
test/fixtures/issues.yml
vendored
1
test/fixtures/issues.yml
vendored
@ -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
|
||||
|
||||
@ -571,6 +571,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
|
||||
@ -580,6 +583,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
|
||||
|
||||
@ -590,6 +594,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
|
||||
@ -599,6 +604,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
|
||||
@ -608,8 +616,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
|
||||
|
||||
@ -618,10 +628,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…
x
Reference in New Issue
Block a user