if self.effective_date
if version.effective_date
if self.effective_date == version.effective_date
- "#{self.project.name} - #{self.name}" <=> "#{version.project.name} - #{version.name}"
+ name == version.name ? id <=> version.id : name <=> version.name
else
self.effective_date <=> version.effective_date
end
if version.effective_date
1
else
- "#{self.project.name} - #{self.name}" <=> "#{version.project.name} - #{version.name}"
+ name == version.name ? id <=> version.id : name <=> version.name
end
end
end
v1 = Version.create!(:project_id => 1, :name => 'v3', :effective_date => '2012-08-02')
v5 = Version.create!(:project_id => 1, :name => 'v5', :effective_date => '2012-07-02')
+ assert_equal [v5, v3, v1, v2, v4], [v1, v2, v3, v4, v5].sort
assert_equal [v5, v3, v1, v2, v4], Version.sorted.all
end