##// END OF EJS Templates
Adds a sorted scope to IssueStatus model....
Jean-Philippe Lang -
r9806:7946f4a69668
parent child
Show More
@@ -28,6 +28,7 class IssueStatus < ActiveRecord::Base
28 validates_length_of :name, :maximum => 30
28 validates_length_of :name, :maximum => 30
29 validates_inclusion_of :default_done_ratio, :in => 0..100, :allow_nil => true
29 validates_inclusion_of :default_done_ratio, :in => 0..100, :allow_nil => true
30
30
31 scope :sorted, order("#{table_name}.position ASC")
31 scope :named, lambda {|arg| where(["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip])}
32 scope :named, lambda {|arg| where(["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip])}
32
33
33 def update_default
34 def update_default
@@ -112,6 +112,10 class IssueStatusTest < ActiveSupport::TestCase
112 end
112 end
113 end
113 end
114
114
115 def test_sorted_scope
116 assert_equal IssueStatus.all.sort, IssueStatus.sorted.all
117 end
118
115 def test_named_scope
119 def test_named_scope
116 status = IssueStatus.named("resolved").first
120 status = IssueStatus.named("resolved").first
117 assert_not_nil status
121 assert_not_nil status
General Comments 0
You need to be logged in to leave comments. Login now