Make the versions with the same date sorted by name (#864).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1296 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
7a434c902a
commit
ecc742f3ce
|
@ -89,11 +89,11 @@ class Version < ActiveRecord::Base
|
||||||
|
|
||||||
def to_s; name end
|
def to_s; name end
|
||||||
|
|
||||||
# Versions are sorted by effective_date
|
# Versions are sorted by effective_date and name
|
||||||
# Those with no effective_date are at the end, sorted by name
|
# Those with no effective_date are at the end, sorted by name
|
||||||
def <=>(version)
|
def <=>(version)
|
||||||
if self.effective_date
|
if self.effective_date
|
||||||
version.effective_date ? (self.effective_date <=> version.effective_date) : -1
|
version.effective_date ? (self.effective_date == version.effective_date ? self.name <=> version.name : self.effective_date <=> version.effective_date) : -1
|
||||||
else
|
else
|
||||||
version.effective_date ? 1 : (self.name <=> version.name)
|
version.effective_date ? 1 : (self.name <=> version.name)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue