diff options
author | Go MAEDA <maeda@farend.jp> | 2023-09-20 04:48:52 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2023-09-20 04:48:52 +0000 |
commit | 50e9c2e10b7124d37dc995eeb55ee62d887ab696 (patch) | |
tree | a4decf0f66c553e5432148962f782c62047818ff | |
parent | 60c6f5a7c4582c6bc18ec28685e0bb58f523577f (diff) | |
download | redmine-50e9c2e10b7124d37dc995eeb55ee62d887ab696.tar.gz redmine-50e9c2e10b7124d37dc995eeb55ee62d887ab696.zip |
Merged r22311 from trunk to 4.2-stable (#39079).
git-svn-id: https://svn.redmine.org/redmine/branches/4.2-stable@22313 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/models/time_entry.rb | 2 | ||||
-rw-r--r-- | test/unit/time_entry_test.rb | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb index d2a1ee6cd..8bd600809 100644 --- a/app/models/time_entry.rb +++ b/app/models/time_entry.rb @@ -181,7 +181,7 @@ class TimeEntry < ActiveRecord::Base 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 diff --git a/test/unit/time_entry_test.rb b/test/unit/time_entry_test.rb index 15f9a9836..59e0b78f5 100644 --- a/test/unit/time_entry_test.rb +++ b/test/unit/time_entry_test.rb @@ -156,6 +156,16 @@ class TimeEntryTest < ActiveSupport::TestCase 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 = '' |