Defect #42066 ยป 0001-Fix-NoMethodError-in-IssuePriority-high-and-low-when.patch
| app/models/issue_priority.rb | ||
|---|---|---|
| 60 | 60 |
end |
| 61 | 61 | |
| 62 | 62 |
def high? |
| 63 |
position > self.class.default_or_middle.position |
|
| 63 |
return false unless (default_or_middle_position = self.class.default_or_middle&.position) |
|
| 64 |
position > default_or_middle_position |
|
| 64 | 65 |
end |
| 65 | 66 | |
| 66 | 67 |
def low? |
| 67 |
position < self.class.default_or_middle.position |
|
| 68 |
return false unless (default_or_middle_position = self.class.default_or_middle&.position) |
|
| 69 |
position < default_or_middle_position |
|
| 68 | 70 |
end |
| 69 | 71 | |
| 70 | 72 |
# Updates position_name for active priorities |
| test/unit/issue_priority_test.rb | ||
|---|---|---|
| 156 | 156 |
IssuePriority.find_by_position_name('highest').destroy
|
| 157 | 157 |
assert_equal %w(lowest default high2 highest), IssuePriority.active.to_a.sort.map(&:position_name) |
| 158 | 158 |
end |
| 159 | ||
| 160 |
def test_high_should_return_false_when_no_default_priority_and_no_active_priorities |
|
| 161 |
IssuePriority.update_all(active: false, is_default: false) |
|
| 162 |
priority = IssuePriority.order(:position).last # Highest priority |
|
| 163 |
assert_nothing_raised do |
|
| 164 |
assert_equal false, priority.high? |
|
| 165 |
end |
|
| 166 |
end |
|
| 167 | ||
| 168 |
def test_low_should_return_false_when_no_default_priority_and_no_active_priorities |
|
| 169 |
IssuePriority.update_all(active: false, is_default: false) |
|
| 170 |
priority = IssuePriority.order(:position).first # Lowest priority |
|
| 171 |
assert_nothing_raised do |
|
| 172 |
assert_equal false, priority.low? |
|
| 173 |
end |
|
| 174 |
end |
|
| 159 | 175 |
end |