mirror of
https://github.com/meineerde/redmine.git
synced 2026-01-25 00:27:14 +00:00
Redmine::SortCriteria#normalize! does not limit properly the maximum number of elements (#29632).
Patch by Mizuki ISHIKAWA. git-svn-id: http://svn.redmine.org/redmine/trunk@17494 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
4a5a68f19c
commit
1d596677f2
@ -88,8 +88,7 @@ module Redmine
|
||||
|
||||
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
|
||||
|
||||
@ -1490,6 +1490,12 @@ class QueryTest < ActiveSupport::TestCase
|
||||
assert_equal [['id', 'desc']], q.sort_criteria
|
||||
end
|
||||
|
||||
def test_sort_criteria_should_have_only_first_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']}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user