]> source.dussan.org Git - redmine.git/commitdiff
Fixed group sorted scope order (#20066).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 28 Jun 2015 08:39:31 +0000 (08:39 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 28 Jun 2015 08:39:31 +0000 (08:39 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@14380 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/group.rb
test/unit/group_test.rb

index 279e145ed9043d99b6ddab32ec572dc4e05a51d2..8c683305e72d92ffe22a1e16875a9b232dc78d0c 100644 (file)
@@ -32,7 +32,7 @@ class Group < Principal
 
   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')}
 
index 703c423c1a1a5b56468262087c3d945dae3fdb14..9383cc7e7cfd06a6c5ef6009b892c024c9f9316d 100644 (file)
@@ -158,4 +158,12 @@ class GroupTest < ActiveSupport::TestCase
     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