Patch #29632 » restrict_the_number_of_elements_of_sort_criteria.patch
| lib/redmine/sort_criteria.rb | ||
|---|---|---|
|
def normalize!
|
||
|
self.collect! {|s| s = Array(s); [s.first, (s.last == false || s.last.to_s == 'desc') ? 'desc' : 'asc']}
|
||
|
self.slice!(3)
|
||
|
self
|
||
|
self.replace self.first(3)
|
||
|
end
|
||
|
# Appends ASC/DESC to the sort criterion unless it has a fixed order
|
||
| test/unit/query_test.rb | ||
|---|---|---|
|
assert_equal [['id', 'desc']], q.sort_criteria
|
||
|
end
|
||
|
def test_sort_criteria_should_have_no_more_than_three_elements
|
||
|
q = IssueQuery.new
|
||
|
q.sort_criteria = [['priority', 'desc'], ['tracker', 'asc'], ['priority', 'asc'], ['id', 'asc'], ['project', 'asc'], ['subject', 'asc']]
|
||
|
assert_equal [['priority', 'desc'], ['tracker', 'asc'], ['priority', 'asc']], q.sort_criteria
|
||
|
end
|
||
|
def test_set_sort_criteria_with_hash
|
||
|
q = IssueQuery.new
|
||
|
q.sort_criteria = {'0' => ['priority', 'desc'], '2' => ['tracker']}
|
||
- « Previous
- 1
- 2
- Next »