Adds a sorted scope to IssueStatus model.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9989 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-07-15 15:33:17 +00:00
parent cb09055d60
commit 7946f4a696
2 changed files with 5 additions and 0 deletions

View 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

View 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