mirror of
https://github.com/meineerde/redmine.git
synced 2026-01-09 09:01:31 +00:00
Remove blank keys from sort criteria (#30009).
Patch by Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@17638 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
7fbcb8c908
commit
14d441a144
@ -87,6 +87,7 @@ module Redmine
|
||||
private
|
||||
|
||||
def normalize!
|
||||
self.reject! {|s| s.first.blank? }
|
||||
self.collect! {|s| s = Array(s); [s.first, (s.last == false || s.last.to_s == 'desc') ? 'desc' : 'asc']}
|
||||
self.replace self.first(3)
|
||||
end
|
||||
|
||||
@ -1496,6 +1496,12 @@ class QueryTest < ActiveSupport::TestCase
|
||||
assert_equal [['priority', 'desc'], ['tracker', 'asc'], ['priority', 'asc']], q.sort_criteria
|
||||
end
|
||||
|
||||
def test_sort_criteria_should_remove_blank_keys
|
||||
q = IssueQuery.new
|
||||
q.sort_criteria = [['priority', 'desc'], [nil, 'desc'], ['', 'asc'], ['project', 'asc']]
|
||||
assert_equal [['priority', 'desc'], ['project', '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