@@ -525,10 +525,14 class Issue < ActiveRecord::Base | |||||
525 | end |
|
525 | end | |
526 |
|
526 | |||
527 | def validate_issue |
|
527 | def validate_issue | |
528 |
if |
|
528 | if due_date.nil? && @attributes['due_date'].present? | |
529 | errors.add :due_date, :not_a_date |
|
529 | errors.add :due_date, :not_a_date | |
530 | end |
|
530 | end | |
531 |
|
531 | |||
|
532 | if start_date.nil? && @attributes['start_date'].present? | |||
|
533 | errors.add :start_date, :not_a_date | |||
|
534 | end | |||
|
535 | ||||
532 | if self.due_date and self.start_date and self.due_date < self.start_date |
|
536 | if self.due_date and self.start_date and self.due_date < self.start_date | |
533 | errors.add :due_date, :greater_than_start_date |
|
537 | errors.add :due_date, :greater_than_start_date | |
534 | end |
|
538 | end |
@@ -54,6 +54,24 class IssueTest < ActiveSupport::TestCase | |||||
54 | assert_nil issue.estimated_hours |
|
54 | assert_nil issue.estimated_hours | |
55 | end |
|
55 | end | |
56 |
|
56 | |||
|
57 | def test_start_date_format_should_be_validated | |||
|
58 | set_language_if_valid 'en' | |||
|
59 | ['2012', 'ABC', '2012-15-20'].each do |invalid_date| | |||
|
60 | issue = Issue.new(:start_date => invalid_date) | |||
|
61 | assert !issue.valid? | |||
|
62 | assert_include 'Start date is not a valid date', issue.errors.full_messages, "No error found for invalid date #{invalid_date}" | |||
|
63 | end | |||
|
64 | end | |||
|
65 | ||||
|
66 | def test_due_date_format_should_be_validated | |||
|
67 | set_language_if_valid 'en' | |||
|
68 | ['2012', 'ABC', '2012-15-20'].each do |invalid_date| | |||
|
69 | issue = Issue.new(:due_date => invalid_date) | |||
|
70 | assert !issue.valid? | |||
|
71 | assert_include 'Due date is not a valid date', issue.errors.full_messages, "No error found for invalid date #{invalid_date}" | |||
|
72 | end | |||
|
73 | end | |||
|
74 | ||||
57 | def test_create_with_required_custom_field |
|
75 | def test_create_with_required_custom_field | |
58 | set_language_if_valid 'en' |
|
76 | set_language_if_valid 'en' | |
59 | field = IssueCustomField.find_by_name('Database') |
|
77 | field = IssueCustomField.find_by_name('Database') |
General Comments 0
You need to be logged in to leave comments.
Login now