before_destroy :remove_references_before_destroy
- scope :sorted, lambda { order(:type => :asc, :lastname => :desc) }
+ scope :sorted, lambda { order(:type => :asc, :lastname => :asc) }
scope :named, lambda {|arg| where("LOWER(#{table_name}.lastname) = LOWER(?)", arg.to_s.strip)}
scope :givable, lambda {where(:type => 'Group')}
end
assert_equal 0, group.reload.users.count
end
+
+ def test_sorted_scope_should_sort_groups_alphabetically
+ Group.delete_all
+ b = Group.generate!(:name => 'B')
+ a = Group.generate!(:name => 'A')
+
+ assert_equal %w(A B), Group.sorted.to_a.map(&:name)
+ end
end