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
23:59 is the max settable time
Klaus Zanders537fefd81283
diff --git a/modules/costs/app/models/time_entry.rb b/modules/costs/app/models/time_entry.rbindex 93b5b3ea544..962f12750a5 100644--- a/modules/costs/app/models/time_entry.rb+++ b/modules/costs/app/models/time_entry.rb@@ -36,6 +36,9 @@ class TimeEntry < ApplicationRecordbelongs_to :rate, -> { where(type: %w[HourlyRate DefaultHourlyRate]) }, class_name: "Rate"belongs_to :logged_by, class_name: "User"+ MIN_TIME = 0 # => 00:00+ MAX_TIME = (60 * 24) - 1 # => 23:59+acts_as_customizableacts_as_journalized@@ -49,14 +52,14 @@ class TimeEntry < ApplicationRecordif: -> { TimeEntry.must_track_start_and_end_time? }validates :start_time,- numericality: { only_integer: true, greater_than_or_equal_to: 0, less_than_or_equal_to: 60 * 24 },+ numericality: { only_integer: true, greater_than_or_equal_to: MIN_TIME, less_than_or_equal_to: MAX_TIME },allow_blank: truevalidates :end_time,numericality: {only_integer: true,greater_than: ->(te) { te.start_time.to_i },- less_than_or_equal_to: 60 * 24+ less_than_or_equal_to: MAX_TIME# TODO: nice error message},allow_blank: truediff --git a/modules/costs/spec/models/time_entry_spec.rb b/modules/costs/spec/models/time_entry_spec.rbindex b3110c1291f..521288515a6 100644--- a/modules/costs/spec/models/time_entry_spec.rb+++ b/modules/costs/spec/models/time_entry_spec.rb@@ -441,11 +441,16 @@ RSpec.describe TimeEntry doexpect(time_entry).to be_validend- it "allows integer values between 0 and 1440" do+ it "allows integer values between 0 and 1439" dotime_entry.end_time = 1337expect(time_entry).to be_validend+ it "does not allow values > 1439" do+ time_entry.end_time = 1440+ expect(time_entry).not_to be_valid+ end+it "does not allow non integer values" dotime_entry.end_time = 1.5expect(time_entry).not_to be_valid