Versions can now be created with no date.
Versions with no date appear at the end of the roadmap, sorted by name. git-svn-id: http://redmine.rubyforge.org/svn/trunk@536 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
1 parent
bb1fccb7b7
commit
d34ea9a569
10 files changed
+61
-34
No files matched your search
+11
-1
@@ -23,7 +23,7 @@ class Version < ActiveRecord::Base
|
||||
|
||||
validates_presence_of :name
|
||||
validates_uniqueness_of :name, :scope => [:project_id]
|
||||
validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :activerecord_error_not_a_date
|
||||
validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :activerecord_error_not_a_date, :allow_nil => true
|
||||
|
||||
def start_date
|
||||
effective_date
|
||||
@@ -37,6 +37,16 @@ class Version < ActiveRecord::Base
|
||||
effective_date && effective_date <= Date.today
|
||||
end
|
||||
|
||||
# Versions are sorted by effective_date
|
||||
# Those with no effective_date are at the end, sorted by name
|
||||
def <=>(version)
|
||||
if self.effective_date
|
||||
version.effective_date ? (self.effective_date <=> version.effective_date) : -1
|
||||
else
|
||||
version.effective_date ? 1 : (self.name <=> version.name)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def check_integrity
|
||||
raise "Can't delete version" if self.fixed_issues.find(:first)
|
||||
|
||||
Reference in new issue
Block a user