Fixed that invalid start date is ignored (#12092).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10670 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
9ff16dd411
commit
1737552eca
|
@ -525,10 +525,14 @@ class Issue < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_issue
|
def validate_issue
|
||||||
if self.due_date.nil? && @attributes['due_date'] && !@attributes['due_date'].empty?
|
if due_date.nil? && @attributes['due_date'].present?
|
||||||
errors.add :due_date, :not_a_date
|
errors.add :due_date, :not_a_date
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if start_date.nil? && @attributes['start_date'].present?
|
||||||
|
errors.add :start_date, :not_a_date
|
||||||
|
end
|
||||||
|
|
||||||
if self.due_date and self.start_date and self.due_date < self.start_date
|
if self.due_date and self.start_date and self.due_date < self.start_date
|
||||||
errors.add :due_date, :greater_than_start_date
|
errors.add :due_date, :greater_than_start_date
|
||||||
end
|
end
|
||||||
|
|
|
@ -54,6 +54,24 @@ class IssueTest < ActiveSupport::TestCase
|
||||||
assert_nil issue.estimated_hours
|
assert_nil issue.estimated_hours
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_start_date_format_should_be_validated
|
||||||
|
set_language_if_valid 'en'
|
||||||
|
['2012', 'ABC', '2012-15-20'].each do |invalid_date|
|
||||||
|
issue = Issue.new(:start_date => invalid_date)
|
||||||
|
assert !issue.valid?
|
||||||
|
assert_include 'Start date is not a valid date', issue.errors.full_messages, "No error found for invalid date #{invalid_date}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_due_date_format_should_be_validated
|
||||||
|
set_language_if_valid 'en'
|
||||||
|
['2012', 'ABC', '2012-15-20'].each do |invalid_date|
|
||||||
|
issue = Issue.new(:due_date => invalid_date)
|
||||||
|
assert !issue.valid?
|
||||||
|
assert_include 'Due date is not a valid date', issue.errors.full_messages, "No error found for invalid date #{invalid_date}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_create_with_required_custom_field
|
def test_create_with_required_custom_field
|
||||||
set_language_if_valid 'en'
|
set_language_if_valid 'en'
|
||||||
field = IssueCustomField.find_by_name('Database')
|
field = IssueCustomField.find_by_name('Database')
|
||||||
|
|
Loading…
Reference in New Issue