Defect #39079 ยป 0001-Avoid-exception-during-validation-if-the-spent_on-da.patch
| app/models/time_entry.rb | ||
|---|---|---|
|
end
|
||
|
errors.add :issue_id, :invalid if (issue_id && !issue) || (issue && project!=issue.project) || @invalid_issue_id
|
||
|
errors.add :activity_id, :inclusion if activity_id_changed? && project && !project.activities.include?(activity)
|
||
|
if spent_on_changed? && user
|
||
|
if spent_on && spent_on_changed? && user
|
||
|
errors.add :base, I18n.t(:error_spent_on_future_date) if !Setting.timelog_accept_future_dates? && (spent_on > user.today)
|
||
|
end
|
||
|
end
|
||
| test/unit/time_entry_test.rb | ||
|---|---|---|
|
end
|
||
|
end
|
||
|
def test_should_require_spent_on
|
||
|
with_settings :timelog_accept_future_dates => '0' do
|
||
|
entry = TimeEntry.find(1)
|
||
|
entry.spent_on = ''
|
||
|
assert !entry.save
|
||
|
assert entry.errors[:spent_on].present?
|
||
|
end
|
||
|
end
|
||
|
def test_spent_on_with_blank
|
||
|
c = TimeEntry.new
|
||
|
c.spent_on = ''
|
||