Project

General

Profile

Defect #30009 » 0001-Remove-blank-keys-from-sort-criterias.patch

Marius BĂLTEANU, 2018-11-25 21:35

View differences:

lib/redmine/sort_criteria.rb
87 87
    private
88 88

  
89 89
    def normalize!
90
      self.reject! {|s| s.first.blank? }
90 91
      self.collect! {|s| s = Array(s); [s.first, (s.last == false || s.last.to_s == 'desc') ? 'desc' : 'asc']}
91 92
      self.replace self.first(3)
92 93
    end
test/unit/query_test.rb
1496 1496
    assert_equal [['priority', 'desc'], ['tracker', 'asc'], ['priority', 'asc']], q.sort_criteria
1497 1497
  end
1498 1498

  
1499
  def test_sort_criteria_should_remove_blank_keys
1500
    q = IssueQuery.new
1501
    q.sort_criteria = [['priority', 'desc'], [nil, 'desc'], ['', 'asc'], ['project', 'asc']]
1502
    assert_equal [['priority', 'desc'], ['project', 'asc']], q.sort_criteria
1503
  end
1504

  
1499 1505
  def test_set_sort_criteria_with_hash
1500 1506
    q = IssueQuery.new
1501 1507
    q.sort_criteria = {'0' => ['priority', 'desc'], '2' => ['tracker']}
(2-2/2)