@@ -32,7 +32,7 class Group < Principal | |||||
32 |
|
32 | |||
33 | before_destroy :remove_references_before_destroy |
|
33 | before_destroy :remove_references_before_destroy | |
34 |
|
34 | |||
35 |
scope :sorted, lambda { order(:type => :asc, :lastname => : |
|
35 | scope :sorted, lambda { order(:type => :asc, :lastname => :asc) } | |
36 | scope :named, lambda {|arg| where("LOWER(#{table_name}.lastname) = LOWER(?)", arg.to_s.strip)} |
|
36 | scope :named, lambda {|arg| where("LOWER(#{table_name}.lastname) = LOWER(?)", arg.to_s.strip)} | |
37 | scope :givable, lambda {where(:type => 'Group')} |
|
37 | scope :givable, lambda {where(:type => 'Group')} | |
38 |
|
38 |
@@ -158,4 +158,12 class GroupTest < ActiveSupport::TestCase | |||||
158 | end |
|
158 | end | |
159 | assert_equal 0, group.reload.users.count |
|
159 | assert_equal 0, group.reload.users.count | |
160 | end |
|
160 | end | |
|
161 | ||||
|
162 | def test_sorted_scope_should_sort_groups_alphabetically | |||
|
163 | Group.delete_all | |||
|
164 | b = Group.generate!(:name => 'B') | |||
|
165 | a = Group.generate!(:name => 'A') | |||
|
166 | ||||
|
167 | assert_equal %w(A B), Group.sorted.to_a.map(&:name) | |||
|
168 | end | |||
161 | end |
|
169 | end |
General Comments 0
You need to be logged in to leave comments.
Login now