Defect #5880 ยป defect-5880.diff
app/models/issue.rb (working copy) | ||
---|---|---|
1451 | 1451 |
def recalculate_attributes_for(issue_id) |
1452 | 1452 |
if issue_id && p = Issue.find_by_id(issue_id) |
1453 | 1453 |
if p.priority_derived? |
1454 |
# priority = highest priority of children |
|
1455 |
if priority_position = p.children.joins(:priority).maximum("#{IssuePriority.table_name}.position") |
|
1454 |
# priority = highest priority of open children
|
|
1455 |
if priority_position = p.children.open.joins(:priority).maximum("#{IssuePriority.table_name}.position")
|
|
1456 | 1456 |
p.priority = IssuePriority.find_by_position(priority_position) |
1457 |
else |
|
1458 |
p.priority = IssuePriority.default |
|
1457 | 1459 |
end |
1458 | 1460 |
end |
1459 | 1461 |
test/unit/issue_subtasking_test.rb (working copy) | ||
---|---|---|
78 | 78 |
end |
79 | 79 |
end |
80 | 80 | |
81 |
def test_parent_priority_should_be_the_highest_child_priority |
|
81 |
def test_parent_priority_should_be_the_highest_open_child_priority
|
|
82 | 82 |
with_settings :parent_issue_priority => 'derived' do |
83 | 83 |
parent = Issue.generate!(:priority => IssuePriority.find_by_name('Normal')) |
84 | 84 |
# Create children |
... | ... | |
88 | 88 |
assert_equal 'Immediate', child1.reload.priority.name |
89 | 89 |
assert_equal 'Immediate', parent.reload.priority.name |
90 | 90 |
child3 = parent.generate_child!(:priority => IssuePriority.find_by_name('Low')) |
91 |
child4 = parent.generate_child!(:priority => IssuePriority.find_by_name('Urgent')) |
|
91 | 92 |
assert_equal 'Immediate', parent.reload.priority.name |
92 | 93 |
# Destroy a child |
93 | 94 |
child1.destroy |
95 |
assert_equal 'Urgent', parent.reload.priority.name |
|
96 |
# Close a child |
|
97 |
child4.status = IssueStatus.where(:is_closed => true).first |
|
98 |
child4.save! |
|
94 | 99 |
assert_equal 'Low', parent.reload.priority.name |
95 | 100 |
# Update a child |
96 | 101 |
child3.reload.priority = IssuePriority.find_by_name('Normal') |
97 | 102 |
child3.save! |
98 | 103 |
assert_equal 'Normal', parent.reload.priority.name |
104 |
# Reopen a child |
|
105 |
child4.status = IssueStatus.where(:is_closed => false).first |
|
106 |
child4.save! |
|
107 |
assert_equal 'Urgent', parent.reload.priority.name |
|
99 | 108 |
end |
100 | 109 |
end |