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:
parent
cb09055d60
commit
7946f4a696
|
@ -28,6 +28,7 @@ class IssueStatus < ActiveRecord::Base
|
||||||
validates_length_of :name, :maximum => 30
|
validates_length_of :name, :maximum => 30
|
||||||
validates_inclusion_of :default_done_ratio, :in => 0..100, :allow_nil => true
|
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])}
|
scope :named, lambda {|arg| where(["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip])}
|
||||||
|
|
||||||
def update_default
|
def update_default
|
||||||
|
|
|
@ -112,6 +112,10 @@ class IssueStatusTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_sorted_scope
|
||||||
|
assert_equal IssueStatus.all.sort, IssueStatus.sorted.all
|
||||||
|
end
|
||||||
|
|
||||||
def test_named_scope
|
def test_named_scope
|
||||||
status = IssueStatus.named("resolved").first
|
status = IssueStatus.named("resolved").first
|
||||||
assert_not_nil status
|
assert_not_nil status
|
||||||
|
|
Loading…
Reference in New Issue