Project

General

Profile

Defect #32737 » 32737-remove-duplicate-keys.patch

Go MAEDA, 2020-01-27 12:58

View differences:

lib/redmine/sort_criteria.rb
90 90

  
91 91
    def normalize!
92 92
      self.reject! {|s| s.first.blank? }
93
      self.uniq! {|s| s.first }
93 94
      self.collect! {|s| s = Array(s); [s.first, (s.last == false || s.last.to_s == 'desc') ? 'desc' : 'asc']}
94 95
      self.replace self.first(3)
95 96
    end
test/unit/query_test.rb
1610 1610
  def test_sort_criteria_should_have_only_first_three_elements
1611 1611
    q = IssueQuery.new
1612 1612
    q.sort_criteria = [['priority', 'desc'], ['tracker', 'asc'], ['priority', 'asc'], ['id', 'asc'], ['project', 'asc'], ['subject', 'asc']]
1613
    assert_equal [['priority', 'desc'], ['tracker', 'asc'], ['priority', 'asc']], q.sort_criteria
1613
    assert_equal [['priority', 'desc'], ['tracker', 'asc'], ['id', 'asc']], q.sort_criteria
1614 1614
  end
1615 1615

  
1616
  def test_sort_criteria_should_remove_blank_keys
1616
  def test_sort_criteria_should_remove_blank_or_duplicate_keys
1617 1617
    q = IssueQuery.new
1618
    q.sort_criteria = [['priority', 'desc'], [nil, 'desc'], ['', 'asc'], ['project', 'asc']]
1618
    q.sort_criteria = [['priority', 'desc'], [nil, 'desc'], ['', 'asc'], ['priority', 'asc'], ['project', 'asc']]
1619 1619
    assert_equal [['priority', 'desc'], ['project', 'asc']], q.sort_criteria
1620 1620
  end
1621 1621

  
(3-3/4)