]> source.dussan.org Git - redmine.git/commitdiff
Trackers should be sorted by position not by name.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 5 May 2012 16:21:22 +0000 (16:21 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 5 May 2012 16:21:22 +0000 (16:21 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9644 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/tracker.rb
test/unit/tracker_test.rb

index acd0253c631f0e613a084e71217f58122ddf9f55..d489d6d4511681968a832cddb442fd8d79e5a53a 100644 (file)
@@ -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
index 735f7e8682f4fb7c43c06ab8d9a7d21f394c1130..493637db50eedbe636c1b74305171976cff414f3 100644 (file)
@@ -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