##// END OF EJS Templates
Fixed: invalid effective date (eg. 99999-01-01) causes an error on version edition screen....
Jean-Philippe Lang -
r1886:199428804fd8
parent child
Show More
@@ -0,0 +1,36
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 require File.dirname(__FILE__) + '/../test_helper'
19
20 class ProjectTest < Test::Unit::TestCase
21 fixtures :projects, :issues, :issue_statuses, :versions
22
23 def setup
24 end
25
26 def test_create
27 v = Version.new(:project => Project.find(1), :name => '1.1', :effective_date => '2011-03-25')
28 assert v.save
29 end
30
31 def test_invalid_effective_date_validation
32 v = Version.new(:project => Project.find(1), :name => '1.1', :effective_date => '99999-01-01')
33 assert !v.save
34 assert_equal 'activerecord_error_not_a_date', v.errors.on(:effective_date)
35 end
36 end
@@ -24,7 +24,7 class Version < ActiveRecord::Base
24 24 validates_presence_of :name
25 25 validates_uniqueness_of :name, :scope => [:project_id]
26 26 validates_length_of :name, :maximum => 60
27 validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :activerecord_error_not_a_date, :allow_nil => true
27 validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => 'activerecord_error_not_a_date', :allow_nil => true
28 28
29 29 def start_date
30 30 effective_date
General Comments 0
You need to be logged in to leave comments. Login now