]> source.dussan.org Git - redmine.git/commitdiff
Adds a sorted scope to IssueStatus model.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 15 Jul 2012 15:33:17 +0000 (15:33 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 15 Jul 2012 15:33:17 +0000 (15:33 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9989 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue_status.rb
test/unit/issue_status_test.rb

index 1562d049a24719125b95c79f7de136510d9c29fe..95c7e4d513fb77634149acbe017606f18e271f65 100644 (file)
@@ -28,6 +28,7 @@ class IssueStatus < ActiveRecord::Base
   validates_length_of :name, :maximum => 30
   validates_inclusion_of :default_done_ratio, :in => 0..100, :allow_nil => true
 
+  scope :sorted, order("#{table_name}.position ASC")
   scope :named, lambda {|arg| where(["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip])}
 
   def update_default
index 5d3b6a11213fff41924c2288bf0cefec5095d9ad..75c86e39ebb2608a5888a5e4d12ad98b538b2bfb 100644 (file)
@@ -112,6 +112,10 @@ class IssueStatusTest < ActiveSupport::TestCase
     end
   end
 
+  def test_sorted_scope
+    assert_equal IssueStatus.all.sort, IssueStatus.sorted.all
+  end
+
   def test_named_scope
     status = IssueStatus.named("resolved").first
     assert_not_nil status