From 18852b765a8a1715086cdb1b06d2f15680e56676 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 5 May 2012 16:21:22 +0000 Subject: [PATCH] Trackers should be sorted by position not by name. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9644 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/tracker.rb | 2 +- test/unit/tracker_test.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/tracker.rb b/app/models/tracker.rb index acd0253c6..d489d6d45 100644 --- a/app/models/tracker.rb +++ b/app/models/tracker.rb @@ -37,7 +37,7 @@ class Tracker < ActiveRecord::Base def to_s; name end def <=>(tracker) - name <=> tracker.name + position <=> tracker.position end def self.all diff --git a/test/unit/tracker_test.rb b/test/unit/tracker_test.rb index 735f7e868..493637db5 100644 --- a/test/unit/tracker_test.rb +++ b/test/unit/tracker_test.rb @@ -50,4 +50,11 @@ class TrackerTest < ActiveSupport::TestCase def test_issue_statuses_should_be_empty_for_new_record assert_equal [], Tracker.new.issue_statuses end + + def test_sort_should_sort_by_position + a = Tracker.new(:name => 'Tracker A', :position => 2) + b = Tracker.new(:name => 'Tracker B', :position => 1) + + assert_equal [b, a], [a, b].sort + end end -- 2.39.5