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)
# 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
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
@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
should "read the issue's field" do
assert_equal 0, @issue.done_ratio
+ assert_equal 30, @issue2.done_ratio
end
end
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
@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
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
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