OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#43393] [AppSignal] TimeEntry#spent_time date out of range for timestamp
Dombi Attilabd4d45d843b1
diff --git a/modules/costs/app/contracts/time_entries/base_contract.rb b/modules/costs/app/contracts/time_entries/base_contract.rbindex ca91d19a13c..031a72c8d9c 100644--- a/modules/costs/app/contracts/time_entries/base_contract.rb+++ b/modules/costs/app/contracts/time_entries/base_contract.rb@@ -45,6 +45,11 @@ module TimeEntriesvalidate :validate_project_is_setvalidate :validate_work_package+ validates :spent_on,+ date: { before_or_equal_to: Proc.new { Time.zone.today },+ allow_blank: true },+ unless: Proc.new { spent_on.blank? }+attribute :project_idattribute :work_package_idattribute :activity_id dodiff --git a/modules/costs/spec/contracts/time_entries/shared_contract_examples.rb b/modules/costs/spec/contracts/time_entries/shared_contract_examples.rbindex 1fe7611148e..0b766fc5fd2 100644--- a/modules/costs/spec/contracts/time_entries/shared_contract_examples.rb+++ b/modules/costs/spec/contracts/time_entries/shared_contract_examples.rb@@ -162,6 +162,30 @@ shared_examples_for 'time entry contract' doendend+ context 'when spent_on is in the future' do+ let(:time_entry_spent_on) { Time.zone.tomorrow }++ it 'is invalid' do+ expect_valid(false, spent_on: %i(date_before_or_equal_to))+ end+ end++ context 'when spent_on is today' do+ let(:time_entry_spent_on) { Time.zone.today }++ it 'is valid' do+ expect_valid(true)+ end+ end++ context 'when spent_on is in the past' do+ let(:time_entry_spent_on) { Time.zone.yesterday }++ it 'is valid' do+ expect_valid(true)+ end+ end+context 'when hours is nil' dolet(:time_entry_hours) { nil }