mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-29 21:38:49 +01:00
Fix #497 (Project page "Sort Alphabetically" feature should sort case-insensitively)
git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@525 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
2d73602d98
commit
419f97ae9f
2 changed files with 11 additions and 1 deletions
|
|
@ -44,7 +44,7 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
def alphabetize(scope_conditions = {})
|
||||
projects = find(:all, :conditions => scope_conditions)
|
||||
projects.sort!{ |x,y| x.name <=> y.name }
|
||||
projects.sort!{ |x,y| x.name.downcase <=> y.name.downcase }
|
||||
self.update_positions(projects.map{ |p| p.id })
|
||||
return projects
|
||||
end
|
||||
|
|
|
|||
|
|
@ -278,5 +278,15 @@ class UserTest < Test::Unit::TestCase
|
|||
assert_equal 3, projects(:moremoney).position
|
||||
end
|
||||
|
||||
def test_sort_active_projects_alphabetically_case_insensitive
|
||||
u = users(:admin_user)
|
||||
projects(:timemachine).name = projects(:timemachine).name.downcase
|
||||
projects(:timemachine).save!
|
||||
u.projects.alphabetize(:state => "active")
|
||||
assert_equal 1, projects(:timemachine).position
|
||||
assert_equal 2, projects(:gardenclean).position
|
||||
assert_equal 3, projects(:moremoney).position
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue