]> source.dussan.org Git - redmine.git/commitdiff
Merged r17638 from trunk to 3.4-stable (#30009).
authorGo MAEDA <maeda@farend.jp>
Mon, 26 Nov 2018 05:44:35 +0000 (05:44 +0000)
committerGo MAEDA <maeda@farend.jp>
Mon, 26 Nov 2018 05:44:35 +0000 (05:44 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/3.4-stable@17639 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/sort_criteria.rb
test/unit/query_test.rb

index 3d440f010dd02d3330e50072f0c82fc58a7d09e1..d8fa3ee3d72043d182899d65e61d141d21398256 100644 (file)
@@ -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.slice!(3)
       self
index dfa2ace6d208964621fe633a4e90bc8b8bb86e29..c7c8e97f725ce2ed0667a4acec3dfcc1e5479daf 100644 (file)
@@ -1490,6 +1490,12 @@ class QueryTest < ActiveSupport::TestCase
     assert_equal [['id', 'desc']], 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']}