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
[OP#65622] Do not calculate an end_time when no hours are set
Klaus Zanders28c7a1745ff1
diff --git a/modules/costs/app/models/time_entry.rb b/modules/costs/app/models/time_entry.rbindex ee502d13d4c..688a3fc35e4 100644--- a/modules/costs/app/models/time_entry.rb+++ b/modules/costs/app/models/time_entry.rb@@ -160,10 +160,11 @@ class TimeEntry < ApplicationRecordtime_zone_object.local(spent_on.year, spent_on.month, spent_on.day, start_time / 60, start_time % 60)end- def end_timestamp+ def end_timestamp # rubocop:disable Metrics/AbcSizereturn nil if start_time.blank?return nil if time_zone.blank?return nil if spent_on.blank?+ return nil if hours.blank? && !ongoing?if ongoing?start_timestamp + ongoing_hours.hoursdiff --git a/modules/costs/spec/models/time_entry_spec.rb b/modules/costs/spec/models/time_entry_spec.rbindex b03088352b8..595a6c880ff 100644--- a/modules/costs/spec/models/time_entry_spec.rb+++ b/modules/costs/spec/models/time_entry_spec.rb@@ -522,6 +522,11 @@ RSpec.describe TimeEntry doexpect(time_entry.end_timestamp).to be_nilend+ it "returns nil if hours are nil" do+ time_entry.hours = nil+ expect(time_entry.end_timestamp).to be_nil+ end+it "generates a proper timestamp from the stored information" dotime_entry.start_time = 8 * 60time_entry.hours = 2.5