summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/tracker.rb2
-rw-r--r--test/unit/tracker_test.rb7
2 files changed, 8 insertions, 1 deletions
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