]> source.dussan.org Git - redmine.git/commitdiff
Merged r22311 from trunk to 5.0-stable (#39079).
authorGo MAEDA <maeda@farend.jp>
Wed, 20 Sep 2023 04:47:15 +0000 (04:47 +0000)
committerGo MAEDA <maeda@farend.jp>
Wed, 20 Sep 2023 04:47:15 +0000 (04:47 +0000)
git-svn-id: https://svn.redmine.org/redmine/branches/5.0-stable@22312 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/time_entry.rb
test/unit/time_entry_test.rb

index d2a1ee6cd9c917fe5423bf16f897d883fc02daff..8bd6008093e380a1d8f5c3a7c7bf876006cd805d 100644 (file)
@@ -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
index 15f9a98369685a2af7092f81126a321ee05783a4..59e0b78f56bba28d67e71edc01134af955d86026 100644 (file)
@@ -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 = ''