@@ -67,7 +67,7 class Issue < ActiveRecord::Base | |||||
67 |
|
67 | |||
68 | validates_length_of :subject, :maximum => 255 |
|
68 | validates_length_of :subject, :maximum => 255 | |
69 | validates_inclusion_of :done_ratio, :in => 0..100 |
|
69 | validates_inclusion_of :done_ratio, :in => 0..100 | |
70 | validates_numericality_of :estimated_hours, :allow_nil => true |
|
70 | validates :estimated_hours, :numericality => {:greater_than_or_equal_to => 0, :allow_nil => true, :message => :invalid} | |
71 | validates :start_date, :date => true |
|
71 | validates :start_date, :date => true | |
72 | validates :due_date, :date => true |
|
72 | validates :due_date, :date => true | |
73 | validate :validate_issue, :validate_required_fields |
|
73 | validate :validate_issue, :validate_required_fields |
@@ -79,6 +79,15 class IssueTest < ActiveSupport::TestCase | |||||
79 | assert_include 'Due date must be greater than start date', issue.errors.full_messages |
|
79 | assert_include 'Due date must be greater than start date', issue.errors.full_messages | |
80 | end |
|
80 | end | |
81 |
|
81 | |||
|
82 | def test_estimated_hours_should_be_validated | |||
|
83 | set_language_if_valid 'en' | |||
|
84 | ['-2'].each do |invalid| | |||
|
85 | issue = Issue.new(:estimated_hours => invalid) | |||
|
86 | assert !issue.valid? | |||
|
87 | assert_include 'Estimated time is invalid', issue.errors.full_messages | |||
|
88 | end | |||
|
89 | end | |||
|
90 | ||||
82 | def test_create_with_required_custom_field |
|
91 | def test_create_with_required_custom_field | |
83 | set_language_if_valid 'en' |
|
92 | set_language_if_valid 'en' | |
84 | field = IssueCustomField.find_by_name('Database') |
|
93 | field = IssueCustomField.find_by_name('Database') |
General Comments 0
You need to be logged in to leave comments.
Login now