diff options
Diffstat (limited to 'test/unit/principal_test.rb')
-rw-r--r-- | test/unit/principal_test.rb | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/test/unit/principal_test.rb b/test/unit/principal_test.rb index 2ddcc8b1c..b37f781a3 100644 --- a/test/unit/principal_test.rb +++ b/test/unit/principal_test.rb @@ -55,17 +55,11 @@ class PrincipalTest < ActiveSupport::TestCase end def test_sorted_scope_should_sort_users_before_groups - scope = Principal.where("type <> ?", 'AnonymousUser') - expected_order = scope.all.sort do |a, b| - if a.is_a?(User) && b.is_a?(Group) - -1 - elsif a.is_a?(Group) && b.is_a?(User) - 1 - else - a.name.downcase <=> b.name.downcase - end - end - assert_equal expected_order.map(&:name).map(&:downcase), + scope = Principal.where(:type => ['User', 'Group']) + users = scope.select {|p| p.is_a?(User)}.sort + groups = scope.select {|p| p.is_a?(Group)}.sort + + assert_equal (users + groups).map(&:name).map(&:downcase), scope.sorted.map(&:name).map(&:downcase) end |